oneslash-design-system 2.19.0 → 2.20.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 (122) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +28 -4
  3. package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
  4. package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
  5. package/dist/cases/billing-page/self-serve.d.ts +1 -0
  6. package/dist/cases/billing-page/self-serve.jsx +134 -0
  7. package/dist/cases/billing-page.md +247 -0
  8. package/dist/cases/breakdown-list/bars.d.ts +1 -0
  9. package/dist/cases/breakdown-list/bars.jsx +47 -0
  10. package/dist/cases/breakdown-list/table.d.ts +1 -0
  11. package/dist/cases/breakdown-list/table.jsx +69 -0
  12. package/dist/cases/breakdown-list.md +158 -0
  13. package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
  14. package/dist/cases/composer-limit/notice.jsx +3 -3
  15. package/dist/cases/composer-limit.md +8 -8
  16. package/dist/cases/dashboard/numbers-first.d.ts +1 -0
  17. package/dist/cases/dashboard/numbers-first.jsx +165 -0
  18. package/dist/cases/dashboard/work-first.d.ts +1 -0
  19. package/dist/cases/dashboard/work-first.jsx +165 -0
  20. package/dist/cases/dashboard.md +507 -0
  21. package/dist/cases/data-table-page/all-rows.d.ts +1 -0
  22. package/dist/cases/data-table-page/all-rows.jsx +226 -0
  23. package/dist/cases/data-table-page/paged.d.ts +1 -0
  24. package/dist/cases/data-table-page/paged.jsx +284 -0
  25. package/dist/cases/data-table-page.md +771 -0
  26. package/dist/cases/invoice-list/table.d.ts +1 -0
  27. package/dist/cases/invoice-list/table.jsx +64 -0
  28. package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
  29. package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
  30. package/dist/cases/invoice-list.md +237 -0
  31. package/dist/cases/load-failure/inline.jsx +2 -2
  32. package/dist/cases/load-failure.md +2 -2
  33. package/dist/cases/members-list/rows.jsx +2 -1
  34. package/dist/cases/members-list/table.jsx +8 -9
  35. package/dist/cases/members-list.md +12 -13
  36. package/dist/cases/number-format.md +36 -0
  37. package/dist/cases/paged-card/pager.d.ts +1 -0
  38. package/dist/cases/paged-card/pager.jsx +41 -0
  39. package/dist/cases/paged-card/see-all.d.ts +1 -0
  40. package/dist/cases/paged-card/see-all.jsx +34 -0
  41. package/dist/cases/paged-card.md +147 -0
  42. package/dist/cases/payment-method/none.d.ts +1 -0
  43. package/dist/cases/payment-method/none.jsx +17 -0
  44. package/dist/cases/payment-method/on-file.d.ts +1 -0
  45. package/dist/cases/payment-method/on-file.jsx +92 -0
  46. package/dist/cases/payment-method.md +182 -0
  47. package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
  48. package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
  49. package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
  50. package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
  51. package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
  52. package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
  53. package/dist/cases/plan-change-confirm.md +261 -0
  54. package/dist/cases/plan-picker/cards.d.ts +1 -0
  55. package/dist/cases/plan-picker/cards.jsx +97 -0
  56. package/dist/cases/plan-picker/list.d.ts +1 -0
  57. package/dist/cases/plan-picker/list.jsx +103 -0
  58. package/dist/cases/plan-picker.md +297 -0
  59. package/dist/cases/range-switch/segmented.jsx +11 -7
  60. package/dist/cases/range-switch.md +16 -11
  61. package/dist/cases/settings-page/top-tabs.jsx +4 -3
  62. package/dist/cases/settings-page.md +5 -4
  63. package/dist/cases/stat-row/featured.d.ts +1 -0
  64. package/dist/cases/stat-row/featured.jsx +17 -0
  65. package/dist/cases/stat-row/tiles.d.ts +1 -0
  66. package/dist/cases/stat-row/tiles.jsx +34 -0
  67. package/dist/cases/stat-row.md +104 -0
  68. package/dist/cases/status-label/dot.d.ts +1 -0
  69. package/dist/cases/status-label/dot.jsx +39 -0
  70. package/dist/cases/status-label/text.d.ts +1 -0
  71. package/dist/cases/status-label/text.jsx +44 -0
  72. package/dist/cases/status-label.md +143 -0
  73. package/dist/cases/upgrade-prompt/inline.jsx +4 -2
  74. package/dist/cases/upgrade-prompt/modal.jsx +2 -1
  75. package/dist/cases/upgrade-prompt.md +10 -6
  76. package/dist/cases/usage-meters/by-person.d.ts +1 -0
  77. package/dist/cases/usage-meters/by-person.jsx +72 -0
  78. package/dist/cases/usage-meters/meters.d.ts +1 -0
  79. package/dist/cases/usage-meters/meters.jsx +49 -0
  80. package/dist/cases/usage-meters/with-cap.d.ts +1 -0
  81. package/dist/cases/usage-meters/with-cap.jsx +73 -0
  82. package/dist/cases/usage-meters.md +303 -0
  83. package/dist/cases.json +956 -19
  84. package/dist/components/button.d.ts +1 -1
  85. package/dist/components/button.jsx +11 -5
  86. package/dist/components/formatNumber.d.ts +25 -0
  87. package/dist/components/formatNumber.js +125 -0
  88. package/dist/components/iconButton.jsx +12 -7
  89. package/dist/components/pagination.d.ts +28 -0
  90. package/dist/components/pagination.jsx +89 -0
  91. package/dist/components/progress.d.ts +33 -0
  92. package/dist/components/progress.jsx +50 -0
  93. package/dist/components/skeleton.d.ts +21 -0
  94. package/dist/components/skeleton.jsx +41 -0
  95. package/dist/components/statTile.d.ts +32 -0
  96. package/dist/components/statTile.jsx +61 -0
  97. package/dist/components/tableContainer.d.ts +5 -1
  98. package/dist/components/tableContainer.jsx +9 -1
  99. package/dist/components/tableHeaderCell.d.ts +3 -1
  100. package/dist/components/tableHeaderCell.jsx +2 -2
  101. package/dist/components/titleBar.d.ts +3 -1
  102. package/dist/components/titleBar.jsx +4 -3
  103. package/dist/index.d.ts +5 -0
  104. package/dist/index.js +5 -0
  105. package/dist/native-mapping.json +26 -2
  106. package/dist/stories/Button.stories.d.ts +1 -0
  107. package/dist/stories/Button.stories.jsx +19 -1
  108. package/dist/stories/Cases.generated.stories.d.ts +26 -0
  109. package/dist/stories/Cases.generated.stories.jsx +52 -0
  110. package/dist/stories/Pagination.stories.d.ts +9 -0
  111. package/dist/stories/Pagination.stories.jsx +75 -0
  112. package/dist/stories/Progress.stories.d.ts +9 -0
  113. package/dist/stories/Progress.stories.jsx +43 -0
  114. package/dist/stories/Skeleton.stories.d.ts +7 -0
  115. package/dist/stories/Skeleton.stories.jsx +27 -0
  116. package/dist/stories/StatTile.stories.d.ts +10 -0
  117. package/dist/stories/StatTile.stories.jsx +55 -0
  118. package/dist/stories/Table.stories.d.ts +1 -0
  119. package/dist/stories/Table.stories.jsx +49 -1
  120. package/dist/stories/TitleBar.stories.d.ts +1 -0
  121. package/dist/stories/TitleBar.stories.jsx +7 -0
  122. package/package.json +5 -1
