Skip to content

Commit 9290bb6

Browse files
优化首页 Hero、时间轴、卡片与顶栏响应式导航
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2214c38 commit 9290bb6

13 files changed

Lines changed: 232 additions & 166 deletions

File tree

src/components/Card.astro

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const { backgroundColor, icon = "🚀", title } = Astro.props;
1111
<div class="card-box">
1212
<div class="card-title-line">
1313
<div class="card-icon">{icon}</div>
14+
<div class="card-title">{title}</div>
1415
</div>
15-
<div class="card-title">{title}</div>
1616
<div class="card-content">
1717
<slot />
1818
</div>
@@ -51,8 +51,11 @@ const { backgroundColor, icon = "🚀", title } = Astro.props;
5151
}
5252

5353
.card-title {
54+
flex: 1;
55+
min-width: 0;
5456
font-size: 16px;
5557
font-weight: bold;
58+
line-height: 1.3;
5659
}
5760

5861
.card-icon {

src/components/CardContainer.astro

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@
99
<style>
1010
.card-container {
1111
display: grid;
12-
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
12+
grid-template-columns: repeat(4, minmax(0, 1fr));
1313
gap: 20px;
1414
}
15+
16+
@media (max-width: 1080px) {
17+
.card-container {
18+
grid-template-columns: repeat(2, minmax(0, 1fr));
19+
}
20+
}
21+
22+
@media (max-width: 560px) {
23+
.card-container {
24+
grid-template-columns: 1fr;
25+
}
26+
}
1527
</style>

src/components/HomeHero.astro

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,21 @@ import DarkLightButton from "@/components/DarkLightButton.astro";
77
interface Props {
88
title: string;
99
subtitle: string;
10+
rampLabel: string;
11+
rampHref: string;
1012
primaryLabel: string;
1113
primaryHref: string;
12-
secondaryLabel?: string;
13-
secondaryHref?: string;
1414
tertiaryLabel: string;
1515
tertiaryHref: string;
1616
}
1717
1818
const {
1919
title,
2020
subtitle,
21+
rampLabel,
22+
rampHref,
2123
primaryLabel,
2224
primaryHref,
23-
secondaryLabel,
24-
secondaryHref,
2525
tertiaryLabel,
2626
tertiaryHref,
2727
} = Astro.props;
@@ -30,12 +30,8 @@ const {
3030
<Fragment>
3131
<HomeTitle title={title} subtitle={subtitle} />
3232
<ButtonGroup>
33-
<Button href={primaryHref}>{primaryLabel}</Button>
34-
{
35-
secondaryLabel && secondaryHref ? (
36-
<DarkLightButton href={secondaryHref}>{secondaryLabel}</DarkLightButton>
37-
) : null
38-
}
33+
<Button href={rampHref}>{rampLabel}</Button>
34+
<DarkLightButton href={primaryHref}>{primaryLabel}</DarkLightButton>
3935
<DarkLightButton href={tertiaryHref}>{tertiaryLabel}</DarkLightButton>
4036
</ButtonGroup>
4137
</Fragment>

src/components/HomeTimelineSection.astro

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
import type { SiteLang } from "@/lib/blog";
3-
import { renderNewsBody, type NewsEntry } from "@/lib/news";
3+
import { getNewsExcerpt, renderNewsBody, type NewsEntry } from "@/lib/news";
44
import Button from "@/components/Button.astro";
55
66
interface Props {
@@ -52,7 +52,10 @@ const text = copy[lang];
5252
<time class="timeline-date" datetime={item.date.toISOString()}>
5353
{item.rawDate}
5454
</time>
55-
<p class="timeline-body" set:html={renderNewsBody(item.body)} />
55+
<p
56+
class="timeline-body"
57+
set:html={renderNewsBody(getNewsExcerpt(item.body))}
58+
/>
5659
</div>
5760
<div class="timeline-axis" aria-hidden="true">
5861
<span class="timeline-node" />
@@ -73,6 +76,7 @@ const text = copy[lang];
7376
padding: clamp(1.6rem, 4vw, 2.8rem);
7477
border-radius: 2.25rem;
7578
border: 1px solid var(--border-color);
79+
overflow: visible;
7680
background:
7781
radial-gradient(
7882
circle at top left,
@@ -127,15 +131,17 @@ const text = copy[lang];
127131
padding: 0;
128132
margin: 1rem 0 0;
129133
display: grid;
130-
grid-template-columns: repeat(6, minmax(0, 1fr));
134+
grid-template-columns: repeat(10, minmax(0, 1fr));
131135
gap: 0.9rem;
132136
position: relative;
133137
align-items: center;
138+
overflow: visible;
134139
}
135140

136141
.timeline-list::before {
137142
content: "";
138143
position: absolute;
144+
z-index: 0;
139145
left: 0;
140146
right: 0;
141147
top: 50%;
@@ -150,27 +156,41 @@ const text = copy[lang];
150156
}
151157

152158
.timeline-item {
159+
grid-column: span 2;
153160
min-width: 0;
154161
display: grid;
155-
grid-template-rows: 1fr 28px 1fr;
162+
grid-template-rows: minmax(5.5rem, 1fr) 28px minmax(5.5rem, 1fr);
156163
position: relative;
164+
overflow: visible;
157165
}
158166

159167
.timeline-entry {
160168
display: grid;
161169
gap: 0.45rem;
162-
align-content: end;
163-
min-height: 104px;
164-
padding: 0.35rem 0.2rem;
170+
min-height: 0;
171+
padding: 0.2rem 0.35rem 0.2rem 0;
172+
box-sizing: border-box;
173+
position: relative;
174+
z-index: 1;
175+
width: calc(150% + 0.9rem);
176+
max-width: none;
177+
pointer-events: auto;
165178
}
166179

167180
.timeline-item-reverse .timeline-entry {
168181
grid-row: 3;
182+
align-self: start;
169183
align-content: start;
170184
}
171185

172186
.timeline-item:not(.timeline-item-reverse) .timeline-entry {
173187
grid-row: 1;
188+
align-self: end;
189+
align-content: end;
190+
}
191+
192+
.timeline-item:last-child .timeline-entry {
193+
width: 100%;
174194
}
175195

176196
.timeline-date {
@@ -205,9 +225,11 @@ const text = copy[lang];
205225
.timeline-axis {
206226
grid-row: 2;
207227
position: relative;
228+
z-index: 2;
208229
display: flex;
209230
justify-content: center;
210231
align-items: center;
232+
pointer-events: none;
211233
}
212234

213235
.timeline-axis::before,
@@ -250,23 +272,7 @@ const text = copy[lang];
250272
display: none;
251273
}
252274

253-
@media (max-width: 1180px) {
254-
.timeline-list {
255-
grid-template-columns: repeat(5, minmax(0, 1fr));
256-
}
257-
}
258-
259-
@media (max-width: 980px) {
260-
.timeline-list {
261-
grid-template-columns: repeat(4, minmax(0, 1fr));
262-
}
263-
264-
.timeline-item:nth-child(n + 5) {
265-
display: none;
266-
}
267-
}
268-
269-
@media (max-width: 820px) {
275+
@media (max-width: 1200px) {
270276
.timeline-list {
271277
min-width: 0;
272278
display: grid;
@@ -296,6 +302,7 @@ const text = copy[lang];
296302

297303
.timeline-item,
298304
.timeline-item-reverse {
305+
grid-column: auto;
299306
min-width: 0;
300307
grid-template-columns: 24px minmax(0, 1fr);
301308
grid-template-rows: auto;
@@ -313,11 +320,18 @@ const text = copy[lang];
313320
.timeline-item-reverse .timeline-entry {
314321
grid-column: 2;
315322
grid-row: auto;
323+
width: 100%;
324+
max-width: none;
316325
min-height: auto;
326+
align-self: auto;
317327
align-content: start;
318328
padding: 0 0 1rem;
319329
}
320330

331+
.timeline-item:last-child .timeline-entry {
332+
width: 100%;
333+
}
334+
321335
.timeline-axis,
322336
.timeline-item-reverse .timeline-axis {
323337
grid-column: 1;

src/components/Topbar.astro

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,10 @@ const translatePath = useTranslatedPath(lang);
1818
1919
interface Props {
2020
logoText?: string;
21+
menuLabel?: string;
2122
}
2223
23-
const { logoText = "YatCC AI" } = Astro.props;
24+
const { logoText = "YatCC AI", menuLabel = "Menu" } = Astro.props;
2425
---
2526

2627
<header class="topbar-container">
@@ -37,11 +38,20 @@ const { logoText = "YatCC AI" } = Astro.props;
3738
</div>
3839

3940
<div class="nav-right">
40-
<div class="nav-items">
41+
<div class="nav-items nav-items--desktop">
4142
<slot name="nav-items" />
4243
</div>
4344

44-
<div class="divider"></div>
45+
<div class="nav-overflow">
46+
<NavDropdown>
47+
<div slot="title">{menuLabel}</div>
48+
<div class="nav-overflow-panel">
49+
<slot name="nav-overflow" />
50+
</div>
51+
</NavDropdown>
52+
</div>
53+
54+
<div class="divider nav-divider--desktop"></div>
4555

4656
<NavDropdown>
4757
<div class="language-icon" slot="title">
@@ -158,8 +168,34 @@ const { logoText = "YatCC AI" } = Astro.props;
158168
background-color: rgba(255, 255, 255, 0.1);
159169
}
160170

161-
@media (max-width: 760px) {
162-
.nav-items {
171+
.nav-overflow {
172+
display: none;
173+
}
174+
175+
.nav-items--desktop {
176+
display: flex;
177+
align-items: center;
178+
}
179+
180+
.nav-overflow-panel {
181+
display: flex;
182+
flex-direction: column;
183+
gap: 0.35rem;
184+
min-width: 13.5rem;
185+
max-height: min(70vh, 32rem);
186+
overflow-y: auto;
187+
}
188+
189+
@media (max-width: 1200px) {
190+
.nav-items--desktop {
191+
display: none;
192+
}
193+
194+
.nav-overflow {
195+
display: inline-block;
196+
}
197+
198+
.nav-divider--desktop {
163199
display: none;
164200
}
165201
}

0 commit comments

Comments
 (0)