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,507 @@
1
+ # Dashboard
2
+
3
+ A page that opens an app and says how things are going and what waits on the person.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
8
+ - Put the page in `AppShell`, with a `TitleBar` named 'Dashboard' and a 'Range' `SegmentedControl` as its `actions`, as the case 'Range switch' says. Set `actionsBelow` so the switch takes its own line under the title on a phone.
9
+ - Let the one range drive every number on the page, and name it in every heading and caption: 'this week'.
10
+ - Show the stat row as the case 'Stat row' says, and a share of a total as the case 'Breakdown of a total' says.
11
+ - Make each section a `SettingsSection`: a hairline, a title and its content. Do not put a section in a box.
12
+ - Put the list of what waits on the person in a section titled with its count and unit: '3 comments waiting on you'. Make each row a link.
13
+ - Show a list that can be longer than its section as the case 'Short list on a dashboard' says.
14
+ - Show `EmptyBox size="small"` in a section with nothing, as the rule 'An empty list says what will fill it' says: 'No questions from your agents this week'. Keep the section.
15
+ - Show a failed section as the case 'Load failure' says, inline with 'Try Again', and keep the rest of the page.
16
+ - Show a `Skeleton` or the tile's own loading state while the range changes. Do not show 0.
17
+
18
+ ## Don't
19
+
20
+ - Do not draw a chart. A trend is the change line on a tile, and a share is a ranked list.
21
+ - Do not count different sections over different ranges.
22
+ - Do not replace the whole page when one section failed.
23
+ - Do not put more than four tiles in the stat row.
24
+ - Do not hide a section that has nothing, or leave it blank.
25
+ - Do not box the sections in cards.
26
+
27
+ ## Option: Numbers first
28
+
29
+ Use when: The page reports how things went, for a lead who checks on a team.
30
+
31
+ Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
32
+
33
+ ```tsx
34
+ 'use client';
35
+ import { useEffect, useRef, useState } from 'react';
36
+ import AppShell from 'oneslash-design-system/components/appShell';
37
+ import TitleBar from 'oneslash-design-system/components/titleBar';
38
+ import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
39
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
40
+ import Navigation from 'oneslash-design-system/components/navigation';
41
+ import MenuItem from 'oneslash-design-system/components/menuItem';
42
+ import StatTile from 'oneslash-design-system/components/statTile';
43
+ import Progress from 'oneslash-design-system/components/progress';
44
+ import Skeleton from 'oneslash-design-system/components/skeleton';
45
+ import Alert from 'oneslash-design-system/components/alert';
46
+ import Button from 'oneslash-design-system/components/button';
47
+ import Paragraph from 'oneslash-design-system/components/paragraph';
48
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
49
+ import List from 'oneslash-design-system/components/list';
50
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
51
+ import { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
52
+
53
+ type Range = 'week' | 'month' | 'quarter';
54
+ const ranges = [
55
+ { value: 'week', label: 'Week' },
56
+ { value: 'month', label: 'Month' },
57
+ { value: 'quarter', label: 'Quarter' },
58
+ ];
59
+
60
+ // A real app counts these on the server. One range drives every number on the page.
61
+ const data = {
62
+ week: {
63
+ stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },
64
+ projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],
65
+ waiting: [
66
+ ['Ben Carter asked for the new screens', '/comments/1'],
67
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
68
+ ['Review the pricing copy', '/comments/3'],
69
+ ],
70
+ questions: [],
71
+ },
72
+ month: {
73
+ stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },
74
+ projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],
75
+ waiting: [
76
+ ['Ben Carter asked for the new screens', '/comments/1'],
77
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
78
+ ['Review the pricing copy', '/comments/3'],
79
+ ['Confirm the release date', '/comments/4'],
80
+ ['Approve the new onboarding text', '/comments/5'],
81
+ ],
82
+ questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],
83
+ },
84
+ quarter: {
85
+ stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },
86
+ projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],
87
+ waiting: [
88
+ ['Ben Carter asked for the new screens', '/comments/1'],
89
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
90
+ ['Review the pricing copy', '/comments/3'],
91
+ ['Confirm the release date', '/comments/4'],
92
+ ],
93
+ questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],
94
+ },
95
+ } as const;
96
+
97
+ const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
98
+
99
+ export default function DashboardNumbersFirst() {
100
+ const [range, setRange] = useState<Range>('week');
101
+ // The numbers load again when the range changes.
102
+ const [loading, setLoading] = useState(false);
103
+ // The projects section fails first, so the rest of the page shows that one section can fail alone.
104
+ const [projectsFailed, setProjectsFailed] = useState(true);
105
+ const [retrying, setRetrying] = useState(false);
106
+ const [navOpen, setNavOpen] = useState(false);
107
+ const timer = useRef<ReturnType<typeof setTimeout>>();
108
+ const retryTimer = useRef<ReturnType<typeof setTimeout>>();
109
+
110
+ // Stops the requests if the example goes away before they end.
111
+ useEffect(() => () => {
112
+ clearTimeout(timer.current);
113
+ clearTimeout(retryTimer.current);
114
+ }, []);
115
+
116
+ function changeRange(next: string) {
117
+ clearTimeout(timer.current);
118
+ setRange(next as Range);
119
+ setLoading(true);
120
+ // Stands in for the request to the server.
121
+ timer.current = setTimeout(() => setLoading(false), 600);
122
+ }
123
+
124
+ function tryAgain() {
125
+ if (retrying) return;
126
+ setRetrying(true);
127
+ retryTimer.current = setTimeout(() => {
128
+ setRetrying(false);
129
+ setProjectsFailed(false);
130
+ }, 1200);
131
+ }
132
+
133
+ const d = data[range];
134
+ const period = range;
135
+ const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);
136
+ const waitingCount: number = d.waiting.length;
137
+
138
+ const sidebar = (
139
+ <Navigation aria-label="Main">
140
+ <Paragraph size="body1" measure="none">Acme</Paragraph>
141
+ {[
142
+ ['Dashboard', 'LayoutDashboard', '/dashboard'],
143
+ ['Comments', 'MessageSquare', '/comments'],
144
+ ['Projects', 'FolderKanban', '/projects'],
145
+ ].map(([label, icon, href]) => (
146
+ <MenuItem
147
+ key={href}
148
+ size="small"
149
+ label={label}
150
+ iconName={icon}
151
+ href={href}
152
+ isSelected={href === '/dashboard'}
153
+ aria-current={href === '/dashboard' ? 'page' : undefined}
154
+ onClick={(event: { preventDefault: () => void }) => {
155
+ // A real app lets the link go to its page. The example stays here.
156
+ event.preventDefault();
157
+ }}
158
+ />
159
+ ))}
160
+ </Navigation>
161
+ );
162
+
163
+ const statRow = (
164
+ <SettingsSection key="stats" title={`Numbers ${noun[range]}`} id="dashboard-stats">
165
+ <Grid compact columns={4}>
166
+ <StatTile label="New comments" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />
167
+ <StatTile label="Marked done" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />
168
+ <StatTile label="People engaged" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />
169
+ <StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading} />
170
+ </Grid>
171
+ </SettingsSection>
172
+ );
173
+
174
+ const projects = (
175
+ <SettingsSection key="projects" title="Projects" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id="dashboard-projects">
176
+ {projectsFailed ? (
177
+ <>
178
+ {/* Only this section failed. The rest of the page still shows. */}
179
+ <Alert type="error" variant="inline" message="Could not load projects." autoDismiss={false} />
180
+ <Cluster>
181
+ <Button size="small" type="primary" state="enabled" label="Try Again" loading={retrying} onClickButton={tryAgain} />
182
+ </Cluster>
183
+ </>
184
+ ) : loading ? (
185
+ <Skeleton variant="text" lines={3} label="Loading projects" />
186
+ ) : (
187
+ <List
188
+ size="body2"
189
+ items={d.projects.map(([name, count]) => (
190
+ <Progress key={name} kind="share" label={name} value={count} max={projectTotal} unit="comments" />
191
+ ))}
192
+ />
193
+ )}
194
+ </SettingsSection>
195
+ );
196
+
197
+ const waiting = (
198
+ <SettingsSection key="waiting" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id="dashboard-waiting">
199
+ {loading ? (
200
+ <Skeleton variant="text" lines={3} label="Loading what waits on you" />
201
+ ) : (
202
+ <Stack gap="small">
203
+ {d.waiting.map(([text, href]) => (
204
+ <MenuItem
205
+ key={href}
206
+ size="medium"
207
+ label={text}
208
+ href={href}
209
+ onClick={(event: { preventDefault: () => void }) => {
210
+ // A real app lets the link go to its page. The example stays here.
211
+ event.preventDefault();
212
+ }}
213
+ />
214
+ ))}
215
+ </Stack>
216
+ )}
217
+ </SettingsSection>
218
+ );
219
+
220
+ const questions = (
221
+ <SettingsSection key="questions" title="Questions from your agents" id="dashboard-questions">
222
+ {loading ? (
223
+ <Skeleton variant="text" lines={2} label="Loading questions" />
224
+ ) : d.questions.length === 0 ? (
225
+ // A section with nothing keeps its place and says what will fill it.
226
+ <EmptyBox size="small" text={`No questions from your agents ${noun[range]}`} secondText="Questions your agents ask you appear here." />
227
+ ) : (
228
+ <Stack gap="small">
229
+ {d.questions.map(([text, href]) => (
230
+ <MenuItem
231
+ key={href}
232
+ size="medium"
233
+ label={text}
234
+ href={href}
235
+ onClick={(event: { preventDefault: () => void }) => {
236
+ // A real app lets the link go to its page. The example stays here.
237
+ event.preventDefault();
238
+ }}
239
+ />
240
+ ))}
241
+ </Stack>
242
+ )}
243
+ </SettingsSection>
244
+ );
245
+
246
+ return (
247
+ <AppShell title="Dashboard" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
248
+ <Stack gap="xlarge">
249
+ {/* One range drives every number below, and each heading says which one. */}
250
+ {/* Below md the range switch takes its own line under the title. */}
251
+ <TitleBar
252
+ title="Dashboard"
253
+ actionsBelow
254
+ actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
255
+ />
256
+ {statRow}
257
+ {projects}
258
+ {waiting}
259
+ {questions}
260
+ </Stack>
261
+ </AppShell>
262
+ );
263
+ }
264
+ ```
265
+
266
+ ## Option: Work first
267
+
268
+ Use when: The person starts their day here, so what waits on them comes before the numbers.
269
+
270
+ Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
271
+
272
+ ```tsx
273
+ 'use client';
274
+ import { useEffect, useRef, useState } from 'react';
275
+ import AppShell from 'oneslash-design-system/components/appShell';
276
+ import TitleBar from 'oneslash-design-system/components/titleBar';
277
+ import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
278
+ import SettingsSection from 'oneslash-design-system/components/settingsSection';
279
+ import Navigation from 'oneslash-design-system/components/navigation';
280
+ import MenuItem from 'oneslash-design-system/components/menuItem';
281
+ import StatTile from 'oneslash-design-system/components/statTile';
282
+ import Progress from 'oneslash-design-system/components/progress';
283
+ import Skeleton from 'oneslash-design-system/components/skeleton';
284
+ import Alert from 'oneslash-design-system/components/alert';
285
+ import Button from 'oneslash-design-system/components/button';
286
+ import Paragraph from 'oneslash-design-system/components/paragraph';
287
+ import EmptyBox from 'oneslash-design-system/components/emptyBox';
288
+ import List from 'oneslash-design-system/components/list';
289
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
290
+ import { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
291
+
292
+ type Range = 'week' | 'month' | 'quarter';
293
+ const ranges = [
294
+ { value: 'week', label: 'Week' },
295
+ { value: 'month', label: 'Month' },
296
+ { value: 'quarter', label: 'Quarter' },
297
+ ];
298
+
299
+ // A real app counts these on the server. One range drives every number on the page.
300
+ const data = {
301
+ week: {
302
+ stats: { comments: [1240, 1106], done: [312, 280], people: [18, 18], reply: [8_640_000, 9_200_000] },
303
+ projects: [['Website', 540], ['Mobile App', 380], ['Docs', 320]],
304
+ waiting: [
305
+ ['Ben Carter asked for the new screens', '/comments/1'],
306
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
307
+ ['Review the pricing copy', '/comments/3'],
308
+ ],
309
+ questions: [],
310
+ },
311
+ month: {
312
+ stats: { comments: [4820, 5210], done: [1190, 1004], people: [31, 27], reply: [7_800_000, 8_100_000] },
313
+ projects: [['Website', 2010], ['Mobile App', 1500], ['Docs', 910], ['Help Center', 400]],
314
+ waiting: [
315
+ ['Ben Carter asked for the new screens', '/comments/1'],
316
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
317
+ ['Review the pricing copy', '/comments/3'],
318
+ ['Confirm the release date', '/comments/4'],
319
+ ['Approve the new onboarding text', '/comments/5'],
320
+ ],
321
+ questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2']],
322
+ },
323
+ quarter: {
324
+ stats: { comments: [15_880, 12_410], done: [3950, 3210], people: [44, 36], reply: [7_200_000, 7_900_000] },
325
+ projects: [['Website', 6100], ['Mobile App', 4800], ['Docs', 3100], ['Help Center', 1880]],
326
+ waiting: [
327
+ ['Ben Carter asked for the new screens', '/comments/1'],
328
+ ['Omar Reyes mentioned you in Launch plan', '/comments/2'],
329
+ ['Review the pricing copy', '/comments/3'],
330
+ ['Confirm the release date', '/comments/4'],
331
+ ],
332
+ questions: [['Is the new pricing public before Friday?', '/questions/1'], ['Who approves the final copy?', '/questions/2'], ['Which logo should the launch page use?', '/questions/3']],
333
+ },
334
+ } as const;
335
+
336
+ const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
337
+
338
+ export default function DashboardWorkFirst() {
339
+ const [range, setRange] = useState<Range>('week');
340
+ // The numbers load again when the range changes.
341
+ const [loading, setLoading] = useState(false);
342
+ // The projects section fails first, so the rest of the page shows that one section can fail alone.
343
+ const [projectsFailed, setProjectsFailed] = useState(true);
344
+ const [retrying, setRetrying] = useState(false);
345
+ const [navOpen, setNavOpen] = useState(false);
346
+ const timer = useRef<ReturnType<typeof setTimeout>>();
347
+ const retryTimer = useRef<ReturnType<typeof setTimeout>>();
348
+
349
+ // Stops the requests if the example goes away before they end.
350
+ useEffect(() => () => {
351
+ clearTimeout(timer.current);
352
+ clearTimeout(retryTimer.current);
353
+ }, []);
354
+
355
+ function changeRange(next: string) {
356
+ clearTimeout(timer.current);
357
+ setRange(next as Range);
358
+ setLoading(true);
359
+ // Stands in for the request to the server.
360
+ timer.current = setTimeout(() => setLoading(false), 600);
361
+ }
362
+
363
+ function tryAgain() {
364
+ if (retrying) return;
365
+ setRetrying(true);
366
+ retryTimer.current = setTimeout(() => {
367
+ setRetrying(false);
368
+ setProjectsFailed(false);
369
+ }, 1200);
370
+ }
371
+
372
+ const d = data[range];
373
+ const period = range;
374
+ const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);
375
+ const waitingCount: number = d.waiting.length;
376
+
377
+ const sidebar = (
378
+ <Navigation aria-label="Main">
379
+ <Paragraph size="body1" measure="none">Acme</Paragraph>
380
+ {[
381
+ ['Dashboard', 'LayoutDashboard', '/dashboard'],
382
+ ['Comments', 'MessageSquare', '/comments'],
383
+ ['Projects', 'FolderKanban', '/projects'],
384
+ ].map(([label, icon, href]) => (
385
+ <MenuItem
386
+ key={href}
387
+ size="small"
388
+ label={label}
389
+ iconName={icon}
390
+ href={href}
391
+ isSelected={href === '/dashboard'}
392
+ aria-current={href === '/dashboard' ? 'page' : undefined}
393
+ onClick={(event: { preventDefault: () => void }) => {
394
+ // A real app lets the link go to its page. The example stays here.
395
+ event.preventDefault();
396
+ }}
397
+ />
398
+ ))}
399
+ </Navigation>
400
+ );
401
+
402
+ const statRow = (
403
+ <SettingsSection key="stats" title={`Numbers ${noun[range]}`} id="dashboard-stats">
404
+ <Grid compact columns={4}>
405
+ <StatTile label="New comments" value={d.stats.comments[0]} previous={d.stats.comments[1]} period={period} loading={loading} />
406
+ <StatTile label="Marked done" value={d.stats.done[0]} previous={d.stats.done[1]} period={period} loading={loading} />
407
+ <StatTile label="People engaged" value={d.stats.people[0]} previous={d.stats.people[1]} period={period} loading={loading} />
408
+ <StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading} />
409
+ </Grid>
410
+ </SettingsSection>
411
+ );
412
+
413
+ const projects = (
414
+ <SettingsSection key="projects" title="Projects" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id="dashboard-projects">
415
+ {projectsFailed ? (
416
+ <>
417
+ {/* Only this section failed. The rest of the page still shows. */}
418
+ <Alert type="error" variant="inline" message="Could not load projects." autoDismiss={false} />
419
+ <Cluster>
420
+ <Button size="small" type="primary" state="enabled" label="Try Again" loading={retrying} onClickButton={tryAgain} />
421
+ </Cluster>
422
+ </>
423
+ ) : loading ? (
424
+ <Skeleton variant="text" lines={3} label="Loading projects" />
425
+ ) : (
426
+ <List
427
+ size="body2"
428
+ items={d.projects.map(([name, count]) => (
429
+ <Progress key={name} kind="share" label={name} value={count} max={projectTotal} unit="comments" />
430
+ ))}
431
+ />
432
+ )}
433
+ </SettingsSection>
434
+ );
435
+
436
+ const waiting = (
437
+ <SettingsSection key="waiting" title={loading ? 'Waiting on you' : `${formatCount(waitingCount)} ${waitingCount === 1 ? 'comment' : 'comments'} waiting on you`} description={`Asked of you ${noun[range]}`} id="dashboard-waiting">
438
+ {loading ? (
439
+ <Skeleton variant="text" lines={3} label="Loading what waits on you" />
440
+ ) : (
441
+ <Stack gap="small">
442
+ {d.waiting.map(([text, href]) => (
443
+ <MenuItem
444
+ key={href}
445
+ size="medium"
446
+ label={text}
447
+ href={href}
448
+ onClick={(event: { preventDefault: () => void }) => {
449
+ // A real app lets the link go to its page. The example stays here.
450
+ event.preventDefault();
451
+ }}
452
+ />
453
+ ))}
454
+ </Stack>
455
+ )}
456
+ </SettingsSection>
457
+ );
458
+
459
+ const questions = (
460
+ <SettingsSection key="questions" title="Questions from your agents" id="dashboard-questions">
461
+ {loading ? (
462
+ <Skeleton variant="text" lines={2} label="Loading questions" />
463
+ ) : d.questions.length === 0 ? (
464
+ // A section with nothing keeps its place and says what will fill it.
465
+ <EmptyBox size="small" text={`No questions from your agents ${noun[range]}`} secondText="Questions your agents ask you appear here." />
466
+ ) : (
467
+ <Stack gap="small">
468
+ {d.questions.map(([text, href]) => (
469
+ <MenuItem
470
+ key={href}
471
+ size="medium"
472
+ label={text}
473
+ href={href}
474
+ onClick={(event: { preventDefault: () => void }) => {
475
+ // A real app lets the link go to its page. The example stays here.
476
+ event.preventDefault();
477
+ }}
478
+ />
479
+ ))}
480
+ </Stack>
481
+ )}
482
+ </SettingsSection>
483
+ );
484
+
485
+ return (
486
+ <AppShell title="Dashboard" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
487
+ <Stack gap="xlarge">
488
+ {/* One range drives every number below, and each heading says which one. */}
489
+ {/* Below md the range switch takes its own line under the title. */}
490
+ <TitleBar
491
+ title="Dashboard"
492
+ actionsBelow
493
+ actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
494
+ />
495
+ {waiting}
496
+ {questions}
497
+ {statRow}
498
+ {projects}
499
+ </Stack>
500
+ </AppShell>
501
+ );
502
+ }
503
+ ```
504
+
505
+ ## Native
506
+
507
+ On Apple use a `List` of `Section`s in a `NavigationStack`, with a `Picker` in the `.segmented` style in the toolbar. On Android use a `LazyColumn` with a `SingleChoiceSegmentedButtonRow` in the top bar.
@@ -0,0 +1 @@
1
+ export default function DataTablePageAllRows(): import("react").JSX.Element;