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