Skip to content

Commit a53c822

Browse files
Merge pull request #25 from minimaldesign/components-cleanup
Replace ArticleCard/PostList with Card/CardList
2 parents d07e1b1 + 7ec7304 commit a53c822

19 files changed

Lines changed: 529 additions & 573 deletions

dist/css/component.card.css

Lines changed: 63 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ xxl: 1920px
2929
--loading-animation: 2s infinite ease-in-out;
3030

3131
position: relative;
32+
/* flex column so .card_byline can pin itself to the bottom */
33+
display: flex;
34+
flex-direction: column;
3235
padding: var(--card-spacing);
3336
color: var(--card-color);
3437
border-radius: var(--card-border-radius);
@@ -55,7 +58,12 @@ xxl: 1920px
5558
box-shadow: var(--card-shadow-hover);
5659
}
5760

58-
.card_link {
61+
/* The card's single link, stretched over the whole card. Put .card_link on a
62+
real anchor (usually the title link) so its text names the link. Positioned
63+
parts later in the DOM (.card_actions) paint above the ::after and stay
64+
clickable; parts before it need a z-index bump (.card_tags). */
65+
.card_link::after {
66+
content: "";
5967
position: absolute;
6068
inset: 0;
6169
}
@@ -71,12 +79,23 @@ xxl: 1920px
7179
.card_header:has( + .card_media) {
7280
margin-bottom: var(--card-spacing);
7381
}
74-
.card_header_text h2 {
75-
font-size: var(--text-lg);
76-
font-weight: var(--semi-bold);
77-
margin-bottom: 0;
82+
83+
.card_title {
84+
margin-bottom: 0;
85+
font-size: var(--text-lg);
86+
font-weight: var(--semi-bold);
87+
}
88+
89+
.card_title a {
90+
color: var(--card-color);
91+
-webkit-text-decoration: none;
92+
text-decoration: none;
93+
transition: color var(--transition);
7894
}
7995

96+
:is(.card_title a):hover {
97+
color: var(--link-color);
98+
}
8099
.card_header_text p {
81100
font-size: var(--text-lg);
82101
color: var(--card-secondary-text-color);
@@ -93,12 +112,26 @@ xxl: 1920px
93112
/* Badge visuals come from the .badge atom (atom.badge.css); the Card
94113
component renders class="badge card_badge" on each badge. */
95114

115+
.card_tags {
116+
/* keep the tags clickable above the stretched .card_link */
117+
position: relative;
118+
z-index: var(--z-1);
119+
margin-bottom: var(--sm2);
120+
}
121+
96122
.card_media {
97123
margin-bottom: var(--card-spacing);
98124
overflow: hidden;
99125
border-radius: var(--card-border-radius);
100126
}
101127

128+
.card_media-flush {
129+
/* edge-to-edge image on top of the card */
130+
margin: calc(var(--card-spacing) * -1);
131+
margin-bottom: var(--card-spacing);
132+
border-radius: var(--card-border-radius) var(--card-border-radius) 0 0;
133+
}
134+
102135
.card_image {
103136
width: 100%;
104137
object-fit: cover;
@@ -109,10 +142,35 @@ xxl: 1920px
109142
margin-bottom: 0;
110143
}
111144

145+
/* guaranteed gap before the byline even when nothing pins it down */
146+
.card_content:has( + .card_byline) {
147+
margin-bottom: var(--sm1);
148+
}
149+
150+
.card_byline {
151+
/* margin-top: auto pins bylines to the bottom, so a row of cards lines up */
152+
display: flex;
153+
align-items: center;
154+
gap: var(--xs2);
155+
margin-top: auto;
156+
font-size: var(--text-sm);
157+
}
158+
159+
.card_byline time {
160+
color: var(--card-secondary-text-color);
161+
}
162+
163+
.card_author {
164+
display: block;
165+
font-weight: var(--semi-bold);
166+
}
167+
112168
.card_actions {
113169
display: flex;
114170
justify-content: flex-end;
115171
gap: var(--xs3);
172+
/* positioned and after .card_link in the DOM, so actions paint above the
173+
stretched link and stay clickable */
116174
position: relative;
117175
margin-top: var(--card-spacing);
118176
}

dist/css/component.cardList.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*! mCSS v0.9.0 | MIT | https://mcss.dev */
2+
/*
3+
SETTINGS MEDIA QUERIES
4+
5+
https://github.com/argyleink/open-props/blob/main/src/props.media.css
6+
https://open-props.style/#media-queries
7+
8+
Can't use var() inside media queries 🤦‍♂️
9+
https://stackoverflow.com/questions/40722882/css-native-variables-not-working-in-media-queries/47212942#47212942
10+
so breakpoints are not in settings.tokens.css
11+
12+
xxs: 240px
13+
xs: 360px
14+
sm: 480px
15+
md: 768px
16+
lg: 1024px
17+
xl: 1440px
18+
xxl: 1920px
19+
*/
20+
21+
/* https://github.com/postcss/postcss-mixins */
22+
23+
/* Example */
24+
25+
/* truncate single line of text and adds … */
26+
27+
@layer components {
28+
/* CARD LIST */
29+
30+
.cardList {
31+
margin: 0;
32+
padding: 0;
33+
list-style: none;
34+
}
35+
36+
.cardList > li {
37+
/* grid items stretch, so cards in a row share the same height */
38+
display: grid;
39+
}
40+
41+
}

dist/css/mcss.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
@import url(./atom.button.css) layer(atoms);
55
@import url(./atom.toggle.css) layer(atoms);
66
@import url(./base.reset.css) layer(base);
7-
@import url(./component.articleCard.css) layer(components);
87
@import url(./component.avatar.css) layer(components);
98
@import url(./component.banner.css) layer(components);
109
@import url(./component.breadcrumbs.css) layer(components);
1110
@import url(./component.card.css) layer(components);
11+
@import url(./component.cardList.css) layer(components);
1212
@import url(./component.faq.css) layer(components);
1313
@import url(./component.featureGrid.css) layer(components);
1414
@import url(./component.featureItem.css) layer(components);
@@ -19,7 +19,6 @@
1919
@import url(./component.hero.css) layer(components);
2020
@import url(./component.notice.css) layer(components);
2121
@import url(./component.pagination.css) layer(components);
22-
@import url(./component.postList.css) layer(components);
2322
@import url(./component.prevNext.css) layer(components);
2423
@import url(./component.pricing.css) layer(components);
2524
@import url(./component.readProgressBar.css) layer(components);

dist/css/settings.theme.default.css

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,6 @@ xxl: 1920px
401401

402402
/* COMPONENTS */
403403

404-
/* ArticleCard */
405-
406-
:root {
407-
--articleCard-image-aspect-ratio: var(--ar-golden);
408-
}
409-
410404
/* Avatar */
411405

412406
:root {

0 commit comments

Comments
 (0)