oneslash-design-system 2.18.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 (227) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +54 -5
  3. package/dist/cases/app-shell/sidebar.d.ts +1 -0
  4. package/dist/cases/app-shell/sidebar.jsx +124 -0
  5. package/dist/cases/app-shell/top-tabs.d.ts +1 -0
  6. package/dist/cases/app-shell/top-tabs.jsx +106 -0
  7. package/dist/cases/app-shell.md +364 -0
  8. package/dist/cases/artifact-card/card.jsx +32 -6
  9. package/dist/cases/artifact-card.md +55 -7
  10. package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
  11. package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
  12. package/dist/cases/billing-page/self-serve.d.ts +1 -0
  13. package/dist/cases/billing-page/self-serve.jsx +134 -0
  14. package/dist/cases/billing-page.md +247 -0
  15. package/dist/cases/breakdown-list/bars.d.ts +1 -0
  16. package/dist/cases/breakdown-list/bars.jsx +47 -0
  17. package/dist/cases/breakdown-list/table.d.ts +1 -0
  18. package/dist/cases/breakdown-list/table.jsx +69 -0
  19. package/dist/cases/breakdown-list.md +158 -0
  20. package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
  21. package/dist/cases/composer-limit/notice.jsx +3 -3
  22. package/dist/cases/composer-limit.md +8 -8
  23. package/dist/cases/dashboard/numbers-first.d.ts +1 -0
  24. package/dist/cases/dashboard/numbers-first.jsx +165 -0
  25. package/dist/cases/dashboard/work-first.d.ts +1 -0
  26. package/dist/cases/dashboard/work-first.jsx +165 -0
  27. package/dist/cases/dashboard.md +507 -0
  28. package/dist/cases/data-table-page/all-rows.d.ts +1 -0
  29. package/dist/cases/data-table-page/all-rows.jsx +226 -0
  30. package/dist/cases/data-table-page/paged.d.ts +1 -0
  31. package/dist/cases/data-table-page/paged.jsx +284 -0
  32. package/dist/cases/data-table-page.md +771 -0
  33. package/dist/cases/error-page/in-shell.jsx +26 -17
  34. package/dist/cases/error-page.md +42 -21
  35. package/dist/cases/invoice-list/table.d.ts +1 -0
  36. package/dist/cases/invoice-list/table.jsx +64 -0
  37. package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
  38. package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
  39. package/dist/cases/invoice-list.md +237 -0
  40. package/dist/cases/load-failure/inline.jsx +2 -2
  41. package/dist/cases/load-failure.md +2 -2
  42. package/dist/cases/master-detail/list-then-page.d.ts +1 -0
  43. package/dist/cases/master-detail/list-then-page.jsx +65 -0
  44. package/dist/cases/master-detail/split.d.ts +1 -0
  45. package/dist/cases/master-detail/split.jsx +49 -0
  46. package/dist/cases/master-detail.md +213 -0
  47. package/dist/cases/members-list/rows.jsx +2 -1
  48. package/dist/cases/members-list/table.jsx +8 -9
  49. package/dist/cases/members-list.md +12 -13
  50. package/dist/cases/mobile-menu/links.d.ts +1 -0
  51. package/dist/cases/mobile-menu/links.jsx +24 -0
  52. package/dist/cases/mobile-menu/sections.d.ts +1 -0
  53. package/dist/cases/mobile-menu/sections.jsx +61 -0
  54. package/dist/cases/mobile-menu.md +170 -0
  55. package/dist/cases/not-found-page/in-shell.jsx +26 -17
  56. package/dist/cases/not-found-page.md +41 -20
  57. package/dist/cases/number-format.md +36 -0
  58. package/dist/cases/on-this-page/aside.d.ts +1 -0
  59. package/dist/cases/on-this-page/aside.jsx +39 -0
  60. package/dist/cases/on-this-page.md +80 -0
  61. package/dist/cases/page-header/actions.d.ts +1 -0
  62. package/dist/cases/page-header/actions.jsx +65 -0
  63. package/dist/cases/page-header/sub-page.d.ts +1 -0
  64. package/dist/cases/page-header/sub-page.jsx +37 -0
  65. package/dist/cases/page-header.md +195 -0
  66. package/dist/cases/paged-card/pager.d.ts +1 -0
  67. package/dist/cases/paged-card/pager.jsx +41 -0
  68. package/dist/cases/paged-card/see-all.d.ts +1 -0
  69. package/dist/cases/paged-card/see-all.jsx +34 -0
  70. package/dist/cases/paged-card.md +147 -0
  71. package/dist/cases/payment-method/none.d.ts +1 -0
  72. package/dist/cases/payment-method/none.jsx +17 -0
  73. package/dist/cases/payment-method/on-file.d.ts +1 -0
  74. package/dist/cases/payment-method/on-file.jsx +92 -0
  75. package/dist/cases/payment-method.md +182 -0
  76. package/dist/cases/phone-navigation.md +32 -0
  77. package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
  78. package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
  79. package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
  80. package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
  81. package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
  82. package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
  83. package/dist/cases/plan-change-confirm.md +261 -0
  84. package/dist/cases/plan-picker/cards.d.ts +1 -0
  85. package/dist/cases/plan-picker/cards.jsx +97 -0
  86. package/dist/cases/plan-picker/list.d.ts +1 -0
  87. package/dist/cases/plan-picker/list.jsx +103 -0
  88. package/dist/cases/plan-picker.md +297 -0
  89. package/dist/cases/range-switch/segmented.jsx +11 -7
  90. package/dist/cases/range-switch.md +16 -11
  91. package/dist/cases/route-loading/region.jsx +27 -18
  92. package/dist/cases/route-loading.md +42 -21
  93. package/dist/cases/settings-page/top-tabs.jsx +4 -3
  94. package/dist/cases/settings-page.md +5 -4
  95. package/dist/cases/side-pane/beside.d.ts +1 -0
  96. package/dist/cases/side-pane/beside.jsx +79 -0
  97. package/dist/cases/side-pane/over.d.ts +1 -0
  98. package/dist/cases/side-pane/over.jsx +58 -0
  99. package/dist/cases/side-pane.md +238 -0
  100. package/dist/cases/sidebar-nav/flat.d.ts +1 -0
  101. package/dist/cases/sidebar-nav/flat.jsx +81 -0
  102. package/dist/cases/sidebar-nav/nested.d.ts +1 -0
  103. package/dist/cases/sidebar-nav/nested.jsx +122 -0
  104. package/dist/cases/sidebar-nav.md +261 -0
  105. package/dist/cases/site-footer/columns.d.ts +1 -0
  106. package/dist/cases/site-footer/columns.jsx +51 -0
  107. package/dist/cases/site-footer/simple.d.ts +1 -0
  108. package/dist/cases/site-footer/simple.jsx +24 -0
  109. package/dist/cases/site-footer.md +133 -0
  110. package/dist/cases/site-header/links.d.ts +1 -0
  111. package/dist/cases/site-header/links.jsx +26 -0
  112. package/dist/cases/site-header/sections.d.ts +1 -0
  113. package/dist/cases/site-header/sections.jsx +64 -0
  114. package/dist/cases/site-header.md +183 -0
  115. package/dist/cases/stat-row/featured.d.ts +1 -0
  116. package/dist/cases/stat-row/featured.jsx +17 -0
  117. package/dist/cases/stat-row/tiles.d.ts +1 -0
  118. package/dist/cases/stat-row/tiles.jsx +34 -0
  119. package/dist/cases/stat-row.md +104 -0
  120. package/dist/cases/status-label/dot.d.ts +1 -0
  121. package/dist/cases/status-label/dot.jsx +39 -0
  122. package/dist/cases/status-label/text.d.ts +1 -0
  123. package/dist/cases/status-label/text.jsx +44 -0
  124. package/dist/cases/status-label.md +143 -0
  125. package/dist/cases/theme-switcher/menu.d.ts +1 -0
  126. package/dist/cases/theme-switcher/menu.jsx +47 -0
  127. package/dist/cases/theme-switcher/segmented.d.ts +1 -0
  128. package/dist/cases/theme-switcher/segmented.jsx +26 -0
  129. package/dist/cases/theme-switcher.md +149 -0
  130. package/dist/cases/upgrade-prompt/inline.jsx +4 -2
  131. package/dist/cases/upgrade-prompt/modal.jsx +2 -1
  132. package/dist/cases/upgrade-prompt.md +10 -6
  133. package/dist/cases/usage-meters/by-person.d.ts +1 -0
  134. package/dist/cases/usage-meters/by-person.jsx +72 -0
  135. package/dist/cases/usage-meters/meters.d.ts +1 -0
  136. package/dist/cases/usage-meters/meters.jsx +49 -0
  137. package/dist/cases/usage-meters/with-cap.d.ts +1 -0
  138. package/dist/cases/usage-meters/with-cap.jsx +73 -0
  139. package/dist/cases/usage-meters.md +303 -0
  140. package/dist/cases.json +1756 -172
  141. package/dist/components/appShell.d.ts +44 -0
  142. package/dist/components/appShell.jsx +121 -0
  143. package/dist/components/button.d.ts +1 -1
  144. package/dist/components/button.jsx +11 -5
  145. package/dist/components/drawer.d.ts +31 -0
  146. package/dist/components/drawer.jsx +121 -0
  147. package/dist/components/formatNumber.d.ts +25 -0
  148. package/dist/components/formatNumber.js +125 -0
  149. package/dist/components/heading.d.ts +3 -1
  150. package/dist/components/heading.jsx +2 -2
  151. package/dist/components/iconButton.jsx +12 -7
  152. package/dist/components/link.d.ts +6 -1
  153. package/dist/components/link.jsx +11 -3
  154. package/dist/components/menuItem.d.ts +7 -1
  155. package/dist/components/menuItem.jsx +4 -3
  156. package/dist/components/modal.jsx +12 -23
  157. package/dist/components/onThisPage.d.ts +29 -0
  158. package/dist/components/onThisPage.jsx +151 -0
  159. package/dist/components/pageShell.d.ts +7 -1
  160. package/dist/components/pageShell.jsx +14 -1
  161. package/dist/components/pagination.d.ts +28 -0
  162. package/dist/components/pagination.jsx +89 -0
  163. package/dist/components/popover.jsx +4 -0
  164. package/dist/components/progress.d.ts +33 -0
  165. package/dist/components/progress.jsx +50 -0
  166. package/dist/components/settingsSection.d.ts +6 -1
  167. package/dist/components/settingsSection.jsx +10 -3
  168. package/dist/components/sidePane.d.ts +32 -0
  169. package/dist/components/sidePane.jsx +128 -0
  170. package/dist/components/siteFooter.d.ts +24 -0
  171. package/dist/components/siteFooter.jsx +48 -0
  172. package/dist/components/siteHeader.d.ts +55 -0
  173. package/dist/components/siteHeader.jsx +125 -0
  174. package/dist/components/skeleton.d.ts +21 -0
  175. package/dist/components/skeleton.jsx +41 -0
  176. package/dist/components/statTile.d.ts +32 -0
  177. package/dist/components/statTile.jsx +61 -0
  178. package/dist/components/tableContainer.d.ts +5 -1
  179. package/dist/components/tableContainer.jsx +9 -1
  180. package/dist/components/tableHeaderCell.d.ts +3 -1
  181. package/dist/components/tableHeaderCell.jsx +2 -2
  182. package/dist/components/titleBar.d.ts +19 -0
  183. package/dist/components/titleBar.jsx +18 -0
  184. package/dist/index.d.ts +12 -0
  185. package/dist/index.js +12 -0
  186. package/dist/internal/overlayStack.d.ts +24 -0
  187. package/dist/internal/overlayStack.js +71 -0
  188. package/dist/internal/resize.d.ts +9 -0
  189. package/dist/internal/resize.js +31 -0
  190. package/dist/internal/scrollSpy.d.ts +24 -0
  191. package/dist/internal/scrollSpy.js +53 -0
  192. package/dist/internal/siteBrand.d.ts +6 -0
  193. package/dist/internal/siteBrand.jsx +11 -0
  194. package/dist/native-mapping.json +69 -3
  195. package/dist/stories/AppShell.stories.d.ts +15 -0
  196. package/dist/stories/AppShell.stories.jsx +137 -0
  197. package/dist/stories/Button.stories.d.ts +1 -0
  198. package/dist/stories/Button.stories.jsx +19 -1
  199. package/dist/stories/Cases.generated.stories.d.ts +45 -0
  200. package/dist/stories/Cases.generated.stories.jsx +90 -0
  201. package/dist/stories/Drawer.stories.d.ts +10 -0
  202. package/dist/stories/Drawer.stories.jsx +123 -0
  203. package/dist/stories/Link.stories.d.ts +1 -0
  204. package/dist/stories/Link.stories.jsx +8 -0
  205. package/dist/stories/OnThisPage.stories.d.ts +10 -0
  206. package/dist/stories/OnThisPage.stories.jsx +105 -0
  207. package/dist/stories/Pagination.stories.d.ts +9 -0
  208. package/dist/stories/Pagination.stories.jsx +75 -0
  209. package/dist/stories/Progress.stories.d.ts +9 -0
  210. package/dist/stories/Progress.stories.jsx +43 -0
  211. package/dist/stories/SettingsSection.stories.d.ts +1 -0
  212. package/dist/stories/SettingsSection.stories.jsx +27 -0
  213. package/dist/stories/SidePane.stories.d.ts +6 -0
  214. package/dist/stories/SidePane.stories.jsx +37 -0
  215. package/dist/stories/SiteFooter.stories.d.ts +7 -0
  216. package/dist/stories/SiteFooter.stories.jsx +63 -0
  217. package/dist/stories/SiteHeader.stories.d.ts +10 -0
  218. package/dist/stories/SiteHeader.stories.jsx +94 -0
  219. package/dist/stories/Skeleton.stories.d.ts +7 -0
  220. package/dist/stories/Skeleton.stories.jsx +27 -0
  221. package/dist/stories/StatTile.stories.d.ts +10 -0
  222. package/dist/stories/StatTile.stories.jsx +55 -0
  223. package/dist/stories/Table.stories.d.ts +1 -0
  224. package/dist/stories/Table.stories.jsx +49 -1
  225. package/dist/stories/TitleBar.stories.d.ts +7 -0
  226. package/dist/stories/TitleBar.stories.jsx +41 -0
  227. package/package.json +5 -1
