oneslash-design-system 2.20.0 → 2.22.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.
Files changed (167) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +34 -1
  3. package/dist/cases/about-page/profile.d.ts +1 -0
  4. package/dist/cases/about-page/profile.jsx +64 -0
  5. package/dist/cases/about-page.md +114 -0
  6. package/dist/cases/admin-inbox/list.d.ts +1 -0
  7. package/dist/cases/admin-inbox/list.jsx +104 -0
  8. package/dist/cases/admin-inbox/split.d.ts +1 -0
  9. package/dist/cases/admin-inbox/split.jsx +68 -0
  10. package/dist/cases/admin-inbox.md +254 -0
  11. package/dist/cases/api-keys.md +1 -1
  12. package/dist/cases/app-shell/top-tabs.jsx +10 -4
  13. package/dist/cases/app-shell.md +13 -5
  14. package/dist/cases/blog-index/cards.d.ts +1 -0
  15. package/dist/cases/blog-index/cards.jsx +45 -0
  16. package/dist/cases/blog-index/list.d.ts +1 -0
  17. package/dist/cases/blog-index/list.jsx +46 -0
  18. package/dist/cases/blog-index.md +160 -0
  19. package/dist/cases/changelog/by-month.d.ts +1 -0
  20. package/dist/cases/changelog/by-month.jsx +70 -0
  21. package/dist/cases/changelog/one-page.d.ts +1 -0
  22. package/dist/cases/changelog/one-page.jsx +70 -0
  23. package/dist/cases/changelog.md +200 -0
  24. package/dist/cases/code-sample/block.d.ts +1 -0
  25. package/dist/cases/code-sample/block.jsx +19 -0
  26. package/dist/cases/code-sample/command.d.ts +1 -0
  27. package/dist/cases/code-sample/command.jsx +17 -0
  28. package/dist/cases/code-sample.md +96 -0
  29. package/dist/cases/contact-page/form.d.ts +1 -0
  30. package/dist/cases/contact-page/form.jsx +83 -0
  31. package/dist/cases/contact-page/links.d.ts +1 -0
  32. package/dist/cases/contact-page/links.jsx +19 -0
  33. package/dist/cases/contact-page.md +142 -0
  34. package/dist/cases/docs-component-page/reference.d.ts +1 -0
  35. package/dist/cases/docs-component-page/reference.jsx +93 -0
  36. package/dist/cases/docs-component-page.md +144 -0
  37. package/dist/cases/faq/accordion.d.ts +1 -0
  38. package/dist/cases/faq/accordion.jsx +25 -0
  39. package/dist/cases/faq/open-list.d.ts +1 -0
  40. package/dist/cases/faq/open-list.jsx +27 -0
  41. package/dist/cases/faq.md +110 -0
  42. package/dist/cases/feature-grid/cards.d.ts +1 -0
  43. package/dist/cases/feature-grid/cards.jsx +33 -0
  44. package/dist/cases/feature-grid/rows.d.ts +1 -0
  45. package/dist/cases/feature-grid/rows.jsx +30 -0
  46. package/dist/cases/feature-grid.md +132 -0
  47. package/dist/cases/image-viewer/gallery.d.ts +1 -0
  48. package/dist/cases/image-viewer/gallery.jsx +32 -0
  49. package/dist/cases/image-viewer/single.d.ts +1 -0
  50. package/dist/cases/image-viewer/single.jsx +25 -0
  51. package/dist/cases/image-viewer.md +123 -0
  52. package/dist/cases/landing-hero/centered.d.ts +1 -0
  53. package/dist/cases/landing-hero/centered.jsx +22 -0
  54. package/dist/cases/landing-hero/split.d.ts +1 -0
  55. package/dist/cases/landing-hero/split.jsx +30 -0
  56. package/dist/cases/landing-hero.md +114 -0
  57. package/dist/cases/legal-page/sections.d.ts +1 -0
  58. package/dist/cases/legal-page/sections.jsx +61 -0
  59. package/dist/cases/legal-page.md +96 -0
  60. package/dist/cases/long-form-page/article.d.ts +1 -0
  61. package/dist/cases/long-form-page/article.jsx +58 -0
  62. package/dist/cases/long-form-page/with-contents.d.ts +1 -0
  63. package/dist/cases/long-form-page/with-contents.jsx +41 -0
  64. package/dist/cases/long-form-page.md +170 -0
  65. package/dist/cases/message-actions/hover-toolbar.jsx +11 -8
  66. package/dist/cases/message-actions/menu.jsx +10 -7
  67. package/dist/cases/message-actions.md +19 -13
  68. package/dist/cases/message-attachments/in-composer.jsx +2 -2
  69. package/dist/cases/message-attachments/in-message.jsx +16 -11
  70. package/dist/cases/message-attachments.md +29 -17
  71. package/dist/cases/one-main-action.md +33 -0
  72. package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
  73. package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
  74. package/dist/cases/overflow-menu.md +16 -10
  75. package/dist/cases/page-end/cta-band.d.ts +1 -0
  76. package/dist/cases/page-end/cta-band.jsx +24 -0
  77. package/dist/cases/page-end/next-link.d.ts +1 -0
  78. package/dist/cases/page-end/next-link.jsx +18 -0
  79. package/dist/cases/page-end.md +88 -0
  80. package/dist/cases/password-gate/inline.d.ts +1 -0
  81. package/dist/cases/password-gate/inline.jsx +94 -0
  82. package/dist/cases/password-gate/modal.d.ts +1 -0
  83. package/dist/cases/password-gate/modal.jsx +81 -0
  84. package/dist/cases/password-gate/page.d.ts +1 -0
  85. package/dist/cases/password-gate/page.jsx +82 -0
  86. package/dist/cases/password-gate.md +351 -0
  87. package/dist/cases/pricing-section/cards.d.ts +1 -0
  88. package/dist/cases/pricing-section/cards.jsx +41 -0
  89. package/dist/cases/pricing-section.md +87 -0
  90. package/dist/cases/product-cards/grid.d.ts +1 -0
  91. package/dist/cases/product-cards/grid.jsx +20 -0
  92. package/dist/cases/product-cards.md +71 -0
  93. package/dist/cases/reply-feedback/thumbs.jsx +11 -8
  94. package/dist/cases/reply-feedback/with-reason.jsx +11 -8
  95. package/dist/cases/reply-feedback.md +20 -14
  96. package/dist/cases/section-index/cards.d.ts +1 -0
  97. package/dist/cases/section-index/cards.jsx +25 -0
  98. package/dist/cases/section-index/list.d.ts +1 -0
  99. package/dist/cases/section-index/list.jsx +56 -0
  100. package/dist/cases/section-index.md +140 -0
  101. package/dist/cases/settings-page/top-tabs.jsx +9 -6
  102. package/dist/cases/settings-page.md +13 -7
  103. package/dist/cases/site-header.md +1 -1
  104. package/dist/cases/site-search/dialog.d.ts +1 -0
  105. package/dist/cases/site-search/dialog.jsx +131 -0
  106. package/dist/cases/site-search.md +176 -0
  107. package/dist/cases/tabbed-panels/tabs.d.ts +1 -0
  108. package/dist/cases/tabbed-panels/tabs.jsx +40 -0
  109. package/dist/cases/tabbed-panels.md +81 -0
  110. package/dist/cases.json +1177 -31
  111. package/dist/components/accordion.d.ts +31 -0
  112. package/dist/components/accordion.jsx +103 -0
  113. package/dist/components/button.d.ts +2 -0
  114. package/dist/components/button.jsx +2 -2
  115. package/dist/components/codeBlock.d.ts +26 -0
  116. package/dist/components/codeBlock.jsx +101 -0
  117. package/dist/components/lightbox.d.ts +34 -0
  118. package/dist/components/lightbox.jsx +206 -0
  119. package/dist/components/linkCard.d.ts +10 -1
  120. package/dist/components/linkCard.jsx +32 -6
  121. package/dist/components/menuItem.jsx +1 -1
  122. package/dist/components/modal.d.ts +10 -2
  123. package/dist/components/modal.jsx +17 -12
  124. package/dist/components/pageHeader.jsx +1 -1
  125. package/dist/components/searchDialog.d.ts +44 -0
  126. package/dist/components/searchDialog.jsx +152 -0
  127. package/dist/components/siteHeader.d.ts +13 -2
  128. package/dist/components/siteHeader.jsx +21 -12
  129. package/dist/components/tab.d.ts +5 -1
  130. package/dist/components/tab.jsx +2 -2
  131. package/dist/components/tabPanel.d.ts +16 -0
  132. package/dist/components/tabPanel.jsx +12 -0
  133. package/dist/components/tabsContainer.d.ts +5 -1
  134. package/dist/components/tabsContainer.jsx +2 -2
  135. package/dist/components/tag.d.ts +6 -1
  136. package/dist/components/tag.jsx +10 -5
  137. package/dist/index.d.ts +5 -0
  138. package/dist/index.js +5 -0
  139. package/dist/internal/accordion.d.ts +4 -0
  140. package/dist/internal/accordion.js +53 -0
  141. package/dist/internal/combobox.d.ts +20 -0
  142. package/dist/internal/combobox.js +28 -0
  143. package/dist/internal/highlight.d.ts +5 -0
  144. package/dist/internal/highlight.js +18 -0
  145. package/dist/native-mapping.json +31 -1
  146. package/dist/stories/Accordion.stories.d.ts +11 -0
  147. package/dist/stories/Accordion.stories.jsx +93 -0
  148. package/dist/stories/Button.stories.jsx +12 -8
  149. package/dist/stories/Cases.generated.stories.d.ts +34 -0
  150. package/dist/stories/Cases.generated.stories.jsx +68 -0
  151. package/dist/stories/CodeBlock.stories.d.ts +12 -0
  152. package/dist/stories/CodeBlock.stories.jsx +65 -0
  153. package/dist/stories/Lightbox.stories.d.ts +11 -0
  154. package/dist/stories/Lightbox.stories.jsx +83 -0
  155. package/dist/stories/LinkCard.stories.d.ts +6 -0
  156. package/dist/stories/LinkCard.stories.jsx +17 -0
  157. package/dist/stories/MenuItem.stories.d.ts +1 -0
  158. package/dist/stories/MenuItem.stories.jsx +8 -0
  159. package/dist/stories/PageHeader.stories.d.ts +2 -0
  160. package/dist/stories/PageHeader.stories.jsx +13 -0
  161. package/dist/stories/SearchDialog.stories.d.ts +17 -0
  162. package/dist/stories/SearchDialog.stories.jsx +111 -0
  163. package/dist/stories/SiteHeader.stories.d.ts +4 -0
  164. package/dist/stories/SiteHeader.stories.jsx +89 -0
  165. package/dist/stories/TabPanel.stories.d.ts +7 -0
  166. package/dist/stories/TabPanel.stories.jsx +31 -0
  167. package/package.json +1 -1
