oneslash-design-system 2.23.1 → 2.24.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 (78) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +13 -2
  3. package/dist/cases/activity-timeline/activity.d.ts +1 -0
  4. package/dist/cases/activity-timeline/activity.jsx +43 -0
  5. package/dist/cases/activity-timeline/versions.d.ts +1 -0
  6. package/dist/cases/activity-timeline/versions.jsx +130 -0
  7. package/dist/cases/activity-timeline.md +315 -0
  8. package/dist/cases/agent-plan-proposal.md +1 -0
  9. package/dist/cases/ask-page/answered.d.ts +1 -0
  10. package/dist/cases/ask-page/answered.jsx +240 -0
  11. package/dist/cases/ask-page/first-visit.d.ts +1 -0
  12. package/dist/cases/ask-page/first-visit.jsx +118 -0
  13. package/dist/cases/ask-page.md +542 -0
  14. package/dist/cases/chart/bars.d.ts +1 -0
  15. package/dist/cases/chart/bars.jsx +83 -0
  16. package/dist/cases/chart/lines.d.ts +1 -0
  17. package/dist/cases/chart/lines.jsx +71 -0
  18. package/dist/cases/chart.md +258 -0
  19. package/dist/cases/comment-thread/card.d.ts +1 -0
  20. package/dist/cases/comment-thread/card.jsx +141 -0
  21. package/dist/cases/comment-thread/thread.d.ts +1 -0
  22. package/dist/cases/comment-thread/thread.jsx +87 -0
  23. package/dist/cases/comment-thread.md +349 -0
  24. package/dist/cases/dashboard/numbers-first.jsx +62 -1
  25. package/dist/cases/dashboard.md +75 -3
  26. package/dist/cases/leaderboard/ranked.d.ts +1 -0
  27. package/dist/cases/leaderboard/ranked.jsx +44 -0
  28. package/dist/cases/leaderboard/table.d.ts +1 -0
  29. package/dist/cases/leaderboard/table.jsx +87 -0
  30. package/dist/cases/leaderboard.md +177 -0
  31. package/dist/cases/number-format.md +4 -2
  32. package/dist/cases/onboarding/checklist.d.ts +1 -0
  33. package/dist/cases/onboarding/checklist.jsx +92 -0
  34. package/dist/cases/onboarding/steps.d.ts +3 -0
  35. package/dist/cases/onboarding/steps.jsx +177 -0
  36. package/dist/cases/onboarding.md +368 -0
  37. package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
  38. package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
  39. package/dist/cases/plan-sign-off/team.d.ts +1 -0
  40. package/dist/cases/plan-sign-off/team.jsx +213 -0
  41. package/dist/cases/plan-sign-off.md +541 -0
  42. package/dist/cases/stat-row.md +1 -1
  43. package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
  44. package/dist/cases/task-header/agent-sets-status.jsx +164 -0
  45. package/dist/cases/task-header/people-change-status.d.ts +1 -0
  46. package/dist/cases/task-header/people-change-status.jsx +175 -0
  47. package/dist/cases/task-header.md +576 -0
  48. package/dist/cases.json +645 -7
  49. package/dist/components/barChart.d.ts +35 -0
  50. package/dist/components/barChart.jsx +90 -0
  51. package/dist/components/heading.d.ts +2 -2
  52. package/dist/components/heading.jsx +5 -3
  53. package/dist/components/lineChart.d.ts +39 -0
  54. package/dist/components/lineChart.jsx +128 -0
  55. package/dist/components/timeline.d.ts +32 -0
  56. package/dist/components/timeline.jsx +54 -0
  57. package/dist/components/titleBar.d.ts +3 -1
  58. package/dist/components/titleBar.jsx +9 -4
  59. package/dist/internal/chart.d.ts +39 -0
  60. package/dist/internal/chart.js +110 -0
  61. package/dist/internal/chartFrame.d.ts +29 -0
  62. package/dist/internal/chartFrame.jsx +57 -0
  63. package/dist/native-mapping.json +19 -1
  64. package/dist/stories/BarChart.stories.d.ts +10 -0
  65. package/dist/stories/BarChart.stories.jsx +104 -0
  66. package/dist/stories/Cases.generated.stories.d.ts +16 -0
  67. package/dist/stories/Cases.generated.stories.jsx +32 -0
  68. package/dist/stories/Heading.stories.d.ts +1 -0
  69. package/dist/stories/Heading.stories.jsx +17 -0
  70. package/dist/stories/LineChart.stories.d.ts +9 -0
  71. package/dist/stories/LineChart.stories.jsx +34 -0
  72. package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
  73. package/dist/stories/Onboarding.probe.stories.jsx +12 -0
  74. package/dist/stories/Timeline.stories.d.ts +8 -0
  75. package/dist/stories/Timeline.stories.jsx +49 -0
  76. package/dist/stories/TitleBar.stories.d.ts +1 -0
  77. package/dist/stories/TitleBar.stories.jsx +13 -0
  78. package/package.json +1 -1