@@ -0,0 +1,297 @@
1
+ # Plan picker
2
+
3
+ An admin compares the plans a workspace can be on and chooses one.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
8
+ - Make each plan a `Surface` with its name as a heading, its price and a `List` of what it includes. Write each limit as a number with its unit: '3 members', '50 AI agent responses a month'.
9
+ - Put the cards in `Grid columns={3}`, which stacks them on a phone. Put the rows in one column.
10
+ - Mark the current plan with `Tag variant="textOnly"` 'Current plan', and give it no Button.
11
+ - Give every other plan one Button named for the move: 'Upgrade to Pro' as primary, 'Downgrade to Free' as tertiary. It opens the case 'Plan change confirm'.
12
+ - Say a change that starts later with a Tag 'Starts Dec 1' on the new plan, and a line under the heading: 'Acme is on Pro until Dec 1, 2026, then Free.'
13
+ - Open the picker from 'Change Plan' on the case 'Billing page'. Show it only to a person who can change the plan.
14
+ - Add a `SegmentedControl` as the case 'Range switch' says once the plans bill by the year too. Leave it out while every plan bills monthly.
15
+
16
+ ## Don't
17
+
18
+ - Do not make a card clickable as a whole. Its Button is the one control, so a keyboard and a screen reader find it.
19
+ - Do not label the Buttons 'Select' or 'Choose'. Say the move: 'Upgrade to Pro'.
20
+ - Do not run the limits together in one line with dots between them. Use a `List`, one limit per item.
21
+ - Do not add a monthly and yearly switch when no plan bills yearly.
22
+ - Do not change a Button label to show it is busy, such as to 'Checking...'.
23
+ - Do not charge or change the plan from this page. The confirm does that.
24
+
25
+ ## Option: Cards side by side
26
+
27
+ Use when: Two or three plans are compared at once, on a page with room for columns.
28
+
29
+ Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import { useEffect, useRef, useState } from 'react';
34
+ import Modal from 'oneslash-design-system/components/modal';
35
+ import Surface from 'oneslash-design-system/components/surface';
36
+ import Heading from 'oneslash-design-system/components/heading';
37
+ import Paragraph from 'oneslash-design-system/components/paragraph';
38
+ import List from 'oneslash-design-system/components/list';
39
+ import Tag from 'oneslash-design-system/components/tag';
40
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
41
+ import Button from 'oneslash-design-system/components/button';
42
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
43
+ import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
44
+
45
+ type PlanId = 'free' | 'pro' | 'business';
46
+
47
+ // Made-up plans. A real app reads them from the server, with the limits as numbers.
48
+ const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
49
+ { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
50
+ { 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'] },
51
+ { 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'] },
52
+ ];
53
+
54
+ const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
55
+
56
+ // What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
57
+ function describe(from: PlanId, to: PlanId) {
58
+ const name = plans.find((p) => p.id === to)!.name;
59
+ if (rank[to] > rank[from]) {
60
+ // Three members, 15 of 30 days left in November: half of the first month today.
61
+ const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
62
+ const monthly = to === 'pro' ? 24 : 48;
63
+ const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
64
+ return { title: `Upgrade to ${name}`, body, detail: false };
65
+ }
66
+ // A downgrade changes nothing today. It says when it starts and what stops.
67
+ return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
68
+ }
69
+
70
+ export default function PlanPickerCards() {
71
+ const [current, setCurrent] = useState<PlanId>('free');
72
+ const [scheduled, setScheduled] = useState<PlanId | null>(null);
73
+ const [target, setTarget] = useState<PlanId | null>(null);
74
+ const [busy, setBusy] = useState(false);
75
+ const timer = useRef<ReturnType<typeof setTimeout>>();
76
+
77
+ // On unmount it stops the request.
78
+ useEffect(() => () => clearTimeout(timer.current), []);
79
+
80
+ // Escape, a click outside and Cancel all close it, except while the request runs.
81
+ function handleClose() {
82
+ if (busy) return;
83
+ setTarget(null);
84
+ }
85
+
86
+ function handleConfirm() {
87
+ if (busy || !target) return;
88
+ const to = target;
89
+ setBusy(true);
90
+ // Stands in for the request to the server.
91
+ timer.current = setTimeout(() => {
92
+ setBusy(false);
93
+ setTarget(null);
94
+ if (rank[to] > rank[current]) {
95
+ setCurrent(to);
96
+ setScheduled(null);
97
+ // The plan line on the page says it: 'Acme is on Pro.' No toast.
98
+ } else {
99
+ // A downgrade changes nothing today, so the page says when it starts.
100
+ setScheduled(to);
101
+ }
102
+ }, 1200);
103
+ }
104
+
105
+ const copy = target ? describe(current, target) : null;
106
+ const currentName = plans.find((p) => p.id === current)!.name;
107
+
108
+ return (
109
+ <Center width="page">
110
+ <SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
111
+ {/* Two or three plans side by side from md up, stacked on a phone. A card is not itself clickable. */}
112
+ <Grid columns={3}>
113
+ {plans.map((p) => (
114
+ <Surface key={p.id} padding="small">
115
+ <Stack gap="medium">
116
+ <Stack gap="small">
117
+ <Heading level={3} size="h6">{p.name}</Heading>
118
+ <Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
119
+ </Stack>
120
+ <List items={p.includes} size="body2" marker="dot" />
121
+ {p.id === current ? (
122
+ <Cluster><Tag variant="textOnly" size="small" label="Current plan" /></Cluster>
123
+ ) : p.id === scheduled ? (
124
+ <Cluster><Tag variant="dot" size="small" label="Starts Dec 1" /></Cluster>
125
+ ) : rank[p.id] > rank[current] ? (
126
+ <Cluster><Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
127
+ ) : (
128
+ <Cluster><Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
129
+ )}
130
+ </Stack>
131
+ </Surface>
132
+ ))}
133
+ </Grid>
134
+ </SettingsSection>
135
+ <Modal
136
+ isOpen={target !== null}
137
+ size="small"
138
+ title={copy?.title ?? ''}
139
+ onClose={handleClose}
140
+ actions={
141
+ <>
142
+ <Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
143
+ <Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
144
+ </>
145
+ }
146
+ >
147
+ <Paragraph measure="none">{copy?.body}</Paragraph>
148
+ {copy?.detail && (
149
+ <>
150
+ <Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
151
+ <List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
152
+ </>
153
+ )}
154
+ </Modal>
155
+ </Center>
156
+ );
157
+ }
158
+ ```
159
+
160
+ ## Option: Rows in a settings column
161
+
162
+ Use when: The picker sits in a narrow settings column, or the plans have long lists of what they include.
163
+
164
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
165
+
166
+ ```tsx
167
+ 'use client';
168
+ import { useEffect, useRef, useState } from 'react';
169
+ import Modal from 'oneslash-design-system/components/modal';
170
+ import Surface from 'oneslash-design-system/components/surface';
171
+ import Heading from 'oneslash-design-system/components/heading';
172
+ import Paragraph from 'oneslash-design-system/components/paragraph';
173
+ import List from 'oneslash-design-system/components/list';
174
+ import Tag from 'oneslash-design-system/components/tag';
175
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
176
+ import Button from 'oneslash-design-system/components/button';
177
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
178
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
179
+
180
+ type PlanId = 'free' | 'pro' | 'business';
181
+
182
+ // Made-up plans. A real app reads them from the server, with the limits as numbers.
183
+ const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
184
+ { id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
185
+ { 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'] },
186
+ { 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'] },
187
+ ];
188
+
189
+ const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
190
+
191
+ // What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
192
+ function describe(from: PlanId, to: PlanId) {
193
+ const name = plans.find((p) => p.id === to)!.name;
194
+ if (rank[to] > rank[from]) {
195
+ // Three members, 15 of 30 days left in November: half of the first month today.
196
+ const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
197
+ const monthly = to === 'pro' ? 24 : 48;
198
+ const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
199
+ return { title: `Upgrade to ${name}`, body, detail: false };
200
+ }
201
+ // A downgrade changes nothing today. It says when it starts and what stops.
202
+ return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
203
+ }
204
+
205
+ export default function PlanPickerList() {
206
+ const [current, setCurrent] = useState<PlanId>('pro');
207
+ const [scheduled, setScheduled] = useState<PlanId | null>(null);
208
+ const [target, setTarget] = useState<PlanId | null>(null);
209
+ const [busy, setBusy] = useState(false);
210
+ const timer = useRef<ReturnType<typeof setTimeout>>();
211
+
212
+ // On unmount it stops the request.
213
+ useEffect(() => () => clearTimeout(timer.current), []);
214
+
215
+ // Escape, a click outside and Cancel all close it, except while the request runs.
216
+ function handleClose() {
217
+ if (busy) return;
218
+ setTarget(null);
219
+ }
220
+
221
+ function handleConfirm() {
222
+ if (busy || !target) return;
223
+ const to = target;
224
+ setBusy(true);
225
+ // Stands in for the request to the server.
226
+ timer.current = setTimeout(() => {
227
+ setBusy(false);
228
+ setTarget(null);
229
+ if (rank[to] > rank[current]) {
230
+ setCurrent(to);
231
+ setScheduled(null);
232
+ // The plan line on the page says it: 'Acme is on Pro.' No toast.
233
+ } else {
234
+ // A downgrade changes nothing today, so the page says when it starts.
235
+ setScheduled(to);
236
+ }
237
+ }, 1200);
238
+ }
239
+
240
+ const copy = target ? describe(current, target) : null;
241
+ const currentName = plans.find((p) => p.id === current)!.name;
242
+
243
+ return (
244
+ <Center width="page">
245
+ <SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
246
+ {/* Rows in the settings column. The plan and what it includes on the left, the one action on the right. */}
247
+ <Stack gap="medium">
248
+ {plans.map((p) => (
249
+ <Surface key={p.id} padding="small">
250
+ <Cluster justify="between" align="start" gap="medium">
251
+ <Stack gap="small">
252
+ <Cluster gap="small">
253
+ <Heading level={3} size="h6">{p.name}</Heading>
254
+ {p.id === current && <Tag variant="textOnly" size="small" label="Current plan" />}
255
+ {p.id === scheduled && <Tag variant="dot" size="small" label="Starts Dec 1" />}
256
+ </Cluster>
257
+ <Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
258
+ <List items={p.includes} size="body2" marker="dot" />
259
+ </Stack>
260
+ {p.id !== current && p.id !== scheduled && (
261
+ rank[p.id] > rank[current]
262
+ ? <Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
263
+ : <Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
264
+ )}
265
+ </Cluster>
266
+ </Surface>
267
+ ))}
268
+ </Stack>
269
+ </SettingsSection>
270
+ <Modal
271
+ isOpen={target !== null}
272
+ size="small"
273
+ title={copy?.title ?? ''}
274
+ onClose={handleClose}
275
+ actions={
276
+ <>
277
+ <Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
278
+ <Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
279
+ </>
280
+ }
281
+ >
282
+ <Paragraph measure="none">{copy?.body}</Paragraph>
283
+ {copy?.detail && (
284
+ <>
285
+ <Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
286
+ <List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
287
+ </>
288
+ )}
289
+ </Modal>
290
+ </Center>
291
+ );
292
+ }
293
+ ```
294
+
295
+ ## Native
296
+
297
+ On Apple use a `List` of plans with the system purchase sheet, and mark the current plan with a checkmark and the words 'Current plan'. Never build a card by hand.
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
  import { useState } from 'react';
3
3
  import Heading from '../../components/heading';
4
- import Paragraph from '../../components/paragraph';
4
+ import StatTile from '../../components/statTile';
5
5
  import SegmentedControl from '../../components/segmentedControl';
6
- import { Center, Cluster, Stack } from '../../components/layout';
6
+ import { Center, Cluster, Grid, Stack } from '../../components/layout';
7
7
  // A real app counts these on the server.
8
8
  var ranges = [
9
- { value: 'week', label: 'Week', count: 18 },
10
- { value: 'month', label: 'Month', count: 64 },
11
- { value: 'quarter', label: 'Quarter', count: 171 },
9
+ { value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
10
+ { value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
11
+ { value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
12
12
  ];
13
13
  export default function RangeSwitchSegmented() {
14
14
  var _a;
@@ -23,8 +23,12 @@ export default function RangeSwitchSegmented() {
23
23
  return ({ value: value, label: label });
24
24
  })} value={range} onChange={setRange}/>
25
25
  </Cluster>
26
- {/* The chart or list below changes with the range. This page stays the same. */}
27
- <Paragraph size="body2" measure="none">{current.count} comments this {current.label.toLowerCase()}.</Paragraph>
26
+ {/* The numbers change with the range. This page stays the same. */}
27
+ <Grid compact columns={3}>
28
+ <StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period}/>
29
+ <StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period}/>
30
+ <StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period}/>
31
+ </Grid>
28
32
  </Stack>
29
33
  </Center>);
30
34
  }
@@ -1,11 +1,12 @@
1
1
  # Range switch
2
2
 
3
- A person changes the time range of a chart or a list on the same page, such as Week, Month or Quarter.
3
+ A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter.
4
4
 
5
5
  ## Do
6
6
 
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
7
8
  - Use `SegmentedControl` with `size="small"` and `aria-label="Range"`: 'Week', 'Month', 'Quarter'.
8
- - Put it beside the heading of the chart or list it changes, with `width="fit"` so it is as wide as its options.
9
+ - Put it beside the heading of the numbers or list it changes, with `width="fit"` so it is as wide as its options.
9
10
  - Keep one option on at all times. Start on 'Week', the newest numbers, unless the page is about a longer period.
10
11
  - Change the numbers in place and keep the page, the heading and the scroll position.
11
12
  - Move between options with the arrow keys. They select as they move.
@@ -19,21 +20,21 @@ A person changes the time range of a chart or a list on the same page, such as W
19
20
 
20
21
  ## Example: Segmented control
21
22
 
22
- Uses: `Center`, `Cluster`, `Heading`, `Paragraph`, `SegmentedControl`, `Stack`
23
+ Uses: `Center`, `Cluster`, `Grid`, `Heading`, `SegmentedControl`, `Stack`, `StatTile`
23
24
 
24
25
  ```tsx
25
26
  'use client';
26
27
  import { useState } from 'react';
27
28
  import Heading from 'oneslash-design-system/components/heading';
28
- import Paragraph from 'oneslash-design-system/components/paragraph';
29
+ import StatTile from 'oneslash-design-system/components/statTile';
29
30
  import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
30
- import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
31
+ import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
31
32
 
32
33
  // A real app counts these on the server.
33
- const ranges = [
34
- { value: 'week', label: 'Week', count: 18 },
35
- { value: 'month', label: 'Month', count: 64 },
36
- { value: 'quarter', label: 'Quarter', count: 171 },
34
+ const ranges: { value: string; label: string; period: 'week' | 'month' | 'quarter'; comments: number[]; done: number[]; people: number[] }[] = [
35
+ { value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
36
+ { value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
37
+ { value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
37
38
  ];
38
39
 
39
40
  export default function RangeSwitchSegmented() {
@@ -54,8 +55,12 @@ export default function RangeSwitchSegmented() {
54
55
  onChange={setRange}
55
56
  />
56
57
  </Cluster>
57
- {/* The chart or list below changes with the range. This page stays the same. */}
58
- <Paragraph size="body2" measure="none">{current.count} comments this {current.label.toLowerCase()}.</Paragraph>
58
+ {/* The numbers change with the range. This page stays the same. */}
59
+ <Grid compact columns={3}>
60
+ <StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period} />
61
+ <StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period} />
62
+ <StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period} />
63
+ </Grid>
59
64
  </Stack>
60
65
  </Center>
61
66
  );
@@ -22,6 +22,7 @@ import Button from '../../components/button';
22
22
  import TabsContainer from '../../components/tabsContainer';
23
23
  import Tab from '../../components/tab';
24
24
  import SettingsSection, { SettingsColumns } from '../../components/settingsSection';
25
+ import { formatMoney } from '../../components/formatNumber';
25
26
  import { Center, Cluster, Stack } from '../../components/layout';
26
27
  // Four areas or fewer, each named with one short word, so the tabs fit on a phone. Each tab is a page of its own in a real app, so it has an `href`.
27
28
  var areas = [
@@ -29,7 +30,7 @@ var areas = [
29
30
  { id: 'notifications', label: 'Notifications' },
30
31
  { id: 'billing', label: 'Billing' },
31
32
  ];
32
- var invoices = ['January 2025, $40.00', 'December 2024, $40.00', 'November 2024, $40.00'];
33
+ var invoices = ["November 2026, ".concat(formatMoney(24)), "October 2026, ".concat(formatMoney(24)), "September 2026, ".concat(formatMoney(24))];
33
34
  export default function SettingsPageTopTabs() {
34
35
  var _a = useState('profile'), area = _a[0], setArea = _a[1];
35
36
  var _b = useState('Dana Lee'), savedName = _b[0], setSavedName = _b[1];
@@ -108,8 +109,8 @@ export default function SettingsPageTopTabs() {
108
109
  </SettingsSection>
109
110
  </SettingsColumns>);
110
111
  var billing = (<SettingsColumns>
111
- <SettingsSection id="settings-page-tabs-plan" title="Plan" description="Team plan, 5 seats.">
112
- <Paragraph size="body2" measure="none">Renews on January 15. Only owners can change the plan.</Paragraph>
112
+ <SettingsSection id="settings-page-tabs-plan" title="Plan" description="Pro plan, 3 members.">
113
+ <Paragraph size="body2" measure="none">Renews on Dec 1, 2026. Only owners can change the plan.</Paragraph>
113
114
  </SettingsSection>
114
115
  <SettingsSection id="settings-page-tabs-invoices" title="Invoices" description="The last three months.">
115
116
  <List items={invoices} size="body2"/>
@@ -28,7 +28,7 @@ A person opens the settings of the product and looks for one area, such as Profi
28
28
 
29
29
  Use when: Four areas or fewer, with short names that fit on a phone.
30
30
 
31
- Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `List`, `Paragraph`, `SettingsColumns`, `SettingsSection`, `Stack`, `Switch`, `Tab`, `TabsContainer`, `TextField`
31
+ Uses: `Button`, `Center`, `Cluster`, `Form`, `FormField`, `Heading`, `List`, `Paragraph`, `SettingsColumns`, `SettingsSection`, `Stack`, `Switch`, `Tab`, `TabsContainer`, `TextField`, `formatMoney`
32
32
 
33
33
  ```tsx
34
34
  'use client';
@@ -44,6 +44,7 @@ import Button from 'oneslash-design-system/components/button';
44
44
  import TabsContainer from 'oneslash-design-system/components/tabsContainer';
45
45
  import Tab from 'oneslash-design-system/components/tab';
46
46
  import SettingsSection, { SettingsColumns } from 'oneslash-design-system/components/settingsSection';
47
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
47
48
  import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
48
49
 
49
50
  type Area = 'profile' | 'notifications' | 'billing';
@@ -55,7 +56,7 @@ const areas: { id: Area; label: string }[] = [
55
56
  { id: 'billing', label: 'Billing' },
56
57
  ];
57
58
 
58
- const invoices = ['January 2025, $40.00', 'December 2024, $40.00', 'November 2024, $40.00'];
59
+ const invoices = [`November 2026, ${formatMoney(24)}`, `October 2026, ${formatMoney(24)}`, `September 2026, ${formatMoney(24)}`];
59
60
 
60
61
  export default function SettingsPageTopTabs() {
61
62
  const [area, setArea] = useState<Area>('profile');
@@ -136,8 +137,8 @@ export default function SettingsPageTopTabs() {
136
137
 
137
138
  const billing = (
138
139
  <SettingsColumns>
139
- <SettingsSection id="settings-page-tabs-plan" title="Plan" description="Team plan, 5 seats.">
140
- <Paragraph size="body2" measure="none">Renews on January 15. Only owners can change the plan.</Paragraph>
140
+ <SettingsSection id="settings-page-tabs-plan" title="Plan" description="Pro plan, 3 members.">
141
+ <Paragraph size="body2" measure="none">Renews on Dec 1, 2026. Only owners can change the plan.</Paragraph>
141
142
  </SettingsSection>
142
143
  <SettingsSection id="settings-page-tabs-invoices" title="Invoices" description="The last three months.">
143
144
  <List items={invoices} size="body2" />
@@ -0,0 +1 @@
1
+ export default function StatRowFeatured(): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import StatTile from '../../components/statTile';
4
+ import { Center, Grid, Stack } from '../../components/layout';
5
+ export default function StatRowFeatured() {
6
+ return (<Center width="page">
7
+ <Stack gap="large">
8
+ <Heading level={2} size="h6">This month</Heading>
9
+ {/* The number that matters most is one step larger and has the row to itself. */}
10
+ <StatTile label="Responses" value={48210} previous={41980} period="month" size="large"/>
11
+ <Grid compact columns={2}>
12
+ <StatTile label="Estimated cost" value={96.4} format="money" previous={88.2} period="month"/>
13
+ <StatTile label="Data stored" value={1288490188} format="bytes" previous={1073741824} period="month"/>
14
+ </Grid>
15
+ </Stack>
16
+ </Center>);
17
+ }
@@ -0,0 +1 @@
1
+ export default function StatRowTiles(): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import StatTile from '../../components/statTile';
5
+ import Button from '../../components/button';
6
+ import { Center, Cluster, Grid, Stack } from '../../components/layout';
7
+ export default function StatRowTiles() {
8
+ var _a = useState(false), loading = _a[0], setLoading = _a[1];
9
+ var timer = useRef();
10
+ // Stops the request if the example goes away before it ends.
11
+ useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
12
+ function reload() {
13
+ if (loading)
14
+ return;
15
+ setLoading(true);
16
+ // Stands in for the request to the server.
17
+ timer.current = setTimeout(function () { return setLoading(false); }, 1200);
18
+ }
19
+ return (<Center width="page">
20
+ <Stack gap="large">
21
+ <Cluster justify="between">
22
+ <Heading level={2} size="h6">This week</Heading>
23
+ <Button size="small" type="tertiary" state="enabled" label="Reload" decoIcon="RefreshCw" onClickButton={reload}/>
24
+ </Cluster>
25
+ {/* Four tiles at most. Two across on a phone, four from md up. Each counts one thing over the same range. */}
26
+ <Grid compact columns={4}>
27
+ <StatTile label="New comments" value={1240} previous={1106} loading={loading}/>
28
+ <StatTile label="Marked done" value={312} previous={280} loading={loading}/>
29
+ <StatTile label="People engaged" value={18} previous={18} loading={loading}/>
30
+ <StatTile label="Average reply time" value={8640000} format="duration" previous={9200000} loading={loading}/>
31
+ </Grid>
32
+ </Stack>
33
+ </Center>);
34
+ }
@@ -0,0 +1,104 @@
1
+ # Stat row
2
+
3
+ A page opens with the few numbers that say how things are going, counted over one range.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'. Use `StatTile`, which does.
8
+ - Put the tiles in `<Grid compact columns={4}>`: two across on a phone, up to four from md up.
9
+ - Use four tiles at most. A fifth number goes in a table.
10
+ - Make each tile count one thing, with its unit in the label or the `unit` prop: 'New comments', 'Responses'.
11
+ - Count every tile over the same range, and say the range in the heading above the row: 'This week'.
12
+ - Pass `previous` and `period` to get the change line, such as 'Up 12% from last week'. Leave `previous` out when there is nothing to compare with.
13
+ - Pass `loading` while the numbers load, so a `Skeleton` holds each place. Pass `value={null}` when there is no data: the tile says 'No data yet'.
14
+ - Pass `format` for money, a percent, a size or a time, such as `format="money"`. Do not format a number by hand.
15
+ - Give the one number that matters most `size="large"` and a row of its own, with the others under it.
16
+
17
+ ## Don't
18
+
19
+ - Do not show 0 while a number loads or when it is missing.
20
+ - Do not color a change green or red. More is not good or bad by itself.
21
+ - Do not put more than four tiles in a row, or two things in one tile.
22
+ - Do not draw a chart or a sparkline in a tile. A trend is the change line.
23
+ - Do not box each tile in a card. The row sits on the page.
24
+
25
+ ## Option: Tiles of equal weight
26
+
27
+ Use when: Two to four numbers matter about the same, over one range.
28
+
29
+ Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `Stack`, `StatTile`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import { useEffect, useRef, useState } from 'react';
34
+ import Heading from 'oneslash-design-system/components/heading';
35
+ import StatTile from 'oneslash-design-system/components/statTile';
36
+ import Button from 'oneslash-design-system/components/button';
37
+ import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
38
+
39
+ export default function StatRowTiles() {
40
+ const [loading, setLoading] = useState(false);
41
+ const timer = useRef<ReturnType<typeof setTimeout>>();
42
+
43
+ // Stops the request if the example goes away before it ends.
44
+ useEffect(() => () => clearTimeout(timer.current), []);
45
+
46
+ function reload() {
47
+ if (loading) return;
48
+ setLoading(true);
49
+ // Stands in for the request to the server.
50
+ timer.current = setTimeout(() => setLoading(false), 1200);
51
+ }
52
+
53
+ return (
54
+ <Center width="page">
55
+ <Stack gap="large">
56
+ <Cluster justify="between">
57
+ <Heading level={2} size="h6">This week</Heading>
58
+ <Button size="small" type="tertiary" state="enabled" label="Reload" decoIcon="RefreshCw" onClickButton={reload} />
59
+ </Cluster>
60
+ {/* Four tiles at most. Two across on a phone, four from md up. Each counts one thing over the same range. */}
61
+ <Grid compact columns={4}>
62
+ <StatTile label="New comments" value={1240} previous={1106} loading={loading} />
63
+ <StatTile label="Marked done" value={312} previous={280} loading={loading} />
64
+ <StatTile label="People engaged" value={18} previous={18} loading={loading} />
65
+ <StatTile label="Average reply time" value={8_640_000} format="duration" previous={9_200_000} loading={loading} />
66
+ </Grid>
67
+ </Stack>
68
+ </Center>
69
+ );
70
+ }
71
+ ```
72
+
73
+ ## Option: One number first
74
+
75
+ Use when: One number matters most, with two others under it.
76
+
77
+ Uses: `Center`, `Grid`, `Heading`, `Stack`, `StatTile`
78
+
79
+ ```tsx
80
+ 'use client';
81
+ import Heading from 'oneslash-design-system/components/heading';
82
+ import StatTile from 'oneslash-design-system/components/statTile';
83
+ import { Center, Grid, Stack } from 'oneslash-design-system/components/layout';
84
+
85
+ export default function StatRowFeatured() {
86
+ return (
87
+ <Center width="page">
88
+ <Stack gap="large">
89
+ <Heading level={2} size="h6">This month</Heading>
90
+ {/* The number that matters most is one step larger and has the row to itself. */}
91
+ <StatTile label="Responses" value={48210} previous={41980} period="month" size="large" />
92
+ <Grid compact columns={2}>
93
+ <StatTile label="Estimated cost" value={96.4} format="money" previous={88.2} period="month" />
94
+ <StatTile label="Data stored" value={1_288_490_188} format="bytes" previous={1_073_741_824} period="month" />
95
+ </Grid>
96
+ </Stack>
97
+ </Center>
98
+ );
99
+ }
100
+ ```
101
+
102
+ ## Native
103
+
104
+ On Apple use a `LabeledContent` or a `Grid` of `VStack`s with the number in `.title2` and `monospacedDigit()`. On Android use a `Row` of `Column`s with `headlineMedium` text.
@@ -0,0 +1 @@
1
+ export default function StatusLabelDot(): import("react").JSX.Element;