oneslash-design-system 2.23.1 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/DESIGN.md +20 -5
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +248 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +551 -0
- package/dist/cases/billing-page/self-serve.jsx +4 -4
- package/dist/cases/billing-page/trial.d.ts +1 -0
- package/dist/cases/billing-page/trial.jsx +115 -0
- package/dist/cases/billing-page.md +166 -5
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/collapsible-search/popover.jsx +1 -1
- package/dist/cases/collapsible-search.md +2 -2
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/cookie-choice/banner.d.ts +1 -0
- package/dist/cases/cookie-choice/banner.jsx +82 -0
- package/dist/cases/cookie-choice/settings.d.ts +1 -0
- package/dist/cases/cookie-choice/settings.jsx +75 -0
- package/dist/cases/cookie-choice.md +234 -0
- package/dist/cases/dashboard/numbers-first.jsx +63 -2
- package/dist/cases/dashboard/work-first.jsx +1 -1
- package/dist/cases/dashboard.md +77 -5
- package/dist/cases/data-table-page/all-rows.jsx +1 -1
- package/dist/cases/data-table-page/paged.jsx +1 -1
- package/dist/cases/data-table-page.md +2 -2
- package/dist/cases/invoice-list/table.jsx +21 -9
- package/dist/cases/invoice-list.md +27 -12
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/message-reactions/picker.jsx +1 -1
- package/dist/cases/message-reactions.md +2 -2
- package/dist/cases/message-row.md +2 -1
- package/dist/cases/newsletter-signup/inline.d.ts +1 -0
- package/dist/cases/newsletter-signup/inline.jsx +72 -0
- package/dist/cases/newsletter-signup/section.d.ts +1 -0
- package/dist/cases/newsletter-signup/section.jsx +72 -0
- package/dist/cases/newsletter-signup.md +234 -0
- package/dist/cases/number-format.md +9 -3
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/people-row/stack.jsx +1 -1
- package/dist/cases/people-row.md +2 -2
- package/dist/cases/plan-comparison/table.d.ts +1 -0
- package/dist/cases/plan-comparison/table.jsx +47 -0
- package/dist/cases/plan-comparison.md +94 -0
- package/dist/cases/plan-picker.md +1 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/pricing-section.md +1 -1
- package/dist/cases/site-footer/columns.jsx +2 -1
- package/dist/cases/site-footer.md +3 -1
- package/dist/cases/stat-row/tiles.jsx +2 -1
- package/dist/cases/stat-row.md +5 -2
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +883 -30
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +92 -0
- package/dist/components/dateField.jsx +1 -1
- package/dist/components/formatNumber.d.ts +10 -2
- package/dist/components/formatNumber.js +44 -9
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/layout.d.ts +4 -2
- package/dist/components/layout.jsx +13 -2
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.jsx +81 -0
- package/dist/components/pageShell.d.ts +3 -3
- package/dist/components/pageShell.jsx +6 -5
- package/dist/components/popover.d.ts +5 -1
- package/dist/components/popover.jsx +3 -2
- package/dist/components/progress.jsx +1 -1
- package/dist/components/select.jsx +5 -2
- package/dist/components/statTile.d.ts +1 -1
- package/dist/components/statTile.jsx +7 -2
- package/dist/components/tableCell.d.ts +4 -3
- package/dist/components/tableCell.jsx +2 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/components/toaster.jsx +81 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/internal/markdown.d.ts +40 -0
- package/dist/internal/markdown.js +577 -0
- package/dist/internal/toaster.d.ts +2 -0
- package/dist/internal/toaster.js +8 -0
- package/dist/native-mapping.json +28 -4
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +22 -0
- package/dist/stories/Cases.generated.stories.jsx +44 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Markdown.stories.d.ts +9 -0
- package/dist/stories/Markdown.stories.jsx +66 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +2 -0
- package/dist/stories/Popover.stories.jsx +33 -0
- package/dist/stories/StatTile.stories.d.ts +4 -0
- package/dist/stories/StatTile.stories.jsx +47 -2
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/dist/stories/Toaster.stories.d.ts +4 -0
- package/dist/stories/Toaster.stories.jsx +30 -0
- package/package.json +1 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Newsletter sign-up
|
|
2
|
+
|
|
3
|
+
A reader of the public site wants to hear about the product by email, without making an account.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rules 'A form error shows next to the problem' and 'Success shows where the person is looking'.
|
|
8
|
+
- Use a `Form` with a visible label 'Email address' on a `TextField type="email" autoComplete="email"`, and a Button 'Subscribe'.
|
|
9
|
+
- Make 'Subscribe' secondary. The page's one primary Button stays 'Sign Up', as the rule 'A marketing page asks for one main action, in the same words everywhere' says.
|
|
10
|
+
- Show a bad address on submit, under the field: 'Enter an email address, like name@example.com.' Keep the Button enabled.
|
|
11
|
+
- Make the pressed Button `loading` while the request runs, and keep its label. Make the field `readOnly` meanwhile, so focus stays in it.
|
|
12
|
+
- Replace the form with 'Check your email to confirm.' when the request works, and move focus to that line, so a screen reader reads it.
|
|
13
|
+
- Send an email to an address already on the list too, saying it is subscribed and how to leave, so the line is true for both.
|
|
14
|
+
- Show the same line for an address that is already on the list, so the form never tells who is subscribed.
|
|
15
|
+
- Confirm by email before sending anything, as the case 'Check your email' says.
|
|
16
|
+
- Say how often the email comes and how to leave, in `section`: 'One email a month with what shipped. Leave any time from the link in each email.'
|
|
17
|
+
- Put `section` after the post's text and before the case 'Page end' `next-link`, which still ends the page. It asks for an email, not an account, so it is not a sign-up banner.
|
|
18
|
+
- Put the sign-up above the footer, not in it, as the case 'Site footer' says. The footer's 'Newsletter' link goes to a page with this form.
|
|
19
|
+
|
|
20
|
+
## Don't
|
|
21
|
+
|
|
22
|
+
- Do not open the sign-up in a popup on scroll or when the reader leaves.
|
|
23
|
+
- Do not tick a box for marketing email before the reader does.
|
|
24
|
+
- Do not use a placeholder as the only label.
|
|
25
|
+
- Do not label the Button 'Sign Up'. That word means making an account.
|
|
26
|
+
- Do not say 'You are already subscribed'. It tells anyone whether an address is on the list.
|
|
27
|
+
- Do not disable the Button until the field is filled. Show the error on submit.
|
|
28
|
+
|
|
29
|
+
## Option: One field above the footer
|
|
30
|
+
|
|
31
|
+
Use when: A sign-up just above the footer or at the end of a page, one field wide.
|
|
32
|
+
|
|
33
|
+
Uses: `Button`, `Center`, `Form`, `Heading`, `SiteFooter`, `Stack`, `TextField`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
'use client';
|
|
37
|
+
import { useEffect, useRef, useState } from 'react';
|
|
38
|
+
import Form from 'oneslash-design-system/components/form';
|
|
39
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
40
|
+
import Button from 'oneslash-design-system/components/button';
|
|
41
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
42
|
+
import SiteFooter from 'oneslash-design-system/components/siteFooter';
|
|
43
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
44
|
+
|
|
45
|
+
// A small check: some text, an @, then some text.
|
|
46
|
+
function looksLikeEmail(value: string) {
|
|
47
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default function NewsletterSignupInline() {
|
|
51
|
+
const [email, setEmail] = useState('');
|
|
52
|
+
const [error, setError] = useState('');
|
|
53
|
+
const [sending, setSending] = useState(false);
|
|
54
|
+
const [done, setDone] = useState(false);
|
|
55
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
56
|
+
const doneLine = useRef<HTMLHeadingElement>(null);
|
|
57
|
+
|
|
58
|
+
// Stops the request if the example goes away before it ends.
|
|
59
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
60
|
+
|
|
61
|
+
// The form is gone, so focus moves to the line that took its place, and a screen reader reads it.
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (done) doneLine.current?.focus({ preventScroll: true });
|
|
64
|
+
}, [done]);
|
|
65
|
+
|
|
66
|
+
// While it sends, the field is read-only, not disabled, so focus stays in it.
|
|
67
|
+
function handleSubmit() {
|
|
68
|
+
if (sending) return;
|
|
69
|
+
// An empty field and a bad address get their own words. The Button stays enabled either way.
|
|
70
|
+
const value = email.trim();
|
|
71
|
+
if (!value) {
|
|
72
|
+
setError('Enter your email.');
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (!looksLikeEmail(value)) {
|
|
76
|
+
setError('Enter an email address, like name@example.com.');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
setError('');
|
|
80
|
+
setSending(true);
|
|
81
|
+
// Stands in for the request to the server. It always sends an email: a link to confirm a new address,
|
|
82
|
+
// or a note that an address already on the list is subscribed, with the link to leave.
|
|
83
|
+
// A failed request shows an inline error Alert above the field instead, such as 'Could not subscribe. Try again.'
|
|
84
|
+
timer.current = setTimeout(() => {
|
|
85
|
+
setSending(false);
|
|
86
|
+
// Both get an email, so the same line is true for both, and the form never tells who is subscribed.
|
|
87
|
+
setDone(true);
|
|
88
|
+
}, 1200);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<Stack gap="huge">
|
|
93
|
+
{/* The sign-up sits just above the footer, one field wide. The footer itself holds only links. */}
|
|
94
|
+
<Center width="form">
|
|
95
|
+
<Stack gap="large">
|
|
96
|
+
<Heading level={2} size="subtitle1">Get the Acme newsletter</Heading>
|
|
97
|
+
{done ? (
|
|
98
|
+
<Heading ref={doneLine} tabIndex={-1} level={3} size="subtitle1">Check your email to confirm.</Heading>
|
|
99
|
+
) : (
|
|
100
|
+
<Form aria-label="Get the Acme newsletter" onSubmit={handleSubmit}>
|
|
101
|
+
<TextField
|
|
102
|
+
id="newsletter-signup-inline-email"
|
|
103
|
+
label="Email address"
|
|
104
|
+
type="email"
|
|
105
|
+
autoComplete="email"
|
|
106
|
+
value={email}
|
|
107
|
+
readOnly={sending}
|
|
108
|
+
error={Boolean(error)}
|
|
109
|
+
errorText={error}
|
|
110
|
+
onChange={(e) => { setEmail(e.target.value); setError(''); }}
|
|
111
|
+
/>
|
|
112
|
+
<Stack align="start">
|
|
113
|
+
<Button size="medium" type="secondary" state="enabled" label="Subscribe" htmlType="submit" loading={sending} />
|
|
114
|
+
</Stack>
|
|
115
|
+
</Form>
|
|
116
|
+
)}
|
|
117
|
+
</Stack>
|
|
118
|
+
</Center>
|
|
119
|
+
<SiteFooter
|
|
120
|
+
brand={{ href: '#top', name: 'Acme' }}
|
|
121
|
+
links={[
|
|
122
|
+
{ label: 'Pricing', href: '#pricing' },
|
|
123
|
+
{ label: 'Blog', href: '#blog' },
|
|
124
|
+
{ label: 'Privacy', href: '#privacy' },
|
|
125
|
+
]}
|
|
126
|
+
legal="© 2026 Acme. All rights reserved."
|
|
127
|
+
/>
|
|
128
|
+
</Stack>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Option: A section at the end of a post
|
|
134
|
+
|
|
135
|
+
Use when: The end of a post, where a reader decides whether to hear more, so it says what comes and how often.
|
|
136
|
+
|
|
137
|
+
Uses: `Button`, `Center`, `Form`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
|
|
138
|
+
|
|
139
|
+
```tsx
|
|
140
|
+
'use client';
|
|
141
|
+
import { useEffect, useRef, useState } from 'react';
|
|
142
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
143
|
+
import Form from 'oneslash-design-system/components/form';
|
|
144
|
+
import TextField from 'oneslash-design-system/components/textField';
|
|
145
|
+
import Button from 'oneslash-design-system/components/button';
|
|
146
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
147
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
148
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
149
|
+
|
|
150
|
+
// A small check: some text, an @, then some text.
|
|
151
|
+
function looksLikeEmail(value: string) {
|
|
152
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export default function NewsletterSignupSection() {
|
|
156
|
+
const [email, setEmail] = useState('');
|
|
157
|
+
const [error, setError] = useState('');
|
|
158
|
+
const [sending, setSending] = useState(false);
|
|
159
|
+
const [done, setDone] = useState(false);
|
|
160
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
161
|
+
const doneLine = useRef<HTMLHeadingElement>(null);
|
|
162
|
+
|
|
163
|
+
// Stops the request if the example goes away before it ends.
|
|
164
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
165
|
+
|
|
166
|
+
// The form is gone, so focus moves to the line that took its place, and a screen reader reads it.
|
|
167
|
+
useEffect(() => {
|
|
168
|
+
if (done) doneLine.current?.focus({ preventScroll: true });
|
|
169
|
+
}, [done]);
|
|
170
|
+
|
|
171
|
+
// While it sends, the field is read-only, not disabled, so focus stays in it.
|
|
172
|
+
function handleSubmit() {
|
|
173
|
+
if (sending) return;
|
|
174
|
+
// An empty field and a bad address get their own words. The Button stays enabled either way.
|
|
175
|
+
const value = email.trim();
|
|
176
|
+
if (!value) {
|
|
177
|
+
setError('Enter your email.');
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
if (!looksLikeEmail(value)) {
|
|
181
|
+
setError('Enter an email address, like name@example.com.');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
setError('');
|
|
185
|
+
setSending(true);
|
|
186
|
+
// Stands in for the request to the server. It always sends an email: a link to confirm a new address,
|
|
187
|
+
// or a note that an address already on the list is subscribed, with the link to leave.
|
|
188
|
+
// A failed request shows an inline error Alert above the field instead, such as 'Could not subscribe. Try again.'
|
|
189
|
+
timer.current = setTimeout(() => {
|
|
190
|
+
setSending(false);
|
|
191
|
+
// Both get an email, so the same line is true for both, and the form never tells who is subscribed.
|
|
192
|
+
setDone(true);
|
|
193
|
+
}, 1200);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
// The end of a post: the section says what comes and how often, then asks for one address.
|
|
198
|
+
<Center width="form">
|
|
199
|
+
<Surface padding="small">
|
|
200
|
+
<Stack gap="large">
|
|
201
|
+
<Stack gap="small">
|
|
202
|
+
<Heading level={2} size="h6">Get the Acme newsletter</Heading>
|
|
203
|
+
<Paragraph tone="secondary" size="body2" measure="none">One email a month with what shipped. Leave any time from the link in each email.</Paragraph>
|
|
204
|
+
</Stack>
|
|
205
|
+
{done ? (
|
|
206
|
+
<Heading ref={doneLine} tabIndex={-1} level={3} size="subtitle1">Check your email to confirm.</Heading>
|
|
207
|
+
) : (
|
|
208
|
+
<Form aria-label="Get the Acme newsletter" onSubmit={handleSubmit}>
|
|
209
|
+
<TextField
|
|
210
|
+
id="newsletter-signup-section-email"
|
|
211
|
+
label="Email address"
|
|
212
|
+
type="email"
|
|
213
|
+
autoComplete="email"
|
|
214
|
+
value={email}
|
|
215
|
+
readOnly={sending}
|
|
216
|
+
error={Boolean(error)}
|
|
217
|
+
errorText={error}
|
|
218
|
+
onChange={(e) => { setEmail(e.target.value); setError(''); }}
|
|
219
|
+
/>
|
|
220
|
+
<Stack align="start">
|
|
221
|
+
<Button size="medium" type="secondary" state="enabled" label="Subscribe" htmlType="submit" loading={sending} />
|
|
222
|
+
</Stack>
|
|
223
|
+
</Form>
|
|
224
|
+
)}
|
|
225
|
+
</Stack>
|
|
226
|
+
</Surface>
|
|
227
|
+
</Center>
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Native
|
|
233
|
+
|
|
234
|
+
On Apple and Android an app has no newsletter form. Link to the web page that has it, or let the person turn on product news in the app's notification settings.
|
|
@@ -4,7 +4,7 @@ A page shows counts, money, sizes, shares or changes.
|
|
|
4
4
|
|
|
5
5
|
## Answer
|
|
6
6
|
|
|
7
|
-
Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and
|
|
7
|
+
Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. On a chart's axis, a number from 10,000 up shows its short form too: '12.4K'. The chart's readout and its table show the exact number. Money has its symbol and its currency's decimals: '$1,240.00', '¥1,240', 'KWD 1,240.000'. A cost under the smallest unit reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. A change in a percent is in points: 'Up 3 pts from last week'. A refund in a list of charges has a minus: '-$12.00'. In a sentence, say the word: 'Refunded $12.00'. A change has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
|
|
8
8
|
|
|
9
9
|
## Why
|
|
10
10
|
|
|
@@ -14,11 +14,14 @@ One page that rounds a cost to four decimals and another that rounds it to two m
|
|
|
14
14
|
|
|
15
15
|
- Show a count whole and grouped: '1,240'. In a tile, show a count or an amount from 10,000 up in its short form: '12.4K', '$12.4K'.
|
|
16
16
|
- Show the exact number in a table, right-aligned.
|
|
17
|
-
- Show
|
|
17
|
+
- Show a number from 10,000 up on a chart's axis in its short form too: '12.4K'. Show the exact number in the chart's readout and its table.
|
|
18
|
+
- Show money with its symbol and its currency's decimals: '$1,240.00', '¥1,240', 'KWD 1,240.000'. Show a cost under the smallest unit as '< $0.01'.
|
|
18
19
|
- Show a time as '340 ms', '1.2 s' or '2 h 24 min'. Show a share as a whole percent, and a small one as '< 1%'. Show a size in base 1024: '52 MB', '1.2 GB'.
|
|
19
20
|
- Put the unit in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'.
|
|
20
21
|
- Match the noun to the count: '1 invoice', '290 invoices'.
|
|
21
22
|
- Say a change's direction, size and comparison: 'Up 12% from last week'. Say 'New this week' when there was nothing before.
|
|
23
|
+
- Say a change in a percent in points: 'Up 3 pts from last week'. A screen reader hears 'percentage points'.
|
|
24
|
+
- Show a refund in a list of charges with a minus: '-$12.00'. In a sentence, say the word: 'Refunded $12.00'.
|
|
22
25
|
- Show a `Skeleton` while a number loads, 'No data yet' when there is none, and the case 'Load failure' when it could not load.
|
|
23
26
|
- Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. Do not format a number by hand.
|
|
24
27
|
|
|
@@ -27,10 +30,13 @@ One page that rounds a cost to four decimals and another that rounds it to two m
|
|
|
27
30
|
- Do not show 0 for a number that is loading, missing or failed.
|
|
28
31
|
- Do not show a bare number, or a unit only in a tooltip.
|
|
29
32
|
- Do not round a cost to four decimals in one place and two in another.
|
|
33
|
+
- Do not give every currency two decimals. Yen has none: '¥1,240', not '¥1,240.00'.
|
|
34
|
+
- Do not say a change in a percent as a percent ('Up 25%' for 12% against 9.6%).
|
|
30
35
|
- Do not color a change green or red. More is not good or bad by itself.
|
|
31
36
|
- Do not show the compact form ('12.4K') in a table, or give a screen reader only the compact form.
|
|
37
|
+
- Do not show only the short form in a chart. Its readout and table are exact.
|
|
32
38
|
- Do not show 100% for a share that is not the whole.
|
|
33
39
|
|
|
34
40
|
## Native
|
|
35
41
|
|
|
36
|
-
On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`.
|
|
42
|
+
On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`. On a chart's axis use `.notation(.compactName)` on Apple and `CompactDecimalFormat` on Android.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function OnboardingChecklist(): import("react").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import Toaster, { toast, dismissToast } from '../../components/toaster';
|
|
15
|
+
import Heading from '../../components/heading';
|
|
16
|
+
import Paragraph from '../../components/paragraph';
|
|
17
|
+
import SettingsSection from '../../components/settingsSection';
|
|
18
|
+
import StepList from '../../components/stepList';
|
|
19
|
+
import Progress from '../../components/progress';
|
|
20
|
+
import Alert from '../../components/alert';
|
|
21
|
+
import Button from '../../components/button';
|
|
22
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
23
|
+
// Things to set up that can wait. The app works without them. A real app reads them from the server.
|
|
24
|
+
var first = [
|
|
25
|
+
{ id: 'workspace', label: 'Name your workspace', detail: 'Done Nov 14, 2026', action: 'Rename Workspace', href: '/settings/workspace', done: true },
|
|
26
|
+
{ id: 'invite', label: 'Invite your team', detail: 'Done Nov 14, 2026', action: 'Invite People', href: '/settings/members', done: true },
|
|
27
|
+
{ id: 'calendar', label: 'Connect a calendar', detail: 'In Settings, under Integrations', action: 'Connect Calendar', href: '/settings/integrations', done: false },
|
|
28
|
+
{ id: 'project', label: 'Create your first project', detail: 'On the Projects page', action: 'Create Project', href: '/projects/new', done: false },
|
|
29
|
+
];
|
|
30
|
+
export default function OnboardingChecklist() {
|
|
31
|
+
var _a = useState(first), tasks = _a[0], setTasks = _a[1];
|
|
32
|
+
var _b = useState(false), hidden = _b[0], setHidden = _b[1];
|
|
33
|
+
var page = useRef(null);
|
|
34
|
+
var hideButton = useRef(null);
|
|
35
|
+
var firstAction = useRef(null);
|
|
36
|
+
var toastIds = useRef([]);
|
|
37
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
38
|
+
var focusNext = useRef();
|
|
39
|
+
// On unmount it closes every toast it opened.
|
|
40
|
+
useEffect(function () { return function () {
|
|
41
|
+
toastIds.current.forEach(function (id) { return dismissToast(id); });
|
|
42
|
+
toastIds.current = [];
|
|
43
|
+
}; }, []);
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
var move = focusNext.current;
|
|
46
|
+
focusNext.current = undefined;
|
|
47
|
+
move === null || move === void 0 ? void 0 : move();
|
|
48
|
+
});
|
|
49
|
+
var done = tasks.filter(function (t) { return t.done; }).length;
|
|
50
|
+
var waiting = tasks.filter(function (t) { return !t.done; });
|
|
51
|
+
var allDone = waiting.length === 0;
|
|
52
|
+
// A real app lets the link go to its page, and the step is done when the person comes back.
|
|
53
|
+
// The example marks it done here, so the end of the checklist shows.
|
|
54
|
+
function finish(event, id) {
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
var next = tasks.map(function (t) { return (t.id === id ? __assign(__assign({}, t), { done: true, detail: 'Done Nov 16, 2026' }) : t); });
|
|
57
|
+
setTasks(next);
|
|
58
|
+
// The pressed link goes away. Focus goes to the next link, or to 'Hide Checklist' after the last one.
|
|
59
|
+
focusNext.current = next.every(function (t) { return t.done; })
|
|
60
|
+
? function () { var _a; return (_a = hideButton.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); }
|
|
61
|
+
: function () { var _a; return (_a = firstAction.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
|
|
62
|
+
}
|
|
63
|
+
// The checklist leaves the home page for good. Its Button goes with it, so focus goes to the page's heading.
|
|
64
|
+
function hide() {
|
|
65
|
+
setHidden(true);
|
|
66
|
+
toastIds.current.push(toast({ type: 'success', message: 'Setup checklist hidden.' }));
|
|
67
|
+
focusNext.current = function () { var _a; return (_a = page.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
|
|
68
|
+
}
|
|
69
|
+
return (<Center width="page">
|
|
70
|
+
<Stack gap="xlarge">
|
|
71
|
+
<Heading ref={page} tabIndex={-1} level={1} size="h5">Home</Heading>
|
|
72
|
+
{!hidden && (<SettingsSection title="Set up Acme" description="The app works without these. Finish them when you are ready." id="onboarding-checklist-setup">
|
|
73
|
+
<Stack gap="large">
|
|
74
|
+
<Progress kind="share" label="Set up" value={done} max={tasks.length} valueText={"".concat(done, " of ").concat(tasks.length, " done")}/>
|
|
75
|
+
<StepList aria-label="Setup steps" steps={tasks.map(function (t) { return ({ label: t.label, detail: t.detail, status: t.done ? 'done' : 'waiting' }); })}/>
|
|
76
|
+
{allDone ? (<Stack gap="medium" align="start">
|
|
77
|
+
{/* An inline Alert is a polite status, so a screen reader hears it. */}
|
|
78
|
+
<Alert variant="inline" type="success" autoDismiss={false} message="Acme is set up."/>
|
|
79
|
+
<Button ref={hideButton} size="small" type="tertiary" state="enabled" label="Hide Checklist" onClickButton={hide}/>
|
|
80
|
+
</Stack>) : (
|
|
81
|
+
// Each waiting step links to the place where it is done.
|
|
82
|
+
<Cluster gap="small">
|
|
83
|
+
{waiting.map(function (t, i) { return (<Button key={t.id} ref={i === 0 ? firstAction : undefined} size="small" type="secondary" state="enabled" label={t.action} href={t.href} onClickButton={function (event) { return finish(event, t.id); }}/>); })}
|
|
84
|
+
</Cluster>)}
|
|
85
|
+
</Stack>
|
|
86
|
+
</SettingsSection>)}
|
|
87
|
+
<Paragraph tone="secondary" measure="none">Your projects and comments show here.</Paragraph>
|
|
88
|
+
</Stack>
|
|
89
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
90
|
+
<Toaster />
|
|
91
|
+
</Center>);
|
|
92
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useEffect, useRef, useState } from 'react';
|
|
12
|
+
import Heading from '../../components/heading';
|
|
13
|
+
import Paragraph from '../../components/paragraph';
|
|
14
|
+
import Form from '../../components/form';
|
|
15
|
+
import TextField from '../../components/textField';
|
|
16
|
+
import Alert from '../../components/alert';
|
|
17
|
+
import Button from '../../components/button';
|
|
18
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
19
|
+
var titles = ['Name your workspace', 'Invite your team', 'You are set'];
|
|
20
|
+
// A small check: some text, an @, then some text.
|
|
21
|
+
function looksLikeEmail(value) {
|
|
22
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
23
|
+
}
|
|
24
|
+
function addresses(text) {
|
|
25
|
+
return text.split(',').map(function (a) { return a.trim(); }).filter(Boolean);
|
|
26
|
+
}
|
|
27
|
+
// `failOn` makes the workspace request fail once, so a test can see the error. A real app leaves it out.
|
|
28
|
+
// A real app saves each step on Continue. A person who leaves comes back to the first step not done,
|
|
29
|
+
// with what they entered, and the steps before it show what was saved.
|
|
30
|
+
export default function OnboardingSteps(_a) {
|
|
31
|
+
var _b = _a === void 0 ? {} : _a, failOn = _b.failOn;
|
|
32
|
+
var _c = useState(0), step = _c[0], setStep = _c[1];
|
|
33
|
+
// What the person typed stays in state, so Back shows it again.
|
|
34
|
+
var _d = useState(''), name = _d[0], setName = _d[1];
|
|
35
|
+
var _e = useState(''), emails = _e[0], setEmails = _e[1];
|
|
36
|
+
var _f = useState(''), nameError = _f[0], setNameError = _f[1];
|
|
37
|
+
var _g = useState(''), emailError = _g[0], setEmailError = _g[1];
|
|
38
|
+
var _h = useState(''), error = _h[0], setError = _h[1];
|
|
39
|
+
var _j = useState(false), loading = _j[0], setLoading = _j[1];
|
|
40
|
+
// What was saved: the workspace's name once it exists, and the addresses already invited.
|
|
41
|
+
// Back and Continue again never make the workspace twice or send an invite twice.
|
|
42
|
+
var _k = useState(null), created = _k[0], setCreated = _k[1];
|
|
43
|
+
var _l = useState([]), sent = _l[0], setSent = _l[1];
|
|
44
|
+
var heading = useRef(null);
|
|
45
|
+
var failed = useRef(false);
|
|
46
|
+
var timer = useRef();
|
|
47
|
+
// Set on a step change; run after the next render, once the new heading is on screen.
|
|
48
|
+
var focusNext = useRef();
|
|
49
|
+
// Stops the request if the example goes away before it ends.
|
|
50
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
var move = focusNext.current;
|
|
53
|
+
focusNext.current = undefined;
|
|
54
|
+
move === null || move === void 0 ? void 0 : move();
|
|
55
|
+
});
|
|
56
|
+
// Each step change moves focus to the step's heading, so a screen reader reads where the person is.
|
|
57
|
+
// The first step keeps focus where the page put it.
|
|
58
|
+
function go(next) {
|
|
59
|
+
setError('');
|
|
60
|
+
setNameError('');
|
|
61
|
+
setEmailError('');
|
|
62
|
+
setStep(next);
|
|
63
|
+
focusNext.current = function () { var _a; return (_a = heading.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true }); };
|
|
64
|
+
}
|
|
65
|
+
function back() {
|
|
66
|
+
if (loading)
|
|
67
|
+
return;
|
|
68
|
+
go(step - 1);
|
|
69
|
+
}
|
|
70
|
+
function createWorkspace() {
|
|
71
|
+
if (loading)
|
|
72
|
+
return;
|
|
73
|
+
setError('');
|
|
74
|
+
setNameError('');
|
|
75
|
+
var wanted = name.trim();
|
|
76
|
+
if (!wanted) {
|
|
77
|
+
setNameError('Enter a name for your workspace.');
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
// Already saved with this name: go on with no request.
|
|
81
|
+
if (wanted === created) {
|
|
82
|
+
go(1);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
setLoading(true);
|
|
86
|
+
// Stands in for the request to the server: it creates the workspace, or renames it when it exists.
|
|
87
|
+
// The step and its Buttons stay while it runs.
|
|
88
|
+
timer.current = setTimeout(function () {
|
|
89
|
+
setLoading(false);
|
|
90
|
+
if (failOn === 'workspace' && !failed.current) {
|
|
91
|
+
failed.current = true;
|
|
92
|
+
setError(created === null ? 'The workspace was not created. Try again.' : 'The workspace was not renamed. Try again.');
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
setCreated(wanted);
|
|
96
|
+
go(1);
|
|
97
|
+
}, 1200);
|
|
98
|
+
}
|
|
99
|
+
function sendInvites() {
|
|
100
|
+
if (loading)
|
|
101
|
+
return;
|
|
102
|
+
setError('');
|
|
103
|
+
setEmailError('');
|
|
104
|
+
var list = addresses(emails);
|
|
105
|
+
if (list.length === 0 && sent.length === 0) {
|
|
106
|
+
setEmailError('Enter an email address, or choose Skip for Now.');
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
var wrong = list.find(function (a) { return !looksLikeEmail(a); });
|
|
110
|
+
if (wrong) {
|
|
111
|
+
setEmailError("Check ".concat(wrong, ". Enter an address like name@example.com."));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
// Only addresses not yet invited are sent. With none, the step goes on at once.
|
|
115
|
+
var fresh = list.filter(function (a) { return !sent.includes(a); });
|
|
116
|
+
if (fresh.length === 0) {
|
|
117
|
+
go(2);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
setLoading(true);
|
|
121
|
+
// Stands in for the request to the server. A failed request shows an inline error Alert, as on the first step.
|
|
122
|
+
timer.current = setTimeout(function () {
|
|
123
|
+
setLoading(false);
|
|
124
|
+
setSent(function (s) { return __spreadArray(__spreadArray([], s, true), fresh, true); });
|
|
125
|
+
go(2);
|
|
126
|
+
}, 1200);
|
|
127
|
+
}
|
|
128
|
+
// Skip sends nothing and goes on at once. Invites already sent stay sent.
|
|
129
|
+
function skip() {
|
|
130
|
+
if (loading)
|
|
131
|
+
return;
|
|
132
|
+
go(2);
|
|
133
|
+
}
|
|
134
|
+
var workspace = created !== null && created !== void 0 ? created : name.trim();
|
|
135
|
+
return (<Center width="form">
|
|
136
|
+
<Stack gap="small">
|
|
137
|
+
{/* The count of steps is said up front, in words. */}
|
|
138
|
+
<Paragraph size="body2" tone="secondary" measure="none">{"Step ".concat(step + 1, " of ").concat(titles.length)}</Paragraph>
|
|
139
|
+
<Heading ref={heading} tabIndex={-1} level={1} size="h5">{titles[step]}</Heading>
|
|
140
|
+
</Stack>
|
|
141
|
+
|
|
142
|
+
{step === 0 && (<Form aria-label={titles[0]} onSubmit={createWorkspace}>
|
|
143
|
+
{/* A failed request keeps the step and what was typed, and says so above the fields and the Buttons. */}
|
|
144
|
+
{error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
|
|
145
|
+
<TextField id="onboarding-steps-workspace" label="Workspace name" value={name} disabled={loading} error={Boolean(nameError)} errorText={nameError} helperText="Your team works here. You can change the name later." onChange={function (e) { setName(e.target.value); setNameError(''); }}/>
|
|
146
|
+
<Cluster gap="small">
|
|
147
|
+
<Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading}/>
|
|
148
|
+
</Cluster>
|
|
149
|
+
</Form>)}
|
|
150
|
+
|
|
151
|
+
{step === 1 && (<Form aria-label={titles[1]} onSubmit={sendInvites}>
|
|
152
|
+
{error && <Alert type="error" variant="inline" message={error} showCloseButton onClose={function () { return setError(''); }}/>}
|
|
153
|
+
<Paragraph measure="none">{"Invite the people you work with to ".concat(workspace, ". You can skip this and invite them later.")}</Paragraph>
|
|
154
|
+
<TextField id="onboarding-steps-emails" label="Email addresses" type="email" value={emails} disabled={loading} error={Boolean(emailError)} errorText={emailError} helperText="Separate addresses with commas." onChange={function (e) { setEmails(e.target.value); setEmailError(''); }}/>
|
|
155
|
+
<Cluster gap="small" justify="between">
|
|
156
|
+
<Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back}/>
|
|
157
|
+
<Cluster gap="small">
|
|
158
|
+
<Button size="medium" type="tertiary" state="enabled" label="Skip for Now" onClickButton={skip}/>
|
|
159
|
+
<Button size="medium" type="primary" state="enabled" label="Continue" htmlType="submit" loading={loading}/>
|
|
160
|
+
</Cluster>
|
|
161
|
+
</Cluster>
|
|
162
|
+
</Form>)}
|
|
163
|
+
|
|
164
|
+
{step === 2 && (<Stack gap="large">
|
|
165
|
+
<Paragraph measure="none">
|
|
166
|
+
{sent.length === 0
|
|
167
|
+
? "".concat(workspace, " is ready. No invites were sent. You can invite your team later in Settings, under Members.")
|
|
168
|
+
: "".concat(workspace, " is ready. Invites went to ").concat(sent.length, " ").concat(sent.length === 1 ? 'person' : 'people', ".")}
|
|
169
|
+
</Paragraph>
|
|
170
|
+
<Cluster gap="small" justify="between">
|
|
171
|
+
<Button size="medium" type="tertiary" state="enabled" label="Back" decoIcon="ChevronLeft" onClickButton={back}/>
|
|
172
|
+
{/* A real app goes to the new workspace. */}
|
|
173
|
+
<Button size="medium" type="primary" state="enabled" label="Go to Workspace" href="/workspace"/>
|
|
174
|
+
</Cluster>
|
|
175
|
+
</Stack>)}
|
|
176
|
+
</Center>);
|
|
177
|
+
}
|