@@ -0,0 +1,349 @@
1
+ # Comment and thread
2
+
3
+ A person reads comments left on a piece of work, opens one, and reads and answers its thread.
4
+
5
+ ## Do
6
+
7
+ - Follow the cases 'Message row' and 'Message composer'.
8
+ - Show each comment as a `Message`: the face, the name, then the time and any state in `meta`, such as a text `Tag` 'Done'.
9
+ - Write a card's date and time in full, such as 'Nov 16, 2026, 2:40 PM', since a list of cards spans days.
10
+ - Say where the comment is, in a secondary line under the text: 'Homepage design, frame Hero'.
11
+ - Cut a long comment to about three lines in the text you pass, and show it in full in the thread.
12
+ - Open the thread from a link in the card, named for whose it is: 'Open thread from Ben Carter'. Say how many replies it has beside it.
13
+ - Put the card's actions in a More menu, as the case 'Message actions' says: `<Popover returnFocus>` around `<Menu navigable aria-label="Comment actions">`. The More button is in the tab order, so a keyboard always reaches it.
14
+ - Mark an unread comment with a dot `Tag` 'Unread' in `info`, as the case 'Admin inbox' does, and say it in the row's `aria-label`: 'Unread comment from Ben Carter'.
15
+ - Title the open thread with `TitleBar level={2}` 'Thread' under the page's level 1 heading. On a phone, where it takes the screen, pass `back` 'Back to Comments'.
16
+ - Give the thread a secondary 'Mark Done'. Once done it reads 'Reopen', and a text `Tag` 'Done' shows in the `meta` line.
17
+ - Announce the change politely: the app says 'Marked done.' or 'Reopened.' in a polite live region, since a screen reader may not read a Button's new name while it has focus. Do the same when the change comes from the card's menu. Show no toast, since the change is in view.
18
+ - Show the first comment in full, then the replies in order. Make a reply `compact` when the reply above is from the same person, as the case 'Message row' says.
19
+ - Put a `Composer` under the replies, named for who reads it: 'Reply to Ben Carter'. Add the reply to the thread at once and empty the box.
20
+
21
+ ## Don't
22
+
23
+ - Do not show the actions on pointer hover only. A keyboard and a touch screen must reach them too.
24
+ - Do not make the whole card one clickable box. Its link opens the thread, and its buttons stay their own.
25
+ - Do not mark unread with bold text alone. Show the word.
26
+ - Do not leave out where the comment is. A comment about a frame means little without it.
27
+ - Do not group replies from two people into one row.
28
+
29
+ ## Option: Comment cards
30
+
31
+ Use when: Comments show in a list or a feed, and each one opens its thread.
32
+
33
+ Uses: `Alert`, `Center`, `Cluster`, `Heading`, `IconButton`, `Link`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Popover`, `Stack`, `Tag`, `Tooltip`, `UserImage`
34
+
35
+ ```tsx
36
+ 'use client';
37
+ import { useState } from 'react';
38
+ import Message from 'oneslash-design-system/components/message';
39
+ import UserImage from 'oneslash-design-system/components/userImage';
40
+ import Tag from 'oneslash-design-system/components/tag';
41
+ import Heading from 'oneslash-design-system/components/heading';
42
+ import Paragraph from 'oneslash-design-system/components/paragraph';
43
+ import Link from 'oneslash-design-system/components/link';
44
+ import IconButton from 'oneslash-design-system/components/iconButton';
45
+ import Tooltip from 'oneslash-design-system/components/tooltip';
46
+ import Popover from 'oneslash-design-system/components/popover';
47
+ import Alert from 'oneslash-design-system/components/alert';
48
+ import Menu from 'oneslash-design-system/components/menu';
49
+ import MenuItem from 'oneslash-design-system/components/menuItem';
50
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
51
+
52
+ type Comment = {
53
+ id: string;
54
+ from: string;
55
+ when: string;
56
+ text: string;
57
+ place: string;
58
+ replies: number;
59
+ unread?: boolean;
60
+ done?: boolean;
61
+ saved?: boolean;
62
+ reacted?: boolean;
63
+ };
64
+
65
+ const firstComments: Comment[] = [
66
+ {
67
+ id: 'c1',
68
+ from: 'Ben Carter',
69
+ when: 'Nov 16, 2026, 2:40 PM',
70
+ text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',
71
+ place: 'Homepage design, frame Hero',
72
+ replies: 2,
73
+ unread: true,
74
+ },
75
+ {
76
+ id: 'c2',
77
+ from: 'Omar Reyes',
78
+ when: 'Nov 16, 2026, 11:15 AM',
79
+ text: 'The Team plan should read $25 per seat, not $25.',
80
+ place: 'Homepage design, frame Pricing',
81
+ replies: 1,
82
+ done: true,
83
+ },
84
+ {
85
+ id: 'c3',
86
+ from: 'Mia Park',
87
+ when: 'Nov 15, 2026, 4:30 PM',
88
+ text: 'The footer links need more room between them on a phone.',
89
+ place: 'Homepage design, frame Footer',
90
+ replies: 0,
91
+ },
92
+ ];
93
+
94
+ // The card shows about three lines. The caller cuts the text at a word, and the thread shows it in full.
95
+ function excerpt(text: string, max = 160) {
96
+ if (text.length <= max) return text;
97
+ return `${text.slice(0, text.lastIndexOf(' ', max))}…`;
98
+ }
99
+
100
+ function repliesLine(n: number) {
101
+ if (n === 0) return 'No replies yet';
102
+ return `${n} ${n === 1 ? 'reply' : 'replies'}`;
103
+ }
104
+
105
+ export default function CommentThreadCard() {
106
+ const [comments, setComments] = useState(firstComments);
107
+ // The comment whose menu is open, and the More button it opens from. Both stay set while the menu fades out.
108
+ const [menuId, setMenuId] = useState<string | null>(null);
109
+ const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null);
110
+ const [menuOpen, setMenuOpen] = useState(false);
111
+ // What the polite line says after Mark Done or Reopen. The count gives each change a fresh line, so it is read again.
112
+ const [said, setSaid] = useState<{ text: string; n: number } | null>(null);
113
+
114
+ const menuComment = comments.find((c) => c.id === menuId);
115
+
116
+ function openMenu(c: Comment, anchor: HTMLElement) {
117
+ if (menuOpen && menuId === c.id) {
118
+ setMenuOpen(false);
119
+ return;
120
+ }
121
+ setMenuId(c.id);
122
+ setMenuAnchor(anchor);
123
+ setMenuOpen(true);
124
+ }
125
+
126
+ // Every item closes the menu, and the Popover gives focus back to More. The change shows on the card.
127
+ function choose(change: (c: Comment) => Partial<Comment>) {
128
+ const id = menuId;
129
+ setMenuOpen(false);
130
+ // A real app sends the change to the server here.
131
+ setComments((list) => list.map((c) => (c.id === id ? { ...c, ...change(c) } : c)));
132
+ }
133
+
134
+ // Focus goes back to More, whose name does not change, so the polite line says what happened.
135
+ function toggleDone() {
136
+ const wasDone = !!menuComment?.done;
137
+ choose((c) => ({ done: !c.done }));
138
+ setSaid((s) => ({ text: wasDone ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));
139
+ }
140
+
141
+ return (
142
+ <Center width="page">
143
+ <Stack gap="large">
144
+ <Heading level={1} size="h5">Comments</Heading>
145
+ {said && (
146
+ // An inline Alert is a polite status. It leaves after 5 seconds; the card's Tag still shows the state.
147
+ <Alert key={said.n} variant="inline" type="success" message={said.text} onClose={() => setSaid(null)} />
148
+ )}
149
+ {/* A real app gives the list that holds the cards role="feed". */}
150
+ <Stack gap="medium">
151
+ {comments.map((c) => (
152
+ <Message
153
+ key={c.id}
154
+ aria-label={c.unread ? `Unread comment from ${c.from}` : `Comment from ${c.from}`}
155
+ avatar={<UserImage userHandle={c.from} decorative />}
156
+ name={c.from}
157
+ meta={
158
+ <>
159
+ {/* Cards span days, so each says its date and time in full, written by the app. */}
160
+ <Paragraph size="caption" tone="secondary" measure="none">{c.when}</Paragraph>
161
+ {c.unread && <Tag variant="dot" size="small" color="info" label="Unread" />}
162
+ {c.done && <Tag variant="textOnly" size="small" label="Done" />}
163
+ {c.saved && <Tag variant="textOnly" size="small" label="Saved" />}
164
+ </>
165
+ }
166
+ footer={
167
+ <Stack gap="small">
168
+ <Paragraph size="body2" tone="secondary" measure="none">{c.place}</Paragraph>
169
+ {c.reacted && (
170
+ <Cluster>
171
+ <Tag variant="contained" size="small" state="selected" label="👍 1" aria-label="Thumbs up, 1 reaction" />
172
+ </Cluster>
173
+ )}
174
+ {/* The link opens the thread. The card itself is not a button. */}
175
+ <Cluster gap="small">
176
+ <Link href={`/comments/${c.id}`} size="body2">Open thread from {c.from}</Link>
177
+ <Paragraph size="body2" tone="secondary" measure="none">{repliesLine(c.replies)}</Paragraph>
178
+ </Cluster>
179
+ </Stack>
180
+ }
181
+ // One More button, in the tab order. It stays on screen while its menu is open.
182
+ actionsVisible={menuOpen && menuId === c.id}
183
+ actions={
184
+ <Tooltip title="More">
185
+ <IconButton
186
+ color="iconOnly"
187
+ state={menuOpen && menuId === c.id ? 'selected' : 'enabled'}
188
+ size="small"
189
+ iconName="Ellipsis"
190
+ ariaLabel={`More actions for comment from ${c.from}`}
191
+ aria-haspopup="menu"
192
+ aria-expanded={menuOpen && menuId === c.id}
193
+ onClick={(e: { currentTarget: HTMLElement }) => openMenu(c, e.currentTarget)}
194
+ />
195
+ </Tooltip>
196
+ }
197
+ >
198
+ <Paragraph measure="none">{excerpt(c.text)}</Paragraph>
199
+ </Message>
200
+ ))}
201
+ </Stack>
202
+ </Stack>
203
+ {/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}
204
+ <Popover open={menuOpen} anchorEl={menuAnchor} onClose={() => setMenuOpen(false)} returnFocus>
205
+ <Menu navigable aria-label="Comment actions" width={200}>
206
+ <MenuItem size="small" iconName="SmilePlus" label={menuComment?.reacted ? 'Remove Reaction' : 'Add Reaction'} onClick={() => choose((c) => ({ reacted: !c.reacted }))} />
207
+ <MenuItem size="small" iconName="Bookmark" label={menuComment?.saved ? 'Remove from Saved' : 'Save'} onClick={() => choose((c) => ({ saved: !c.saved }))} />
208
+ <MenuItem size="small" iconName="Check" label={menuComment?.done ? 'Reopen' : 'Mark Done'} onClick={toggleDone} />
209
+ {menuComment?.unread && <MenuItem size="small" iconName="MailOpen" label="Mark as Read" onClick={() => choose(() => ({ unread: false }))} />}
210
+ </Menu>
211
+ </Popover>
212
+ </Center>
213
+ );
214
+ }
215
+ ```
216
+
217
+ ## Option: Open thread
218
+
219
+ Use when: One thread is open, with its replies and a reply box.
220
+
221
+ Uses: `Alert`, `Button`, `Center`, `Composer`, `Heading`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `TitleBar`, `UserImage`
222
+
223
+ ```tsx
224
+ 'use client';
225
+ import { useState } from 'react';
226
+ import Message from 'oneslash-design-system/components/message';
227
+ import UserImage from 'oneslash-design-system/components/userImage';
228
+ import Tag from 'oneslash-design-system/components/tag';
229
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
230
+ import Heading from 'oneslash-design-system/components/heading';
231
+ import Paragraph from 'oneslash-design-system/components/paragraph';
232
+ import TitleBar from 'oneslash-design-system/components/titleBar';
233
+ import Button from 'oneslash-design-system/components/button';
234
+ import Composer from 'oneslash-design-system/components/composer';
235
+ import Alert from 'oneslash-design-system/components/alert';
236
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
237
+
238
+ // A real app reads this from the session.
239
+ const me = 'Dana Lee';
240
+
241
+ type Reply = { id: string; from: string; at: Date; text: string };
242
+
243
+ const comment = {
244
+ from: 'Ben Carter',
245
+ at: new Date('2026-11-16T14:40:00Z'),
246
+ text: 'The headline wraps to three lines on a phone, and the sign-up button drops below the fold. Can we cut the headline to one line there, or make the type a size smaller? I would rather keep the button in view than keep every word.',
247
+ place: 'Homepage design, frame Hero',
248
+ };
249
+
250
+ const firstReplies: Reply[] = [
251
+ { id: 'r1', from: 'Omar Reyes', at: new Date('2026-11-16T14:52:00Z'), text: 'I can cut it to "Plan your launch in one place." That fits on one line on a phone.' },
252
+ { id: 'r2', from: 'Ben Carter', at: new Date('2026-11-16T15:01:00Z'), text: 'That works for me.' },
253
+ { id: 'r3', from: 'Ben Carter', at: new Date('2026-11-16T15:02:00Z'), text: 'Keep the type size as it is, then.' },
254
+ ];
255
+
256
+ // A reply is compact when the one above is from the same person, on the same day and less than 5 minutes older.
257
+ function isFollowOn(list: Reply[], i: number) {
258
+ const above = list[i - 1];
259
+ if (!above || above.from !== list[i].from) return false;
260
+ const sameDay = above.at.toDateString() === list[i].at.toDateString();
261
+ return sameDay && list[i].at.getTime() - above.at.getTime() < 5 * 60 * 1000;
262
+ }
263
+
264
+ export default function CommentThreadThread() {
265
+ const [replies, setReplies] = useState(firstReplies);
266
+ const [text, setText] = useState('');
267
+ const [done, setDone] = useState(false);
268
+ // What the polite line says after the last press. The count gives each press a fresh line, so it is read again.
269
+ const [said, setSaid] = useState<{ text: string; n: number } | null>(null);
270
+
271
+ // A real app sends the change to the server here. The Button keeps focus as its label changes,
272
+ // and a screen reader may not read that new name, so the polite line says it.
273
+ function toggleDone() {
274
+ setDone(!done);
275
+ setSaid((s) => ({ text: done ? 'Reopened.' : 'Marked done.', n: (s?.n ?? 0) + 1 }));
276
+ }
277
+
278
+ function send() {
279
+ // A real app sends the reply to the server here and shows it at once.
280
+ setReplies((list) => [...list, { id: `r${list.length + 1}`, from: me, at: new Date('2026-11-16T15:10:00Z'), text: text.trim() }]);
281
+ setText('');
282
+ }
283
+
284
+ return (
285
+ <Center width="page">
286
+ <Stack gap="large">
287
+ <Heading level={1} size="h5">Comments</Heading>
288
+ {/* On a phone the thread takes the screen, so Back goes to the list. From md a real app shows the list beside it and leaves Back out. */}
289
+ <TitleBar
290
+ level={2}
291
+ title="Thread"
292
+ back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Comments" />}
293
+ meta={
294
+ <>
295
+ {comment.place}
296
+ {done && <Tag variant="textOnly" size="small" label="Done" />}
297
+ </>
298
+ }
299
+ actions={
300
+ <Button size="small" type="secondary" state="enabled" label={done ? 'Reopen' : 'Mark Done'} onClickButton={toggleDone} />
301
+ }
302
+ />
303
+ {said && (
304
+ // An inline Alert is a polite status. It leaves after 5 seconds; the Tag and the Button still show the state.
305
+ <Alert key={said.n} variant="inline" type="success" message={said.text} onClose={() => setSaid(null)} />
306
+ )}
307
+ {/* A real app gives the list that holds the rows role="log". */}
308
+ <Stack gap="small">
309
+ <Message
310
+ aria-label={comment.from}
311
+ avatar={<UserImage userHandle={comment.from} decorative />}
312
+ name={comment.from}
313
+ meta={<TimeStamp createdAt={comment.at} dateFormat="absolute" data="time" />}
314
+ >
315
+ <Paragraph measure="none">{comment.text}</Paragraph>
316
+ </Message>
317
+ {replies.map((r, i) => {
318
+ const compact = isFollowOn(replies, i);
319
+ return (
320
+ <Message
321
+ key={r.id}
322
+ compact={compact}
323
+ aria-label={r.from}
324
+ avatar={compact ? undefined : <UserImage userHandle={r.from} decorative />}
325
+ name={compact ? undefined : r.from}
326
+ meta={compact ? undefined : <TimeStamp createdAt={r.at} dateFormat="absolute" data="time" />}
327
+ >
328
+ <Paragraph measure="none">{r.text}</Paragraph>
329
+ </Message>
330
+ );
331
+ })}
332
+ </Stack>
333
+ <Composer
334
+ id="comment-thread-reply"
335
+ aria-label={`Reply to ${comment.from}`}
336
+ placeholder={`Reply to ${comment.from}`}
337
+ value={text}
338
+ onChange={setText}
339
+ onSubmit={send}
340
+ />
341
+ </Stack>
342
+ </Center>
343
+ );
344
+ }
345
+ ```
346
+
347
+ ## Native
348
+
349
+ On Apple show the comments in a `List` with a `NavigationLink` per comment, its actions in a `contextMenu` and `swipeActions`, and the thread as a pushed view with a text field in a bottom bar. On Android use a `LazyColumn` of cards that each have a clickable title, a dropdown menu for the actions, and a thread screen.
@@ -1,4 +1,13 @@
1
1
  'use client';
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
2
11
  import { useEffect, useRef, useState } from 'react';
3
12
  import AppShell from '../../components/appShell';
4
13
  import TitleBar from '../../components/titleBar';
@@ -14,6 +23,7 @@ import Button from '../../components/button';
14
23
  import Paragraph from '../../components/paragraph';
15
24
  import EmptyBox from '../../components/emptyBox';
16
25
  import List from '../../components/list';
26
+ import BarChart from '../../components/barChart';
17
27
  import { formatCount } from '../../components/formatNumber';
18
28
  import { Cluster, Grid, Stack } from '../../components/layout';
19
29
  var ranges = [
@@ -58,6 +68,32 @@ var data = {
58
68
  },
59
69
  };
60
70
  var noun = { week: 'this week', month: 'this month', quarter: 'this quarter' };
71
+ var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
72
+ // 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
73
+ function day(back) {
74
+ var d = new Date(Date.UTC(2026, 10, 16 - back));
75
+ return "".concat(months[d.getUTCMonth()], " ").concat(d.getUTCDate());
76
+ }
77
+ // New comments per day, adding up to the tile above. The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
78
+ var week = [152, 168, 149, 181, 190, 186, 214];
79
+ var month = __spreadArray([144, 157, 148, 162, 153, 145, 159, 150, 164, 155, 147, 160, 152, 166, 157, 149, 162, 153, 168, 159, 151, 164, 155], week, true);
80
+ var quarter = [1181, 1234, 1216, 1198, 1251, 1233, 1215, 1197, 1250, 1232, 1214, 1219, 1240];
81
+ var perDay = {
82
+ week: week.map(function (value, i) { return ({ label: day(6 - i), value: value }); }),
83
+ month: month.map(function (value, i) { return ({ label: day(29 - i), value: value }); }),
84
+ quarter: quarter.map(function (value, i) { return ({ label: day(6 + (12 - i) * 7), value: value }); }),
85
+ };
86
+ // The summary says what changed, written from the same data the chart draws.
87
+ function summary(range) {
88
+ var points = perDay[range];
89
+ var first = points[0];
90
+ var last = points[points.length - 1];
91
+ var when = function (p) { return (range === 'quarter' ? "in the week of ".concat(p.label) : "on ".concat(p.label)); };
92
+ var move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';
93
+ return move === 'stayed'
94
+ ? "Comments stayed at ".concat(formatCount(first.value), " from ").concat(first.label, " to ").concat(last.label, ".")
95
+ : "Comments ".concat(move, " from ").concat(formatCount(first.value), " ").concat(when(first), " to ").concat(formatCount(last.value), " ").concat(when(last), ".");
96
+ }
61
97
  export default function DashboardNumbersFirst() {
62
98
  var _a = useState('week'), range = _a[0], setRange = _a[1];
63
99
  // The numbers load again when the range changes.
@@ -65,13 +101,18 @@ export default function DashboardNumbersFirst() {
65
101
  // The projects section fails first, so the rest of the page shows that one section can fail alone.
66
102
  var _c = useState(true), projectsFailed = _c[0], setProjectsFailed = _c[1];
67
103
  var _d = useState(false), retrying = _d[0], setRetrying = _d[1];
68
- var _e = useState(false), navOpen = _e[0], setNavOpen = _e[1];
104
+ // The chart starts loaded. A real app sets this when the chart's request fails.
105
+ var _e = useState(false), trendFailed = _e[0], setTrendFailed = _e[1];
106
+ var _f = useState(false), trendRetrying = _f[0], setTrendRetrying = _f[1];
107
+ var _g = useState(false), navOpen = _g[0], setNavOpen = _g[1];
69
108
  var timer = useRef();
70
109
  var retryTimer = useRef();
110
+ var trendTimer = useRef();
71
111
  // Stops the requests if the example goes away before they end.
72
112
  useEffect(function () { return function () {
73
113
  clearTimeout(timer.current);
74
114
  clearTimeout(retryTimer.current);
115
+ clearTimeout(trendTimer.current);
75
116
  }; }, []);
76
117
  function changeRange(next) {
77
118
  clearTimeout(timer.current);
@@ -89,6 +130,15 @@ export default function DashboardNumbersFirst() {
89
130
  setProjectsFailed(false);
90
131
  }, 1200);
91
132
  }
133
+ function tryTrendAgain() {
134
+ if (trendRetrying)
135
+ return;
136
+ setTrendRetrying(true);
137
+ trendTimer.current = setTimeout(function () {
138
+ setTrendRetrying(false);
139
+ setTrendFailed(false);
140
+ }, 1200);
141
+ }
92
142
  var d = data[range];
93
143
  var period = range;
94
144
  var projectTotal = d.projects.reduce(function (sum, p) { return sum + p[1]; }, 0);
@@ -115,6 +165,16 @@ export default function DashboardNumbersFirst() {
115
165
  <StatTile label="Average reply time" value={d.stats.reply[0]} format="duration" previous={d.stats.reply[1]} period={period} loading={loading}/>
116
166
  </Grid>
117
167
  </SettingsSection>);
168
+ // A trend over the range goes under the stat row, over the same range.
169
+ var trend = (<SettingsSection key="trend" title={"Comments ".concat(noun[range])} id="dashboard-trend">
170
+ {trendFailed ? (<>
171
+ {/* Only the chart failed, as the case 'Load failure' says. The rest of the page still shows. */}
172
+ <Alert type="error" variant="inline" message="Could not load comments." autoDismiss={false}/>
173
+ <Cluster>
174
+ <Button size="small" type="primary" state="enabled" label="Try Again" loading={trendRetrying} onClickButton={tryTrendAgain}/>
175
+ </Cluster>
176
+ </>) : (<BarChart id="dashboard-comments-per-day" title={range === 'quarter' ? 'Comments per week' : 'Comments per day'} summary={summary(range)} data={perDay[range]} unit="comments" labelHeader={range === 'quarter' ? 'Week of' : 'Date'} loading={loading} emptyText={"No comments ".concat(noun[range])}/>)}
177
+ </SettingsSection>);
118
178
  var projects = (<SettingsSection key="projects" title="Projects" description={"".concat(formatCount(projectTotal), " comments ").concat(noun[range], ", by project")} id="dashboard-projects">
119
179
  {projectsFailed ? (<>
120
180
  {/* Only this section failed. The rest of the page still shows. */}
@@ -157,6 +217,7 @@ export default function DashboardNumbersFirst() {
157
217
  {/* Below md the range switch takes its own line under the title. */}
158
218
  <TitleBar title="Dashboard" actionsBelow actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange}/>}/>
159
219
  {statRow}
220
+ {trend}
160
221
  {projects}
161
222
  {waiting}
162
223
  {questions}
@@ -8,6 +8,7 @@ A page that opens an app and says how things are going and what waits on the per
8
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
9
  - Let the one range drive every number on the page, and name it in every heading and caption: 'this week'.
10
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
+ - Show a trend over the range as the case 'Chart' says, under the stat row, over the same range.
11
12
  - Make each section a `SettingsSection`: a hairline, a title and its content. Do not put a section in a box.
12
13
  - 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
14
  - Show a list that can be longer than its section as the case 'Short list on a dashboard' says.
@@ -17,7 +18,7 @@ A page that opens an app and says how things are going and what waits on the per
17
18
 
18
19
  ## Don't
19
20
 
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 draw a chart for one number or for a share. A trend over the range follows the case 'Chart'.
21
22
  - Do not count different sections over different ranges.
22
23
  - Do not replace the whole page when one section failed.
23
24
  - Do not put more than four tiles in the stat row.
@@ -28,7 +29,7 @@ A page that opens an app and says how things are going and what waits on the per
28
29
 
29
30
  Use when: The page reports how things went, for a lead who checks on a team.
30
31
 
31
- Uses: `Alert`, `AppShell`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
32
+ Uses: `Alert`, `AppShell`, `BarChart`, `Button`, `Cluster`, `EmptyBox`, `Grid`, `List`, `MenuItem`, `Navigation`, `Paragraph`, `Progress`, `SegmentedControl`, `SettingsSection`, `Skeleton`, `Stack`, `StatTile`, `TitleBar`, `formatCount`
32
33
 
33
34
  ```tsx
