Skip to content

Commit 619370d

Browse files
committed
fix: float featured card image inline with text content
Move the image inside the content flow and float it to the end, so text wraps around it naturally instead of occupying a separate column or stacking below.
1 parent 8afc773 commit 619370d

2 files changed

Lines changed: 34 additions & 55 deletions

File tree

src/design/components/featured-card/index.tsx

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,32 +18,27 @@ export function FeaturedCard({ entry, basePath }: { entry: CatalogEntry; basePat
1818
? url(entry.overlay.image, basePath)
1919
: null
2020
const imageAlt = entry.overlay?.imageAlt ?? ''
21-
const hasImage = Boolean(image)
2221

2322
return (
24-
<article class={`featured-card${hasImage ? ' featured-card--has-image' : ''}`}>
25-
<div class="featured-card__content">
26-
<h3 class="featured-card__title">
27-
<a href={href}>{title}</a>
28-
</h3>
29-
<p class="featured-card__summary">{summary}</p>
30-
{excerpt ? <p class="featured-card__excerpt">{raw(excerpt)}</p> : null}
31-
{highlights ? (
32-
<ul class="featured-card__tags">
33-
{highlights.map((h) => <li>{h}</li>)}
34-
</ul>
35-
) : null}
36-
<p class="featured-card__cta">
37-
<a href={href}>Explore {title} &rarr;</a>
38-
</p>
39-
</div>
23+
<article class="featured-card">
24+
<h3 class="featured-card__title">
25+
<a href={href}>{title}</a>
26+
</h3>
4027
{image ? (
41-
<div class="featured-card__image">
42-
<a href={href} tabindex={-1} aria-hidden="true">
43-
<img src={image} alt={imageAlt} loading="lazy" />
44-
</a>
45-
</div>
28+
<a class="featured-card__image" href={href} tabindex={-1} aria-hidden="true">
29+
<img src={image} alt={imageAlt} loading="lazy" />
30+
</a>
4631
) : null}
32+
<p class="featured-card__summary">{summary}</p>
33+
{excerpt ? <p class="featured-card__excerpt">{raw(excerpt)}</p> : null}
34+
{highlights ? (
35+
<ul class="featured-card__tags">
36+
{highlights.map((h) => <li>{h}</li>)}
37+
</ul>
38+
) : null}
39+
<p class="featured-card__cta">
40+
<a href={href}>Explore {title} &rarr;</a>
41+
</p>
4742
</article>
4843
)
4944
}
Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,15 @@
11
.featured-card {
2-
display: grid;
3-
gap: var(--space-5);
42
padding: var(--space-6);
53
border-inline-start: 3px solid var(--color-accent);
64
border-radius: var(--radius-sm);
75
background: var(--color-surface);
86
box-shadow: var(--shadow-card);
9-
container-type: inline-size;
10-
}
11-
12-
@container (min-width: 40rem) {
13-
.featured-card--has-image {
14-
grid-template-columns: 1fr 12rem;
15-
align-items: start;
16-
}
17-
}
18-
19-
/* ---- Content column ---- */
20-
21-
.featured-card__content {
22-
display: grid;
23-
gap: var(--space-3);
24-
align-content: start;
257
}
268

279
.featured-card__title {
2810
font-size: var(--step-2);
2911
line-height: 1.2;
12+
margin-block-end: var(--space-3);
3013
}
3114

3215
.featured-card__title a {
@@ -38,18 +21,33 @@
3821
color: var(--color-link-hover);
3922
}
4023

24+
.featured-card__image {
25+
float: inline-end;
26+
margin-inline-start: var(--space-5);
27+
margin-block-end: var(--space-3);
28+
}
29+
30+
.featured-card__image img {
31+
display: block;
32+
max-block-size: 16rem;
33+
inline-size: auto;
34+
border-radius: var(--radius-sm);
35+
}
36+
4137
.featured-card__summary {
4238
font-size: var(--step-0);
4339
color: var(--color-ink-subtle);
4440
font-weight: 500;
4541
max-inline-size: var(--measure-prose);
42+
margin-block-end: var(--space-3);
4643
}
4744

4845
.featured-card__excerpt {
4946
font-size: var(--step--1);
5047
color: var(--color-ink-subtle);
5148
line-height: 1.6;
5249
max-inline-size: var(--measure-prose);
50+
margin-block-end: var(--space-3);
5351
}
5452

5553
.featured-card__tags {
@@ -58,7 +56,7 @@
5856
gap: var(--space-2);
5957
list-style: none;
6058
padding: 0;
61-
margin: 0;
59+
margin: 0 0 var(--space-3);
6260
}
6361

6462
.featured-card__tags li {
@@ -71,7 +69,6 @@
7169
}
7270

7371
.featured-card__cta {
74-
margin-block-start: var(--space-2);
7572
font-size: var(--step--1);
7673
}
7774

@@ -85,16 +82,3 @@
8582
color: var(--color-link-hover);
8683
text-decoration: underline;
8784
}
88-
89-
/* ---- Image column ---- */
90-
91-
.featured-card__image {
92-
justify-self: center;
93-
}
94-
95-
.featured-card__image img {
96-
display: block;
97-
max-block-size: 20rem;
98-
inline-size: auto;
99-
border-radius: var(--radius-sm);
100-
}

0 commit comments

Comments
 (0)