Skip to content

Commit 699a9c8

Browse files
committed
feat: redesign featured section as stacked content cards
Replace the 4-column card grid with a single-column stacked layout. Each card now shows the project title, highlights as metadata tags, the summary, and an excerpt pulled from the detail page body content. Uses a left accent border instead of top border for visual hierarchy.
1 parent d25a960 commit 699a9c8

4 files changed

Lines changed: 71 additions & 36 deletions

File tree

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

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,38 @@
11
import type { CatalogEntry } from '../../../catalog/types'
22
import { url } from '../../../build/config'
3+
import { raw } from 'hono/html'
4+
5+
/** Extract first <p>…</p> from rendered HTML body */
6+
function firstParagraph(html: string): string | null {
7+
const match = html.match(/<p>([\s\S]*?)<\/p>/)
8+
return match ? match[1] : null
9+
}
310

411
export function FeaturedCard({ entry, basePath }: { entry: CatalogEntry; basePath: string }) {
512
const href = url(`/work/${entry.name}/`, basePath)
613
const title = entry.overlay?.title ?? entry.name
714
const summary = entry.overlay?.summary ?? entry.description ?? ''
815
const highlights = entry.overlay?.highlights
16+
const excerpt = entry.overlay?.body ? firstParagraph(entry.overlay.body) : null
917

1018
return (
1119
<article class="featured-card">
12-
<h3 class="featured-card__title">
13-
<a href={href}>{title}</a>
14-
</h3>
15-
{summary ? <p class="featured-card__summary">{summary}</p> : null}
16-
{highlights ? (
17-
<ul class="featured-card__highlights">
18-
{highlights.map((h) => <li>{h}</li>)}
19-
</ul>
20-
) : null}
20+
<div class="featured-card__header">
21+
<h3 class="featured-card__title">
22+
<a href={href}>{title}</a>
23+
</h3>
24+
{highlights ? (
25+
<ul class="featured-card__tags">
26+
{highlights.map((h) => <li>{h}</li>)}
27+
</ul>
28+
) : null}
29+
</div>
30+
<div class="featured-card__body">
31+
<p class="featured-card__summary">{summary}</p>
32+
{excerpt ? <p class="featured-card__excerpt">{raw(excerpt)}</p> : null}
33+
</div>
2134
<p class="featured-card__cta">
22-
<a href={href}>Learn more &rarr;</a>
35+
<a href={href}>Explore {title} &rarr;</a>
2336
</p>
2437
</article>
2538
)

src/design/components/featured-card/styles.css

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
.featured-card {
2-
padding: var(--space-5);
3-
border: 1px solid var(--color-surface-alt);
4-
border-block-start: 3px solid var(--color-accent);
5-
border-radius: var(--radius-md);
2+
display: grid;
3+
gap: var(--space-4);
4+
padding: var(--space-5) var(--space-6);
5+
border-inline-start: 3px solid var(--color-accent);
6+
border-radius: var(--radius-sm);
67
background: var(--color-surface);
78
box-shadow: var(--shadow-card);
8-
display: grid;
9+
}
10+
11+
.featured-card__header {
12+
display: flex;
13+
flex-wrap: wrap;
14+
align-items: baseline;
915
gap: var(--space-3);
10-
align-content: start;
1116
}
1217

1318
.featured-card__title {
14-
font-size: var(--step-1);
19+
font-size: var(--step-2);
1520
line-height: 1.2;
1621
}
1722

@@ -24,28 +29,43 @@
2429
color: var(--color-link-hover);
2530
}
2631

27-
.featured-card__summary {
28-
color: var(--color-ink-subtle);
29-
font-size: var(--step--1);
30-
}
31-
32-
.featured-card__highlights {
32+
.featured-card__tags {
33+
display: flex;
34+
flex-wrap: wrap;
35+
gap: var(--space-2);
3336
list-style: none;
3437
padding: 0;
35-
display: flex;
36-
flex-direction: column;
37-
gap: var(--space-1);
38+
margin: 0;
39+
}
40+
41+
.featured-card__tags li {
3842
font-size: var(--step--1);
43+
color: var(--color-ink-subtle);
44+
padding: var(--space-1) var(--space-3);
45+
background: var(--color-surface-highlight);
46+
border-radius: var(--radius-sm);
47+
white-space: nowrap;
48+
}
49+
50+
.featured-card__body {
51+
display: grid;
52+
gap: var(--space-3);
53+
max-inline-size: var(--measure-prose);
3954
}
4055

41-
.featured-card__highlights li::before {
42-
content: "\2713\0020";
43-
color: var(--color-tier-active);
44-
font-weight: 700;
56+
.featured-card__summary {
57+
font-size: var(--step-0);
58+
color: var(--color-ink-subtle);
59+
font-weight: 500;
60+
}
61+
62+
.featured-card__excerpt {
63+
font-size: var(--step--1);
64+
color: var(--color-ink-subtle);
65+
line-height: 1.6;
4566
}
4667

4768
.featured-card__cta {
48-
margin-block-start: auto;
4969
font-size: var(--step--1);
5070
}
5171

src/design/layout.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,20 +66,22 @@
6666
margin-inline: calc(-1 * var(--space-5));
6767
border-radius: var(--radius-md);
6868
}
69-
.home-featured__grid,
69+
.home-featured__list {
70+
display: flex;
71+
flex-direction: column;
72+
gap: var(--space-5);
73+
}
7074
.home-stats__grid,
7175
.work-index__list {
7276
display: grid;
7377
gap: var(--space-5);
7478
container-type: inline-size;
7579
}
7680
@container (min-width: 48rem) {
77-
.home-featured__grid { grid-template-columns: repeat(2, 1fr); }
7881
.home-stats__grid { grid-template-columns: repeat(3, 1fr); }
7982
.work-index__list { grid-template-columns: repeat(2, 1fr); }
8083
}
8184
@container (min-width: 72rem) {
82-
.home-featured__grid { grid-template-columns: repeat(4, 1fr); }
8385
.work-index__list { grid-template-columns: repeat(3, 1fr); }
8486
}
8587
.work-index__section-heading {

src/pages/home.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ export function Home({
3737
</section>
3838

3939
<section class="home-featured" aria-labelledby="featured-heading">
40-
<h2 id="featured-heading">Featured labs</h2>
41-
<div class="home-featured__grid">
40+
<h2 id="featured-heading">Featured</h2>
41+
<div class="home-featured__list">
4242
{featured.map((entry) => (
4343
<FeaturedCard entry={entry} basePath={config.basePath} />
4444
))}

0 commit comments

Comments
 (0)