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.
- package/README.md +2 -2
- package/dist/DESIGN.md +56 -17
- package/dist/cases/accept-invite/signed-in.jsx +1 -1
- package/dist/cases/accept-invite/signed-out.jsx +1 -1
- package/dist/cases/accept-invite.md +3 -7
- package/dist/cases/account-menu/menu.d.ts +1 -0
- package/dist/cases/account-menu/menu.jsx +99 -0
- package/dist/cases/account-menu.md +164 -0
- package/dist/cases/agent-asks-before-risky-action.md +0 -4
- package/dist/cases/agent-cancels-when-unanswered.md +0 -4
- 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 +164 -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 +428 -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 +652 -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 +334 -0
- package/dist/cases/agent-refuses-clearly.md +0 -4
- package/dist/cases/agent-says-what-it-is.md +0 -2
- package/dist/cases/agent-settings/form.d.ts +1 -0
- package/dist/cases/agent-settings/form.jsx +164 -0
- package/dist/cases/agent-settings.md +259 -0
- package/dist/cases/agent-shows-progress.md +0 -2
- package/dist/cases/agent-shows-sources.md +2 -4
- package/dist/cases/api-keys/list.d.ts +1 -0
- package/dist/cases/api-keys/list.jsx +162 -0
- package/dist/cases/api-keys.md +229 -0
- 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 +99 -0
- package/dist/cases/auth-gate-loading.md +0 -4
- package/dist/cases/check-your-email.md +0 -4
- package/dist/cases/collapsible-search/popover.d.ts +1 -0
- package/dist/cases/collapsible-search/popover.jsx +74 -0
- package/dist/cases/collapsible-search.md +143 -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 +282 -0
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- 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 +204 -0
- package/dist/cases/create-modal.md +0 -4
- package/dist/cases/danger-zone/collapsed.d.ts +1 -0
- package/dist/cases/danger-zone/collapsed.jsx +75 -0
- package/dist/cases/danger-zone/shown.d.ts +1 -0
- package/dist/cases/danger-zone/shown.jsx +95 -0
- package/dist/cases/danger-zone.md +263 -0
- package/dist/cases/device-login.md +0 -4
- package/dist/cases/email-confirmed.md +0 -4
- package/dist/cases/empty-list.md +0 -4
- package/dist/cases/empty-lists.md +0 -4
- package/dist/cases/empty-not-set-up.md +0 -4
- package/dist/cases/empty-search.md +0 -4
- package/dist/cases/error-page.md +0 -4
- package/dist/cases/feedback-form.md +0 -4
- package/dist/cases/filter-menu/presets.d.ts +1 -0
- package/dist/cases/filter-menu/presets.jsx +53 -0
- package/dist/cases/filter-menu/with-clear.d.ts +1 -0
- package/dist/cases/filter-menu/with-clear.jsx +56 -0
- package/dist/cases/filter-menu.md +204 -0
- package/dist/cases/forgot-password.md +0 -4
- package/dist/cases/form-errors.md +0 -4
- package/dist/cases/import-checklist.md +0 -4
- package/dist/cases/inline-form-feedback.md +0 -4
- package/dist/cases/integrations-list/nested.d.ts +1 -0
- package/dist/cases/integrations-list/nested.jsx +164 -0
- package/dist/cases/integrations-list/rows.d.ts +1 -0
- package/dist/cases/integrations-list/rows.jsx +134 -0
- package/dist/cases/integrations-list.md +379 -0
- package/dist/cases/invite-member.md +0 -4
- package/dist/cases/load-failure.md +0 -4
- package/dist/cases/log-out-confirm.md +0 -4
- package/dist/cases/login-page.md +0 -4
- package/dist/cases/members-list/rows.d.ts +1 -0
- package/dist/cases/members-list/rows.jsx +318 -0
- package/dist/cases/members-list/table.d.ts +1 -0
- package/dist/cases/members-list/table.jsx +351 -0
- package/dist/cases/members-list.md +799 -0
- 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 +248 -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 +647 -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 +306 -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 +352 -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 +175 -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 +367 -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 +185 -0
- package/dist/cases/not-found-page.md +0 -4
- package/dist/cases/notification-menu/menu.d.ts +1 -0
- package/dist/cases/notification-menu/menu.jsx +74 -0
- package/dist/cases/notification-menu.md +135 -0
- package/dist/cases/oauth-consent.md +0 -4
- package/dist/cases/on-off-settings/list.d.ts +1 -0
- package/dist/cases/on-off-settings/list.jsx +97 -0
- package/dist/cases/on-off-settings.md +116 -0
- package/dist/cases/overflow-menu/in-a-header.d.ts +1 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +128 -0
- package/dist/cases/overflow-menu/on-a-row.d.ts +1 -0
- package/dist/cases/overflow-menu/on-a-row.jsx +183 -0
- package/dist/cases/overflow-menu.md +410 -0
- package/dist/cases/profile-form/form.d.ts +1 -0
- package/dist/cases/profile-form/form.jsx +153 -0
- package/dist/cases/profile-form.md +236 -0
- package/dist/cases/quick-switcher/modal.d.ts +1 -0
- package/dist/cases/quick-switcher/modal.jsx +114 -0
- package/dist/cases/quick-switcher.md +205 -0
- package/dist/cases/range-switch/segmented.d.ts +1 -0
- package/dist/cases/range-switch/segmented.jsx +30 -0
- package/dist/cases/range-switch.md +67 -0
- package/dist/cases/rename.md +0 -4
- 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 +548 -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 +243 -0
- package/dist/cases/route-loading.md +0 -2
- package/dist/cases/scope-picker/menu.d.ts +1 -0
- package/dist/cases/scope-picker/menu.jsx +47 -0
- package/dist/cases/scope-picker.md +97 -0
- package/dist/cases/set-new-password.md +0 -4
- package/dist/cases/settings-page/side-nav.d.ts +1 -0
- package/dist/cases/settings-page/side-nav.jsx +171 -0
- package/dist/cases/settings-page/top-tabs.d.ts +1 -0
- package/dist/cases/settings-page/top-tabs.jsx +129 -0
- package/dist/cases/settings-page.md +378 -0
- package/dist/cases/settings-save.md +35 -0
- package/dist/cases/sign-up-page.md +1 -5
- 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 +243 -0
- package/dist/cases/success-feedback.md +1 -5
- package/dist/cases/tag-filter/tags.d.ts +1 -0
- package/dist/cases/tag-filter/tags.jsx +226 -0
- package/dist/cases/tag-filter.md +298 -0
- package/dist/cases/type-to-confirm.md +0 -4
- 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 +92 -0
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +2331 -294
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/button.d.ts +3 -2
- package/dist/components/button.jsx +14 -9
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/composer.d.ts +74 -0
- package/dist/components/composer.jsx +122 -0
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/fileChip.d.ts +33 -0
- package/dist/components/fileChip.jsx +61 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +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/menu.d.ts +21 -0
- package/dist/components/menu.jsx +27 -3
- package/dist/components/menuItem.d.ts +12 -2
- package/dist/components/menuItem.jsx +6 -5
- package/dist/components/message.d.ts +28 -0
- package/dist/components/message.jsx +25 -0
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- 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 +12 -1
- package/dist/components/radioGroup.jsx +20 -9
- package/dist/components/segmentedControl.d.ts +22 -0
- package/dist/components/segmentedControl.jsx +54 -0
- package/dist/components/select.d.ts +5 -1
- package/dist/components/select.jsx +2 -2
- package/dist/components/settingsSection.d.ts +31 -0
- package/dist/components/settingsSection.jsx +58 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -0
- 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/switch.d.ts +25 -0
- package/dist/components/switch.jsx +55 -0
- package/dist/components/tab.jsx +5 -11
- package/dist/components/tabsContainer.jsx +5 -67
- package/dist/components/tag.d.ts +9 -1
- package/dist/components/tag.jsx +6 -4
- package/dist/components/textField.d.ts +12 -2
- package/dist/components/textField.jsx +11 -4
- package/dist/components/textarea.d.ts +5 -1
- package/dist/components/textarea.jsx +6 -21
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/components/userImage.d.ts +9 -1
- package/dist/components/userImage.jsx +10 -3
- package/dist/index.d.ts +6 -0
- package/dist/index.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/copyField.d.ts +5 -0
- package/dist/internal/copyField.js +61 -0
- package/dist/internal/hotkey.d.ts +16 -0
- package/dist/internal/hotkey.js +20 -0
- package/dist/internal/menu.d.ts +6 -0
- package/dist/internal/menu.js +31 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +62 -1
- 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 +53 -0
- package/dist/stories/Cases.generated.stories.jsx +106 -0
- package/dist/stories/Composer.stories.d.ts +23 -0
- package/dist/stories/Composer.stories.jsx +121 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/FileChip.stories.d.ts +7 -0
- package/dist/stories/FileChip.stories.jsx +35 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/IconButton.stories.d.ts +1 -0
- package/dist/stories/IconButton.stories.jsx +18 -1
- 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/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/PageComponents.stories.d.ts +1 -0
- package/dist/stories/PageComponents.stories.jsx +21 -0
- package/dist/stories/RadioGroup.stories.d.ts +2 -0
- package/dist/stories/RadioGroup.stories.jsx +40 -1
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +11 -0
- package/dist/stories/SettingsSection.stories.jsx +64 -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/Switch.stories.d.ts +14 -0
- package/dist/stories/Switch.stories.jsx +87 -0
- package/dist/stories/TextField.stories.d.ts +1 -0
- package/dist/stories/TextField.stories.jsx +13 -0
- package/dist/stories/UserImage.stories.d.ts +2 -0
- package/dist/stories/UserImage.stories.jsx +19 -0
- package/package.json +8 -3
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Bot, Plug } 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, Cluster, Stack } from '../../components/layout';
|
|
10
|
+
var agentName = 'Acme Agent';
|
|
11
|
+
var thread = [
|
|
12
|
+
{ from: 'Ben Carter', at: new Date('2025-01-15T11:36:00Z'), text: 'Testing needs two more weeks. It now ends on January 31.' },
|
|
13
|
+
{ from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Acme Agent, what does that do to the launch date?' },
|
|
14
|
+
];
|
|
15
|
+
var repliedAt = new Date('2025-01-15T11:41:00Z');
|
|
16
|
+
// The agent read only the messages above, which the person can already see.
|
|
17
|
+
var reply = 'If testing ends on January 31, the launch moves to March 3. That keeps the two weeks Ben asked for.';
|
|
18
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
19
|
+
function agentMeta(at) {
|
|
20
|
+
return (<>
|
|
21
|
+
<Tag variant="contained" size="small" label="Agent"/>
|
|
22
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time"/>
|
|
23
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
24
|
+
</>);
|
|
25
|
+
}
|
|
26
|
+
export default function ReplySourcesTagOnly() {
|
|
27
|
+
return (<Center width="page">
|
|
28
|
+
<Stack gap="large">
|
|
29
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
30
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
31
|
+
<Stack gap="small">
|
|
32
|
+
{thread.map(function (m) { return (<Message key={m.from} aria-label={m.from} avatar={<UserImage userHandle={m.from} decorative/>} name={m.from} meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time"/>}>
|
|
33
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
34
|
+
</Message>); })}
|
|
35
|
+
<Message aria-label={"".concat(agentName, ", agent")} avatar={<UserImage userHandle={agentName} icon={Bot} decorative/>} name={agentName} meta={agentMeta(repliedAt)}
|
|
36
|
+
// One kind of source, already on screen: the tag says where the answer came from, and no cards follow.
|
|
37
|
+
footer={<Cluster>
|
|
38
|
+
<Tag variant="contained" size="small" color="success" icon={Plug} label="From Chat"/>
|
|
39
|
+
</Cluster>}>
|
|
40
|
+
<Paragraph measure="none">{reply}</Paragraph>
|
|
41
|
+
</Message>
|
|
42
|
+
</Stack>
|
|
43
|
+
</Stack>
|
|
44
|
+
</Center>);
|
|
45
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
# Reply sources
|
|
2
|
+
|
|
3
|
+
The agent answered from things it read, and the person may want to check them.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'An agent shows its sources': put the sources in the reply's `footer`, directly under the reply.
|
|
8
|
+
- Name the kinds of source in one `Tag`, in the order they first appear: 'From Chat · Knowledge base'.
|
|
9
|
+
- Show each source as a `SourceCard` with an icon for its kind, its title, and in `meta` its kind and where it lives: 'Chat · #launch · Jan 12'.
|
|
10
|
+
- Lay the cards out in `<Grid columns={2}>` and show the first six.
|
|
11
|
+
- Show the rest with a text-only 'Show N More' Button, with the number of hidden cards. It then reads 'Show Fewer', which hides them again.
|
|
12
|
+
- Make a card the person can open a link with `href`. A source on another site opens in a new tab.
|
|
13
|
+
- Make a card the person cannot open static, with no `href` and no `onClick`, and say why in `meta`: 'Chat · Private channel you are not in'.
|
|
14
|
+
- Keep a static card's look at rest the same as the others'. It has no hover look.
|
|
15
|
+
- Link each card to its own source, such as the message it read. Two cards never share a link.
|
|
16
|
+
- Show only the `Tag` when the reply read only the messages already on screen above it, as the rule allows.
|
|
17
|
+
- Show no sources section when the reply used no sources.
|
|
18
|
+
- Mark the agent's row as the rule 'An agent says what it is' says.
|
|
19
|
+
- Give the list that holds the rows `role="log"`.
|
|
20
|
+
|
|
21
|
+
## Don't
|
|
22
|
+
|
|
23
|
+
- Do not show sources on a person's message.
|
|
24
|
+
- Do not link a card to any site other than the product or the service the source came from.
|
|
25
|
+
- Do not make a card look clickable when the person cannot open it.
|
|
26
|
+
- Do not show more than six cards before the person asks for the rest.
|
|
27
|
+
|
|
28
|
+
## Option: Source cards
|
|
29
|
+
|
|
30
|
+
Use when: The reply read things a person can open.
|
|
31
|
+
|
|
32
|
+
Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `Message`, `Paragraph`, `SourceCard`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
'use client';
|
|
36
|
+
import { useState } from 'react';
|
|
37
|
+
import { BookOpen, Bot, MessageSquare, Plug } from 'lucide-react';
|
|
38
|
+
import Message from 'oneslash-design-system/components/message';
|
|
39
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
40
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
41
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
42
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
43
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
44
|
+
import Button from 'oneslash-design-system/components/button';
|
|
45
|
+
import SourceCard from 'oneslash-design-system/components/sourceCard';
|
|
46
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
47
|
+
|
|
48
|
+
const agentName = 'Acme Agent';
|
|
49
|
+
|
|
50
|
+
const request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'What did we decide about the launch date?' };
|
|
51
|
+
const repliedAt = new Date('2025-01-15T11:41:00Z');
|
|
52
|
+
const reply = 'The launch moved to March 3. Ben asked for two more weeks of testing, and the team agreed in #launch on Jan 12.';
|
|
53
|
+
|
|
54
|
+
type Kind = 'chat' | 'kb';
|
|
55
|
+
// A source with no href is one the person cannot open: its meta says why. Each chat card links to the message it read.
|
|
56
|
+
type Source = { kind: Kind; title: string; where: string; href?: string };
|
|
57
|
+
|
|
58
|
+
const kinds = {
|
|
59
|
+
chat: { label: 'Chat', icon: MessageSquare },
|
|
60
|
+
kb: { label: 'Knowledge base', icon: BookOpen },
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const sources: Source[] = [
|
|
64
|
+
{ kind: 'chat', title: 'Launch date', where: '#launch · Jan 12', href: '/chat/launch/m-1042' },
|
|
65
|
+
{ kind: 'kb', title: 'Launch plan 2025', where: 'Acme Design', href: '/docs/launch-plan-2025' },
|
|
66
|
+
{ kind: 'chat', title: 'Testing schedule', where: '#qa · Jan 10', href: '/chat/qa/m-0981' },
|
|
67
|
+
{ kind: 'kb', title: 'Release checklist', where: 'Acme Design', href: '/docs/release-checklist' },
|
|
68
|
+
{ kind: 'chat', title: 'Budget for the launch', where: 'Private channel you are not in' },
|
|
69
|
+
{ kind: 'kb', title: 'Press kit guide', where: 'Acme Marketing', href: '/docs/press-kit-guide' },
|
|
70
|
+
{ kind: 'chat', title: 'Beta feedback', where: '#beta · Jan 8', href: '/chat/beta/m-0917' },
|
|
71
|
+
{ kind: 'kb', title: 'Pricing for the new plans', where: 'Acme Design', href: '/docs/pricing' },
|
|
72
|
+
{ kind: 'chat', title: 'Launch day roles', where: '#launch · Jan 14', href: '/chat/launch/m-1107' },
|
|
73
|
+
{ kind: 'kb', title: 'Support playbook', where: 'Acme Support', href: '/docs/support-playbook' },
|
|
74
|
+
];
|
|
75
|
+
|
|
76
|
+
const visible = 6;
|
|
77
|
+
|
|
78
|
+
// 'From Chat · Knowledge base': each kind once, in the order it first appears.
|
|
79
|
+
function kindsTag(list: Source[]) {
|
|
80
|
+
const labels: string[] = [];
|
|
81
|
+
list.forEach((s) => {
|
|
82
|
+
if (!labels.includes(kinds[s.kind].label)) labels.push(kinds[s.kind].label);
|
|
83
|
+
});
|
|
84
|
+
return `From ${labels.join(' · ')}`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
88
|
+
function agentMeta(at: Date) {
|
|
89
|
+
return (
|
|
90
|
+
<>
|
|
91
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
92
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
93
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
94
|
+
</>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default function ReplySourcesCards() {
|
|
99
|
+
const [expanded, setExpanded] = useState(false);
|
|
100
|
+
const shown = expanded ? sources : sources.slice(0, visible);
|
|
101
|
+
const more = sources.length - visible;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<Center width="page">
|
|
105
|
+
<Stack gap="large">
|
|
106
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
107
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
108
|
+
<Stack gap="small">
|
|
109
|
+
<Message
|
|
110
|
+
aria-label={request.from}
|
|
111
|
+
avatar={<UserImage userHandle={request.from} decorative />}
|
|
112
|
+
name={request.from}
|
|
113
|
+
meta={<TimeStamp createdAt={request.at} dateFormat="absolute" data="time" />}
|
|
114
|
+
>
|
|
115
|
+
<Paragraph measure="none">{request.text}</Paragraph>
|
|
116
|
+
</Message>
|
|
117
|
+
<Message
|
|
118
|
+
aria-label={`${agentName}, agent`}
|
|
119
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
120
|
+
name={agentName}
|
|
121
|
+
meta={agentMeta(repliedAt)}
|
|
122
|
+
// A reply that used no sources has no footer at all.
|
|
123
|
+
footer={
|
|
124
|
+
<Stack gap="medium">
|
|
125
|
+
<Cluster>
|
|
126
|
+
<Tag variant="contained" size="small" color="success" icon={Plug} label={kindsTag(sources)} />
|
|
127
|
+
</Cluster>
|
|
128
|
+
<Grid columns={2} gap="medium">
|
|
129
|
+
{shown.map((s) => (
|
|
130
|
+
// A source in the product is a path; one on another site is an https:// URL and opens in a new tab.
|
|
131
|
+
<SourceCard
|
|
132
|
+
key={`${s.kind}:${s.title}`}
|
|
133
|
+
icon={kinds[s.kind].icon}
|
|
134
|
+
title={s.title}
|
|
135
|
+
meta={`${kinds[s.kind].label} · ${s.where}`}
|
|
136
|
+
href={s.href}
|
|
137
|
+
/>
|
|
138
|
+
))}
|
|
139
|
+
</Grid>
|
|
140
|
+
{more > 0 && (
|
|
141
|
+
<Cluster>
|
|
142
|
+
<Button
|
|
143
|
+
size="small"
|
|
144
|
+
type="textOnly"
|
|
145
|
+
state="enabled"
|
|
146
|
+
label={expanded ? 'Show Fewer' : `Show ${more} More`}
|
|
147
|
+
aria-expanded={expanded}
|
|
148
|
+
onClickButton={() => setExpanded((e) => !e)}
|
|
149
|
+
/>
|
|
150
|
+
</Cluster>
|
|
151
|
+
)}
|
|
152
|
+
</Stack>
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
<Paragraph measure="none">{reply}</Paragraph>
|
|
156
|
+
</Message>
|
|
157
|
+
</Stack>
|
|
158
|
+
</Stack>
|
|
159
|
+
</Center>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Option: Tag only
|
|
165
|
+
|
|
166
|
+
Use when: The reply read only the messages already on screen above it.
|
|
167
|
+
|
|
168
|
+
Uses: `Center`, `Cluster`, `Heading`, `Message`, `Paragraph`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
'use client';
|
|
172
|
+
import { Bot, Plug } from 'lucide-react';
|
|
173
|
+
import Message from 'oneslash-design-system/components/message';
|
|
174
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
175
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
176
|
+
import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
177
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
178
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
179
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
180
|
+
|
|
181
|
+
const agentName = 'Acme Agent';
|
|
182
|
+
|
|
183
|
+
const thread = [
|
|
184
|
+
{ from: 'Ben Carter', at: new Date('2025-01-15T11:36:00Z'), text: 'Testing needs two more weeks. It now ends on January 31.' },
|
|
185
|
+
{ from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Acme Agent, what does that do to the launch date?' },
|
|
186
|
+
];
|
|
187
|
+
const repliedAt = new Date('2025-01-15T11:41:00Z');
|
|
188
|
+
// The agent read only the messages above, which the person can already see.
|
|
189
|
+
const reply = 'If testing ends on January 31, the launch moves to March 3. That keeps the two weeks Ben asked for.';
|
|
190
|
+
|
|
191
|
+
// The agent's marks, as the rule 'An agent says what it is' says.
|
|
192
|
+
function agentMeta(at: Date) {
|
|
193
|
+
return (
|
|
194
|
+
<>
|
|
195
|
+
<Tag variant="contained" size="small" label="Agent" />
|
|
196
|
+
<TimeStamp createdAt={at} dateFormat="absolute" data="time" />
|
|
197
|
+
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
198
|
+
</>
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export default function ReplySourcesTagOnly() {
|
|
203
|
+
return (
|
|
204
|
+
<Center width="page">
|
|
205
|
+
<Stack gap="large">
|
|
206
|
+
<Heading level={1} size="h5">Launch plan</Heading>
|
|
207
|
+
{/* A real app gives the list that holds the rows role="log". */}
|
|
208
|
+
<Stack gap="small">
|
|
209
|
+
{thread.map((m) => (
|
|
210
|
+
<Message
|
|
211
|
+
key={m.from}
|
|
212
|
+
aria-label={m.from}
|
|
213
|
+
avatar={<UserImage userHandle={m.from} decorative />}
|
|
214
|
+
name={m.from}
|
|
215
|
+
meta={<TimeStamp createdAt={m.at} dateFormat="absolute" data="time" />}
|
|
216
|
+
>
|
|
217
|
+
<Paragraph measure="none">{m.text}</Paragraph>
|
|
218
|
+
</Message>
|
|
219
|
+
))}
|
|
220
|
+
<Message
|
|
221
|
+
aria-label={`${agentName}, agent`}
|
|
222
|
+
avatar={<UserImage userHandle={agentName} icon={Bot} decorative />}
|
|
223
|
+
name={agentName}
|
|
224
|
+
meta={agentMeta(repliedAt)}
|
|
225
|
+
// One kind of source, already on screen: the tag says where the answer came from, and no cards follow.
|
|
226
|
+
footer={
|
|
227
|
+
<Cluster>
|
|
228
|
+
<Tag variant="contained" size="small" color="success" icon={Plug} label="From Chat" />
|
|
229
|
+
</Cluster>
|
|
230
|
+
}
|
|
231
|
+
>
|
|
232
|
+
<Paragraph measure="none">{reply}</Paragraph>
|
|
233
|
+
</Message>
|
|
234
|
+
</Stack>
|
|
235
|
+
</Stack>
|
|
236
|
+
</Center>
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Native
|
|
242
|
+
|
|
243
|
+
On Apple the cards fill as many columns as fit. A card with a link opens it in the browser, and a card with nothing to open cannot be tapped.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ScopePickerMenu(): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import Button from '../../components/button';
|
|
6
|
+
import Popover from '../../components/popover';
|
|
7
|
+
import Menu from '../../components/menu';
|
|
8
|
+
import MenuItem from '../../components/menuItem';
|
|
9
|
+
import Line from '../../components/line';
|
|
10
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
11
|
+
var workspaces = ['Acme Design', 'Acme Engineering', 'Acme Marketing'];
|
|
12
|
+
var all = 'All Workspaces';
|
|
13
|
+
export default function ScopePickerMenu() {
|
|
14
|
+
// null means every workspace.
|
|
15
|
+
var _a = useState(null), scope = _a[0], setScope = _a[1];
|
|
16
|
+
var _b = useState(null), anchor = _b[0], setAnchor = _b[1];
|
|
17
|
+
var _c = useState(false), open = _c[0], setOpen = _c[1];
|
|
18
|
+
var label = scope !== null && scope !== void 0 ? scope : all;
|
|
19
|
+
function toggle(anchorEl) {
|
|
20
|
+
setAnchor(anchorEl);
|
|
21
|
+
setOpen(function (o) { return !o; });
|
|
22
|
+
}
|
|
23
|
+
function choose(next) {
|
|
24
|
+
setScope(next);
|
|
25
|
+
setOpen(false);
|
|
26
|
+
}
|
|
27
|
+
return (<Center width="page">
|
|
28
|
+
<Stack gap="large">
|
|
29
|
+
<Heading level={1} size="h5">Ask Acme</Heading>
|
|
30
|
+
<Cluster gap="small">
|
|
31
|
+
<Paragraph tone="secondary" size="body2" measure="none">Searching in</Paragraph>
|
|
32
|
+
{/* The label is the scope. The chevron says it opens a menu. */}
|
|
33
|
+
<Button size="small" type="tertiary" state={open ? 'selected' : 'enabled'} label={label} actionIcon="ChevronDown" aria-label={"".concat(label, ", change where to search")} aria-haspopup="menu" aria-expanded={open} onClickButton={function (e) { return toggle(e.currentTarget); }}/>
|
|
34
|
+
</Cluster>
|
|
35
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
36
|
+
{scope ? "Answers use only ".concat(scope, ".") : "Answers use all ".concat(workspaces.length, " of your workspaces.")}
|
|
37
|
+
</Paragraph>
|
|
38
|
+
</Stack>
|
|
39
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
40
|
+
<Menu navigable aria-label="Where to search" width={220}>
|
|
41
|
+
<MenuItem size="small" label={all} isSelected={scope === null} role="menuitemradio" onClick={function () { return choose(null); }}/>
|
|
42
|
+
<Line />
|
|
43
|
+
{workspaces.map(function (w) { return (<MenuItem key={w} size="small" label={w} isSelected={scope === w} role="menuitemradio" onClick={function () { return choose(w); }}/>); })}
|
|
44
|
+
</Menu>
|
|
45
|
+
</Popover>
|
|
46
|
+
</Center>);
|
|
47
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Scope picker
|
|
2
|
+
|
|
3
|
+
A person chooses where a search or a question looks, such as one workspace or all of them.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Use a small tertiary `Button` whose label is the current scope, with `actionIcon="ChevronDown"` so it looks like it opens a menu.
|
|
8
|
+
- Open a navigable menu from it: `<Popover returnFocus>` around `<Menu navigable aria-label="Where to search">` with `onClick` items.
|
|
9
|
+
- Put 'All Workspaces' first, then a `Line`, then one item for each workspace.
|
|
10
|
+
- Give each item `role="menuitemradio"` and mark the current scope with `isSelected`, which sets `aria-checked`.
|
|
11
|
+
- Give the Button an `aria-label` that starts with its label and says what it does: 'Acme Design, change where to search'.
|
|
12
|
+
- Set `aria-haspopup="menu"` and `aria-expanded` on the Button, and `state="selected"` while the menu is open.
|
|
13
|
+
- Say what the scope means under the control, such as which workspaces the answers use.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not use a `Select` for a scope that sits in a toolbar.
|
|
18
|
+
- Do not put the scope in the Button without a chevron.
|
|
19
|
+
- Do not open the menu when the page loads.
|
|
20
|
+
- Do not keep the menu open after a choice.
|
|
21
|
+
|
|
22
|
+
## Example: Button with a menu
|
|
23
|
+
|
|
24
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Line`, `Menu`, `MenuItem`, `Paragraph`, `Popover`, `Stack`
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
'use client';
|
|
28
|
+
import { useState } from 'react';
|
|
29
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
30
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
31
|
+
import Button from 'oneslash-design-system/components/button';
|
|
32
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
33
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
34
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
35
|
+
import Line from 'oneslash-design-system/components/line';
|
|
36
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
37
|
+
|
|
38
|
+
const workspaces = ['Acme Design', 'Acme Engineering', 'Acme Marketing'];
|
|
39
|
+
const all = 'All Workspaces';
|
|
40
|
+
|
|
41
|
+
export default function ScopePickerMenu() {
|
|
42
|
+
// null means every workspace.
|
|
43
|
+
const [scope, setScope] = useState<string | null>(null);
|
|
44
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
45
|
+
const [open, setOpen] = useState(false);
|
|
46
|
+
const label = scope ?? all;
|
|
47
|
+
|
|
48
|
+
function toggle(anchorEl: HTMLElement) {
|
|
49
|
+
setAnchor(anchorEl);
|
|
50
|
+
setOpen((o) => !o);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function choose(next: string | null) {
|
|
54
|
+
setScope(next);
|
|
55
|
+
setOpen(false);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Center width="page">
|
|
60
|
+
<Stack gap="large">
|
|
61
|
+
<Heading level={1} size="h5">Ask Acme</Heading>
|
|
62
|
+
<Cluster gap="small">
|
|
63
|
+
<Paragraph tone="secondary" size="body2" measure="none">Searching in</Paragraph>
|
|
64
|
+
{/* The label is the scope. The chevron says it opens a menu. */}
|
|
65
|
+
<Button
|
|
66
|
+
size="small"
|
|
67
|
+
type="tertiary"
|
|
68
|
+
state={open ? 'selected' : 'enabled'}
|
|
69
|
+
label={label}
|
|
70
|
+
actionIcon="ChevronDown"
|
|
71
|
+
aria-label={`${label}, change where to search`}
|
|
72
|
+
aria-haspopup="menu"
|
|
73
|
+
aria-expanded={open}
|
|
74
|
+
onClickButton={(e: { currentTarget: HTMLElement }) => toggle(e.currentTarget)}
|
|
75
|
+
/>
|
|
76
|
+
</Cluster>
|
|
77
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
78
|
+
{scope ? `Answers use only ${scope}.` : `Answers use all ${workspaces.length} of your workspaces.`}
|
|
79
|
+
</Paragraph>
|
|
80
|
+
</Stack>
|
|
81
|
+
<Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
|
|
82
|
+
<Menu navigable aria-label="Where to search" width={220}>
|
|
83
|
+
<MenuItem size="small" label={all} isSelected={scope === null} role="menuitemradio" onClick={() => choose(null)} />
|
|
84
|
+
<Line />
|
|
85
|
+
{workspaces.map((w) => (
|
|
86
|
+
<MenuItem key={w} size="small" label={w} isSelected={scope === w} role="menuitemradio" onClick={() => choose(w)} />
|
|
87
|
+
))}
|
|
88
|
+
</Menu>
|
|
89
|
+
</Popover>
|
|
90
|
+
</Center>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Native
|
|
96
|
+
|
|
97
|
+
On Apple use a toolbar `Menu` with a `Picker` inside it, and on Android a dropdown menu.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A person opened the link to reset their password and now chooses a new one.
|
|
4
4
|
|
|
5
|
-
**Not built yet:** Commentify and Scindo on the web replace the form with a spinner while updating, and show field problems in an Alert above the fields. Both accept 6 characters, and say 'Password must be at least 6 characters.' only after it is broken. Scindo's reset page has no invalid-link state.
|
|
6
|
-
|
|
7
5
|
## Do
|
|
8
6
|
|
|
9
7
|
- Name the page 'Set new password' in a `Heading` with `level={1}`, and name the account it is for.
|
|
@@ -243,5 +241,3 @@ export default function SetNewPasswordInvalidLink() {
|
|
|
243
241
|
);
|
|
244
242
|
}
|
|
245
243
|
```
|
|
246
|
-
|
|
247
|
-
Seen in: Commentify, Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SettingsPageSideNav(): import("react").JSX.Element;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
|
+
import Modal from '../../components/modal';
|
|
15
|
+
import Heading from '../../components/heading';
|
|
16
|
+
import Paragraph from '../../components/paragraph';
|
|
17
|
+
import Form from '../../components/form';
|
|
18
|
+
import FormField from '../../components/formField';
|
|
19
|
+
import TextField from '../../components/textField';
|
|
20
|
+
import Switch from '../../components/switch';
|
|
21
|
+
import Button from '../../components/button';
|
|
22
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
23
|
+
import MenuItem from '../../components/menuItem';
|
|
24
|
+
import SettingsSection, { SettingsLayout } from '../../components/settingsSection';
|
|
25
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
26
|
+
// Areas in groups, as the side nav lists them. Each is a page of its own in a real app, so it has an `href`.
|
|
27
|
+
var areas = [
|
|
28
|
+
{ id: 'profile', label: 'Profile', icon: 'User', group: 'Account', description: 'How people see you in Acme.' },
|
|
29
|
+
{ id: 'notifications', label: 'Notifications', icon: 'Bell', group: 'Account', description: 'Choose what reaches you.' },
|
|
30
|
+
{ id: 'general', label: 'General', icon: 'Settings', group: 'Workspace', description: 'The name and defaults of the Acme workspace.' },
|
|
31
|
+
{ id: 'members', label: 'Members', icon: 'Users', group: 'Workspace', description: 'Who is in Acme, and what they can do.' },
|
|
32
|
+
{ id: 'billing', label: 'Billing', icon: 'CreditCard', group: 'Workspace', description: 'Your plan and invoices.' },
|
|
33
|
+
{ id: 'api-keys', label: 'API Keys', icon: 'Key', group: 'Developers', description: 'Keys for tools that use Acme.' },
|
|
34
|
+
{ id: 'webhooks', label: 'Webhooks', icon: 'Webhook', group: 'Developers', description: 'Send Acme events to other tools.' },
|
|
35
|
+
];
|
|
36
|
+
var groups = ['Account', 'Workspace', 'Developers'];
|
|
37
|
+
export default function SettingsPageSideNav() {
|
|
38
|
+
var _a;
|
|
39
|
+
var _b = useState('profile'), areaId = _b[0], setAreaId = _b[1];
|
|
40
|
+
// On a phone the nav is the page: it shows until the person opens an area, and 'Back to Settings' returns to it.
|
|
41
|
+
var _c = useState(false), opened = _c[0], setOpened = _c[1];
|
|
42
|
+
var _d = useState('Dana Lee'), savedName = _d[0], setSavedName = _d[1];
|
|
43
|
+
var _e = useState('Dana Lee'), name = _e[0], setName = _e[1];
|
|
44
|
+
var _f = useState(''), nameError = _f[0], setNameError = _f[1];
|
|
45
|
+
var _g = useState(false), saving = _g[0], setSaving = _g[1];
|
|
46
|
+
var _h = useState(false), saved = _h[0], setSaved = _h[1];
|
|
47
|
+
var _j = useState({ mentions: true, digest: false }), values = _j[0], setValues = _j[1];
|
|
48
|
+
var _k = useState({ mentions: false, digest: false }), busy = _k[0], setBusy = _k[1];
|
|
49
|
+
var _l = useState(false), confirmingLogOut = _l[0], setConfirmingLogOut = _l[1];
|
|
50
|
+
var _m = useState(false), loggingOut = _m[0], setLoggingOut = _m[1];
|
|
51
|
+
var _o = useState(false), loggedOut = _o[0], setLoggedOut = _o[1];
|
|
52
|
+
var timers = useRef([]);
|
|
53
|
+
// Cleared before a new 'Saved' starts, so an old timer cannot end it early.
|
|
54
|
+
var savedTimer = useRef();
|
|
55
|
+
// Stops every request and the 'Saved' if the example goes away before they end.
|
|
56
|
+
useEffect(function () { return function () {
|
|
57
|
+
timers.current.forEach(clearTimeout);
|
|
58
|
+
clearTimeout(savedTimer.current);
|
|
59
|
+
}; }, []);
|
|
60
|
+
var area = (_a = areas.find(function (a) { return a.id === areaId; })) !== null && _a !== void 0 ? _a : areas[0];
|
|
61
|
+
function handleOpen(id) {
|
|
62
|
+
setAreaId(id);
|
|
63
|
+
setOpened(true);
|
|
64
|
+
}
|
|
65
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
66
|
+
function handleLogOutClose() {
|
|
67
|
+
if (loggingOut)
|
|
68
|
+
return;
|
|
69
|
+
setConfirmingLogOut(false);
|
|
70
|
+
}
|
|
71
|
+
function handleLogOut() {
|
|
72
|
+
if (loggingOut)
|
|
73
|
+
return;
|
|
74
|
+
setLoggingOut(true);
|
|
75
|
+
timers.current.push(setTimeout(function () {
|
|
76
|
+
setLoggingOut(false);
|
|
77
|
+
setConfirmingLogOut(false);
|
|
78
|
+
setLoggedOut(true);
|
|
79
|
+
}, 1200));
|
|
80
|
+
}
|
|
81
|
+
// A group of fields has one Save Button: `loading`, then 'Saved' for 2 seconds.
|
|
82
|
+
function handleSave() {
|
|
83
|
+
if (saving)
|
|
84
|
+
return;
|
|
85
|
+
if (!name.trim()) {
|
|
86
|
+
setNameError('Enter your name.');
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
setNameError('');
|
|
90
|
+
setSaving(true);
|
|
91
|
+
// Stands in for the request to the server.
|
|
92
|
+
timers.current.push(setTimeout(function () {
|
|
93
|
+
setSavedName(name.trim());
|
|
94
|
+
setName(name.trim());
|
|
95
|
+
setSaving(false);
|
|
96
|
+
setSaved(true);
|
|
97
|
+
clearTimeout(savedTimer.current);
|
|
98
|
+
savedTimer.current = setTimeout(function () { return setSaved(false); }, 2000);
|
|
99
|
+
}, 1200));
|
|
100
|
+
}
|
|
101
|
+
// A switch on its own saves as soon as it changes, and shows nothing when it works.
|
|
102
|
+
function handleSwitch(key, next) {
|
|
103
|
+
setBusy(function (current) {
|
|
104
|
+
var _a;
|
|
105
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = true, _a)));
|
|
106
|
+
});
|
|
107
|
+
setValues(function (current) {
|
|
108
|
+
var _a;
|
|
109
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = next, _a)));
|
|
110
|
+
});
|
|
111
|
+
timers.current.push(setTimeout(function () { return setBusy(function (current) {
|
|
112
|
+
var _a;
|
|
113
|
+
return (__assign(__assign({}, current), (_a = {}, _a[key] = false, _a)));
|
|
114
|
+
}); }, 900));
|
|
115
|
+
}
|
|
116
|
+
var profile = (<SettingsSection id="settings-page-nav-name" title="Name" description="How people see you in messages and on tasks.">
|
|
117
|
+
<Form aria-label="Name" gap="medium" onSubmit={handleSave}>
|
|
118
|
+
<FormField id="settings-page-nav-name-field" label="Name" error={nameError}>
|
|
119
|
+
{function (f) { return <TextField id={f.id} aria-describedby={f['aria-describedby']} aria-invalid={f['aria-invalid']} value={name} disabled={saving} onChange={function (e) { setName(e.target.value); setNameError(''); setSaved(false); }}/>; }}
|
|
120
|
+
</FormField>
|
|
121
|
+
<Cluster>
|
|
122
|
+
<Button size="medium" type="primary" state={name !== savedName || saving ? 'enabled' : 'disabled'} label={saved ? 'Saved' : 'Save'} htmlType="submit" loading={saving}/>
|
|
123
|
+
</Cluster>
|
|
124
|
+
</Form>
|
|
125
|
+
</SettingsSection>);
|
|
126
|
+
var notifications = (<SettingsSection id="settings-page-nav-email" title="Email" description="Sent to dana@acme.example.">
|
|
127
|
+
<Switch id="settings-page-nav-mentions" label="Mentions" description="An email when someone mentions you." checked={values.mentions} busy={busy.mentions} onChange={function (next) { return handleSwitch('mentions', next); }}/>
|
|
128
|
+
<Switch id="settings-page-nav-digest" label="Weekly digest" description="A summary of last week, every Monday." checked={values.digest} busy={busy.digest} onChange={function (next) { return handleSwitch('digest', next); }}/>
|
|
129
|
+
</SettingsSection>);
|
|
130
|
+
// A real app goes to its login page here. The example shows a short logged-out page instead.
|
|
131
|
+
if (loggedOut) {
|
|
132
|
+
return (<Center fill>
|
|
133
|
+
<Heading level={1} size="h5">You are logged out</Heading>
|
|
134
|
+
<Cluster>
|
|
135
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={function () { return setLoggedOut(false); }}/>
|
|
136
|
+
</Cluster>
|
|
137
|
+
</Center>);
|
|
138
|
+
}
|
|
139
|
+
var nav = (<Navigation aria-label="Settings">
|
|
140
|
+
{groups.map(function (group) { return (<NavigationGroup key={group} label={group}>
|
|
141
|
+
{areas.filter(function (a) { return a.group === group; }).map(function (a) { return (<MenuItem key={a.id} size="small" label={a.label} iconName={a.icon} href={"/settings/".concat(a.id)} isSelected={a.id === area.id} aria-current={a.id === area.id ? 'page' : undefined} onClick={function (event) {
|
|
142
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
143
|
+
event.preventDefault();
|
|
144
|
+
handleOpen(a.id);
|
|
145
|
+
}}/>); })}
|
|
146
|
+
</NavigationGroup>); })}
|
|
147
|
+
<NavigationGroup label="Session">
|
|
148
|
+
<MenuItem size="small" label="Log Out" iconName="LogOut" role="button" onClick={function () { return setConfirmingLogOut(true); }}/>
|
|
149
|
+
</NavigationGroup>
|
|
150
|
+
</Navigation>);
|
|
151
|
+
return (<Center width="page">
|
|
152
|
+
<Stack gap="xlarge">
|
|
153
|
+
<Heading level={1} size="h5">Settings</Heading>
|
|
154
|
+
<SettingsLayout nav={nav} showContent={opened} back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Settings" onClickButton={function () { return setOpened(false); }}/>}>
|
|
155
|
+
<Stack gap="small">
|
|
156
|
+
<Heading level={2} size="h6">{area.label}</Heading>
|
|
157
|
+
<Paragraph tone="secondary" size="body2" measure="none">{area.description}</Paragraph>
|
|
158
|
+
</Stack>
|
|
159
|
+
{area.id === 'profile' && profile}
|
|
160
|
+
{area.id === 'notifications' && notifications}
|
|
161
|
+
{area.id !== 'profile' && area.id !== 'notifications' && (<Paragraph size="body2" measure="none">Nothing to show for {area.label} in this example.</Paragraph>)}
|
|
162
|
+
</SettingsLayout>
|
|
163
|
+
</Stack>
|
|
164
|
+
<Modal isOpen={confirmingLogOut} size="small" title="Log Out" onClose={handleLogOutClose} actions={<>
|
|
165
|
+
<Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleLogOutClose}/>
|
|
166
|
+
<Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={handleLogOut}/>
|
|
167
|
+
</>}>
|
|
168
|
+
<Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
|
|
169
|
+
</Modal>
|
|
170
|
+
</Center>);
|
|
171
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SettingsPageTopTabs(): import("react").JSX.Element;
|