Skip to content

Commit 98c474b

Browse files
committed
docs(website): refine homepage hero actions
1 parent 19ae749 commit 98c474b

4 files changed

Lines changed: 69 additions & 187 deletions

File tree

‎website/i18n.json‎

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
"en": "Quick start",
44
"zh": "快速上手"
55
},
6-
"viewSource": {
7-
"en": "View the code",
8-
"zh": "查看源码"
6+
"getStarted": {
7+
"en": "Get Started",
8+
"zh": "开始使用"
99
},
10-
"copyCommand": {
11-
"en": "Copy command",
12-
"zh": "复制命令"
13-
},
14-
"copiedCommand": {
15-
"en": "Command copied",
16-
"zh": "命令已复制"
10+
"github": {
11+
"en": "GitHub",
12+
"zh": "GitHub"
1713
},
1814
"title": {
1915
"en": "Unified Toolchain for",

‎website/theme/components/Hero.module.scss‎

Lines changed: 54 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,21 @@
22
--hero-title: #111214;
33
--hero-title-muted: #747474;
44
--hero-text: #707174;
5-
--hero-border: #d9dbde;
6-
--hero-command-bg: rgba(255, 255, 255, 0.72);
7-
--hero-link: #686a6d;
8-
--hero-link-hover: #111214;
5+
--hero-primary-bg: #111214;
6+
--hero-primary-bg-hover: #383838;
7+
--hero-primary-text: #fff;
8+
--hero-secondary-bg: #fff;
9+
--hero-secondary-bg-hover: #f5f5f5;
10+
--hero-secondary-border: #d2d4d7;
11+
--hero-secondary-text: #111214;
912

1013
position: relative;
1114
display: flex;
1215
align-items: center;
1316
justify-content: center;
1417
box-sizing: border-box;
1518
min-height: calc(100svh - var(--rp-nav-height));
16-
padding: clamp(4.5rem, 9vh, 7rem) 2rem;
19+
padding: clamp(3.75rem, 7.5vh, 6rem) 2rem;
1720
overflow: hidden;
1821
background: var(--rp-c-bg);
1922
}
@@ -22,10 +25,13 @@
2225
--hero-title: #f5f5f5;
2326
--hero-title-muted: #9a9a9a;
2427
--hero-text: #a1a3a6;
25-
--hero-border: #3a3c40;
26-
--hero-command-bg: rgba(255, 255, 255, 0.025);
27-
--hero-link: #a6a8ab;
28-
--hero-link-hover: #f5f5f5;
28+
--hero-primary-bg: #f2f2f2;
29+
--hero-primary-bg-hover: #fff;
30+
--hero-primary-text: #111214;
31+
--hero-secondary-bg: transparent;
32+
--hero-secondary-bg-hover: #171717;
33+
--hero-secondary-border: #333;
34+
--hero-secondary-text: #f2f2f2;
2935
}
3036

3137
.inner {
@@ -67,121 +73,67 @@
6773
text-wrap: balance;
6874
}
6975

70-
.command {
71-
display: grid;
72-
grid-template-columns: auto minmax(0, 1fr) auto;
76+
.links {
77+
display: flex;
78+
flex-wrap: wrap;
7379
align-items: center;
74-
box-sizing: border-box;
75-
width: min(100%, 20rem);
76-
min-height: 3.125rem;
80+
justify-content: center;
81+
gap: 1rem;
7782
margin-top: clamp(2.75rem, 6vh, 4rem);
78-
padding: 0 0.5rem 0 1rem;
79-
color: var(--hero-title);
80-
text-align: left;
81-
border: 1px solid var(--hero-border);
82-
border-radius: 0.5rem;
83-
background: var(--hero-command-bg);
84-
85-
code,
86-
.prompt {
87-
font-family:
88-
ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
89-
monospace;
90-
font-size: clamp(0.8125rem, 1vw, 0.9375rem);
91-
line-height: 1.4;
92-
}
93-
94-
code {
95-
padding: 0 0.625rem;
96-
overflow: hidden;
97-
color: inherit;
98-
text-overflow: ellipsis;
99-
white-space: nowrap;
100-
background: transparent;
101-
}
10283
}
10384

104-
.prompt {
105-
color: var(--hero-text);
106-
}
107-
108-
.copyButton {
85+
.link {
10986
display: inline-flex;
11087
align-items: center;
11188
justify-content: center;
112-
width: 2rem;
113-
height: 2rem;
114-
padding: 0;
115-
color: var(--hero-text);
116-
cursor: pointer;
117-
border: 0;
89+
box-sizing: border-box;
90+
width: 7.5rem;
91+
min-height: 2.375rem;
92+
padding: 0.5rem 1rem;
93+
font-size: 0.9375rem;
94+
font-weight: 500;
95+
line-height: 1.25;
96+
white-space: nowrap;
97+
text-decoration: none;
98+
border: 1px solid transparent;
11899
border-radius: 0.5rem;
119-
background: transparent;
120100
transition:
121101
color 0.2s ease,
102+
border-color 0.2s ease,
122103
background-color 0.2s ease;
123104

124-
svg {
125-
width: 1.125rem;
126-
height: 1.125rem;
127-
}
128-
129-
&:hover {
130-
color: var(--hero-link-hover);
131-
background: color-mix(in srgb, var(--hero-title) 7%, transparent);
132-
}
133-
134105
&:focus-visible {
135106
outline: 2px solid var(--rp-c-brand);
136-
outline-offset: 2px;
107+
outline-offset: 3px;
137108
}
138109
}
139110

140-
.links {
141-
display: flex;
142-
flex-wrap: wrap;
143-
align-items: center;
144-
justify-content: center;
145-
gap: 1rem 2.5rem;
146-
margin-top: clamp(2rem, 4vh, 2.5rem);
147-
}
148-
149-
.link {
150-
display: inline-flex;
151-
align-items: center;
152-
gap: 0.5rem;
153-
color: var(--hero-link);
154-
font-size: 0.9375rem;
155-
font-weight: 500;
156-
line-height: 1.5;
157-
text-decoration: none;
158-
transition: color 0.2s ease;
159-
160-
svg {
161-
width: 0.75rem;
162-
height: 0.75rem;
163-
transition: transform 0.2s ease;
164-
}
111+
.primaryLink {
112+
color: var(--hero-primary-text);
113+
background: var(--hero-primary-bg);
165114

166115
&:hover {
167-
color: var(--hero-link-hover);
168-
169-
svg {
170-
transform: translateX(0.2rem);
171-
}
116+
color: var(--hero-primary-text);
117+
background: var(--hero-primary-bg-hover);
172118
}
119+
}
173120

174-
&:focus-visible {
175-
border-radius: 0.25rem;
176-
outline: 2px solid var(--rp-c-brand);
177-
outline-offset: 4px;
121+
.secondaryLink {
122+
color: var(--hero-secondary-text);
123+
border-color: var(--hero-secondary-border);
124+
background: var(--hero-secondary-bg);
125+
126+
&:hover {
127+
color: var(--hero-secondary-text);
128+
border-color: var(--hero-title-muted);
129+
background: var(--hero-secondary-bg-hover);
178130
}
179131
}
180132

181133
@media (max-width: 640px) {
182134
.hero {
183135
min-height: calc(100svh - var(--rp-nav-height));
184-
padding: 4rem 1.25rem;
136+
padding: 3.25rem 1.25rem;
185137
}
186138

187139
.title {
@@ -197,46 +149,20 @@
197149
line-height: 1.55;
198150
}
199151

200-
.command {
201-
min-height: 3.25rem;
202-
margin-top: 2.25rem;
203-
padding: 0 0.5rem 0 0.875rem;
204-
border-radius: 0.625rem;
205-
206-
code,
207-
.prompt {
208-
font-size: 0.8125rem;
209-
}
210-
211-
code {
212-
padding: 0 0.625rem;
213-
}
214-
}
215-
216-
.copyButton {
217-
width: 2rem;
218-
height: 2rem;
219-
220-
svg {
221-
width: 1.125rem;
222-
height: 1.125rem;
223-
}
224-
}
225-
226152
.links {
227-
gap: 1rem 1.75rem;
228-
margin-top: 2rem;
153+
gap: 0.75rem;
154+
margin-top: 2.25rem;
229155
}
230156

231157
.link {
158+
min-height: 2.25rem;
159+
padding: 0.5rem 0.875rem;
232160
font-size: 0.875rem;
233161
}
234162
}
235163

236164
@media (prefers-reduced-motion: reduce) {
237-
.copyButton,
238-
.link,
239-
.link svg {
165+
.link {
240166
transition: none;
241167
}
242168
}

‎website/theme/components/Hero.tsx‎

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,13 @@
11
import { useI18n } from '@rspress/core/runtime';
2-
import {
3-
IconArrowRight,
4-
IconCopy,
5-
IconSuccess,
6-
Link,
7-
SvgWrapper,
8-
copyToClipboard,
9-
} from '@rspress/core/theme-original';
10-
import { useCallback, useEffect, useRef, useState } from 'react';
2+
import { Link } from '@rspress/core/theme-original';
113
import { useI18nUrl } from './utils';
124
import styles from './Hero.module.scss';
135

14-
const createCommand = 'pnpm create rstack';
156
const githubUrl = 'https://github.com/rstackjs/rstack-cli';
167

178
export function Hero() {
189
const tUrl = useI18nUrl();
1910
const t = useI18n<typeof import('i18n')>();
20-
const [copied, setCopied] = useState(false);
21-
const resetTimer = useRef<number | undefined>(undefined);
22-
23-
const handleCopy = useCallback(async () => {
24-
const copiedSuccessfully = await copyToClipboard(createCommand);
25-
26-
if (!copiedSuccessfully) {
27-
return;
28-
}
29-
30-
setCopied(true);
31-
window.clearTimeout(resetTimer.current);
32-
resetTimer.current = window.setTimeout(() => setCopied(false), 1600);
33-
}, []);
34-
35-
useEffect(() => () => window.clearTimeout(resetTimer.current), []);
3611

3712
return (
3813
<section className={styles.hero} aria-labelledby="home-hero-title">
@@ -44,35 +19,20 @@ export function Hero() {
4419

4520
<p className={styles.description}>{t('slogan')}</p>
4621

47-
<div className={styles.command}>
48-
<span className={styles.prompt} aria-hidden="true">
49-
$
50-
</span>
51-
<code>{createCommand}</code>
52-
<button
53-
type="button"
54-
className={styles.copyButton}
55-
aria-label={copied ? t('copiedCommand') : t('copyCommand')}
56-
title={copied ? t('copiedCommand') : t('copyCommand')}
57-
onClick={() => void handleCopy()}
58-
>
59-
<SvgWrapper icon={copied ? IconSuccess : IconCopy} />
60-
</button>
61-
</div>
62-
6322
<div className={styles.links}>
64-
<Link className={styles.link} href={tUrl('/guide/quick-start')}>
65-
<span>{t('quickStart')}</span>
66-
<SvgWrapper icon={IconArrowRight} />
23+
<Link
24+
className={`${styles.link} ${styles.primaryLink}`}
25+
href={tUrl('/guide/quick-start')}
26+
>
27+
{t('getStarted')}
6728
</Link>
6829
<a
69-
className={styles.link}
30+
className={`${styles.link} ${styles.secondaryLink}`}
7031
href={githubUrl}
7132
target="_blank"
7233
rel="noopener noreferrer"
7334
>
74-
<span>{t('viewSource')}</span>
75-
<SvgWrapper icon={IconArrowRight} />
35+
{t('github')}
7636
</a>
7737
</div>
7838
</div>

‎website/theme/index.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515

1616
body:has(#home-hero-title) .rp-nav {
17-
border-bottom: none;
17+
border-bottom-color: transparent;
1818
}
1919

2020
.rspress-logo {

0 commit comments

Comments
 (0)