34
35
  'use client';
@@ -47,6 +48,7 @@ import Button from 'oneslash-design-system/components/button';
47
48
  import Paragraph from 'oneslash-design-system/components/paragraph';
48
49
  import EmptyBox from 'oneslash-design-system/components/emptyBox';
49
50
  import List from 'oneslash-design-system/components/list';
51
+ import BarChart from 'oneslash-design-system/components/barChart';
50
52
  import { formatCount } from 'oneslash-design-system/components/formatNumber';
51
53
  import { Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
52
54
 
@@ -96,6 +98,35 @@ const data = {
96
98
 
97
99
  const noun: Record<Range, string> = { week: 'this week', month: 'this month', quarter: 'this quarter' };
98
100
 
101
+ const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
102
+ // 'Nov 14' for the day `back` days before Nov 16, 2026. Written from UTC, so the server and the browser agree.
103
+ function day(back: number) {
104
+ const d = new Date(Date.UTC(2026, 10, 16 - back));
105
+ return `${months[d.getUTCMonth()]} ${d.getUTCDate()}`;
106
+ }
107
+
108
+ // New comments per day, adding up to the tile above. The quarter is counted by week: 13 weeks, the last from Nov 10 to Nov 16.
109
+ const week = [152, 168, 149, 181, 190, 186, 214];
110
+ const month = [144, 157, 148, 162, 153, 145, 159, 150, 164, 155, 147, 160, 152, 166, 157, 149, 162, 153, 168, 159, 151, 164, 155, ...week];
111
+ const quarter = [1181, 1234, 1216, 1198, 1251, 1233, 1215, 1197, 1250, 1232, 1214, 1219, 1240];
112
+ const perDay: Record<Range, { label: string; value: number }[]> = {
113
+ week: week.map((value, i) => ({ label: day(6 - i), value })),
114
+ month: month.map((value, i) => ({ label: day(29 - i), value })),
115
+ quarter: quarter.map((value, i) => ({ label: day(6 + (12 - i) * 7), value })),
116
+ };
117
+
118
+ // The summary says what changed, written from the same data the chart draws.
119
+ function summary(range: Range) {
120
+ const points = perDay[range];
121
+ const first = points[0];
122
+ const last = points[points.length - 1];
123
+ const when = (p: { label: string }) => (range === 'quarter' ? `in the week of ${p.label}` : `on ${p.label}`);
124
+ const move = last.value > first.value ? 'rose' : last.value < first.value ? 'fell' : 'stayed';
125
+ return move === 'stayed'
126
+ ? `Comments stayed at ${formatCount(first.value)} from ${first.label} to ${last.label}.`
127
+ : `Comments ${move} from ${formatCount(first.value)} ${when(first)} to ${formatCount(last.value)} ${when(last)}.`;
128
+ }
129
+
99
130
  export default function DashboardNumbersFirst() {
100
131
  const [range, setRange] = useState<Range>('week');
101
132
  // The numbers load again when the range changes.
@@ -103,14 +134,19 @@ export default function DashboardNumbersFirst() {
103
134
  // The projects section fails first, so the rest of the page shows that one section can fail alone.
104
135
  const [projectsFailed, setProjectsFailed] = useState(true);
105
136
  const [retrying, setRetrying] = useState(false);
137
+ // The chart starts loaded. A real app sets this when the chart's request fails.
138
+ const [trendFailed, setTrendFailed] = useState(false);
139
+ const [trendRetrying, setTrendRetrying] = useState(false);
106
140
  const [navOpen, setNavOpen] = useState(false);
107
141
  const timer = useRef<ReturnType<typeof setTimeout>>();
108
142
  const retryTimer = useRef<ReturnType<typeof setTimeout>>();
143
+ const trendTimer = useRef<ReturnType<typeof setTimeout>>();
109
144
 
110
145
  // Stops the requests if the example goes away before they end.
111
146
  useEffect(() => () => {
112
147
  clearTimeout(timer.current);
113
148
  clearTimeout(retryTimer.current);
149
+ clearTimeout(trendTimer.current);
114
150
  }, []);
115
151
 
116
152
  function changeRange(next: string) {
@@ -130,6 +166,15 @@ export default function DashboardNumbersFirst() {
130
166
  }, 1200);
131
167
  }
132
168
 
169
+ function tryTrendAgain() {
170
+ if (trendRetrying) return;
171
+ setTrendRetrying(true);
172
+ trendTimer.current = setTimeout(() => {
173
+ setTrendRetrying(false);
174
+ setTrendFailed(false);
175
+ }, 1200);
176
+ }
177
+
133
178
  const d = data[range];
134
179
  const period = range;
135
180
  const projectTotal = d.projects.reduce((sum, p) => sum + p[1], 0);
@@ -171,6 +216,32 @@ export default function DashboardNumbersFirst() {
171
216
  </SettingsSection>
172
217
  );
173
218
 
219
+ // A trend over the range goes under the stat row, over the same range.
220
+ const trend = (
221
+ <SettingsSection key="trend" title={`Comments ${noun[range]}`} id="dashboard-trend">
222
+ {trendFailed ? (
223
+ <>
224
+ {/* Only the chart failed, as the case 'Load failure' says. The rest of the page still shows. */}
225
+ <Alert type="error" variant="inline" message="Could not load comments." autoDismiss={false} />
226
+ <Cluster>
227
+ <Button size="small" type="primary" state="enabled" label="Try Again" loading={trendRetrying} onClickButton={tryTrendAgain} />
228
+ </Cluster>
229
+ </>
230
+ ) : (
231
+ <BarChart
232
+ id="dashboard-comments-per-day"
233
+ title={range === 'quarter' ? 'Comments per week' : 'Comments per day'}
234
+ summary={summary(range)}
235
+ data={perDay[range]}
236
+ unit="comments"
237
+ labelHeader={range === 'quarter' ? 'Week of' : 'Date'}
238
+ loading={loading}
239
+ emptyText={`No comments ${noun[range]}`}
240
+ />
241
+ )}
242
+ </SettingsSection>
243
+ );
244
+
174
245
  const projects = (
175
246
  <SettingsSection key="projects" title="Projects" description={`${formatCount(projectTotal)} comments ${noun[range]}, by project`} id="dashboard-projects">
176
247
  {projectsFailed ? (
@@ -254,6 +325,7 @@ export default function DashboardNumbersFirst() {
254
325
  actions={<SegmentedControl size="small" width="fit" aria-label="Range" options={ranges} value={range} onChange={changeRange} />}
255
326
  />
256
327
  {statRow}
328
+ {trend}
257
329
  {projects}
258
330
  {waiting}
259
331
  {questions}
@@ -504,4 +576,4 @@ export default function DashboardWorkFirst() {
504
576
 
505
577
  ## Native
506
578
 
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.
579
+ 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. Draw a trend over the range with Swift Charts as the case 'Chart' says; on Android draw it on a `Canvas` or show the table.
@@ -0,0 +1 @@
1
+ export default function LeaderboardRanked(): import("react").JSX.Element;
@@ -0,0 +1,44 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import SettingsSection from '../../components/settingsSection';
4
+ import List from '../../components/list';
5
+ import UserImage from '../../components/userImage';
6
+ import Paragraph from '../../components/paragraph';
7
+ import Link from '../../components/link';
8
+ import { formatChange, formatCount } from '../../components/formatNumber';
9
+ import { Center, Cluster, Stack } from '../../components/layout';
10
+ // A real app counts these on the server, largest first. `previous` is last week's count.
11
+ // The table example has a tie for second; this list has none, since its numbers are the ranks.
12
+ var people = [
13
+ { name: 'Omar Reyes', comments: 58, previous: 52 },
14
+ { name: 'Ben Carter', comments: 42, previous: 0 },
15
+ { name: 'Mia Park', comments: 37, previous: 41 },
16
+ { name: 'Dana Lee', comments: 30, previous: 30 },
17
+ { name: 'Leo Grant', comments: 21, previous: 14 },
18
+ { name: 'Ana Silva', comments: 9, previous: 12 },
19
+ ];
20
+ var top = people.slice(0, 5);
21
+ export default function LeaderboardRanked() {
22
+ return (<Center width="page">
23
+ <Stack gap="xlarge">
24
+ <Heading level={1} size="h5">Dashboard</Heading>
25
+ <SettingsSection title="Most active this week" description="Comments each person left from Nov 10 to Nov 16, 2026" id="leaderboard-ranked-people">
26
+ <Stack gap="large">
27
+ {/* The list's numbers are the ranks. The count and the change say the rest, so there are no bars. */}
28
+ <List marker="number" items={top.map(function (p) { return (<Cluster key={p.name} justify="between" gap="small">
29
+ <Cluster gap="small">
30
+ <UserImage userHandle={p.name} decorative size={24}/>
31
+ <Paragraph measure="none">{p.name}</Paragraph>
32
+ </Cluster>
33
+ <Cluster gap="small">
34
+ <Paragraph measure="none">{"".concat(formatCount(p.comments), " ").concat(p.comments === 1 ? 'comment' : 'comments')}</Paragraph>
35
+ <Paragraph size="body2" tone="secondary" measure="none">{formatChange(p.comments, p.previous, 'week').text}</Paragraph>
36
+ </Cluster>
37
+ </Cluster>); })}/>
38
+ {/* A real app goes to the table of everyone. */}
39
+ <Link href="/people" size="body2">See All People</Link>
40
+ </Stack>
41
+ </SettingsSection>
42
+ </Stack>
43
+ </Center>);
44
+ }