oneslash-design-system 2.16.0 → 2.18.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 (301) hide show
  1. package/README.md +2 -2
  2. package/dist/DESIGN.md +56 -17
  3. package/dist/cases/accept-invite/signed-in.jsx +1 -1
  4. package/dist/cases/accept-invite/signed-out.jsx +1 -1
  5. package/dist/cases/accept-invite.md +3 -7
  6. package/dist/cases/account-menu/menu.d.ts +1 -0
  7. package/dist/cases/account-menu/menu.jsx +99 -0
  8. package/dist/cases/account-menu.md +164 -0
  9. package/dist/cases/agent-asks-before-risky-action.md +0 -4
  10. package/dist/cases/agent-cancels-when-unanswered.md +0 -4
  11. package/dist/cases/agent-options/cards.d.ts +1 -0
  12. package/dist/cases/agent-options/cards.jsx +91 -0
  13. package/dist/cases/agent-options.md +164 -0
  14. package/dist/cases/agent-pending-reply/steps.d.ts +1 -0
  15. package/dist/cases/agent-pending-reply/steps.jsx +149 -0
  16. package/dist/cases/agent-pending-reply/streaming.d.ts +1 -0
  17. package/dist/cases/agent-pending-reply/streaming.jsx +146 -0
  18. package/dist/cases/agent-pending-reply.md +428 -0
  19. package/dist/cases/agent-plan-proposal/changes.d.ts +1 -0
  20. package/dist/cases/agent-plan-proposal/changes.jsx +224 -0
  21. package/dist/cases/agent-plan-proposal/steps.d.ts +1 -0
  22. package/dist/cases/agent-plan-proposal/steps.jsx +211 -0
  23. package/dist/cases/agent-plan-proposal.md +652 -0
  24. package/dist/cases/agent-question/choices.d.ts +1 -0
  25. package/dist/cases/agent-question/choices.jsx +132 -0
  26. package/dist/cases/agent-question/free-text.d.ts +1 -0
  27. package/dist/cases/agent-question/free-text.jsx +81 -0
  28. package/dist/cases/agent-question.md +334 -0
  29. package/dist/cases/agent-refuses-clearly.md +0 -4
  30. package/dist/cases/agent-says-what-it-is.md +0 -2
  31. package/dist/cases/agent-settings/form.d.ts +1 -0
  32. package/dist/cases/agent-settings/form.jsx +164 -0
  33. package/dist/cases/agent-settings.md +259 -0
  34. package/dist/cases/agent-shows-progress.md +0 -2
  35. package/dist/cases/agent-shows-sources.md +2 -4
  36. package/dist/cases/api-keys/list.d.ts +1 -0
  37. package/dist/cases/api-keys/list.jsx +162 -0
  38. package/dist/cases/api-keys.md +229 -0
  39. package/dist/cases/artifact-card/card.d.ts +1 -0
  40. package/dist/cases/artifact-card/card.jsx +45 -0
  41. package/dist/cases/artifact-card.md +99 -0
  42. package/dist/cases/auth-gate-loading.md +0 -4
  43. package/dist/cases/check-your-email.md +0 -4
  44. package/dist/cases/collapsible-search/popover.d.ts +1 -0
  45. package/dist/cases/collapsible-search/popover.jsx +74 -0
  46. package/dist/cases/collapsible-search.md +143 -0
  47. package/dist/cases/composer-limit/notice-with-action.d.ts +1 -0
  48. package/dist/cases/composer-limit/notice-with-action.jsx +87 -0
  49. package/dist/cases/composer-limit/notice.d.ts +1 -0
  50. package/dist/cases/composer-limit/notice.jsx +84 -0
  51. package/dist/cases/composer-limit.md +282 -0
  52. package/dist/cases/confirm-destructive-action.md +0 -4
  53. package/dist/cases/confirm-dialogs.md +0 -4
  54. package/dist/cases/conversation-starters/chips.d.ts +1 -0
  55. package/dist/cases/conversation-starters/chips.jsx +69 -0
  56. package/dist/cases/conversation-starters/none.d.ts +1 -0
  57. package/dist/cases/conversation-starters/none.jsx +45 -0
  58. package/dist/cases/conversation-starters.md +204 -0
  59. package/dist/cases/create-modal.md +0 -4
  60. package/dist/cases/danger-zone/collapsed.d.ts +1 -0
  61. package/dist/cases/danger-zone/collapsed.jsx +75 -0
  62. package/dist/cases/danger-zone/shown.d.ts +1 -0
  63. package/dist/cases/danger-zone/shown.jsx +95 -0
  64. package/dist/cases/danger-zone.md +263 -0
  65. package/dist/cases/device-login.md +0 -4
  66. package/dist/cases/email-confirmed.md +0 -4
  67. package/dist/cases/empty-list.md +0 -4
  68. package/dist/cases/empty-lists.md +0 -4
  69. package/dist/cases/empty-not-set-up.md +0 -4
  70. package/dist/cases/empty-search.md +0 -4
  71. package/dist/cases/error-page.md +0 -4
  72. package/dist/cases/feedback-form.md +0 -4
  73. package/dist/cases/filter-menu/presets.d.ts +1 -0
  74. package/dist/cases/filter-menu/presets.jsx +53 -0
  75. package/dist/cases/filter-menu/with-clear.d.ts +1 -0
  76. package/dist/cases/filter-menu/with-clear.jsx +56 -0
  77. package/dist/cases/filter-menu.md +204 -0
  78. package/dist/cases/forgot-password.md +0 -4
  79. package/dist/cases/form-errors.md +0 -4
  80. package/dist/cases/import-checklist.md +0 -4
  81. package/dist/cases/inline-form-feedback.md +0 -4
  82. package/dist/cases/integrations-list/nested.d.ts +1 -0
  83. package/dist/cases/integrations-list/nested.jsx +164 -0
  84. package/dist/cases/integrations-list/rows.d.ts +1 -0
  85. package/dist/cases/integrations-list/rows.jsx +134 -0
  86. package/dist/cases/integrations-list.md +379 -0
  87. package/dist/cases/invite-member.md +0 -4
  88. package/dist/cases/load-failure.md +0 -4
  89. package/dist/cases/log-out-confirm.md +0 -4
  90. package/dist/cases/login-page.md +0 -4
  91. package/dist/cases/members-list/rows.d.ts +1 -0
  92. package/dist/cases/members-list/rows.jsx +318 -0
  93. package/dist/cases/members-list/table.d.ts +1 -0
  94. package/dist/cases/members-list/table.jsx +351 -0
  95. package/dist/cases/members-list.md +799 -0
  96. package/dist/cases/mention-list/in-composer.d.ts +1 -0
  97. package/dist/cases/mention-list/in-composer.jsx +169 -0
  98. package/dist/cases/mention-list.md +248 -0
  99. package/dist/cases/message-actions/hover-toolbar.d.ts +1 -0
  100. package/dist/cases/message-actions/hover-toolbar.jsx +229 -0
  101. package/dist/cases/message-actions/menu.d.ts +1 -0
  102. package/dist/cases/message-actions/menu.jsx +258 -0
  103. package/dist/cases/message-actions.md +647 -0
  104. package/dist/cases/message-attachments/in-composer.d.ts +1 -0
  105. package/dist/cases/message-attachments/in-composer.jsx +134 -0
  106. package/dist/cases/message-attachments/in-message.d.ts +1 -0
  107. package/dist/cases/message-attachments/in-message.jsx +46 -0
  108. package/dist/cases/message-attachments.md +306 -0
  109. package/dist/cases/message-composer/plain.d.ts +1 -0
  110. package/dist/cases/message-composer/plain.jsx +57 -0
  111. package/dist/cases/message-composer/with-tools.d.ts +1 -0
  112. package/dist/cases/message-composer/with-tools.jsx +182 -0
  113. package/dist/cases/message-composer.md +352 -0
  114. package/dist/cases/message-edit/in-place.d.ts +1 -0
  115. package/dist/cases/message-edit/in-place.jsx +99 -0
  116. package/dist/cases/message-edit.md +175 -0
  117. package/dist/cases/message-reactions/chips.d.ts +1 -0
  118. package/dist/cases/message-reactions/chips.jsx +118 -0
  119. package/dist/cases/message-reactions/quick-pick.d.ts +1 -0
  120. package/dist/cases/message-reactions/quick-pick.jsx +155 -0
  121. package/dist/cases/message-reactions.md +367 -0
  122. package/dist/cases/message-row/grouped.d.ts +1 -0
  123. package/dist/cases/message-row/grouped.jsx +56 -0
  124. package/dist/cases/message-row/person-and-agent.d.ts +1 -0
  125. package/dist/cases/message-row/person-and-agent.jsx +41 -0
  126. package/dist/cases/message-row.md +185 -0
  127. package/dist/cases/not-found-page.md +0 -4
  128. package/dist/cases/notification-menu/menu.d.ts +1 -0
  129. package/dist/cases/notification-menu/menu.jsx +74 -0
  130. package/dist/cases/notification-menu.md +135 -0
  131. package/dist/cases/oauth-consent.md +0 -4
  132. package/dist/cases/on-off-settings/list.d.ts +1 -0
  133. package/dist/cases/on-off-settings/list.jsx +97 -0
  134. package/dist/cases/on-off-settings.md +116 -0
  135. package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
  136. package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
  137. package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
  138. package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
  139. package/dist/cases/overflow-menu.md +410 -0
  140. package/dist/cases/profile-form/form.d.ts +1 -0
  141. package/dist/cases/profile-form/form.jsx +153 -0
  142. package/dist/cases/profile-form.md +236 -0
  143. package/dist/cases/quick-switcher/modal.d.ts +1 -0
  144. package/dist/cases/quick-switcher/modal.jsx +114 -0
  145. package/dist/cases/quick-switcher.md +205 -0
  146. package/dist/cases/range-switch/segmented.d.ts +1 -0
  147. package/dist/cases/range-switch/segmented.jsx +30 -0
  148. package/dist/cases/range-switch.md +67 -0
  149. package/dist/cases/rename.md +0 -4
  150. package/dist/cases/reply-feedback/thumbs.d.ts +1 -0
  151. package/dist/cases/reply-feedback/thumbs.jsx +191 -0
  152. package/dist/cases/reply-feedback/with-reason.d.ts +1 -0
  153. package/dist/cases/reply-feedback/with-reason.jsx +221 -0
  154. package/dist/cases/reply-feedback.md +548 -0
  155. package/dist/cases/reply-sources/cards.d.ts +1 -0
  156. package/dist/cases/reply-sources/cards.jsx +83 -0
  157. package/dist/cases/reply-sources/tag-only.d.ts +1 -0
  158. package/dist/cases/reply-sources/tag-only.jsx +45 -0
  159. package/dist/cases/reply-sources.md +243 -0
  160. package/dist/cases/route-loading.md +0 -2
  161. package/dist/cases/scope-picker/menu.d.ts +1 -0
  162. package/dist/cases/scope-picker/menu.jsx +47 -0
  163. package/dist/cases/scope-picker.md +97 -0
  164. package/dist/cases/set-new-password.md +0 -4
  165. package/dist/cases/settings-page/side-nav.d.ts +1 -0
  166. package/dist/cases/settings-page/side-nav.jsx +171 -0
  167. package/dist/cases/settings-page/top-tabs.d.ts +1 -0
  168. package/dist/cases/settings-page/top-tabs.jsx +129 -0
  169. package/dist/cases/settings-page.md +378 -0
  170. package/dist/cases/settings-save.md +35 -0
  171. package/dist/cases/sign-up-page.md +1 -5
  172. package/dist/cases/slash-command-list/in-composer.d.ts +1 -0
  173. package/dist/cases/slash-command-list/in-composer.jsx +162 -0
  174. package/dist/cases/slash-command-list.md +243 -0
  175. package/dist/cases/success-feedback.md +1 -5
  176. package/dist/cases/tag-filter/tags.d.ts +1 -0
  177. package/dist/cases/tag-filter/tags.jsx +226 -0
  178. package/dist/cases/tag-filter.md +298 -0
  179. package/dist/cases/type-to-confirm.md +0 -4
  180. package/dist/cases/typing-and-status/line.d.ts +1 -0
  181. package/dist/cases/typing-and-status/line.jsx +50 -0
  182. package/dist/cases/typing-and-status.md +92 -0
  183. package/dist/cases/unsaved-changes-guard.md +0 -4
  184. package/dist/cases/upgrade-prompt.md +0 -4
  185. package/dist/cases.json +2331 -294
  186. package/dist/components/alert.d.ts +3 -1
  187. package/dist/components/alert.jsx +2 -2
  188. package/dist/components/button.d.ts +3 -2
  189. package/dist/components/button.jsx +14 -9
  190. package/dist/components/checkBox.d.ts +5 -1
  191. package/dist/components/checkBox.jsx +2 -2
  192. package/dist/components/composer.d.ts +74 -0
  193. package/dist/components/composer.jsx +122 -0
  194. package/dist/components/copyField.d.ts +20 -0
  195. package/dist/components/copyField.jsx +99 -0
  196. package/dist/components/fileChip.d.ts +33 -0
  197. package/dist/components/fileChip.jsx +61 -0
  198. package/dist/components/formField.d.ts +34 -0
  199. package/dist/components/formField.jsx +28 -0
  200. package/dist/components/heading.d.ts +3 -1
  201. package/dist/components/heading.jsx +2 -2
  202. package/dist/components/iconButton.d.ts +3 -3
  203. package/dist/components/iconButton.jsx +9 -7
  204. package/dist/components/layout.d.ts +7 -1
  205. package/dist/components/layout.jsx +5 -2
  206. package/dist/components/menu.d.ts +21 -0
  207. package/dist/components/menu.jsx +27 -3
  208. package/dist/components/menuItem.d.ts +12 -2
  209. package/dist/components/menuItem.jsx +6 -5
  210. package/dist/components/message.d.ts +28 -0
  211. package/dist/components/message.jsx +25 -0
  212. package/dist/components/navigation.d.ts +9 -1
  213. package/dist/components/navigation.jsx +15 -3
  214. package/dist/components/paragraph.d.ts +3 -1
  215. package/dist/components/paragraph.jsx +2 -2
  216. package/dist/components/popover.d.ts +7 -1
  217. package/dist/components/popover.jsx +35 -9
  218. package/dist/components/radioGroup.d.ts +12 -1
  219. package/dist/components/radioGroup.jsx +20 -9
  220. package/dist/components/segmentedControl.d.ts +22 -0
  221. package/dist/components/segmentedControl.jsx +54 -0
  222. package/dist/components/select.d.ts +5 -1
  223. package/dist/components/select.jsx +2 -2
  224. package/dist/components/settingsSection.d.ts +31 -0
  225. package/dist/components/settingsSection.jsx +58 -0
  226. package/dist/components/slidingIndicator.d.ts +50 -0
  227. package/dist/components/slidingIndicator.jsx +102 -0
  228. package/dist/components/sourceCard.d.ts +23 -0
  229. package/dist/components/sourceCard.jsx +56 -0
  230. package/dist/components/stepList.d.ts +17 -0
  231. package/dist/components/stepList.jsx +79 -0
  232. package/dist/components/switch.d.ts +25 -0
  233. package/dist/components/switch.jsx +55 -0
  234. package/dist/components/tab.jsx +5 -11
  235. package/dist/components/tabsContainer.jsx +5 -67
  236. package/dist/components/tag.d.ts +9 -1
  237. package/dist/components/tag.jsx +6 -4
  238. package/dist/components/textField.d.ts +12 -2
  239. package/dist/components/textField.jsx +11 -4
  240. package/dist/components/textarea.d.ts +5 -1
  241. package/dist/components/textarea.jsx +6 -21
  242. package/dist/components/useHotkey.d.ts +7 -0
  243. package/dist/components/useHotkey.js +24 -0
  244. package/dist/components/userImage.d.ts +9 -1
  245. package/dist/components/userImage.jsx +10 -3
  246. package/dist/index.d.ts +6 -0
  247. package/dist/index.js +6 -0
  248. package/dist/internal/autoGrow.d.ts +11 -0
  249. package/dist/internal/autoGrow.js +28 -0
  250. package/dist/internal/composer.d.ts +16 -0
  251. package/dist/internal/composer.js +18 -0
  252. package/dist/internal/copyField.d.ts +5 -0
  253. package/dist/internal/copyField.js +61 -0
  254. package/dist/internal/hotkey.d.ts +16 -0
  255. package/dist/internal/hotkey.js +20 -0
  256. package/dist/internal/menu.d.ts +6 -0
  257. package/dist/internal/menu.js +31 -0
  258. package/dist/internal/switch.d.ts +5 -0
  259. package/dist/internal/switch.js +9 -0
  260. package/dist/native-mapping.json +62 -1
  261. package/dist/stories/Button.stories.d.ts +1 -0
  262. package/dist/stories/Button.stories.jsx +17 -1
  263. package/dist/stories/Cases.generated.stories.d.ts +53 -0
  264. package/dist/stories/Cases.generated.stories.jsx +106 -0
  265. package/dist/stories/Composer.stories.d.ts +23 -0
  266. package/dist/stories/Composer.stories.jsx +121 -0
  267. package/dist/stories/CopyField.stories.d.ts +11 -0
  268. package/dist/stories/CopyField.stories.jsx +65 -0
  269. package/dist/stories/FileChip.stories.d.ts +7 -0
  270. package/dist/stories/FileChip.stories.jsx +35 -0
  271. package/dist/stories/FormField.stories.d.ts +6 -0
  272. package/dist/stories/FormField.stories.jsx +44 -0
  273. package/dist/stories/IconButton.stories.d.ts +1 -0
  274. package/dist/stories/IconButton.stories.jsx +18 -1
  275. package/dist/stories/Menu.stories.d.ts +4 -0
  276. package/dist/stories/Menu.stories.jsx +46 -1
  277. package/dist/stories/MenuItem.stories.d.ts +1 -0
  278. package/dist/stories/MenuItem.stories.jsx +8 -0
  279. package/dist/stories/Message.stories.d.ts +10 -0
  280. package/dist/stories/Message.stories.jsx +77 -0
  281. package/dist/stories/Navigation.stories.d.ts +1 -0
  282. package/dist/stories/Navigation.stories.jsx +17 -1
  283. package/dist/stories/PageComponents.stories.d.ts +1 -0
  284. package/dist/stories/PageComponents.stories.jsx +21 -0
  285. package/dist/stories/RadioGroup.stories.d.ts +2 -0
  286. package/dist/stories/RadioGroup.stories.jsx +40 -1
  287. package/dist/stories/SegmentedControl.stories.d.ts +8 -0
  288. package/dist/stories/SegmentedControl.stories.jsx +33 -0
  289. package/dist/stories/SettingsSection.stories.d.ts +11 -0
  290. package/dist/stories/SettingsSection.stories.jsx +64 -0
  291. package/dist/stories/SourceCard.stories.d.ts +8 -0
  292. package/dist/stories/SourceCard.stories.jsx +33 -0
  293. package/dist/stories/StepList.stories.d.ts +8 -0
  294. package/dist/stories/StepList.stories.jsx +35 -0
  295. package/dist/stories/Switch.stories.d.ts +14 -0
  296. package/dist/stories/Switch.stories.jsx +87 -0
  297. package/dist/stories/TextField.stories.d.ts +1 -0
  298. package/dist/stories/TextField.stories.jsx +13 -0
  299. package/dist/stories/UserImage.stories.d.ts +2 -0
  300. package/dist/stories/UserImage.stories.jsx +19 -0
  301. package/package.json +8 -3