@@ -0,0 +1,351 @@
1
+ # Password gate
2
+
3
+ Some work is private. A visitor needs the password to read it, and someone who does not have it needs to know how to ask.
4
+
5
+ ## Do
6
+
7
+ - Put the gate in a `Surface` with a heading that says what is behind it: 'This case study needs a password'. It is the h1 on a whole page and an h2 inside a page.
8
+ - Say in one line how to get access, with a `Link` to the contact page.
9
+ - Use a password `TextField` and a Button named 'View Work'. Put them in a `Form`, so Enter submits.
10
+ - Show a wrong password under the field: 'That password is not right.' Keep focus in the field and keep what was typed.
11
+ - Keep the Button's label while it checks, and make it `loading`.
12
+ - Keep the field enabled while it checks. A disabled field loses focus, and after a wrong password the cursor must still be in the field.
13
+ - Show the work when the password is right, and move focus to the first control in it.
14
+ - Follow the rule 'A confirm says exactly what will happen' for `modal`. Put 'Cancel' first and make the Modal title and its action the same words: 'View Work'.
15
+ - Let the server check the password and set the cookie. The server sends the private content only to a visitor with the cookie. The page never holds the password.
16
+ - Keep the summary and the facts in the page for `inline`, and leave the private part out of the HTML sent to a visitor without the cookie.
17
+
18
+ ## Don't
19
+
20
+ - Do not send private content to the browser and hide it there, with a style or a check in the page. A visitor can still read it.
21
+ - Do not put the password in the page, in a script or in the address.
22
+ - Do not say which part of a password was wrong.
23
+ - Do not show a bare field with no word on what is behind it or how to ask.
24
+ - Do not change the Button's label while it checks.
25
+
26
+ ## Option: The whole page is private
27
+
28
+ Use when: The whole page is private, and nothing on it is public.
29
+
30
+ Uses: `Button`, `Form`, `Heading`, `Link`, `PageHeader`, `PageShell`, `Paragraph`, `Stack`, `Surface`, `TextField`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { useEffect, useRef, useState } from 'react';
35
+ import PageShell from 'oneslash-design-system/components/pageShell';
36
+ import PageHeader from 'oneslash-design-system/components/pageHeader';
37
+ import Surface from 'oneslash-design-system/components/surface';
38
+ import Heading from 'oneslash-design-system/components/heading';
39
+ import Paragraph from 'oneslash-design-system/components/paragraph';
40
+ import Link from 'oneslash-design-system/components/link';
41
+ import Form from 'oneslash-design-system/components/form';
42
+ import TextField from 'oneslash-design-system/components/textField';
43
+ import Button from 'oneslash-design-system/components/button';
44
+ import { Stack } from 'oneslash-design-system/components/layout';
45
+
46
+ // The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
47
+ // A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
48
+ const PASSPHRASE = 'acme-demo';
49
+
50
+ export default function PasswordGatePage() {
51
+ const [password, setPassword] = useState('');
52
+ const [error, setError] = useState('');
53
+ const [checking, setChecking] = useState(false);
54
+ const [unlocked, setUnlocked] = useState(false);
55
+ // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
56
+ const [attempt, setAttempt] = useState(0);
57
+ const timer = useRef<ReturnType<typeof setTimeout>>();
58
+ const lockAgain = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
59
+
60
+ // Stops the request if the example goes away before it ends.
61
+ useEffect(() => () => clearTimeout(timer.current), []);
62
+
63
+ // The field is gone once the work shows, so focus moves to the first control in it.
64
+ useEffect(() => {
65
+ if (unlocked) lockAgain.current?.focus();
66
+ }, [unlocked]);
67
+
68
+ function handleSubmit() {
69
+ if (checking) return;
70
+ if (!password.trim()) {
71
+ setError('Enter the password.');
72
+ setAttempt((n) => n + 1);
73
+ return;
74
+ }
75
+ setError('');
76
+ setChecking(true);
77
+ // Stands in for the request to the server.
78
+ timer.current = setTimeout(() => {
79
+ setChecking(false);
80
+ if (password === PASSPHRASE) {
81
+ setUnlocked(true);
82
+ } else {
83
+ setError('That password is not right.');
84
+ setAttempt((n) => n + 1);
85
+ }
86
+ }, 600);
87
+ }
88
+
89
+ if (unlocked) {
90
+ return (
91
+ <PageShell>
92
+ <Stack gap="xlarge">
93
+ <PageHeader level={1} title="Plan changes, a case study" lede="How we made a plan change clear before anyone pays." />
94
+ <Paragraph tone="secondary">The screens, the notes and the decisions for this case study are here.</Paragraph>
95
+ <Stack align="start">
96
+ <Button ref={lockAgain} size="medium" type="secondary" state="enabled" label="Lock Again" onClickButton={() => { setUnlocked(false); setPassword(''); }} />
97
+ </Stack>
98
+ </Stack>
99
+ </PageShell>
100
+ );
101
+ }
102
+
103
+ return (
104
+ <PageShell>
105
+ <Surface padding="xlarge" minHeight="tall" align="center">
106
+ <Stack gap="large">
107
+ <Heading level={1} size="h5">This case study needs a password</Heading>
108
+ <Paragraph>
109
+ The password comes by email. <Link href="#contact">Ask for the password</Link>.
110
+ </Paragraph>
111
+ <Form aria-label="Private work" onSubmit={handleSubmit}>
112
+ <TextField key={attempt} id="password-gate-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />
113
+ <Stack align="start">
114
+ <Button size="medium" type="primary" state="enabled" label="View Work" htmlType="submit" loading={checking} />
115
+ </Stack>
116
+ </Form>
117
+ </Stack>
118
+ </Surface>
119
+ </PageShell>
120
+ );
121
+ }
122
+ ```
123
+
124
+ ## Option: Part of the page is private
125
+
126
+ Use when: The summary and the facts stay readable, and the rest is behind the gate.
127
+
128
+ Uses: `Button`, `Figure`, `Form`, `Heading`, `Image`, `Link`, `PageHeader`, `PageShell`, `Paragraph`, `Stack`, `Surface`, `TextField`
129
+
130
+ ```tsx
131
+ 'use client';
132
+ import { useEffect, useRef, useState } from 'react';
133
+ import PageShell from 'oneslash-design-system/components/pageShell';
134
+ import PageHeader from 'oneslash-design-system/components/pageHeader';
135
+ import Figure from 'oneslash-design-system/components/figure';
136
+ import Image from 'oneslash-design-system/components/image';
137
+ import Surface from 'oneslash-design-system/components/surface';
138
+ import Heading from 'oneslash-design-system/components/heading';
139
+ import Paragraph from 'oneslash-design-system/components/paragraph';
140
+ import Link from 'oneslash-design-system/components/link';
141
+ import Form from 'oneslash-design-system/components/form';
142
+ import TextField from 'oneslash-design-system/components/textField';
143
+ import Button from 'oneslash-design-system/components/button';
144
+ import { Stack } from 'oneslash-design-system/components/layout';
145
+
146
+ // The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
147
+ // A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
148
+
149
+ // A stand-in for a screen. A real page passes its own picture.
150
+ const screen =
151
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3C/svg%3E";
152
+
153
+ const PASSPHRASE = 'acme-demo';
154
+
155
+ export default function PasswordGateInline() {
156
+ const [password, setPassword] = useState('');
157
+ const [error, setError] = useState('');
158
+ const [checking, setChecking] = useState(false);
159
+ const [unlocked, setUnlocked] = useState(false);
160
+ // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
161
+ const [attempt, setAttempt] = useState(0);
162
+ const timer = useRef<ReturnType<typeof setTimeout>>();
163
+ const lockAgain = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
164
+
165
+ // Stops the request if the example goes away before it ends.
166
+ useEffect(() => () => clearTimeout(timer.current), []);
167
+
168
+ // The field is gone once the work shows, so focus moves to the first control in it.
169
+ useEffect(() => {
170
+ if (unlocked) lockAgain.current?.focus();
171
+ }, [unlocked]);
172
+
173
+ function handleSubmit() {
174
+ if (checking) return;
175
+ if (!password.trim()) {
176
+ setError('Enter the password.');
177
+ setAttempt((n) => n + 1);
178
+ return;
179
+ }
180
+ setError('');
181
+ setChecking(true);
182
+ // Stands in for the request to the server.
183
+ timer.current = setTimeout(() => {
184
+ setChecking(false);
185
+ if (password === PASSPHRASE) {
186
+ setUnlocked(true);
187
+ } else {
188
+ setError('That password is not right.');
189
+ setAttempt((n) => n + 1);
190
+ }
191
+ }, 600);
192
+ }
193
+
194
+ const header = (
195
+ <PageHeader
196
+ level={1}
197
+ title="Plan changes, a case study"
198
+ lede="How we made a plan change clear before anyone pays."
199
+ facts={[
200
+ { label: 'Role', value: 'Lead designer' },
201
+ { label: 'Team', value: '4 people' },
202
+ { label: 'Year', value: '2026' },
203
+ ]}
204
+ />
205
+ );
206
+
207
+ return (
208
+ <PageShell>
209
+ <Stack gap="giant">
210
+ {/* The summary and the facts stay readable. Only the screens are behind the gate. */}
211
+ <Stack gap="xlarge">
212
+ {header}
213
+ <Paragraph tone="secondary">People could not tell what a new plan would cost them. We showed the new price and the day it starts before the last step, and fewer people wrote to ask.</Paragraph>
214
+ </Stack>
215
+ {unlocked ? (
216
+ <Stack gap="xlarge">
217
+ <Figure crop={16 / 9} caption="The plan change, before the person pays.">
218
+ <Image src={screen} alt="A plan change screen: the current plan beside the new plan, with the new price in green" width={1280} height={720} />
219
+ </Figure>
220
+ <Stack align="start">
221
+ <Button ref={lockAgain} size="medium" type="secondary" state="enabled" label="Lock Again" onClickButton={() => { setUnlocked(false); setPassword(''); }} />
222
+ </Stack>
223
+ </Stack>
224
+ ) : (
225
+ <Surface padding="large">
226
+ <Stack gap="large">
227
+ <Heading level={2} size="h6">This case study needs a password</Heading>
228
+ <Paragraph>
229
+ The password comes by email. <Link href="#contact">Ask for the password</Link>.
230
+ </Paragraph>
231
+ <Form aria-label="Private work" onSubmit={handleSubmit}>
232
+ <TextField key={attempt} id="password-gate-inline-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />
233
+ <Stack align="start">
234
+ <Button size="medium" type="primary" state="enabled" label="View Work" htmlType="submit" loading={checking} />
235
+ </Stack>
236
+ </Form>
237
+ </Stack>
238
+ </Surface>
239
+ )}
240
+ </Stack>
241
+ </PageShell>
242
+ );
243
+ }
244
+ ```
245
+
246
+ ## Option: A link to private work asks first
247
+
248
+ Use when: A list links to private work, and the gate should not leave the list.
249
+
250
+ Uses: `Button`, `Form`, `Link`, `Modal`, `PageHeader`, `PageShell`, `Paragraph`, `Stack`, `TextField`
251
+
252
+ ```tsx
253
+ 'use client';
254
+ import { useEffect, useRef, useState } from 'react';
255
+ import PageShell from 'oneslash-design-system/components/pageShell';
256
+ import PageHeader from 'oneslash-design-system/components/pageHeader';
257
+ import Modal from 'oneslash-design-system/components/modal';
258
+ import Form from 'oneslash-design-system/components/form';
259
+ import TextField from 'oneslash-design-system/components/textField';
260
+ import Paragraph from 'oneslash-design-system/components/paragraph';
261
+ import Link from 'oneslash-design-system/components/link';
262
+ import Button from 'oneslash-design-system/components/button';
263
+ import { Stack } from 'oneslash-design-system/components/layout';
264
+
265
+ // The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
266
+ // A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
267
+ const PASSPHRASE = 'acme-demo';
268
+
269
+ export default function PasswordGateModal() {
270
+ const [open, setOpen] = useState(false);
271
+ const [unlocked, setUnlocked] = useState(false);
272
+ const [password, setPassword] = useState('');
273
+ const [error, setError] = useState('');
274
+ const [checking, setChecking] = useState(false);
275
+ // A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
276
+ const [attempt, setAttempt] = useState(0);
277
+ const timer = useRef<ReturnType<typeof setTimeout>>();
278
+
279
+ // Stops the request if the example goes away before it ends.
280
+ useEffect(() => () => clearTimeout(timer.current), []);
281
+
282
+ // Escape, a click outside and Cancel all close it, except while the request runs.
283
+ function handleClose() {
284
+ if (checking) return;
285
+ setOpen(false);
286
+ setPassword('');
287
+ setError('');
288
+ }
289
+
290
+ function handleSubmit() {
291
+ if (checking) return;
292
+ if (!password.trim()) {
293
+ setError('Enter the password.');
294
+ setAttempt((n) => n + 1);
295
+ return;
296
+ }
297
+ setError('');
298
+ setChecking(true);
299
+ // Stands in for the request to the server.
300
+ timer.current = setTimeout(() => {
301
+ setChecking(false);
302
+ if (password === PASSPHRASE) {
303
+ setUnlocked(true);
304
+ setOpen(false);
305
+ setPassword('');
306
+ } else {
307
+ setError('That password is not right.');
308
+ setAttempt((n) => n + 1);
309
+ }
310
+ }, 600);
311
+ }
312
+
313
+ return (
314
+ <PageShell>
315
+ <Stack gap="xlarge">
316
+ <PageHeader level={1} title="Selected work" lede="Three case studies. The first is open. The others need a password." />
317
+ <Stack gap="large" align="start">
318
+ <Link href="#how-we-write-errors">How we write error messages</Link>
319
+ {/* A link to private work asks for the password first. A real page keeps the link's address, so the work opens there after the check. The trigger stays, so focus has somewhere to go back to. */}
320
+ <Button size="medium" type="textOnly" state="enabled" label="Read the Plan Changes Case Study" onClickButton={() => { if (!unlocked) setOpen(true); }} />
321
+ {unlocked && <Paragraph>It is open for you now.</Paragraph>}
322
+ </Stack>
323
+ </Stack>
324
+ <Modal
325
+ isOpen={open}
326
+ size="small"
327
+ initialFocus="body"
328
+ title="View Work"
329
+ onClose={handleClose}
330
+ actions={
331
+ <>
332
+ <Button size="small" type="tertiary" state={checking ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
333
+ <Button size="small" type="primary" state="enabled" label="View Work" loading={checking} onClickButton={handleSubmit} />
334
+ </>
335
+ }
336
+ >
337
+ <Form aria-label="Private work" onSubmit={handleSubmit}>
338
+ <TextField key={attempt} id="password-gate-modal-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={(e) => { setPassword(e.target.value); setError(''); }} />
339
+ <Paragraph tone="secondary" size="body2" measure="none">
340
+ This case study needs a password, and it comes by email. <Link href="#contact">Ask for the password</Link>.
341
+ </Paragraph>
342
+ </Form>
343
+ </Modal>
344
+ </PageShell>
345
+ );
346
+ }
347
+ ```
348
+
349
+ ## Native
350
+
351
+ On Apple use a `SecureField` in a grouped form, and let the server check it. A locked item opens a sheet with the field and Cancel first.
@@ -0,0 +1 @@
1
+ export default function PricingSectionCards(): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import PageShell from '../../components/pageShell';
3
+ import SectionIntro from '../../components/sectionIntro';
4
+ import Surface from '../../components/surface';
5
+ import Heading from '../../components/heading';
6
+ import Paragraph from '../../components/paragraph';
7
+ import List from '../../components/list';
8
+ import Button from '../../components/button';
9
+ import { formatMoney } from '../../components/formatNumber';
10
+ import { Grid, PageSection, Stack } from '../../components/layout';
11
+ // The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.
12
+ var plans = [
13
+ { id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
14
+ { id: 'pro', name: 'Pro', price: "".concat(formatMoney(8), " per member per month"), includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
15
+ { id: 'business', name: 'Business', price: "".concat(formatMoney(16), " per member per month"), includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
16
+ ];
17
+ export default function PricingSectionCards() {
18
+ return (<PageShell>
19
+ <PageSection gap="xxlarge">
20
+ <SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team."/>
21
+ <Stack gap="medium">
22
+ {/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
23
+ {/* The small padding leaves room for the longest label, 'Sign Up for Business', inside its Button at md. */}
24
+ <Grid columns={3}>
25
+ {plans.map(function (p) { return (<Surface key={p.id} padding="small">
26
+ <Stack gap="large">
27
+ <Stack gap="small">
28
+ <Heading level={3} size="h6">{p.name}</Heading>
29
+ <Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
30
+ </Stack>
31
+ <List items={p.includes} size="body2" marker="dot"/>
32
+ {/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}
33
+ <Button size="medium" type={p.id === 'pro' ? 'primary' : 'secondary'} state="enabled" label={"Sign Up for ".concat(p.name)} href={"https://acme.example/sign-up?plan=".concat(p.id)} fullWidth/>
34
+ </Stack>
35
+ </Surface>); })}
36
+ </Grid>
37
+ <Paragraph tone="secondary" size="body2" measure="none">Prices in USD. Pro and Business bill each member monthly.</Paragraph>
38
+ </Stack>
39
+ </PageSection>
40
+ </PageShell>);
41
+ }
@@ -0,0 +1,87 @@
1
+ # Pricing section
2
+
3
+ A visitor to the public site compares the plans and signs up for one.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.
8
+ - Show the same plans as the case 'Plan picker', word for word: the names, the prices and what each includes. A price comes from `formatMoney`, as the rule 'A number shows its unit and never shows 0 for unknown' says.
9
+ - Make each plan a `Surface` with its name as a level 3 heading, its price, a `List` of what it includes and one `Button` with `fullWidth`. Put them in `Grid columns={3}`, which stacks them on a phone. Give each `Surface` `padding="small"`, so the longest label stays inside its Button from md.
10
+ - Name each Button for the plan: 'Sign Up for Free', 'Sign Up for Pro', 'Sign Up for Business'. Give it an `href` to the sign-up page with the plan in the address, so it works as a link.
11
+ - Make the Button of the plan most visitors start on primary, and the others secondary. A visitor has no current plan, so no card carries 'Current plan'.
12
+ - Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.
13
+ - Put one line under the cards that says what the prices are in and who pays: 'Prices in USD. Pro and Business bill each member monthly.'
14
+ - Add a `SegmentedControl` for monthly and yearly as the case 'Range switch' says once a plan bills by the year. Leave it out while every plan bills monthly.
15
+
16
+ ## Don't
17
+
18
+ - Do not name a Button 'Get Started', 'Choose' or 'Select'. Name the plan it signs up for.
19
+ - Do not open the sign-up page in a new tab.
20
+ - Do not give two plans a primary Button.
21
+ - Do not change a price or a limit here without changing it in the case 'Plan picker' too. A visitor sees one set of plans.
22
+ - Do not make a card clickable as a whole. Its Button is the one control.
23
+
24
+ ## Example: Plan cards side by side
25
+
26
+ Uses: `Button`, `Grid`, `Heading`, `List`, `PageSection`, `PageShell`, `Paragraph`, `SectionIntro`, `Stack`, `Surface`, `formatMoney`
27
+
28
+ ```tsx
29
+ 'use client';
30
+ import PageShell from 'oneslash-design-system/components/pageShell';
31
+ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
32
+ import Surface from 'oneslash-design-system/components/surface';
33
+ import Heading from 'oneslash-design-system/components/heading';
34
+ import Paragraph from 'oneslash-design-system/components/paragraph';
35
+ import List from 'oneslash-design-system/components/list';
36
+ import Button from 'oneslash-design-system/components/button';
37
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
38
+ import { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';
39
+
40
+ // The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.
41
+ const plans = [
42
+ { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
43
+ { id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
44
+ { id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
45
+ ];
46
+
47
+ export default function PricingSectionCards() {
48
+ return (
49
+ <PageShell>
50
+ <PageSection gap="xxlarge">
51
+ <SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team." />
52
+ <Stack gap="medium">
53
+ {/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
54
+ {/* The small padding leaves room for the longest label, 'Sign Up for Business', inside its Button at md. */}
55
+ <Grid columns={3}>
56
+ {plans.map((p) => (
57
+ <Surface key={p.id} padding="small">
58
+ <Stack gap="large">
59
+ <Stack gap="small">
60
+ <Heading level={3} size="h6">{p.name}</Heading>
61
+ <Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
62
+ </Stack>
63
+ <List items={p.includes} size="body2" marker="dot" />
64
+ {/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}
65
+ <Button
66
+ size="medium"
67
+ type={p.id === 'pro' ? 'primary' : 'secondary'}
68
+ state="enabled"
69
+ label={`Sign Up for ${p.name}`}
70
+ href={`https://acme.example/sign-up?plan=${p.id}`}
71
+ fullWidth
72
+ />
73
+ </Stack>
74
+ </Surface>
75
+ ))}
76
+ </Grid>
77
+ <Paragraph tone="secondary" size="body2" measure="none">Prices in USD. Pro and Business bill each member monthly.</Paragraph>
78
+ </Stack>
79
+ </PageSection>
80
+ </PageShell>
81
+ );
82
+ }
83
+ ```
84
+
85
+ ## Native
86
+
87
+ On Apple an app has no pricing section. The plans are in the app as a `List` with the system purchase sheet, as the case 'Plan picker' says.
@@ -0,0 +1 @@
1
+ export default function ProductCardsGrid(): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ 'use client';
2
+ import PageShell from '../../components/pageShell';
3
+ import SectionIntro from '../../components/sectionIntro';
4
+ import LinkCard from '../../components/linkCard';
5
+ import { Grid, PageSection } from '../../components/layout';
6
+ // Stand-ins for a picture of each product. A real page passes a screenshot or the product's mark.
7
+ var notesPicture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23efe9df'/%3E%3Crect x='200' y='50' width='240' height='260' rx='14' fill='%23ffffff'/%3E%3Crect x='224' y='84' width='120' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='224' y='116' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='142' width='170' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='168' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='194' width='110' height='10' rx='5' fill='%23dfe7ef'/%3E%3C/svg%3E";
8
+ var tasksPicture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23e6efe9'/%3E%3Crect x='180' y='60' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='134' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='208' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='198' y='78' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='152' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='226' width='16' height='16' rx='4' fill='%23aab8c6'/%3E%3Crect x='230' y='82' width='160' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='156' width='120' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='230' width='140' height='8' rx='4' fill='%23dfe7ef'/%3E%3C/svg%3E";
9
+ export default function ProductCardsGrid() {
10
+ return (<PageShell>
11
+ <PageSection gap="xxlarge">
12
+ <SectionIntro id="products" name="Products" statement="Apps from Acme, each with its own site."/>
13
+ {/* Two across from md, one on a phone. Each card is one link to the product's own site, in a new tab, and says so to a screen reader. */}
14
+ <Grid columns={2}>
15
+ <LinkCard href="https://notes.acme.example" title="Acme Notes" description="Write a thing down once and find it again." caption="Notes app" image={{ src: notesPicture, alt: '' }} external/>
16
+ <LinkCard href="https://tasks.acme.example" title="Acme Tasks" description="A short list for today, and a long one for later." caption="Task app" image={{ src: tasksPicture, alt: '' }} external/>
17
+ </Grid>
18
+ </PageSection>
19
+ </PageShell>);
20
+ }
@@ -0,0 +1,71 @@
1
+ # Product cards
2
+
3
+ A maker lists its products on one page, and each product has its own site.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A list of products has no main action of its own: each card is a link, not a Button.
8
+ - Use `LinkCard` with `image`, `title`, `description` and `caption`, in `Grid columns={2}`.
9
+ - Pass `external`. The list stays open in its tab while the product opens in another, and a screen reader hears that the link opens in a new tab. This follows the case 'Site footer': a link to another site opens in a new tab and says so.
10
+ - Give each product a title that is its name, a description of one short line, and a caption that says what kind of product it is.
11
+ - Pass `alt: ''` for the picture when the title names the product, so a screen reader does not say it twice. Otherwise say what the picture shows.
12
+ - Open the section with `SectionIntro`, such as 'Products'.
13
+ - Keep to six cards or fewer.
14
+
15
+ ## Don't
16
+
17
+ - Do not put a Button inside a card. The card is the link.
18
+ - Do not link only the title or only the picture.
19
+ - Do not name the link 'Learn more'. The title is the name.
20
+ - Do not open a link to a page of your own site in a new tab.
21
+
22
+ ## Example: Cards in a grid
23
+
24
+ Uses: `Grid`, `LinkCard`, `PageSection`, `PageShell`, `SectionIntro`
25
+
26
+ ```tsx
27
+ 'use client';
28
+ import PageShell from 'oneslash-design-system/components/pageShell';
29
+ import SectionIntro from 'oneslash-design-system/components/sectionIntro';
30
+ import LinkCard from 'oneslash-design-system/components/linkCard';
31
+ import { Grid, PageSection } from 'oneslash-design-system/components/layout';
32
+
33
+ // Stand-ins for a picture of each product. A real page passes a screenshot or the product's mark.
34
+ const notesPicture =
35
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23efe9df'/%3E%3Crect x='200' y='50' width='240' height='260' rx='14' fill='%23ffffff'/%3E%3Crect x='224' y='84' width='120' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='224' y='116' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='142' width='170' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='168' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='194' width='110' height='10' rx='5' fill='%23dfe7ef'/%3E%3C/svg%3E";
36
+ const tasksPicture =
37
+ "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23e6efe9'/%3E%3Crect x='180' y='60' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='134' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='208' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='198' y='78' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='152' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='226' width='16' height='16' rx='4' fill='%23aab8c6'/%3E%3Crect x='230' y='82' width='160' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='156' width='120' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='230' width='140' height='8' rx='4' fill='%23dfe7ef'/%3E%3C/svg%3E";
38
+
39
+ export default function ProductCardsGrid() {
40
+ return (
41
+ <PageShell>
42
+ <PageSection gap="xxlarge">
43
+ <SectionIntro id="products" name="Products" statement="Apps from Acme, each with its own site." />
44
+ {/* Two across from md, one on a phone. Each card is one link to the product's own site, in a new tab, and says so to a screen reader. */}
45
+ <Grid columns={2}>
46
+ <LinkCard
47
+ href="https://notes.acme.example"
48
+ title="Acme Notes"
49
+ description="Write a thing down once and find it again."
50
+ caption="Notes app"
51
+ image={{ src: notesPicture, alt: '' }}
52
+ external
53
+ />
54
+ <LinkCard
55
+ href="https://tasks.acme.example"
56
+ title="Acme Tasks"
57
+ description="A short list for today, and a long one for later."
58
+ caption="Task app"
59
+ image={{ src: tasksPicture, alt: '' }}
60
+ external
61
+ />
62
+ </Grid>
63
+ </PageSection>
64
+ </PageShell>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ## Native
70
+
71
+ On Apple use a `Link` in a `List` row with an `Image`, which opens Safari. On Android use a card that opens a custom tab.
@@ -63,14 +63,17 @@ export default function ReplyFeedbackThumbs() {
63
63
  // The clipboard answers later; by then the example may be gone.
64
64
  var mounted = useRef(true);
65
65
  // On unmount it stops every timer and the run.
66
- useEffect(function () { return function () {
67
- mounted.current = false;
68
- clearTimeout(thanksTimer.current);
69
- clearTimeout(copyTimer.current);
70
- clearInterval(tick.current);
71
- clearTimeout(step.current);
72
- clearTimeout(cancel.current);
73
- }; }, []);
66
+ useEffect(function () {
67
+ mounted.current = true;
68
+ return function () {
69
+ mounted.current = false;
70
+ clearTimeout(thanksTimer.current);
71
+ clearTimeout(copyTimer.current);
72
+ clearInterval(tick.current);
73
+ clearTimeout(step.current);
74
+ clearTimeout(cancel.current);
75
+ };
76
+ }, []);
74
77
  useEffect(function () {
75
78
  var move = focusNext.current;
76
79
  focusNext.current = undefined;
@@ -69,14 +69,17 @@ export default function ReplyFeedbackWithReason() {
69
69
  // The clipboard answers later; by then the example may be gone.
70
70
  var mounted = useRef(true);
71
71
  // On unmount it stops every timer and the run.
72
- useEffect(function () { return function () {
73
- mounted.current = false;
74
- clearTimeout(thanksTimer.current);
75
- clearTimeout(copyTimer.current);
76
- clearInterval(tick.current);
77
- clearTimeout(step.current);
78
- clearTimeout(cancel.current);
79
- }; }, []);
72
+ useEffect(function () {
73
+ mounted.current = true;
74
+ return function () {
75
+ mounted.current = false;
76
+ clearTimeout(thanksTimer.current);
77
+ clearTimeout(copyTimer.current);
78
+ clearInterval(tick.current);
79
+ clearTimeout(step.current);
80
+ clearTimeout(cancel.current);
81
+ };
82
+ }, []);
80
83
  useEffect(function () {
81
84
  var move = focusNext.current;
82
85
  focusNext.current = undefined;