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,39 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Tag from '../../components/tag';
4
+ import TableContainer from '../../components/tableContainer';
5
+ import TableHeader from '../../components/tableHeader';
6
+ import TableHeaderCell from '../../components/tableHeaderCell';
7
+ import TableRow from '../../components/tableRow';
8
+ import TableCell from '../../components/tableCell';
9
+ import { Center, Stack } from '../../components/layout';
10
+ // A real app reads these from the server.
11
+ var workspaces = [
12
+ { id: 'acme', name: 'Acme', plan: 'Pro', status: 'Past due', color: 'error' },
13
+ { id: 'acme-labs', name: 'Acme Labs', plan: 'Pro', status: 'Canceling', color: 'warning' },
14
+ { id: 'acme-studio', name: 'Acme Studio', plan: 'Pro', status: 'Active', color: undefined },
15
+ ];
16
+ export default function StatusLabelDot() {
17
+ return (<Center width="page">
18
+ <Stack gap="large">
19
+ <Heading level={2} size="h5">Workspaces</Heading>
20
+ <TableContainer aria-label="Workspaces" minWidth="480px">
21
+ <TableHeader>
22
+ <TableRow>
23
+ <TableHeaderCell>Workspace</TableHeaderCell>
24
+ <TableHeaderCell width="100px">Plan</TableHeaderCell>
25
+ <TableHeaderCell width="160px">Status</TableHeaderCell>
26
+ </TableRow>
27
+ </TableHeader>
28
+ {workspaces.map(function (w) { return (<TableRow key={w.id}>
29
+ <TableCell>{w.name}</TableCell>
30
+ <TableCell width="100px">{w.plan}</TableCell>
31
+ <TableCell width="160px">
32
+ {/* The word is always there. Only a state that needs action gets a color: 'Active' keeps the grey dot. */}
33
+ <Tag variant="dot" size="small" color={w.color} label={w.status}/>
34
+ </TableCell>
35
+ </TableRow>); })}
36
+ </TableContainer>
37
+ </Stack>
38
+ </Center>);
39
+ }
@@ -0,0 +1 @@
1
+ export default function StatusLabelText(): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Tag from '../../components/tag';
4
+ import TableContainer from '../../components/tableContainer';
5
+ import TableHeader from '../../components/tableHeader';
6
+ import TableHeaderCell from '../../components/tableHeaderCell';
7
+ import TableRow from '../../components/tableRow';
8
+ import TableCell from '../../components/tableCell';
9
+ import { formatMoney } from '../../components/formatNumber';
10
+ import { Center, Stack } from '../../components/layout';
11
+ // A real app reads these from the server.
12
+ var payments = [
13
+ { id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
14
+ { id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
15
+ { id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
16
+ { id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
17
+ ];
18
+ export default function StatusLabelText() {
19
+ return (<Center width="page">
20
+ <Stack gap="large">
21
+ <Heading level={2} size="h5">Payments</Heading>
22
+ <TableContainer aria-label="Payments" minWidth="480px">
23
+ <TableHeader>
24
+ <TableRow>
25
+ <TableHeaderCell>Date</TableHeaderCell>
26
+ <TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
27
+ <TableHeaderCell width="160px">Status</TableHeaderCell>
28
+ </TableRow>
29
+ </TableHeader>
30
+ {payments.map(function (p) { return (<TableRow key={p.id}>
31
+ <TableCell>{p.date}</TableCell>
32
+ <TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
33
+ <TableCell width="160px">
34
+ {p.status === 'Upcoming' ? (
35
+ // The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
36
+ <Tag variant="dot" size="small" color="info" label={p.status}/>) : (
37
+ // A settled record is a word with no dot and no color.
38
+ <Tag variant="textOnly" size="small" label={p.status}/>)}
39
+ </TableCell>
40
+ </TableRow>); })}
41
+ </TableContainer>
42
+ </Stack>
43
+ </Center>);
44
+ }
@@ -0,0 +1,143 @@
1
+ # Status in a row
2
+
3
+ A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job.
4
+
5
+ ## Do
6
+
7
+ - Use `Tag` for a state in a row, with `size="small"`. ODS has no Badge part: a second part for the same job would mark the same states two ways.
8
+ - Show the word every time. The dot alone means nothing to a screen reader or to a person who cannot tell the colors apart.
9
+ - Use `variant="dot"` for a state that changes and may need the person: 'Past due', 'Canceling', 'Connected'.
10
+ - Give the dot a color only when the state needs action: `color="error"` for 'Past due', `color="warning"` for 'Canceling'. One exception: `color="info"` for a charge that has not happened yet, 'Upcoming', so it does not read as paid. A usual state, such as 'Connected', keeps the grey dot.
11
+ - Use `variant="textOnly"` with no color for a settled record: 'Paid', 'Refunded'.
12
+ - Write one word or two, in sentence case: 'Past due', 'Needs reconnecting'.
13
+ - Put the Tag in a 'Status' column, or at the end of the row's text. It is not clickable.
14
+
15
+ ## Don't
16
+
17
+ - Do not show a dot with no word, or a color with no word.
18
+ - Do not color a settled state. A green 'Paid' on every row hides the one red 'Past due'.
19
+ - Do not write the word in Title Case ('Past Due') or as a sentence ('Your payment is late').
20
+ - Do not fill the Tag with `variant="contained"` for a status in a row. A filled Tag is a label the person picks.
21
+ - Do not make the Tag a button. A status that opens something is a row action, in the More menu.
22
+ - Do not draw the dot by hand.
23
+
24
+ ## Option: A dot and a word
25
+
26
+ Use when: The state changes and may need the person: Past due, Canceling, Connected.
27
+
28
+ Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`
29
+
30
+ ```tsx
31
+ 'use client';
32
+ import Heading from 'oneslash-design-system/components/heading';
33
+ import Tag from 'oneslash-design-system/components/tag';
34
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
35
+ import TableHeader from 'oneslash-design-system/components/tableHeader';
36
+ import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
37
+ import TableRow from 'oneslash-design-system/components/tableRow';
38
+ import TableCell from 'oneslash-design-system/components/tableCell';
39
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
40
+
41
+ type Color = 'error' | 'warning' | undefined;
42
+
43
+ // A real app reads these from the server.
44
+ const workspaces: { id: string; name: string; plan: string; status: string; color: Color }[] = [
45
+ { id: 'acme', name: 'Acme', plan: 'Pro', status: 'Past due', color: 'error' },
46
+ { id: 'acme-labs', name: 'Acme Labs', plan: 'Pro', status: 'Canceling', color: 'warning' },
47
+ { id: 'acme-studio', name: 'Acme Studio', plan: 'Pro', status: 'Active', color: undefined },
48
+ ];
49
+
50
+ export default function StatusLabelDot() {
51
+ return (
52
+ <Center width="page">
53
+ <Stack gap="large">
54
+ <Heading level={2} size="h5">Workspaces</Heading>
55
+ <TableContainer aria-label="Workspaces" minWidth="480px">
56
+ <TableHeader>
57
+ <TableRow>
58
+ <TableHeaderCell>Workspace</TableHeaderCell>
59
+ <TableHeaderCell width="100px">Plan</TableHeaderCell>
60
+ <TableHeaderCell width="160px">Status</TableHeaderCell>
61
+ </TableRow>
62
+ </TableHeader>
63
+ {workspaces.map((w) => (
64
+ <TableRow key={w.id}>
65
+ <TableCell>{w.name}</TableCell>
66
+ <TableCell width="100px">{w.plan}</TableCell>
67
+ <TableCell width="160px">
68
+ {/* The word is always there. Only a state that needs action gets a color: 'Active' keeps the grey dot. */}
69
+ <Tag variant="dot" size="small" color={w.color} label={w.status} />
70
+ </TableCell>
71
+ </TableRow>
72
+ ))}
73
+ </TableContainer>
74
+ </Stack>
75
+ </Center>
76
+ );
77
+ }
78
+ ```
79
+
80
+ ## Option: A word alone
81
+
82
+ Use when: The record is settled and nothing is left to do: Paid, Refunded.
83
+
84
+ Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `formatMoney`
85
+
86
+ ```tsx
87
+ 'use client';
88
+ import Heading from 'oneslash-design-system/components/heading';
89
+ import Tag from 'oneslash-design-system/components/tag';
90
+ import TableContainer from 'oneslash-design-system/components/tableContainer';
91
+ import TableHeader from 'oneslash-design-system/components/tableHeader';
92
+ import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
93
+ import TableRow from 'oneslash-design-system/components/tableRow';
94
+ import TableCell from 'oneslash-design-system/components/tableCell';
95
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
96
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
97
+
98
+ // A real app reads these from the server.
99
+ const payments = [
100
+ { id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
101
+ { id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
102
+ { id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
103
+ { id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
104
+ ];
105
+
106
+ export default function StatusLabelText() {
107
+ return (
108
+ <Center width="page">
109
+ <Stack gap="large">
110
+ <Heading level={2} size="h5">Payments</Heading>
111
+ <TableContainer aria-label="Payments" minWidth="480px">
112
+ <TableHeader>
113
+ <TableRow>
114
+ <TableHeaderCell>Date</TableHeaderCell>
115
+ <TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
116
+ <TableHeaderCell width="160px">Status</TableHeaderCell>
117
+ </TableRow>
118
+ </TableHeader>
119
+ {payments.map((p) => (
120
+ <TableRow key={p.id}>
121
+ <TableCell>{p.date}</TableCell>
122
+ <TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
123
+ <TableCell width="160px">
124
+ {p.status === 'Upcoming' ? (
125
+ // The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
126
+ <Tag variant="dot" size="small" color="info" label={p.status} />
127
+ ) : (
128
+ // A settled record is a word with no dot and no color.
129
+ <Tag variant="textOnly" size="small" label={p.status} />
130
+ )}
131
+ </TableCell>
132
+ </TableRow>
133
+ ))}
134
+ </TableContainer>
135
+ </Stack>
136
+ </Center>
137
+ );
138
+ }
139
+ ```
140
+
141
+ ## Native
142
+
143
+ On Apple use a `Label` with a small filled circle as its image and the word, colored with a semantic style only when the state needs action. On Android use a leading dot and the word in a `Text`.
@@ -3,6 +3,7 @@ import { useState } from 'react';
3
3
  import Surface from '../../components/surface';
4
4
  import Heading from '../../components/heading';
5
5
  import Paragraph from '../../components/paragraph';
6
+ import Progress from '../../components/progress';
6
7
  import TextField from '../../components/textField';
7
8
  import Button from '../../components/button';
8
9
  import { Center, Cluster, Stack } from '../../components/layout';
@@ -27,12 +28,13 @@ export default function UpgradePromptInline() {
27
28
  <Paragraph measure="none">{m.text}</Paragraph>
28
29
  </Stack>); })}
29
30
  </Stack>
31
+ <Progress label="AI agent responses" value={50} max={50} unit="responses" aria-describedby={showNotice ? 'upgrade-prompt-notice' : undefined}/>
30
32
  {showNotice ? (
31
33
  // The notice takes the place of the message box, where the person was about to type.
32
34
  <Surface padding="medium">
33
35
  <Stack gap="medium">
34
36
  <Stack gap="small">
35
- <Paragraph measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on December 1.</Paragraph>
37
+ <Paragraph id="upgrade-prompt-notice" measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
36
38
  <Paragraph tone="secondary" size="body2" measure="none">
37
39
  {canChangePlan
38
40
  ? 'The Pro plan gives Acme Design 1,000 AI agent responses a month.'
@@ -46,7 +48,7 @@ export default function UpgradePromptInline() {
46
48
  </Stack>
47
49
  </Surface>) : (
48
50
  // After 'Not Now' the message box comes back, closed until the replies start again.
49
- <TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="Agent replies start again on December 1." disabled onChange={function () { }}/>)}
51
+ <TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="AI agent responses start again on Dec 1." disabled onChange={function () { }}/>)}
50
52
  </Stack>
51
53
  </Center>);
52
54
  }
@@ -5,6 +5,7 @@ import Heading from '../../components/heading';
5
5
  import Paragraph from '../../components/paragraph';
6
6
  import Button from '../../components/button';
7
7
  import { Center, Cluster, Stack } from '../../components/layout';
8
+ import { formatMoney } from '../../components/formatNumber';
8
9
  // A real app passes the router from its framework, such as Next's useRouter().
9
10
  var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
10
11
  // A real app reads this from the person's role. Only an admin can change the plan.
@@ -35,7 +36,7 @@ export default function UpgradePromptModal() {
35
36
  <Paragraph measure="none">Exporting to PDF is part of the Pro plan. Acme Design is on the Free plan.</Paragraph>
36
37
  <Paragraph tone="secondary" size="body2" measure="none">
37
38
  {canChangePlan
38
- ? 'Pro also adds version history and unlimited guests, for $8 per member each month.'
39
+ ? "Pro also adds version history and unlimited guests, for ".concat(formatMoney(8), " per member each month.")
39
40
  : 'Ask a workspace admin to upgrade Acme Design to Pro.'}
40
41
  </Paragraph>
41
42
  </Modal>
@@ -5,12 +5,13 @@ A person reaches something their plan does not include, or a limit of their plan
5
5
  ## Do
6
6
 
7
7
  - Say what is locked and which plan unlocks it: 'Exporting to PDF is part of the Pro plan.'
8
- - Say which limit was reached, with the number, and when it resets: "You've used all 50 AI agent responses this month. They start again on December 1."
8
+ - Say which limit was reached, with the number, and when it resets: "You've used all 50 AI agent responses this month. They start again on Dec 1."
9
9
  - Offer 'Not Now' as a tertiary Button, then 'Upgrade to Pro' as a primary Button.
10
10
  - Show 'Upgrade to Pro' only to a person who can change the plan. Tell everyone else to ask a workspace admin, and give them only 'Not Now'.
11
11
  - Title the Modal 'Upgrade to Pro' only for a person who can upgrade. For everyone else, title it 'Pro Feature'.
12
12
  - Follow the rule 'A confirm says exactly what will happen' for the Modal: `size="small"`, and Escape or a click outside means 'Not Now'.
13
13
  - Put the notice where the control was, with the same two Buttons, when a limit is reached inside a flow.
14
+ - At a limit, show a `Progress` above the notice that says 'Limit reached', and point it at the notice with `aria-describedby`.
14
15
  - Follow the rule 'An agent refuses clearly' too when the agent is the one refused.
15
16
 
16
17
  ## Don't
@@ -25,7 +26,7 @@ A person reaches something their plan does not include, or a limit of their plan
25
26
 
26
27
  Use when: The person pressed something their plan does not include.
27
28
 
28
- Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`
29
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`, `formatMoney`
29
30
 
30
31
  ```tsx
31
32
  'use client';
@@ -35,6 +36,7 @@ import Heading from 'oneslash-design-system/components/heading';
35
36
  import Paragraph from 'oneslash-design-system/components/paragraph';
36
37
  import Button from 'oneslash-design-system/components/button';
37
38
  import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
39
+ import { formatMoney } from 'oneslash-design-system/components/formatNumber';
38
40
 
39
41
  // A real app passes the router from its framework, such as Next's useRouter().
40
42
  const router = { push: (url: string) => console.info(`Go to ${url}`) };
@@ -82,7 +84,7 @@ export default function UpgradePromptModal() {
82
84
  <Paragraph measure="none">Exporting to PDF is part of the Pro plan. Acme Design is on the Free plan.</Paragraph>
83
85
  <Paragraph tone="secondary" size="body2" measure="none">
84
86
  {canChangePlan
85
- ? 'Pro also adds version history and unlimited guests, for $8 per member each month.'
87
+ ? `Pro also adds version history and unlimited guests, for ${formatMoney(8)} per member each month.`
86
88
  : 'Ask a workspace admin to upgrade Acme Design to Pro.'}
87
89
  </Paragraph>
88
90
  </Modal>
@@ -95,7 +97,7 @@ export default function UpgradePromptModal() {
95
97
 
96
98
  Use when: A limit was reached inside a flow. The notice takes the place of the control that hit it.
97
99
 
98
- Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
100
+ Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Progress`, `Stack`, `Surface`, `TextField`
99
101
 
100
102
  ```tsx
101
103
  'use client';
@@ -103,6 +105,7 @@ import { useState } from 'react';
103
105
  import Surface from 'oneslash-design-system/components/surface';
104
106
  import Heading from 'oneslash-design-system/components/heading';
105
107
  import Paragraph from 'oneslash-design-system/components/paragraph';
108
+ import Progress from 'oneslash-design-system/components/progress';
106
109
  import TextField from 'oneslash-design-system/components/textField';
107
110
  import Button from 'oneslash-design-system/components/button';
108
111
  import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
@@ -135,12 +138,13 @@ export default function UpgradePromptInline() {
135
138
  </Stack>
136
139
  ))}
137
140
  </Stack>
141
+ <Progress label="AI agent responses" value={50} max={50} unit="responses" aria-describedby={showNotice ? 'upgrade-prompt-notice' : undefined} />
138
142
  {showNotice ? (
139
143
  // The notice takes the place of the message box, where the person was about to type.
140
144
  <Surface padding="medium">
141
145
  <Stack gap="medium">
142
146
  <Stack gap="small">
143
- <Paragraph measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on December 1.</Paragraph>
147
+ <Paragraph id="upgrade-prompt-notice" measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
144
148
  <Paragraph tone="secondary" size="body2" measure="none">
145
149
  {canChangePlan
146
150
  ? 'The Pro plan gives Acme Design 1,000 AI agent responses a month.'
@@ -157,7 +161,7 @@ export default function UpgradePromptInline() {
157
161
  </Surface>
158
162
  ) : (
159
163
  // After 'Not Now' the message box comes back, closed until the replies start again.
160
- <TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="Agent replies start again on December 1." disabled onChange={() => {}} />
164
+ <TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="AI agent responses start again on Dec 1." disabled onChange={() => {}} />
161
165
  )}
162
166
  </Stack>
163
167
  </Center>
@@ -0,0 +1 @@
1
+ export default function UsageMetersByPerson(): import("react").JSX.Element;
@@ -0,0 +1,72 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Surface from '../../components/surface';
4
+ import Paragraph from '../../components/paragraph';
5
+ import Heading from '../../components/heading';
6
+ import Progress from '../../components/progress';
7
+ import Button from '../../components/button';
8
+ import SettingsSection from '../../components/settingsSection';
9
+ import TableContainer from '../../components/tableContainer';
10
+ import TableHeader from '../../components/tableHeader';
11
+ import TableHeaderCell from '../../components/tableHeaderCell';
12
+ import TableRow from '../../components/tableRow';
13
+ import TableCell from '../../components/tableCell';
14
+ import { formatCount } from '../../components/formatNumber';
15
+ import { Center, Cluster, Stack } from '../../components/layout';
16
+ // A real app passes the router from its framework, such as Next's useRouter().
17
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
18
+ // A real app reads this from the person's role. Only an admin can change the plan.
19
+ var canChangePlan = true;
20
+ // A real app counts these on the server, most first. A count can pass its limit by a few: replies that were
21
+ // already running when the limit was reached still finish.
22
+ var people = [
23
+ { id: 'dana', name: 'Dana Lee', responses: 21 },
24
+ { id: 'ben', name: 'Ben Carter', responses: 19 },
25
+ { id: 'omar', name: 'Omar Reyes', responses: 13 },
26
+ ];
27
+ var total = people.reduce(function (sum, p) { return sum + p.responses; }, 0);
28
+ export default function UsageMetersByPerson() {
29
+ var _a = useState(true), showNotice = _a[0], setShowNotice = _a[1];
30
+ return (<Center width="page">
31
+ <SettingsSection title="Usage" description="This month, on the Free plan.">
32
+ <Stack gap="large">
33
+ <Stack gap="small">
34
+ <Progress label="AI agent responses" value={total} max={50} unit="responses" aria-describedby={showNotice ? 'usage-meters-person-notice' : undefined}/>
35
+ <Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
36
+ {showNotice && (<Surface padding="small">
37
+ <Stack gap="medium">
38
+ <Stack gap="small">
39
+ <Paragraph id="usage-meters-person-notice" measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
40
+ <Paragraph tone="secondary" size="body2" measure="none">
41
+ {canChangePlan
42
+ ? 'The Pro plan gives Acme 1,000 AI agent responses a month.'
43
+ : 'Ask a workspace admin to upgrade Acme to Pro for more replies.'}
44
+ </Paragraph>
45
+ </Stack>
46
+ <Cluster gap="small">
47
+ <Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setShowNotice(false); }}/>
48
+ {canChangePlan && (<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return router.push('/settings/billing?plan=pro'); }}/>)}
49
+ </Cluster>
50
+ </Stack>
51
+ </Surface>)}
52
+ </Stack>
53
+ {/* Under the meters: who used it, most first, with exact numbers. */}
54
+ <Stack gap="small">
55
+ <Heading level={3} size="h6">Responses by person</Heading>
56
+ <TableContainer aria-label="Responses by person" minWidth="320px">
57
+ <TableHeader>
58
+ <TableRow>
59
+ <TableHeaderCell>Person</TableHeaderCell>
60
+ <TableHeaderCell width="130px" align="right">Responses</TableHeaderCell>
61
+ </TableRow>
62
+ </TableHeader>
63
+ {people.map(function (p) { return (<TableRow key={p.id}>
64
+ <TableCell>{p.name}</TableCell>
65
+ <TableCell width="130px" align="right">{formatCount(p.responses)}</TableCell>
66
+ </TableRow>); })}
67
+ </TableContainer>
68
+ </Stack>
69
+ </Stack>
70
+ </SettingsSection>
71
+ </Center>);
72
+ }
@@ -0,0 +1 @@
1
+ export default function UsageMetersMeters(): import("react").JSX.Element;
@@ -0,0 +1,49 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Surface from '../../components/surface';
4
+ import Paragraph from '../../components/paragraph';
5
+ import Progress from '../../components/progress';
6
+ import Button from '../../components/button';
7
+ import SettingsSection from '../../components/settingsSection';
8
+ import { formatBytes } from '../../components/formatNumber';
9
+ import { Center, Cluster, Stack } from '../../components/layout';
10
+ // A real app passes the router from its framework, such as Next's useRouter().
11
+ var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
12
+ // A real app reads this from the person's role. Only an admin can change the plan.
13
+ var canChangePlan = true;
14
+ // A real app reads the numbers from the server. This is Free: 50 responses, 3 members and 1 GB.
15
+ var GB = Math.pow(1024, 3);
16
+ var storage = { used: Math.round(0.85 * GB), limit: GB };
17
+ export default function UsageMetersMeters() {
18
+ var _a = useState(true), showNotice = _a[0], setShowNotice = _a[1];
19
+ return (<Center width="page">
20
+ <SettingsSection title="Usage" description="This month, on the Free plan.">
21
+ <Stack gap="large">
22
+ <Stack gap="small">
23
+ {/* At the limit the meter says 'Limit reached' in words. The notice sits under it and names the limit. */}
24
+ <Progress id="usage-meters-responses" label="AI agent responses" value={50} max={50} unit="responses" aria-describedby={showNotice ? 'usage-meters-notice' : undefined}/>
25
+ <Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
26
+ {showNotice && (<Surface padding="small">
27
+ <Stack gap="medium">
28
+ <Stack gap="small">
29
+ <Paragraph id="usage-meters-notice" measure="none">You&apos;ve used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
30
+ <Paragraph tone="secondary" size="body2" measure="none">
31
+ {canChangePlan
32
+ ? 'The Pro plan gives Acme 1,000 AI agent responses a month.'
33
+ : 'Ask a workspace admin to upgrade Acme to Pro for more replies.'}
34
+ </Paragraph>
35
+ </Stack>
36
+ <Cluster gap="small">
37
+ <Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setShowNotice(false); }}/>
38
+ {canChangePlan && (<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return router.push('/settings/billing?plan=pro'); }}/>)}
39
+ </Cluster>
40
+ </Stack>
41
+ </Surface>)}
42
+ </Stack>
43
+ <Progress label="Members" value={2} max={3} unit="members"/>
44
+ {/* Near the limit the bar turns to a warning, and says so in words. */}
45
+ <Progress label="Storage" value={storage.used} max={storage.limit} valueText={"".concat(formatBytes(storage.used), " of ").concat(formatBytes(storage.limit))}/>
46
+ </Stack>
47
+ </SettingsSection>
48
+ </Center>);
49
+ }
@@ -0,0 +1 @@
1
+ export default function UsageMetersWithCap(): import("react").JSX.Element;
@@ -0,0 +1,73 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Alert from '../../components/alert';
4
+ import Paragraph from '../../components/paragraph';
5
+ import Progress from '../../components/progress';
6
+ import Button from '../../components/button';
7
+ import Form from '../../components/form';
8
+ import FormField from '../../components/formField';
9
+ import TextField from '../../components/textField';
10
+ import SettingsSection from '../../components/settingsSection';
11
+ import { formatMoney } from '../../components/formatNumber';
12
+ import { Center, Cluster, Stack } from '../../components/layout';
13
+ // A real app reads these from the server. Extra AI agent responses cost $0.05 each, and $18.40 is spent so far.
14
+ var spent = 18.4;
15
+ // A real app reads this from the person's role. Only an admin sets the cap.
16
+ var canChangeCap = true;
17
+ export default function UsageMetersWithCap() {
18
+ var _a = useState(20), cap = _a[0], setCap = _a[1];
19
+ var _b = useState('20'), draft = _b[0], setDraft = _b[1];
20
+ var _c = useState(''), error = _c[0], setError = _c[1];
21
+ var _d = useState(false), saving = _d[0], setSaving = _d[1];
22
+ var _e = useState(false), saved = _e[0], setSaved = _e[1];
23
+ var timer = useRef();
24
+ // Cleared before a new 'Saved' starts, so an old timer cannot end it early.
25
+ var savedTimer = useRef();
26
+ // Stops the request and the 'Saved' if the example goes away before they end.
27
+ useEffect(function () { return function () {
28
+ clearTimeout(timer.current);
29
+ clearTimeout(savedTimer.current);
30
+ }; }, []);
31
+ var next = draft.trim() === '' ? null : Number(draft);
32
+ var changed = next !== cap;
33
+ // The cap is one field with one Save Button. Empty means no cap.
34
+ function handleSave() {
35
+ if (saving || !changed)
36
+ return;
37
+ if (next !== null && !(Number.isInteger(next) && next >= 1 && next <= 10000)) {
38
+ setError("Enter a whole amount from ".concat(formatMoney(1), " to ").concat(formatMoney(10000), ", or leave it empty for no cap."));
39
+ return;
40
+ }
41
+ setError('');
42
+ setSaving(true);
43
+ // Stands in for the request to the server.
44
+ timer.current = setTimeout(function () {
45
+ setCap(next);
46
+ setSaving(false);
47
+ setSaved(true);
48
+ clearTimeout(savedTimer.current);
49
+ savedTimer.current = setTimeout(function () { return setSaved(false); }, 2000);
50
+ }, 1200);
51
+ }
52
+ var reached = cap !== null && spent >= cap;
53
+ return (<Center width="page">
54
+ <SettingsSection title="Usage" description={"This month, on the Pro plan. Extra AI agent responses cost ".concat(formatMoney(0.05), " each.")}>
55
+ <Stack gap="large">
56
+ <Stack gap="small">
57
+ {/* A cap is a limit: the bar warns near it and says 'Limit reached' at it. With no cap there is no bar. */}
58
+ <Progress label="Spend this month" value={spent} max={cap} valueText={cap === null ? "".concat(formatMoney(spent), " so far, no cap") : "".concat(formatMoney(spent), " of ").concat(formatMoney(cap))}/>
59
+ <Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
60
+ {reached && <Alert type="warning" variant="inline" autoDismiss={false} message="AI agent responses are paused. Raise the cap, or they start again on Dec 1."/>}
61
+ </Stack>
62
+ {canChangeCap ? (<Form aria-label="Monthly spend cap" gap="medium" onSubmit={handleSave}>
63
+ <FormField id="usage-meters-cap" label="Monthly spend cap (USD)" help="AI agent responses pause when the cap is reached. Leave it empty for no cap." error={error}>
64
+ {function (f) { return (<TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} type="number" value={draft} disabled={saving} onChange={function (e) { setDraft(e.target.value); setError(''); setSaved(false); }}/>); }}
65
+ </FormField>
66
+ <Cluster>
67
+ <Button size="medium" type="primary" state={changed || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={saving}/>
68
+ </Cluster>
69
+ </Form>) : (<Paragraph tone="secondary" size="body2" measure="none">{"The monthly spend cap is ".concat(cap === null ? 'not set' : formatMoney(cap), ". Only admins can change it.")}</Paragraph>)}
70
+ </Stack>
71
+ </SettingsSection>
72
+ </Center>);
73
+ }