@@ -0,0 +1,367 @@
1
+ # Reactions
2
+
3
+ People answer a message with an emoji instead of a reply.
4
+
5
+ ## Do
6
+
7
+ - Put the reactions in the Message's `footer`: a `Cluster` of `Tag`s, then a small 'Add reaction' `IconButton`.
8
+ - Label each chip with the emoji and the count, such as '👍 3', and give it `state="selected"` when the person reacted with it.
9
+ - Name the emoji in words in the chip's `aria-label`: 'Thumbs up, 3 reactions'. The chip's `aria-pressed` says whether the person reacted.
10
+ - Wrap each chip in a `Tooltip` that names who reacted, with the person last: 'Omar and you'.
11
+ - Add or remove the reaction when the chip is pressed, and change the count at once.
12
+ - Name the 'Add reaction' button after the row: 'Add reaction to message from Dana Lee'.
13
+ - Open the quick pick from 'Add reaction': `<Popover returnFocus>` around `<Menu navigable aria-label="Add reaction">`, one `MenuItem` per emoji, named in words.
14
+ - Mark the emoji the person already used with an 'Added' tag. Picking it again removes it.
15
+ - Close the quick pick when an emoji is picked. Focus goes back to the button that opened it.
16
+ - Move focus to the 'Add reaction' button when the chip that had it disappears, because its count reached 0.
17
+ - Offer the six emoji for now: ODS has no full emoji picker yet.
18
+
19
+ ## Don't
20
+
21
+ - Do not show a chip with a count of 0.
22
+ - Do not name a chip by its emoji alone. A screen reader may read it differently, or not at all.
23
+ - Do not wait for the server before the count changes.
24
+ - Do not open the quick pick on hover. Open it on a press.
25
+
26
+ ## Option: Reaction chips
27
+
28
+ Use when: A message has reactions: each emoji shows under it with its count.
29
+
30
+ Uses: `Center`, `Cluster`, `Heading`, `IconButton`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `Tooltip`, `UserImage`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { useEffect, useRef, useState } from 'react';
35
+ import Message from 'oneslash-design-system/components/message';
36
+ import UserImage from 'oneslash-design-system/components/userImage';
37
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
38
+ import Heading from 'oneslash-design-system/components/heading';
39
+ import Paragraph from 'oneslash-design-system/components/paragraph';
40
+ import Tag from 'oneslash-design-system/components/tag';
41
+ import IconButton from 'oneslash-design-system/components/iconButton';
42
+ import Tooltip from 'oneslash-design-system/components/tooltip';
43
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
44
+
45
+ // A real app reads this from the session.
46
+ const me = 'Dana Lee';
47
+
48
+ // Each emoji's name in words, for its aria-label.
49
+ const emojiNames: Record<string, string> = { '👍': 'Thumbs up', '❤️': 'Heart', '🎉': 'Party popper' };
50
+
51
+ type Reaction = { emoji: string; by: string[] };
52
+ type Row = { id: string; from: string; at: Date; text: string; reactions: Reaction[] };
53
+
54
+ const firstThread: Row[] = [
55
+ {
56
+ id: 'm1',
57
+ from: 'Ben Carter',
58
+ at: new Date('2025-01-15T11:40:00Z'),
59
+ text: 'The pricing page is live.',
60
+ reactions: [
61
+ { emoji: '👍', by: ['Omar Reyes', me] },
62
+ { emoji: '🎉', by: ['Omar Reyes'] },
63
+ ],
64
+ },
65
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },
66
+ ];
67
+
68
+ const firstName = (name: string) => name.split(' ')[0];
69
+
70
+ // 'Omar and you': other people by first name, the person last.
71
+ function whoReacted(by: string[]) {
72
+ const names = [...by.filter((n) => n !== me).map(firstName), ...(by.includes(me) ? ['you'] : [])];
73
+ if (names.length === 1) return names[0] === 'you' ? 'You' : names[0];
74
+ return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
75
+ }
76
+
77
+ // 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.
78
+ function chipName(r: Reaction) {
79
+ const count = `${r.by.length} ${r.by.length === 1 ? 'reaction' : 'reactions'}`;
80
+ return `${emojiNames[r.emoji]}, ${count}`;
81
+ }
82
+
83
+ export default function MessageReactionsChips() {
84
+ const [thread, setThread] = useState(firstThread);
85
+ // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.
86
+ const addButtons = useRef<Record<string, HTMLButtonElement | HTMLAnchorElement | null>>({});
87
+ const focusAdd = useRef<string | null>(null);
88
+
89
+ useEffect(() => {
90
+ if (!focusAdd.current) return;
91
+ addButtons.current[focusAdd.current]?.focus();
92
+ focusAdd.current = null;
93
+ });
94
+
95
+ // The count changes at once. A real app sends the change to the server and puts it back if that fails.
96
+ function toggle(rowId: string, emoji: string) {
97
+ const row = thread.find((m) => m.id === rowId);
98
+ const chip = row?.reactions.find((r) => r.emoji === emoji);
99
+ // The person's reaction was the last one, so the chip goes away.
100
+ if (chip && chip.by.length === 1 && chip.by[0] === me) focusAdd.current = rowId;
101
+ setThread((rows) =>
102
+ rows.map((m) => {
103
+ if (m.id !== rowId) return m;
104
+ const has = m.reactions.find((r) => r.emoji === emoji);
105
+ const reactions = has
106
+ ? m.reactions.map((r) =>
107
+ r.emoji !== emoji ? r : { ...r, by: r.by.includes(me) ? r.by.filter((n) => n !== me) : [...r.by, me] },
108
+ )
109
+ : [...m.reactions, { emoji, by: [me] }];
110
+ // A chip with no reactions left goes away.
111
+ return { ...m, reactions: reactions.filter((r) => r.by.length > 0) };
112
+ }),
113
+ );
114
+ }
115
+
116
+ return (
117
+ <Center width="page">
118
+ <Stack gap="large">
119
+ <Heading level={1} size="h5">Launch plan</Heading>
120
+ {/* A real app gives the list that holds the rows role="log". */}
121
+ <Stack gap="small">
122
+ {thread.map((m) => (
123
+ <Message
124
+ key={m.id}
125
+ aria-label={m.from}
126
+ avatar={<UserImage userHandle={m.from} decorative />}
127
+ name={m.from}
128
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
129
+ footer={
130
+ <Cluster gap="small">
131
+ {m.reactions.map((r) => (
132
+ <Tooltip key={r.emoji} title={whoReacted(r.by)}>
133
+ <Tag
134
+ variant="contained"
135
+ size="small"
136
+ state={r.by.includes(me) ? 'selected' : 'enabled'}
137
+ label={`${r.emoji} ${r.by.length}`}
138
+ aria-label={chipName(r)}
139
+ onClick={() => toggle(m.id, r.emoji)}
140
+ />
141
+ </Tooltip>
142
+ ))}
143
+ {/* A real app opens the quick pick here, as the option 'Quick pick' shows; this one adds a heart. */}
144
+ <Tooltip title="Add reaction">
145
+ <IconButton
146
+ color="iconOnly"
147
+ state="enabled"
148
+ size="small"
149
+ ref={(el) => { addButtons.current[m.id] = el; }}
150
+ iconName="SmilePlus"
151
+ ariaLabel={`Add reaction to message from ${m.from}`}
152
+ onClick={() => {
153
+ if (!m.reactions.some((r) => r.emoji === '❤️' && r.by.includes(me))) toggle(m.id, '❤️');
154
+ }}
155
+ />
156
+ </Tooltip>
157
+ </Cluster>
158
+ }
159
+ >
160
+ <Paragraph measure="none">{m.text}</Paragraph>
161
+ </Message>
162
+ ))}
163
+ </Stack>
164
+ </Stack>
165
+ </Center>
166
+ );
167
+ }
168
+ ```
169
+
170
+ ## Option: Quick pick
171
+
172
+ Use when: A person adds a reaction from the six emoji people use most.
173
+
174
+ Uses: `Center`, `Cluster`, `Heading`, `IconButton`, `Menu`, `MenuItem`, `Message`, `Paragraph`, `Popover`, `Stack`, `Tag`, `TimeStamp`, `Tooltip`, `UserImage`
175
+
176
+ ```tsx
177
+ 'use client';
178
+ import { useEffect, useRef, useState } from 'react';
179
+ import Message from 'oneslash-design-system/components/message';
180
+ import UserImage from 'oneslash-design-system/components/userImage';
181
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
182
+ import Heading from 'oneslash-design-system/components/heading';
183
+ import Paragraph from 'oneslash-design-system/components/paragraph';
184
+ import Tag from 'oneslash-design-system/components/tag';
185
+ import IconButton from 'oneslash-design-system/components/iconButton';
186
+ import Tooltip from 'oneslash-design-system/components/tooltip';
187
+ import Popover from 'oneslash-design-system/components/popover';
188
+ import Menu from 'oneslash-design-system/components/menu';
189
+ import MenuItem from 'oneslash-design-system/components/menuItem';
190
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
191
+
192
+ // A real app reads this from the session.
193
+ const me = 'Dana Lee';
194
+
195
+ // The six emoji people use most, each named in words. ODS has no full emoji picker yet.
196
+ const quickEmoji = [
197
+ { emoji: '👍', name: 'Thumbs up' },
198
+ { emoji: '❤️', name: 'Heart' },
199
+ { emoji: '😂', name: 'Tears of joy' },
200
+ { emoji: '🎉', name: 'Party popper' },
201
+ { emoji: '👀', name: 'Eyes' },
202
+ { emoji: '🚀', name: 'Rocket' },
203
+ ];
204
+ const emojiName = (emoji: string) => quickEmoji.find((q) => q.emoji === emoji)?.name ?? emoji;
205
+
206
+ type Reaction = { emoji: string; by: string[] };
207
+ type Row = { id: string; from: string; at: Date; text: string; reactions: Reaction[] };
208
+
209
+ const firstThread: Row[] = [
210
+ {
211
+ id: 'm1',
212
+ from: 'Ben Carter',
213
+ at: new Date('2025-01-15T11:40:00Z'),
214
+ text: 'The pricing page is live.',
215
+ reactions: [{ emoji: '👍', by: ['Omar Reyes', me] }],
216
+ },
217
+ { id: 'm2', from: 'Omar Reyes', at: new Date('2025-01-15T11:42:00Z'), text: 'Nice work. I will share it with the sales team.', reactions: [] },
218
+ ];
219
+
220
+ const firstName = (name: string) => name.split(' ')[0];
221
+
222
+ // 'Omar and you': other people by first name, the person last.
223
+ function whoReacted(by: string[]) {
224
+ const names = [...by.filter((n) => n !== me).map(firstName), ...(by.includes(me) ? ['you'] : [])];
225
+ if (names.length === 1) return names[0] === 'you' ? 'You' : names[0];
226
+ return `${names.slice(0, -1).join(', ')} and ${names[names.length - 1]}`;
227
+ }
228
+
229
+ // 'Thumbs up, 3 reactions'. The chip's aria-pressed says whether the person reacted.
230
+ function chipName(r: Reaction) {
231
+ const count = `${r.by.length} ${r.by.length === 1 ? 'reaction' : 'reactions'}`;
232
+ return `${emojiName(r.emoji)}, ${count}`;
233
+ }
234
+
235
+ export default function MessageReactionsQuickPick() {
236
+ const [thread, setThread] = useState(firstThread);
237
+ // Each row's 'Add reaction' button by row id. When the chip that had focus goes away, focus goes there.
238
+ const addButtons = useRef<Record<string, HTMLButtonElement | HTMLAnchorElement | null>>({});
239
+ const focusAdd = useRef<string | null>(null);
240
+
241
+ useEffect(() => {
242
+ if (!focusAdd.current) return;
243
+ addButtons.current[focusAdd.current]?.focus();
244
+ focusAdd.current = null;
245
+ });
246
+ // The row whose quick pick is open, and the button it opens from. Both stay set while it fades out.
247
+ const [pickRow, setPickRow] = useState<Row | null>(null);
248
+ const [pickAnchor, setPickAnchor] = useState<HTMLElement | null>(null);
249
+ const [pickOpen, setPickOpen] = useState(false);
250
+
251
+ // The count changes at once. A real app sends the change to the server and puts it back if that fails.
252
+ function toggle(rowId: string, emoji: string) {
253
+ const row = thread.find((m) => m.id === rowId);
254
+ const chip = row?.reactions.find((r) => r.emoji === emoji);
255
+ // The person's reaction was the last one, so the chip goes away.
256
+ if (chip && chip.by.length === 1 && chip.by[0] === me) focusAdd.current = rowId;
257
+ setThread((rows) =>
258
+ rows.map((m) => {
259
+ if (m.id !== rowId) return m;
260
+ const has = m.reactions.find((r) => r.emoji === emoji);
261
+ const reactions = has
262
+ ? m.reactions.map((r) =>
263
+ r.emoji !== emoji ? r : { ...r, by: r.by.includes(me) ? r.by.filter((n) => n !== me) : [...r.by, me] },
264
+ )
265
+ : [...m.reactions, { emoji, by: [me] }];
266
+ // A chip with no reactions left goes away.
267
+ return { ...m, reactions: reactions.filter((r) => r.by.length > 0) };
268
+ }),
269
+ );
270
+ }
271
+
272
+ function openPick(m: Row, anchor: HTMLElement) {
273
+ if (pickOpen && pickRow?.id === m.id) {
274
+ setPickOpen(false);
275
+ return;
276
+ }
277
+ setPickRow(m);
278
+ setPickAnchor(anchor);
279
+ setPickOpen(true);
280
+ }
281
+
282
+ // Escape, a click outside and a pick close it. Popover's returnFocus gives focus back to 'Add reaction'.
283
+ function closePick() {
284
+ setPickOpen(false);
285
+ }
286
+
287
+ function pick(emoji: string) {
288
+ if (!pickRow) return;
289
+ closePick();
290
+ toggle(pickRow.id, emoji);
291
+ }
292
+
293
+ // The open row, read from the thread so the quick pick shows its reactions as they are now.
294
+ const openRow = thread.find((m) => m.id === pickRow?.id);
295
+
296
+ return (
297
+ <Center width="page">
298
+ <Stack gap="large">
299
+ <Heading level={1} size="h5">Launch plan</Heading>
300
+ {/* A real app gives the list that holds the rows role="log". */}
301
+ <Stack gap="small">
302
+ {thread.map((m) => (
303
+ <Message
304
+ key={m.id}
305
+ aria-label={m.from}
306
+ avatar={<UserImage userHandle={m.from} decorative />}
307
+ name={m.from}
308
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
309
+ footer={
310
+ <Cluster gap="small">
311
+ {m.reactions.map((r) => (
312
+ <Tooltip key={r.emoji} title={whoReacted(r.by)}>
313
+ <Tag
314
+ variant="contained"
315
+ size="small"
316
+ state={r.by.includes(me) ? 'selected' : 'enabled'}
317
+ label={`${r.emoji} ${r.by.length}`}
318
+ aria-label={chipName(r)}
319
+ onClick={() => toggle(m.id, r.emoji)}
320
+ />
321
+ </Tooltip>
322
+ ))}
323
+ <Tooltip title="Add reaction">
324
+ <IconButton
325
+ color="iconOnly"
326
+ state={pickOpen && pickRow?.id === m.id ? 'selected' : 'enabled'}
327
+ size="small"
328
+ ref={(el) => { addButtons.current[m.id] = el; }}
329
+ iconName="SmilePlus"
330
+ ariaLabel={`Add reaction to message from ${m.from}`}
331
+ aria-haspopup="menu"
332
+ aria-expanded={pickOpen && pickRow?.id === m.id}
333
+ onClick={(e: { currentTarget: HTMLElement }) => openPick(m, e.currentTarget)}
334
+ />
335
+ </Tooltip>
336
+ </Cluster>
337
+ }
338
+ >
339
+ <Paragraph measure="none">{m.text}</Paragraph>
340
+ </Message>
341
+ ))}
342
+ </Stack>
343
+ </Stack>
344
+ {/* A navigable Menu focuses its first item and takes the arrow keys, Home, End and letters. */}
345
+ <Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>
346
+ <Menu navigable aria-label="Add reaction" width={200}>
347
+ {quickEmoji.map((q) => (
348
+ <MenuItem
349
+ key={q.emoji}
350
+ size="small"
351
+ icon={q.emoji}
352
+ label={q.name}
353
+ // Picking an emoji the person already used removes it.
354
+ tag={openRow?.reactions.some((r) => r.emoji === q.emoji && r.by.includes(me)) ? { label: 'Added', variant: 'textOnly' } : undefined}
355
+ onClick={() => pick(q.emoji)}
356
+ />
357
+ ))}
358
+ </Menu>
359
+ </Popover>
360
+ </Center>
361
+ );
362
+ }
363
+ ```
364
+
365
+ ## Native
366
+
367
+ On Apple a reaction is added from the row's `contextMenu`, with Add Reaction.
@@ -0,0 +1 @@
1
+ export default function MessageRowGrouped(): import("react").JSX.Element;
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+ import Message from '../../components/message';
3
+ import UserImage from '../../components/userImage';
4
+ import TimeStamp from '../../components/timeStamp';
5
+ import Heading from '../../components/heading';
6
+ import Paragraph from '../../components/paragraph';
7
+ import Line from '../../components/line';
8
+ import { Center, Stack } from '../../components/layout';
9
+ // A real app builds each date line from the message times, in the reader's time zone, and labels the
10
+ // days 'Today', 'Yesterday', or the full date with the year. These lines are fixed, so the times sit
11
+ // near midday UTC, where the date is the same in most time zones.
12
+ var days = [
13
+ {
14
+ label: 'Monday, January 13, 2025',
15
+ rows: [
16
+ { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-13T12:10:00Z'), text: 'I sent the pricing page draft to legal.' },
17
+ { id: 'm2', from: 'Ben Carter', at: new Date('2025-01-13T12:12:00Z'), text: 'They usually answer within a day.' },
18
+ ],
19
+ },
20
+ {
21
+ label: 'Today',
22
+ rows: [
23
+ { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:30:00Z'), text: 'Legal approved the pricing page.' },
24
+ { id: 'm4', from: 'Ben Carter', at: new Date('2025-01-15T11:31:00Z'), text: 'They asked for two small wording changes, both in the footer.' },
25
+ { id: 'm5', from: 'Ben Carter', at: new Date('2025-01-15T11:33:00Z'), text: 'I made them already.' },
26
+ { id: 'm6', from: 'Dana Lee', at: new Date('2025-01-15T11:45:00Z'), text: 'Thanks. I will publish it this afternoon.' },
27
+ ],
28
+ },
29
+ ];
30
+ var FIVE_MINUTES = 5 * 60 * 1000;
31
+ // A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.
32
+ function followsOn(rows, i) {
33
+ var prev = rows[i - 1];
34
+ return (!!prev &&
35
+ prev.from === rows[i].from &&
36
+ rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&
37
+ rows[i].at.toDateString() === prev.at.toDateString());
38
+ }
39
+ export default function MessageRowGrouped() {
40
+ return (<Center width="page">
41
+ <Stack gap="large">
42
+ <Heading level={1} size="h5">Launch plan</Heading>
43
+ {/* A real app gives the list that holds the rows role="log". */}
44
+ <Stack gap="medium">
45
+ {days.map(function (day) { return (<Stack key={day.label} gap="small">
46
+ <Line label={day.label}/>
47
+ {day.rows.map(function (m, i) { return (<Message key={m.id}
48
+ // A compact row shows no name, so its aria-label carries it.
49
+ aria-label={m.from} compact={followsOn(day.rows, i)} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}>
50
+ <Paragraph measure="none">{m.text}</Paragraph>
51
+ </Message>); })}
52
+ </Stack>); })}
53
+ </Stack>
54
+ </Stack>
55
+ </Center>);
56
+ }
@@ -0,0 +1 @@
1
+ export default function MessageRowPersonAndAgent(): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { Bot } from 'lucide-react';
3
+ import Message from '../../components/message';
4
+ import UserImage from '../../components/userImage';
5
+ import Tag from '../../components/tag';
6
+ import TimeStamp from '../../components/timeStamp';
7
+ import Heading from '../../components/heading';
8
+ import Paragraph from '../../components/paragraph';
9
+ import { Center, Stack } from '../../components/layout';
10
+ var thread = [
11
+ { id: 'm1', from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you list what is still open for the launch?' },
12
+ { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'Three tasks are open: the press kit, the pricing page and the launch email.' },
13
+ { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:44:00Z'), text: 'I can take the press kit.' },
14
+ ];
15
+ export default function MessageRowPersonAndAgent() {
16
+ return (<Center width="page">
17
+ <Stack gap="large">
18
+ <Heading level={1} size="h5">Launch plan</Heading>
19
+ {/* A real app gives the list that holds the rows role="log". */}
20
+ <Stack gap="small">
21
+ {thread.map(function (m) {
22
+ return m.agent ? (
23
+ // An agent's row: an icon avatar, its name, an 'Agent' tag, the time and the model line.
24
+ // The product's own agent shows the product's mark; an agent from outside shows a plain bot icon.
25
+ // Acme has no mark here, so Acme Agent uses Bot.
26
+ <Message key={m.id} aria-label={"".concat(m.from, ", agent")} avatar={<UserImage userHandle={m.from} icon={Bot} decorative/>} name={m.from} meta={<>
27
+ <Tag variant="contained" size="small" label="Agent"/>
28
+ <TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>
29
+ <Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
30
+ </>}>
31
+ <Paragraph measure="none">{m.text}</Paragraph>
32
+ </Message>) : (
33
+ // A person's row: their picture or initial, their name and the time.
34
+ <Message key={m.id} aria-label={m.from} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}>
35
+ <Paragraph measure="none">{m.text}</Paragraph>
36
+ </Message>);
37
+ })}
38
+ </Stack>
39
+ </Stack>
40
+ </Center>);
41
+ }
@@ -0,0 +1,185 @@
1
+ # Message row
2
+
3
+ A thread shows messages from people, and sometimes from an agent.
4
+
5
+ ## Do
6
+
7
+ - Show each row with `Message`: the sender's `UserImage`, their name and the time. A person's avatar is their picture or their initial.
8
+ - Pass `decorative` to the avatar, since the name beside it is already read.
9
+ - Mark an agent's row as the rule 'An agent says what it is' says: an icon avatar, its name, an 'Agent' `Tag` and the model line beside the time.
10
+ - Give an agent's avatar `UserImage` with `icon`: the product's own agent shows the product's mark, and an agent from outside shows a plain `Bot` icon.
11
+ - Write the model line in small secondary text, such as `<Paragraph size="caption" tone="secondary">`, when the product knows the model.
12
+ - Show the time with `<TimeStamp dateFormat="absolute" data="time">`. The date line says the day.
13
+ - Make a row `compact` when the row above is from the same sender, less than 5 minutes older and on the same day.
14
+ - Put a date line between days, a `Line` with a `label` that reads 'Today', 'Yesterday', or the full date with the year: 'Monday, January 13, 2025'.
15
+ - Pass an `aria-label` that names the sender on every row, compact ones too: 'Dana Lee', or 'Acme Agent, agent'. The time is in the row.
16
+ - Give the list that holds the rows `role="log"`, so a screen reader reads new messages as they arrive.
17
+ - Write an agent's text as plain sentences in `Paragraph`.
18
+
19
+ ## Don't
20
+
21
+ - Do not show a photo or an initial for an agent.
22
+ - Do not group rows from two senders, or rows from two days. The first row after a date line shows its header.
23
+ - Do not leave the `aria-label` off a compact row. It shows no name.
24
+ - Do not put the agent's model in its name. It goes on the model line.
25
+
26
+ ## Option: People and an agent
27
+
28
+ Use when: A thread with gaps between messages: every row shows who and when.
29
+
30
+ Uses: `Center`, `Heading`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
31
+
32
+ ```tsx
33
+ 'use client';
34
+ import { Bot } from 'lucide-react';
35
+ import Message from 'oneslash-design-system/components/message';
36
+ import UserImage from 'oneslash-design-system/components/userImage';
37
+ import Tag from 'oneslash-design-system/components/tag';
38
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
39
+ import Heading from 'oneslash-design-system/components/heading';
40
+ import Paragraph from 'oneslash-design-system/components/paragraph';
41
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
42
+
43
+ type Row = { id: string; from: string; agent?: boolean; at: Date; text: string };
44
+
45
+ const thread: Row[] = [
46
+ { id: 'm1', from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you list what is still open for the launch?' },
47
+ { id: 'm2', from: 'Acme Agent', agent: true, at: new Date('2025-01-15T11:41:00Z'), text: 'Three tasks are open: the press kit, the pricing page and the launch email.' },
48
+ { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:44:00Z'), text: 'I can take the press kit.' },
49
+ ];
50
+
51
+ export default function MessageRowPersonAndAgent() {
52
+ return (
53
+ <Center width="page">
54
+ <Stack gap="large">
55
+ <Heading level={1} size="h5">Launch plan</Heading>
56
+ {/* A real app gives the list that holds the rows role="log". */}
57
+ <Stack gap="small">
58
+ {thread.map((m) =>
59
+ m.agent ? (
60
+ // An agent's row: an icon avatar, its name, an 'Agent' tag, the time and the model line.
61
+ // The product's own agent shows the product's mark; an agent from outside shows a plain bot icon.
62
+ // Acme has no mark here, so Acme Agent uses Bot.
63
+ <Message
64
+ key={m.id}
65
+ aria-label={`${m.from}, agent`}
66
+ avatar={<UserImage userHandle={m.from} icon={Bot} decorative />}
67
+ name={m.from}
68
+ meta={
69
+ <>
70
+ <Tag variant="contained" size="small" label="Agent" />
71
+ <TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />
72
+ <Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
73
+ </>
74
+ }
75
+ >
76
+ <Paragraph measure="none">{m.text}</Paragraph>
77
+ </Message>
78
+ ) : (
79
+ // A person's row: their picture or initial, their name and the time.
80
+ <Message
81
+ key={m.id}
82
+ aria-label={m.from}
83
+ avatar={<UserImage userHandle={m.from} decorative />}
84
+ name={m.from}
85
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
86
+ >
87
+ <Paragraph measure="none">{m.text}</Paragraph>
88
+ </Message>
89
+ ),
90
+ )}
91
+ </Stack>
92
+ </Stack>
93
+ </Center>
94
+ );
95
+ }
96
+ ```
97
+
98
+ ## Option: Grouped rows
99
+
100
+ Use when: A busy thread: follow-on rows from one sender drop the avatar and the name.
101
+
102
+ Uses: `Center`, `Heading`, `Line`, `Message`, `Paragraph`, `Stack`, `TimeStamp`, `UserImage`
103
+
104
+ ```tsx
105
+ 'use client';
106
+ import Message from 'oneslash-design-system/components/message';
107
+ import UserImage from 'oneslash-design-system/components/userImage';
108
+ import TimeStamp from 'oneslash-design-system/components/timeStamp';
109
+ import Heading from 'oneslash-design-system/components/heading';
110
+ import Paragraph from 'oneslash-design-system/components/paragraph';
111
+ import Line from 'oneslash-design-system/components/line';
112
+ import { Center, Stack } from 'oneslash-design-system/components/layout';
113
+
114
+ type Row = { id: string; from: string; at: Date; text: string };
115
+
116
+ // A real app builds each date line from the message times, in the reader's time zone, and labels the
117
+ // days 'Today', 'Yesterday', or the full date with the year. These lines are fixed, so the times sit
118
+ // near midday UTC, where the date is the same in most time zones.
119
+ const days: { label: string; rows: Row[] }[] = [
120
+ {
121
+ label: 'Monday, January 13, 2025',
122
+ rows: [
123
+ { id: 'm1', from: 'Ben Carter', at: new Date('2025-01-13T12:10:00Z'), text: 'I sent the pricing page draft to legal.' },
124
+ { id: 'm2', from: 'Ben Carter', at: new Date('2025-01-13T12:12:00Z'), text: 'They usually answer within a day.' },
125
+ ],
126
+ },
127
+ {
128
+ label: 'Today',
129
+ rows: [
130
+ { id: 'm3', from: 'Ben Carter', at: new Date('2025-01-15T11:30:00Z'), text: 'Legal approved the pricing page.' },
131
+ { id: 'm4', from: 'Ben Carter', at: new Date('2025-01-15T11:31:00Z'), text: 'They asked for two small wording changes, both in the footer.' },
132
+ { id: 'm5', from: 'Ben Carter', at: new Date('2025-01-15T11:33:00Z'), text: 'I made them already.' },
133
+ { id: 'm6', from: 'Dana Lee', at: new Date('2025-01-15T11:45:00Z'), text: 'Thanks. I will publish it this afternoon.' },
134
+ ],
135
+ },
136
+ ];
137
+
138
+ const FIVE_MINUTES = 5 * 60 * 1000;
139
+
140
+ // A follow-on row: the same sender as the row above, less than 5 minutes later and on the same day.
141
+ function followsOn(rows: Row[], i: number) {
142
+ const prev = rows[i - 1];
143
+ return (
144
+ !!prev &&
145
+ prev.from === rows[i].from &&
146
+ rows[i].at.getTime() - prev.at.getTime() < FIVE_MINUTES &&
147
+ rows[i].at.toDateString() === prev.at.toDateString()
148
+ );
149
+ }
150
+
151
+ export default function MessageRowGrouped() {
152
+ return (
153
+ <Center width="page">
154
+ <Stack gap="large">
155
+ <Heading level={1} size="h5">Launch plan</Heading>
156
+ {/* A real app gives the list that holds the rows role="log". */}
157
+ <Stack gap="medium">
158
+ {days.map((day) => (
159
+ <Stack key={day.label} gap="small">
160
+ <Line label={day.label} />
161
+ {day.rows.map((m, i) => (
162
+ <Message
163
+ key={m.id}
164
+ // A compact row shows no name, so its aria-label carries it.
165
+ aria-label={m.from}
166
+ compact={followsOn(day.rows, i)}
167
+ avatar={<UserImage userHandle={m.from} decorative />}
168
+ name={m.from}
169
+ meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
170
+ >
171
+ <Paragraph measure="none">{m.text}</Paragraph>
172
+ </Message>
173
+ ))}
174
+ </Stack>
175
+ ))}
176
+ </Stack>
177
+ </Stack>
178
+ </Center>
179
+ );
180
+ }
181
+ ```
182
+
183
+ ## Native
184
+
185
+ On Apple a row shows the avatar, the name and the time, with an 'Agent' label next to an agent's name.
@@ -2,8 +2,6 @@
2
2
 
3
3
  A person opens a link to a page that does not exist.
4
4
 
5
- **Not built yet:** Commentify's page not found is one line of bare text, 'Page not found.', with no way home. Scindo on the web shows '404' as its heading, then bare text and a text link home. jinhwankim.com has no heading: it puts '404:' at the start of its `EmptyBox` text and labels its Button 'Go to Home'.
6
-
7
5
  ## Do
8
6
 
9
7
  - Say 'Page not found' in a `Heading` with `level={1}`.
@@ -94,5 +92,3 @@ export default function NotFoundPageInShell() {
94
92
  );
95
93
  }
96
94
  ```
97
-
98
- Seen in: Commentify, Scindo, jinhwankim.com.