@@ -0,0 +1,195 @@
1
+ # Page header with actions
2
+
3
+ A page names itself at the top and offers what the person can do with it.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.
8
+ - Use `TitleBar` with the page's name as the level 1 heading. Inside `AppShell` the top bar names the place on a phone. When the page is the place, the two are the same.
9
+ - Give the page one primary Button, first in `actions`.
10
+ - Put icon buttons after it, each in a `Tooltip` and named for what they act on: 'Search Home page'.
11
+ - Put a More menu last, as the case 'More menu' says: an `IconButton` with `iconName="Ellipsis"`, `aria-haspopup="menu"` and a name such as 'More actions for Home page'.
12
+ - Pass `phoneActions` with the primary Button and More. Below `md` they replace `actions`.
13
+ - Fold the icon buttons you leave out into the More menu, in the same order, so every action is still there. Put them first, before a `Line`. Keep a frequent action, such as Search, as an icon button in `phoneActions`.
14
+ - Pass `back` on a sub-page, a tertiary Button named for the page it goes to: 'Back to Website'. Below `md` it takes its own line.
15
+ - Let a long title wrap. Never cut it short.
16
+
17
+ ## Don't
18
+
19
+ - Do not add a breadcrumb. Back goes one step up, and the title says where the person is.
20
+ - Do not show two primary Buttons.
21
+ - Do not name an icon button only by its icon, or More only by the word.
22
+ - Do not leave an action out on a phone without a way to reach it.
23
+ - Do not name the Back Button 'Back'. Name the page.
24
+
25
+ ## Option: The page's own actions
26
+
27
+ Use when: The page is a place of its own, and the person can add to it, search it or change it.
28
+
29
+ Uses: `Button`, `IconButton`, `Line`, `Menu`, `MenuItem`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `TitleBar`, `Tooltip`
30
+
31
+ ```tsx
32
+ 'use client';
33
+ import { useState } from 'react';
34
+ import PageShell from 'oneslash-design-system/components/pageShell';
35
+ import TitleBar from 'oneslash-design-system/components/titleBar';
36
+ import Button from 'oneslash-design-system/components/button';
37
+ import IconButton from 'oneslash-design-system/components/iconButton';
38
+ import Tooltip from 'oneslash-design-system/components/tooltip';
39
+ import Popover from 'oneslash-design-system/components/popover';
40
+ import Menu from 'oneslash-design-system/components/menu';
41
+ import MenuItem from 'oneslash-design-system/components/menuItem';
42
+ import Line from 'oneslash-design-system/components/line';
43
+ import Paragraph from 'oneslash-design-system/components/paragraph';
44
+ import { Stack } from 'oneslash-design-system/components/layout';
45
+
46
+ export default function PageHeaderActions() {
47
+ const [anchor, setAnchor] = useState<HTMLElement | null>(null);
48
+ // Which More button opened the menu: on a phone the menu also holds Search and Filter.
49
+ const [from, setFrom] = useState<'wide' | 'phone'>('wide');
50
+ const [open, setOpen] = useState(false);
51
+ const [chosen, setChosen] = useState('');
52
+
53
+ function openMore(kind: 'wide' | 'phone', el: HTMLElement) {
54
+ setFrom(kind);
55
+ setAnchor(el);
56
+ setOpen((o) => !o);
57
+ }
58
+
59
+ // Every item closes the menu. Its Popover gives focus back to the More button.
60
+ function choose(label: string) {
61
+ setOpen(false);
62
+ setChosen(label);
63
+ }
64
+
65
+ const newTask = <Button size="medium" type="primary" state="enabled" label="New Task" decoIcon="Plus" onClickButton={() => setChosen('New Task')} />;
66
+
67
+ const more = (kind: 'wide' | 'phone') => (
68
+ <Tooltip title="More">
69
+ <IconButton
70
+ color="iconOnly"
71
+ state={open && from === kind ? 'selected' : 'enabled'}
72
+ size="medium"
73
+ iconName="Ellipsis"
74
+ ariaLabel="More actions for Home page"
75
+ aria-haspopup="menu"
76
+ aria-expanded={open && from === kind}
77
+ onClick={(e: { currentTarget: HTMLElement }) => openMore(kind, e.currentTarget)}
78
+ />
79
+ </Tooltip>
80
+ );
81
+
82
+ return (
83
+ <PageShell>
84
+ <Stack gap="large">
85
+ {/* The title is the page's level 1 heading. One primary Button, then icon buttons, then More last. Below md only the primary and More stay. */}
86
+ <TitleBar
87
+ title="Home page"
88
+ actions={
89
+ <>
90
+ {newTask}
91
+ <Tooltip title="Search">
92
+ <IconButton color="iconOnly" state="enabled" size="medium" iconName="Search" ariaLabel="Search Home page" onClick={() => setChosen('Search')} />
93
+ </Tooltip>
94
+ <Tooltip title="Filter">
95
+ <IconButton color="iconOnly" state="enabled" size="medium" iconName="Filter" ariaLabel="Filter Home page" onClick={() => setChosen('Filter')} />
96
+ </Tooltip>
97
+ {more('wide')}
98
+ </>
99
+ }
100
+ phoneActions={
101
+ <>
102
+ {newTask}
103
+ {more('phone')}
104
+ </>
105
+ }
106
+ />
107
+ <Paragraph tone="secondary" size="body2" measure="none">{chosen ? `You chose ${chosen}.` : '12 tasks are open. Updated 2 days ago by Dana Lee.'}</Paragraph>
108
+ </Stack>
109
+ <Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
110
+ <Menu navigable aria-label="Actions for Home page" width={200}>
111
+ {from === 'phone' && (
112
+ <>
113
+ <MenuItem size="small" iconName="Search" label="Search" onClick={() => choose('Search')} />
114
+ <MenuItem size="small" iconName="Filter" label="Filter" onClick={() => choose('Filter')} />
115
+ <Line />
116
+ </>
117
+ )}
118
+ <MenuItem size="small" iconName="Pencil" label="Rename" onClick={() => choose('Rename')} />
119
+ <MenuItem size="small" iconName="Copy" label="Duplicate" onClick={() => choose('Duplicate')} />
120
+ <MenuItem size="small" iconName="Archive" label="Archive" onClick={() => choose('Archive')} />
121
+ </Menu>
122
+ </Popover>
123
+ </PageShell>
124
+ );
125
+ }
126
+ ```
127
+
128
+ ## Option: A page one step down, with Back
129
+
130
+ Use when: The page opens from another page, such as a task from its project.
131
+
132
+ Uses: `Button`, `Heading`, `MenuItem`, `Navigation`, `PageShell`, `Paragraph`, `Stack`, `TitleBar`
133
+
134
+ ```tsx
135
+ 'use client';
136
+ import { useState } from 'react';
137
+ import PageShell from 'oneslash-design-system/components/pageShell';
138
+ import TitleBar from 'oneslash-design-system/components/titleBar';
139
+ import Heading from 'oneslash-design-system/components/heading';
140
+ import Button from 'oneslash-design-system/components/button';
141
+ import Navigation from 'oneslash-design-system/components/navigation';
142
+ import MenuItem from 'oneslash-design-system/components/menuItem';
143
+ import Paragraph from 'oneslash-design-system/components/paragraph';
144
+ import { Stack } from 'oneslash-design-system/components/layout';
145
+
146
+ const taskTitle = 'Move the sign-up form above the pricing table on the home page';
147
+
148
+ export default function PageHeaderSubPage() {
149
+ // The task is a page one step down from the project's page.
150
+ const [view, setView] = useState<'task' | 'project'>('task');
151
+ const [done, setDone] = useState(false);
152
+
153
+ if (view === 'project') {
154
+ return (
155
+ <PageShell>
156
+ <Stack gap="large">
157
+ <Heading level={1} size="h5">Website</Heading>
158
+ <Navigation aria-label="Tasks">
159
+ <MenuItem
160
+ size="medium"
161
+ label={taskTitle}
162
+ secondLabel={done ? 'Done' : 'Open'}
163
+ iconRight="ChevronRight"
164
+ href="/website/tasks/sign-up-form"
165
+ onClick={(event: { preventDefault: () => void }) => {
166
+ // A real app lets the link go to the task's page. The example keeps the choice in state.
167
+ event.preventDefault();
168
+ setView('task');
169
+ }}
170
+ />
171
+ </Navigation>
172
+ </Stack>
173
+ </PageShell>
174
+ );
175
+ }
176
+
177
+ return (
178
+ <PageShell>
179
+ <Stack gap="large">
180
+ {/* Back names the page it goes to. Below md it takes its own line above the title, and a long title wraps. */}
181
+ <TitleBar
182
+ title={taskTitle}
183
+ back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Website" onClickButton={() => setView('project')} />}
184
+ actions={<Button size="medium" type="primary" state={done ? 'disabled' : 'enabled'} label="Mark Done" onClickButton={() => setDone(true)} />}
185
+ />
186
+ <Paragraph tone="secondary" size="body2" measure="none">{done ? 'Done. Marked by Dana Lee.' : 'Assigned to Ben Carter. Due on Friday.'}</Paragraph>
187
+ </Stack>
188
+ </PageShell>
189
+ );
190
+ }
191
+ ```
192
+
193
+ ## Native
194
+
195
+ On Apple use a navigation title with `.toolbar` items: the primary action as a `ToolbarItem`, the rest in a `Menu`. The system back button names the page before it. On Android use a top app bar with an overflow menu.
@@ -0,0 +1 @@
1
+ export default function PagedCardPager(): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Pagination from '../../components/pagination';
5
+ import MenuItem from '../../components/menuItem';
6
+ import Line from '../../components/line';
7
+ import { formatCount } from '../../components/formatNumber';
8
+ import { Center, Cluster, Stack } from '../../components/layout';
9
+ // A real app reads these from the server.
10
+ var questions = [
11
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
12
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
13
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
14
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
15
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
16
+ { id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
17
+ { id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
18
+ { id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
19
+ ];
20
+ var PER_PAGE = 4;
21
+ export default function PagedCardPager() {
22
+ var _a = useState(1), page = _a[0], setPage = _a[1];
23
+ var pageCount = Math.ceil(questions.length / PER_PAGE);
24
+ var rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
25
+ return (<Center width="page">
26
+ <Stack gap="medium">
27
+ <Line />
28
+ {/* The total is in the title, and the pager is in the title row, named for the card. */}
29
+ <Cluster justify="between">
30
+ <Heading level={2} size="h6">{"".concat(formatCount(questions.length), " ").concat(questions.length === 1 ? 'question' : 'questions', " waiting on you")}</Heading>
31
+ <Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage}/>
32
+ </Cluster>
33
+ <Stack gap="small">
34
+ {rows.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
35
+ // A real app lets the link go to the question's page. The example stays here.
36
+ event.preventDefault();
37
+ }}/>); })}
38
+ </Stack>
39
+ </Stack>
40
+ </Center>);
41
+ }
@@ -0,0 +1 @@
1
+ export default function PagedCardSeeAll(): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Link from '../../components/link';
4
+ import MenuItem from '../../components/menuItem';
5
+ import Line from '../../components/line';
6
+ import { formatCount } from '../../components/formatNumber';
7
+ import { Center, Cluster, Stack } from '../../components/layout';
8
+ // A real app reads these from the server: the newest five, and how many there are in all.
9
+ var total = 142;
10
+ var questions = [
11
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
12
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
13
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
14
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
15
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
16
+ ];
17
+ export default function PagedCardSeeAll() {
18
+ return (<Center width="page">
19
+ <Stack gap="medium">
20
+ <Line />
21
+ <Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
22
+ <Stack gap="small">
23
+ {questions.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
24
+ // A real app lets the link go to the question's page. The example stays here.
25
+ event.preventDefault();
26
+ }}/>); })}
27
+ </Stack>
28
+ {/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
29
+ <Cluster>
30
+ <Link href="#" size="body2">See All Questions</Link>
31
+ </Cluster>
32
+ </Stack>
33
+ </Center>);
34
+ }
@@ -0,0 +1,147 @@
1
+ # Short list on a dashboard
2
+
3
+ A dashboard section lists things that wait on the person, such as questions or comments, and the list may be longer than the section.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
8
+ - Say the total in the title, as a number and its unit: '8 questions waiting on you'.
9
+ - Make every row a link to the thing it names, with a second line for when it was asked.
10
+ - Put `Pagination variant="compact"` in the title row when the list pages, named for the card: 'Pages of questions waiting on you'.
11
+ - Keep the page length the same on every page. `Pagination` shows nothing when there is one page.
12
+ - Show five rows and a 'See All Questions' `Link` after them when the list does not page. The link goes to the full list, the case 'Data table page'.
13
+ - Show `EmptyBox size="small"` when the list is empty, such as 'No questions waiting on you', with a `secondText` that says what will appear.
14
+ - Show the card as a hairline, a title and rows. Do not box it.
15
+
16
+ ## Don't
17
+
18
+ - Do not page a long list on the dashboard. Show five rows and a link.
19
+ - Do not leave the pager unnamed. Name it for the card, so a screen reader hears 'Pages of questions waiting on you'.
20
+ - Do not write the page as '1/3'. `Pagination` writes '1 of 3' in a card and 'Page 1 of 3' elsewhere.
21
+ - Do not make a row that is not a link, or a link with no name.
22
+ - Do not scroll a list inside the card.
23
+
24
+ ## Option: Pager in the title row
25
+
26
+ Use when: The list is short and stays on the dashboard, a few rows a page.
27
+
28
+ Uses: `Center`, `Cluster`, `Heading`, `Line`, `MenuItem`, `Pagination`, `Stack`, `formatCount`
29
+
30
+ ```tsx
31
+ 'use client';
32
+ import { useState } from 'react';
33
+ import Heading from 'oneslash-design-system/components/heading';
34
+ import Pagination from 'oneslash-design-system/components/pagination';
35
+ import MenuItem from 'oneslash-design-system/components/menuItem';
36
+ import Line from 'oneslash-design-system/components/line';
37
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
38
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
39
+
40
+ // A real app reads these from the server.
41
+ const questions = [
42
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
43
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
44
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
45
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
46
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
47
+ { id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
48
+ { id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
49
+ { id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
50
+ ];
51
+
52
+ const PER_PAGE = 4;
53
+
54
+ export default function PagedCardPager() {
55
+ const [page, setPage] = useState(1);
56
+ const pageCount = Math.ceil(questions.length / PER_PAGE);
57
+ const rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
58
+
59
+ return (
60
+ <Center width="page">
61
+ <Stack gap="medium">
62
+ <Line />
63
+ {/* The total is in the title, and the pager is in the title row, named for the card. */}
64
+ <Cluster justify="between">
65
+ <Heading level={2} size="h6">{`${formatCount(questions.length)} ${questions.length === 1 ? 'question' : 'questions'} waiting on you`}</Heading>
66
+ <Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage} />
67
+ </Cluster>
68
+ <Stack gap="small">
69
+ {rows.map((q) => (
70
+ <MenuItem
71
+ key={q.id}
72
+ size="medium"
73
+ label={q.text}
74
+ secondLabel={q.when}
75
+ href={`/questions/${q.id}`}
76
+ onClick={(event: { preventDefault: () => void }) => {
77
+ // A real app lets the link go to the question's page. The example stays here.
78
+ event.preventDefault();
79
+ }}
80
+ />
81
+ ))}
82
+ </Stack>
83
+ </Stack>
84
+ </Center>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ## Option: Five rows and See All
90
+
91
+ Use when: The list is long, so the dashboard shows the newest five and a link to the full page.
92
+
93
+ Uses: `Center`, `Cluster`, `Heading`, `Line`, `Link`, `MenuItem`, `Stack`, `formatCount`
94
+
95
+ ```tsx
96
+ 'use client';
97
+ import Heading from 'oneslash-design-system/components/heading';
98
+ import Link from 'oneslash-design-system/components/link';
99
+ import MenuItem from 'oneslash-design-system/components/menuItem';
100
+ import Line from 'oneslash-design-system/components/line';
101
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
102
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
103
+
104
+ // A real app reads these from the server: the newest five, and how many there are in all.
105
+ const total = 142;
106
+ const questions = [
107
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
108
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
109
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
110
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
111
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
112
+ ];
113
+
114
+ export default function PagedCardSeeAll() {
115
+ return (
116
+ <Center width="page">
117
+ <Stack gap="medium">
118
+ <Line />
119
+ <Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
120
+ <Stack gap="small">
121
+ {questions.map((q) => (
122
+ <MenuItem
123
+ key={q.id}
124
+ size="medium"
125
+ label={q.text}
126
+ secondLabel={q.when}
127
+ href={`/questions/${q.id}`}
128
+ onClick={(event: { preventDefault: () => void }) => {
129
+ // A real app lets the link go to the question's page. The example stays here.
130
+ event.preventDefault();
131
+ }}
132
+ />
133
+ ))}
134
+ </Stack>
135
+ {/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
136
+ <Cluster>
137
+ <Link href="#" size="body2">See All Questions</Link>
138
+ </Cluster>
139
+ </Stack>
140
+ </Center>
141
+ );
142
+ }
143
+ ```
144
+
145
+ ## Native
146
+
147
+ On Apple use a `Section` of a `List` with a `NavigationLink` for each row, and a `NavigationLink` named See All for the footer. On Android use a `LazyColumn` of clickable rows.
@@ -0,0 +1 @@
1
+ export default function PaymentMethodNone(): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import Paragraph from '../../components/paragraph';
3
+ import Button from '../../components/button';
4
+ import SettingsSection from '../../components/settingsSection';
5
+ import { Center, Stack } from '../../components/layout';
6
+ export default function PaymentMethodNone() {
7
+ return (<Center width="page">
8
+ <SettingsSection title="Payment method" description="Pays for Acme's plan.">
9
+ <Stack gap="medium" align="start">
10
+ <Paragraph measure="none">No payment method.</Paragraph>
11
+ <Paragraph tone="secondary" size="body2" measure="none">Acme is on Free, so it needs none. Add one to upgrade.</Paragraph>
12
+ {/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
13
+ <Button size="small" type="secondary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>
14
+ </Stack>
15
+ </SettingsSection>
16
+ </Center>);
17
+ }
@@ -0,0 +1 @@
1
+ export default function PaymentMethodOnFile(): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Alert from '../../components/alert';
5
+ import Modal from '../../components/modal';
6
+ import Surface from '../../components/surface';
7
+ import Paragraph from '../../components/paragraph';
8
+ import Button from '../../components/button';
9
+ import SettingsSection from '../../components/settingsSection';
10
+ import { Center, Cluster, Stack } from '../../components/layout';
11
+ // A real app reads these from the server. Only the brand, the last four digits and the expiry ever reach the page.
12
+ var card = { brand: 'Visa', last4: '4821', month: 8, year: 2028 };
13
+ var today = { month: 11, year: 2026 };
14
+ var plan = 'Free';
15
+ // A paid plan needs a card, so Remove is not offered. The Free plan needs none.
16
+ var planNeedsCard = plan !== 'Free';
17
+ var monthsLeft = (card.year - today.year) * 12 + (card.month - today.month);
18
+ var expiry = "".concat(String(card.month).padStart(2, '0'), "/").concat(String(card.year % 100).padStart(2, '0'));
19
+ var name = "".concat(card.brand, " ending in ").concat(card.last4);
20
+ export default function PaymentMethodOnFile() {
21
+ var _a = useState(false), removed = _a[0], setRemoved = _a[1];
22
+ var _b = useState(false), confirming = _b[0], setConfirming = _b[1];
23
+ var _c = useState(false), removing = _c[0], setRemoving = _c[1];
24
+ var timer = useRef();
25
+ var toastIds = useRef([]);
26
+ var addRef = useRef(null);
27
+ // On unmount it stops the request and closes every toast it opened.
28
+ useEffect(function () { return function () {
29
+ clearTimeout(timer.current);
30
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
31
+ toastIds.current = [];
32
+ }; }, []);
33
+ // The Remove Button is gone with the card, so focus moves to what takes its place.
34
+ useEffect(function () {
35
+ var _a;
36
+ if (removed)
37
+ (_a = addRef.current) === null || _a === void 0 ? void 0 : _a.focus();
38
+ }, [removed]);
39
+ // Escape, a click outside and Cancel all close it, except while the request runs. The Modal gives focus back to Remove.
40
+ function handleClose() {
41
+ if (removing)
42
+ return;
43
+ setConfirming(false);
44
+ }
45
+ function handleRemove() {
46
+ if (removing)
47
+ return;
48
+ setRemoving(true);
49
+ // Stands in for the request to the server.
50
+ timer.current = setTimeout(function () {
51
+ setRemoving(false);
52
+ setConfirming(false);
53
+ setRemoved(true);
54
+ toastIds.current.push(toast({ type: 'success', message: "".concat(name, " removed.") }));
55
+ }, 1200);
56
+ }
57
+ return (<Center width="page">
58
+ {/* A real app mounts one Toaster near its root. */}
59
+ <Toaster />
60
+ <SettingsSection title="Payment method" description="Pays for Acme's plan.">
61
+ {removed ? (<Stack gap="medium" align="start">
62
+ <Paragraph measure="none">No payment method.</Paragraph>
63
+ {/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
64
+ <Button ref={addRef} size="small" type="secondary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>
65
+ </Stack>) : (<Stack gap="medium">
66
+ {/* A month ahead of the expiry, the page says so. */}
67
+ {monthsLeft <= 1 && monthsLeft >= 0 && (<Alert type="warning" variant="inline" autoDismiss={false} message={"This card expires on ".concat(expiry, ". Update it before then.")}/>)}
68
+ <Surface padding="small">
69
+ <Cluster justify="between" gap="medium">
70
+ <Stack gap="small">
71
+ <Paragraph measure="none">{name}</Paragraph>
72
+ <Paragraph tone="secondary" size="body2" measure="none">{"Expires ".concat(expiry)}</Paragraph>
73
+ </Stack>
74
+ <Cluster gap="small">
75
+ {/* Updating the card happens on the provider's page, so Update is a link out. */}
76
+ <Button size="small" type="tertiary" state="enabled" label="Update" aria-label={"Update ".concat(name, ", opens in a new tab")} actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>
77
+ {!planNeedsCard && (<Button size="small" type="tertiary" state="enabled" label="Remove" aria-label={"Remove ".concat(name)} onClickButton={function () { return setConfirming(true); }}/>)}
78
+ </Cluster>
79
+ </Cluster>
80
+ </Surface>
81
+ {planNeedsCard && <Paragraph tone="secondary" size="body2" measure="none">Pro needs a card on file. Downgrade to Free to remove it.</Paragraph>}
82
+ </Stack>)}
83
+ </SettingsSection>
84
+ {/* One card is not a dense list, so the confirm is a small Modal. */}
85
+ <Modal isOpen={confirming} size="small" title="Remove Card" onClose={handleClose} actions={<>
86
+ <Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
87
+ <Button size="small" type="primary" color="danger" state="enabled" label="Remove" loading={removing} onClickButton={handleRemove}/>
88
+ </>}>
89
+ <Paragraph measure="none">{"This removes ".concat(name, " from Acme. Your plan and invoices are not changed.")}</Paragraph>
90
+ </Modal>
91
+ </Center>);
92
+ }