oneslash-design-system 2.17.0 → 2.19.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 +55 -14
- package/dist/cases/accept-invite.md +1 -5
- 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.md +0 -4
- package/dist/cases/agent-pending-reply.md +0 -4
- package/dist/cases/agent-plan-proposal.md +0 -4
- package/dist/cases/agent-question.md +0 -4
- 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 +0 -2
- 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/app-shell/sidebar.d.ts +1 -0
- package/dist/cases/app-shell/sidebar.jsx +124 -0
- package/dist/cases/app-shell/top-tabs.d.ts +1 -0
- package/dist/cases/app-shell/top-tabs.jsx +106 -0
- package/dist/cases/app-shell.md +364 -0
- package/dist/cases/artifact-card/card.jsx +32 -6
- package/dist/cases/artifact-card.md +55 -11
- 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.md +0 -4
- package/dist/cases/confirm-destructive-action.md +0 -4
- package/dist/cases/confirm-dialogs.md +0 -4
- package/dist/cases/conversation-starters.md +0 -4
- 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/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -25
- 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/master-detail/list-then-page.d.ts +1 -0
- package/dist/cases/master-detail/list-then-page.jsx +65 -0
- package/dist/cases/master-detail/split.d.ts +1 -0
- package/dist/cases/master-detail/split.jsx +49 -0
- package/dist/cases/master-detail.md +213 -0
- 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.md +0 -4
- package/dist/cases/message-actions.md +0 -4
- package/dist/cases/message-attachments.md +0 -4
- package/dist/cases/message-composer.md +0 -4
- package/dist/cases/message-edit.md +0 -4
- package/dist/cases/message-reactions.md +0 -4
- package/dist/cases/message-row.md +0 -4
- package/dist/cases/mobile-menu/links.d.ts +1 -0
- package/dist/cases/mobile-menu/links.jsx +24 -0
- package/dist/cases/mobile-menu/sections.d.ts +1 -0
- package/dist/cases/mobile-menu/sections.jsx +61 -0
- package/dist/cases/mobile-menu.md +170 -0
- package/dist/cases/not-found-page/in-shell.jsx +26 -17
- package/dist/cases/not-found-page.md +41 -24
- 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/on-this-page/aside.d.ts +1 -0
- package/dist/cases/on-this-page/aside.jsx +39 -0
- package/dist/cases/on-this-page.md +80 -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/page-header/actions.d.ts +1 -0
- package/dist/cases/page-header/actions.jsx +65 -0
- package/dist/cases/page-header/sub-page.d.ts +1 -0
- package/dist/cases/page-header/sub-page.jsx +37 -0
- package/dist/cases/page-header.md +195 -0
- package/dist/cases/phone-navigation.md +32 -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.md +0 -4
- package/dist/cases/reply-sources.md +0 -4
- package/dist/cases/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -23
- 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/side-pane/beside.d.ts +1 -0
- package/dist/cases/side-pane/beside.jsx +79 -0
- package/dist/cases/side-pane/over.d.ts +1 -0
- package/dist/cases/side-pane/over.jsx +58 -0
- package/dist/cases/side-pane.md +238 -0
- package/dist/cases/sidebar-nav/flat.d.ts +1 -0
- package/dist/cases/sidebar-nav/flat.jsx +81 -0
- package/dist/cases/sidebar-nav/nested.d.ts +1 -0
- package/dist/cases/sidebar-nav/nested.jsx +122 -0
- package/dist/cases/sidebar-nav.md +261 -0
- package/dist/cases/sign-up-page.md +1 -5
- package/dist/cases/site-footer/columns.d.ts +1 -0
- package/dist/cases/site-footer/columns.jsx +51 -0
- package/dist/cases/site-footer/simple.d.ts +1 -0
- package/dist/cases/site-footer/simple.jsx +24 -0
- package/dist/cases/site-footer.md +133 -0
- package/dist/cases/site-header/links.d.ts +1 -0
- package/dist/cases/site-header/links.jsx +26 -0
- package/dist/cases/site-header/sections.d.ts +1 -0
- package/dist/cases/site-header/sections.jsx +64 -0
- package/dist/cases/site-header.md +183 -0
- package/dist/cases/slash-command-list.md +0 -4
- package/dist/cases/success-feedback.md +0 -4
- 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/theme-switcher/menu.d.ts +1 -0
- package/dist/cases/theme-switcher/menu.jsx +47 -0
- package/dist/cases/theme-switcher/segmented.d.ts +1 -0
- package/dist/cases/theme-switcher/segmented.jsx +26 -0
- package/dist/cases/theme-switcher.md +149 -0
- package/dist/cases/type-to-confirm.md +0 -4
- package/dist/cases/typing-and-status.md +0 -4
- package/dist/cases/unsaved-changes-guard.md +0 -4
- package/dist/cases/upgrade-prompt.md +0 -4
- package/dist/cases.json +1737 -315
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +2 -2
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/button.jsx +5 -2
- package/dist/components/checkBox.d.ts +5 -1
- package/dist/components/checkBox.jsx +2 -2
- package/dist/components/copyField.d.ts +20 -0
- package/dist/components/copyField.jsx +99 -0
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/formField.d.ts +34 -0
- package/dist/components/formField.jsx +28 -0
- package/dist/components/heading.d.ts +5 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/link.d.ts +6 -1
- package/dist/components/link.jsx +11 -3
- package/dist/components/menu.jsx +2 -2
- package/dist/components/menuItem.d.ts +10 -2
- package/dist/components/menuItem.jsx +4 -3
- package/dist/components/modal.jsx +12 -23
- package/dist/components/navigation.d.ts +9 -1
- package/dist/components/navigation.jsx +15 -3
- package/dist/components/onThisPage.d.ts +29 -0
- package/dist/components/onThisPage.jsx +151 -0
- package/dist/components/pageShell.d.ts +7 -1
- package/dist/components/pageShell.jsx +14 -1
- package/dist/components/popover.jsx +4 -0
- package/dist/components/radioGroup.d.ts +5 -1
- package/dist/components/radioGroup.jsx +2 -2
- 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 +36 -0
- package/dist/components/settingsSection.jsx +65 -0
- package/dist/components/sidePane.d.ts +32 -0
- package/dist/components/sidePane.jsx +128 -0
- package/dist/components/siteFooter.d.ts +24 -0
- package/dist/components/siteFooter.jsx +48 -0
- package/dist/components/siteHeader.d.ts +55 -0
- package/dist/components/siteHeader.jsx +125 -0
- package/dist/components/slidingIndicator.d.ts +50 -0
- package/dist/components/slidingIndicator.jsx +102 -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/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 +3 -3
- package/dist/components/titleBar.d.ts +17 -0
- package/dist/components/titleBar.jsx +17 -0
- package/dist/components/useHotkey.d.ts +7 -0
- package/dist/components/useHotkey.js +24 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +13 -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/overlayStack.d.ts +24 -0
- package/dist/internal/overlayStack.js +71 -0
- package/dist/internal/resize.d.ts +9 -0
- package/dist/internal/resize.js +31 -0
- package/dist/internal/scrollSpy.d.ts +24 -0
- package/dist/internal/scrollSpy.js +53 -0
- package/dist/internal/siteBrand.d.ts +6 -0
- package/dist/internal/siteBrand.jsx +11 -0
- package/dist/internal/switch.d.ts +5 -0
- package/dist/internal/switch.js +9 -0
- package/dist/native-mapping.json +72 -0
- package/dist/stories/AppShell.stories.d.ts +15 -0
- package/dist/stories/AppShell.stories.jsx +137 -0
- package/dist/stories/Cases.generated.stories.d.ts +42 -0
- package/dist/stories/Cases.generated.stories.jsx +84 -0
- package/dist/stories/CopyField.stories.d.ts +11 -0
- package/dist/stories/CopyField.stories.jsx +65 -0
- package/dist/stories/Drawer.stories.d.ts +10 -0
- package/dist/stories/Drawer.stories.jsx +123 -0
- package/dist/stories/FormField.stories.d.ts +6 -0
- package/dist/stories/FormField.stories.jsx +44 -0
- package/dist/stories/Link.stories.d.ts +1 -0
- package/dist/stories/Link.stories.jsx +8 -0
- package/dist/stories/Navigation.stories.d.ts +1 -0
- package/dist/stories/Navigation.stories.jsx +17 -1
- package/dist/stories/OnThisPage.stories.d.ts +10 -0
- package/dist/stories/OnThisPage.stories.jsx +105 -0
- package/dist/stories/SegmentedControl.stories.d.ts +8 -0
- package/dist/stories/SegmentedControl.stories.jsx +33 -0
- package/dist/stories/SettingsSection.stories.d.ts +12 -0
- package/dist/stories/SettingsSection.stories.jsx +91 -0
- package/dist/stories/SidePane.stories.d.ts +6 -0
- package/dist/stories/SidePane.stories.jsx +37 -0
- package/dist/stories/SiteFooter.stories.d.ts +7 -0
- package/dist/stories/SiteFooter.stories.jsx +63 -0
- package/dist/stories/SiteHeader.stories.d.ts +10 -0
- package/dist/stories/SiteHeader.stories.jsx +94 -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/TitleBar.stories.d.ts +6 -0
- package/dist/stories/TitleBar.stories.jsx +34 -0
- package/package.json +5 -1
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
# App shell
|
|
2
|
+
|
|
3
|
+
A person opens the product and moves between its places, such as Inbox, Tasks and Settings, from every page.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.
|
|
8
|
+
- Build the sidebar frame with `AppShell`. Its places are a `Navigation` of `NavigationGroup`s.
|
|
9
|
+
- Make each place a `MenuItem` with an `href`, and mark the open one with `isSelected` and `aria-current="page"`.
|
|
10
|
+
- Put the account menu last in the sidebar, built as the case 'Account menu' says.
|
|
11
|
+
- Give the page's `TitleBar` the page's name as the level 1 heading, and give `AppShell` the place's name as `title`. When the page is the place, the two are the same.
|
|
12
|
+
- Pass `onSidebarHiddenChange` to `AppShell` so a person can hide the sidebar from `md` up. It adds a 'Hide sidebar' IconButton at the top of the column and a 'Show sidebar' IconButton when it is hidden, and moves focus between them. The phone menu has neither.
|
|
13
|
+
- Add Cmd+B, or Ctrl+B, with `useHotkey('b', …)`, and have it change the same state. It does nothing while the person types in a field. Ignore it while a Modal, such as the 'Log Out' confirm, is open.
|
|
14
|
+
- Close the phone menu in the `onClick` of an item in a Popover, such as Settings in the account menu. A choice in a Popover does not close the Drawer by itself.
|
|
15
|
+
- Render a Modal that the sidebar opens, such as the 'Log Out' confirm, inside the sidebar node, so it is mounted once: in the column or in the Drawer.
|
|
16
|
+
- Use `TabsContainer fill` with a `Tab` for each place, each with an `href` and the app's `router`, when there are four places or fewer. Name each with one short word.
|
|
17
|
+
- With tabs across the top, put the name of the app at the start of the bar and the account menu at the end.
|
|
18
|
+
|
|
19
|
+
## Don't
|
|
20
|
+
|
|
21
|
+
- Do not use tabs for more than four places, or for places the person makes.
|
|
22
|
+
- Do not show the sidebar beside the page on a phone.
|
|
23
|
+
- Do not hide the sidebar with the shortcut alone. Give a person a visible 'Hide sidebar' button as well.
|
|
24
|
+
- Do not let the tabs scroll sideways. When they do not fit at 375px, use the sidebar.
|
|
25
|
+
- Do not mount the sidebar twice, once for the column and once for the menu.
|
|
26
|
+
|
|
27
|
+
## Option: Sidebar in groups
|
|
28
|
+
|
|
29
|
+
Use when: There are more than four places, or the person makes some of them, such as projects or channels.
|
|
30
|
+
|
|
31
|
+
Uses: `AppShell`, `Button`, `Center`, `Cluster`, `Heading`, `Line`, `Menu`, `MenuItem`, `Modal`, `Navigation`, `NavigationGroup`, `Paragraph`, `Popover`, `Stack`, `TitleBar`, `UserImage`, `useHotkey`
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
'use client';
|
|
35
|
+
import { useEffect, useRef, useState } from 'react';
|
|
36
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
37
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
38
|
+
import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
|
|
39
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
40
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
41
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
42
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
43
|
+
import Button from 'oneslash-design-system/components/button';
|
|
44
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
45
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
46
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
47
|
+
import Line from 'oneslash-design-system/components/line';
|
|
48
|
+
import useHotkey from 'oneslash-design-system/components/useHotkey';
|
|
49
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
50
|
+
|
|
51
|
+
type Place = { id: string; label: string; icon: string; group: string; page: string; text: string };
|
|
52
|
+
|
|
53
|
+
// The places. The top bar on a phone names the place; the page's own title is the level 1 heading, so a phone never shows the same words twice.
|
|
54
|
+
const places: Place[] = [
|
|
55
|
+
{ id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
|
|
56
|
+
{ id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail', page: 'Sent this week', text: 'You sent 4 messages this week.' },
|
|
57
|
+
{ id: 'website', label: 'Website', icon: 'Globe', group: 'Projects', page: 'Home page redesign', text: '12 tasks are open. The next review is on Thursday.' },
|
|
58
|
+
{ id: 'mobile', label: 'Mobile App', icon: 'Smartphone', group: 'Projects', page: 'Version 2 release', text: '5 tasks are open. Dana Lee owns the release.' },
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const groups = ['Mail', 'Projects'];
|
|
62
|
+
|
|
63
|
+
// A real app reads this from the session.
|
|
64
|
+
const me = 'Dana Lee';
|
|
65
|
+
|
|
66
|
+
export default function AppShellSidebar() {
|
|
67
|
+
const [placeId, setPlaceId] = useState('inbox');
|
|
68
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
69
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
70
|
+
// From md up the person can hide the column for room. The phone menu still has it.
|
|
71
|
+
const [hidden, setHidden] = useState(false);
|
|
72
|
+
const [accountAnchor, setAccountAnchor] = useState<HTMLElement | null>(null);
|
|
73
|
+
const [accountOpen, setAccountOpen] = useState(false);
|
|
74
|
+
const [confirming, setConfirming] = useState(false);
|
|
75
|
+
const [loggingOut, setLoggingOut] = useState(false);
|
|
76
|
+
const [loggedOut, setLoggedOut] = useState(false);
|
|
77
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
78
|
+
const accountButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
79
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
80
|
+
const focusNext = useRef<() => void>();
|
|
81
|
+
|
|
82
|
+
// Stops the request if the example goes away before it ends.
|
|
83
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const move = focusNext.current;
|
|
87
|
+
focusNext.current = undefined;
|
|
88
|
+
move?.();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Cmd+B, or Ctrl+B. It does nothing while the person types in a field, and nothing while the Log Out confirm is open.
|
|
92
|
+
useHotkey('b', () => {
|
|
93
|
+
if (!confirming) setHidden((h) => !h);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
const place = places.find((p) => p.id === placeId) ?? places[0];
|
|
97
|
+
|
|
98
|
+
// Cancel, Escape and a click outside. 'Cancel' puts focus back on the account Button, inside the Drawer on a phone.
|
|
99
|
+
function cancelLogOut() {
|
|
100
|
+
if (loggingOut) return;
|
|
101
|
+
setConfirming(false);
|
|
102
|
+
focusNext.current = () => accountButton.current?.focus();
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function logOut() {
|
|
106
|
+
if (loggingOut) return;
|
|
107
|
+
setLoggingOut(true);
|
|
108
|
+
// Stands in for the request to the server.
|
|
109
|
+
timer.current = setTimeout(() => {
|
|
110
|
+
setLoggingOut(false);
|
|
111
|
+
setConfirming(false);
|
|
112
|
+
setLoggedOut(true);
|
|
113
|
+
}, 1200);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
// A real app goes to its login page here. The example shows a short logged-out page instead.
|
|
117
|
+
if (loggedOut) {
|
|
118
|
+
return (
|
|
119
|
+
<Center fill>
|
|
120
|
+
<Heading level={1} size="h5">You are logged out</Heading>
|
|
121
|
+
<Cluster>
|
|
122
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={() => { setLoggedOut(false); setPlaceId('inbox'); }} />
|
|
123
|
+
</Cluster>
|
|
124
|
+
</Center>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// The sidebar is mounted once: in the column from md up, in the Drawer below it. Its Modal lives inside it.
|
|
129
|
+
const sidebar = (
|
|
130
|
+
<Navigation aria-label="Main">
|
|
131
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
132
|
+
{groups.map((group) => (
|
|
133
|
+
<NavigationGroup key={group} label={group}>
|
|
134
|
+
{places.filter((p) => p.group === group).map((p) => (
|
|
135
|
+
<MenuItem
|
|
136
|
+
key={p.id}
|
|
137
|
+
size="small"
|
|
138
|
+
label={p.label}
|
|
139
|
+
iconName={p.icon}
|
|
140
|
+
href={`/${p.id}`}
|
|
141
|
+
isSelected={p.id === place.id}
|
|
142
|
+
aria-current={p.id === place.id ? 'page' : undefined}
|
|
143
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
144
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
145
|
+
event.preventDefault();
|
|
146
|
+
setPlaceId(p.id);
|
|
147
|
+
}}
|
|
148
|
+
/>
|
|
149
|
+
))}
|
|
150
|
+
</NavigationGroup>
|
|
151
|
+
))}
|
|
152
|
+
<Line />
|
|
153
|
+
{/* The account menu is last. */}
|
|
154
|
+
<Cluster>
|
|
155
|
+
<Button
|
|
156
|
+
ref={accountButton}
|
|
157
|
+
size="small"
|
|
158
|
+
type="tertiary"
|
|
159
|
+
state={accountOpen ? 'selected' : 'enabled'}
|
|
160
|
+
label={me}
|
|
161
|
+
decoIcon={<UserImage userHandle={me} size={20} decorative />}
|
|
162
|
+
aria-label={`${me}, account menu`}
|
|
163
|
+
aria-haspopup="menu"
|
|
164
|
+
aria-expanded={accountOpen}
|
|
165
|
+
onClickButton={(e: { currentTarget: HTMLElement }) => {
|
|
166
|
+
setAccountAnchor(e.currentTarget);
|
|
167
|
+
setAccountOpen((o) => !o);
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</Cluster>
|
|
171
|
+
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={() => setAccountOpen(false)} returnFocus>
|
|
172
|
+
<Menu navigable aria-label="Account" width={200}>
|
|
173
|
+
{/* A choice in a Popover does not close the phone menu: close it here. */}
|
|
174
|
+
<MenuItem size="small" iconName="Settings" label="Settings" onClick={() => { setAccountOpen(false); setNavOpen(false); }} />
|
|
175
|
+
<MenuItem size="small" iconName="CircleHelp" label="Help" onClick={() => { setAccountOpen(false); setNavOpen(false); }} />
|
|
176
|
+
<Line />
|
|
177
|
+
<MenuItem size="small" iconName="LogOut" label="Log Out" onClick={() => { setAccountOpen(false); setConfirming(true); }} />
|
|
178
|
+
</Menu>
|
|
179
|
+
</Popover>
|
|
180
|
+
<Modal
|
|
181
|
+
isOpen={confirming}
|
|
182
|
+
size="small"
|
|
183
|
+
title="Log Out"
|
|
184
|
+
onClose={cancelLogOut}
|
|
185
|
+
actions={
|
|
186
|
+
<>
|
|
187
|
+
<Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut} />
|
|
188
|
+
<Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut} />
|
|
189
|
+
</>
|
|
190
|
+
}
|
|
191
|
+
>
|
|
192
|
+
<Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
|
|
193
|
+
</Modal>
|
|
194
|
+
</Navigation>
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const newMessage = <Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus" />;
|
|
198
|
+
|
|
199
|
+
return (
|
|
200
|
+
<AppShell title={place.label} navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} sidebarHidden={hidden} onSidebarHiddenChange={setHidden}>
|
|
201
|
+
<Stack gap="large">
|
|
202
|
+
<TitleBar
|
|
203
|
+
title={place.page}
|
|
204
|
+
actions={newMessage}
|
|
205
|
+
/>
|
|
206
|
+
<Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
|
|
207
|
+
</Stack>
|
|
208
|
+
</AppShell>
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
## Option: Tabs across the top
|
|
214
|
+
|
|
215
|
+
Use when: There are four places or fewer, all fixed, each with a short name that fits on a phone.
|
|
216
|
+
|
|
217
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Line`, `Menu`, `MenuItem`, `Modal`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `Tab`, `TabsContainer`, `TitleBar`, `UserImage`
|
|
218
|
+
|
|
219
|
+
```tsx
|
|
220
|
+
'use client';
|
|
221
|
+
import { useEffect, useRef, useState } from 'react';
|
|
222
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
223
|
+
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
224
|
+
import Tab from 'oneslash-design-system/components/tab';
|
|
225
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
226
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
227
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
228
|
+
import Button from 'oneslash-design-system/components/button';
|
|
229
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
230
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
231
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
232
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
233
|
+
import Line from 'oneslash-design-system/components/line';
|
|
234
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
235
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
236
|
+
|
|
237
|
+
type Place = { id: string; label: string; page: string; text: string };
|
|
238
|
+
|
|
239
|
+
// Four fixed places, one short word each, so the tabs fit on a phone.
|
|
240
|
+
const places: Place[] = [
|
|
241
|
+
{ id: 'inbox', label: 'Inbox', page: 'Unread messages', text: 'Ben Carter shared the launch plan. Omar Reyes asked for the new screens by Friday.' },
|
|
242
|
+
{ id: 'tasks', label: 'Tasks', page: 'My tasks', text: '7 tasks are open. 2 are due this week.' },
|
|
243
|
+
{ id: 'files', label: 'Files', page: 'Recent files', text: 'Omar Reyes added the new screens an hour ago.' },
|
|
244
|
+
{ id: 'team', label: 'Team', page: 'People and roles', text: 'Dana Lee, Ben Carter and Omar Reyes are in Acme.' },
|
|
245
|
+
];
|
|
246
|
+
|
|
247
|
+
// A real app reads this from the session.
|
|
248
|
+
const me = 'Dana Lee';
|
|
249
|
+
|
|
250
|
+
export default function AppShellTopTabs() {
|
|
251
|
+
const [placeId, setPlaceId] = useState('inbox');
|
|
252
|
+
const [accountAnchor, setAccountAnchor] = useState<HTMLElement | null>(null);
|
|
253
|
+
const [accountOpen, setAccountOpen] = useState(false);
|
|
254
|
+
const [confirming, setConfirming] = useState(false);
|
|
255
|
+
const [loggingOut, setLoggingOut] = useState(false);
|
|
256
|
+
const [loggedOut, setLoggedOut] = useState(false);
|
|
257
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
258
|
+
const accountButton = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
259
|
+
// Where focus goes after the next render, once the element it goes to is on screen.
|
|
260
|
+
const focusNext = useRef<() => void>();
|
|
261
|
+
|
|
262
|
+
// Stops the request if the example goes away before it ends.
|
|
263
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
264
|
+
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
const move = focusNext.current;
|
|
267
|
+
focusNext.current = undefined;
|
|
268
|
+
move?.();
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
const place = places.find((p) => p.id === placeId) ?? places[0];
|
|
272
|
+
// A real app passes the router from its framework, such as Next's useRouter(). Here it sets the open place.
|
|
273
|
+
const router = { push: (url: string) => setPlaceId(url.split('/').pop() ?? 'inbox') };
|
|
274
|
+
|
|
275
|
+
// 'Cancel' puts focus back on the account Button.
|
|
276
|
+
function cancelLogOut() {
|
|
277
|
+
if (loggingOut) return;
|
|
278
|
+
setConfirming(false);
|
|
279
|
+
focusNext.current = () => accountButton.current?.focus();
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
function logOut() {
|
|
283
|
+
if (loggingOut) return;
|
|
284
|
+
setLoggingOut(true);
|
|
285
|
+
// Stands in for the request to the server.
|
|
286
|
+
timer.current = setTimeout(() => {
|
|
287
|
+
setLoggingOut(false);
|
|
288
|
+
setConfirming(false);
|
|
289
|
+
setLoggedOut(true);
|
|
290
|
+
}, 1200);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
// A real app goes to its login page here. The example shows a short logged-out page instead.
|
|
294
|
+
if (loggedOut) {
|
|
295
|
+
return (
|
|
296
|
+
<Center fill>
|
|
297
|
+
<Heading level={1} size="h5">You are logged out</Heading>
|
|
298
|
+
<Cluster>
|
|
299
|
+
<Button size="medium" type="primary" state="enabled" label="Log In" onClickButton={() => { setLoggedOut(false); setPlaceId('inbox'); }} />
|
|
300
|
+
</Cluster>
|
|
301
|
+
</Center>
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return (
|
|
306
|
+
<PageShell>
|
|
307
|
+
<Stack gap="large">
|
|
308
|
+
{/* The app's name at the start, the account menu at the end. */}
|
|
309
|
+
<Cluster justify="between">
|
|
310
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
311
|
+
<Button
|
|
312
|
+
ref={accountButton}
|
|
313
|
+
size="small"
|
|
314
|
+
type="tertiary"
|
|
315
|
+
state={accountOpen ? 'selected' : 'enabled'}
|
|
316
|
+
label={me}
|
|
317
|
+
decoIcon={<UserImage userHandle={me} size={20} decorative />}
|
|
318
|
+
aria-label={`${me}, account menu`}
|
|
319
|
+
aria-haspopup="menu"
|
|
320
|
+
aria-expanded={accountOpen}
|
|
321
|
+
onClickButton={(e: { currentTarget: HTMLElement }) => {
|
|
322
|
+
setAccountAnchor(e.currentTarget);
|
|
323
|
+
setAccountOpen((o) => !o);
|
|
324
|
+
}}
|
|
325
|
+
/>
|
|
326
|
+
</Cluster>
|
|
327
|
+
<TabsContainer fill>
|
|
328
|
+
{places.map((p) => (
|
|
329
|
+
<Tab key={p.id} label={p.label} href={`/${p.id}`} router={router} isSelected={p.id === place.id} onClickTab={() => setPlaceId(p.id)} />
|
|
330
|
+
))}
|
|
331
|
+
</TabsContainer>
|
|
332
|
+
<TitleBar title={place.page} actions={<Button size="medium" type="primary" state="enabled" label="New Message" decoIcon="Plus" />} />
|
|
333
|
+
<Paragraph tone="secondary" measure="none">{place.text}</Paragraph>
|
|
334
|
+
</Stack>
|
|
335
|
+
<Popover open={accountOpen} anchorEl={accountAnchor} onClose={() => setAccountOpen(false)} returnFocus>
|
|
336
|
+
<Menu navigable aria-label="Account" width={200}>
|
|
337
|
+
<MenuItem size="small" iconName="Settings" label="Settings" onClick={() => setAccountOpen(false)} />
|
|
338
|
+
<MenuItem size="small" iconName="CircleHelp" label="Help" onClick={() => setAccountOpen(false)} />
|
|
339
|
+
<Line />
|
|
340
|
+
<MenuItem size="small" iconName="LogOut" label="Log Out" onClick={() => { setAccountOpen(false); setConfirming(true); }} />
|
|
341
|
+
</Menu>
|
|
342
|
+
</Popover>
|
|
343
|
+
<Modal
|
|
344
|
+
isOpen={confirming}
|
|
345
|
+
size="small"
|
|
346
|
+
title="Log Out"
|
|
347
|
+
onClose={cancelLogOut}
|
|
348
|
+
actions={
|
|
349
|
+
<>
|
|
350
|
+
<Button size="small" type="tertiary" state={loggingOut ? 'disabled' : 'enabled'} label="Cancel" onClickButton={cancelLogOut} />
|
|
351
|
+
<Button size="small" type="primary" state="enabled" label="Log Out" loading={loggingOut} onClickButton={logOut} />
|
|
352
|
+
</>
|
|
353
|
+
}
|
|
354
|
+
>
|
|
355
|
+
<Paragraph measure="none">You will need to log in again to use Acme on this device.</Paragraph>
|
|
356
|
+
</Modal>
|
|
357
|
+
</PageShell>
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
## Native
|
|
363
|
+
|
|
364
|
+
On macOS and iPad use a `NavigationSplitView` with a sidebar `List` in `Section`s. The system adds the hide button and its shortcut. On iPhone use a `TabView` for five places or fewer. On Android use a navigation drawer.
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
2
3
|
import { Bot, FileText } from 'lucide-react';
|
|
4
|
+
import AppShell from '../../components/appShell';
|
|
5
|
+
import SidePane from '../../components/sidePane';
|
|
6
|
+
import Navigation from '../../components/navigation';
|
|
7
|
+
import MenuItem from '../../components/menuItem';
|
|
3
8
|
import Message from '../../components/message';
|
|
4
9
|
import UserImage from '../../components/userImage';
|
|
5
10
|
import Tag from '../../components/tag';
|
|
@@ -7,7 +12,7 @@ import TimeStamp from '../../components/timeStamp';
|
|
|
7
12
|
import Heading from '../../components/heading';
|
|
8
13
|
import Paragraph from '../../components/paragraph';
|
|
9
14
|
import SourceCard from '../../components/sourceCard';
|
|
10
|
-
import {
|
|
15
|
+
import { Grid, Stack } from '../../components/layout';
|
|
11
16
|
var agentName = 'Acme Agent';
|
|
12
17
|
var request = { from: 'Dana Lee', at: new Date('2025-01-15T11:40:00Z'), text: 'Can you write up the launch plan as a document?' };
|
|
13
18
|
var repliedAt = new Date('2025-01-15T11:41:00Z');
|
|
@@ -22,11 +27,32 @@ function agentMeta(at) {
|
|
|
22
27
|
<Paragraph size="caption" tone="secondary" measure="none">Model name</Paragraph>
|
|
23
28
|
</>);
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
30
|
+
var docParagraphs = [
|
|
31
|
+
'Acme ships the new home page on March 3. Omar Reyes owns the copy and Dana Lee the screens.',
|
|
32
|
+
'Ben Carter writes the announcement once the screens are approved.',
|
|
33
|
+
];
|
|
34
|
+
// The threads. A real app lets each link go to its page.
|
|
35
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
36
|
+
<MenuItem size="small" label="Launch plan" iconName="MessageSquare" href="/launch-plan" isSelected aria-current="page" onClick={function (event) { return event.preventDefault(); }}/>
|
|
37
|
+
</Navigation>);
|
|
28
38
|
export default function ArtifactCardCard() {
|
|
29
|
-
|
|
39
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
40
|
+
// The pane opens from the card, so focus moves into it and goes back to the card on close.
|
|
41
|
+
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
42
|
+
var pane = useRef(null);
|
|
43
|
+
// Pressed again while the pane is open, the card brings the pane forward instead of opening a second one.
|
|
44
|
+
function openDocument() {
|
|
45
|
+
var _a;
|
|
46
|
+
if (open)
|
|
47
|
+
(_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
48
|
+
else
|
|
49
|
+
setOpen(true);
|
|
50
|
+
}
|
|
51
|
+
return (<AppShell title="Launch plan" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={open && (<SidePane ref={pane} title={doc.title} onClose={function () { return setOpen(false); }}>
|
|
52
|
+
<Stack gap="medium">
|
|
53
|
+
{docParagraphs.map(function (text) { return (<Paragraph key={text} measure="none">{text}</Paragraph>); })}
|
|
54
|
+
</Stack>
|
|
55
|
+
</SidePane>)}>
|
|
30
56
|
<Stack gap="large">
|
|
31
57
|
<Heading level={1} size="h5">Launch plan</Heading>
|
|
32
58
|
{/* A real app gives the list that holds the rows role="log". */}
|
|
@@ -41,5 +67,5 @@ export default function ArtifactCardCard() {
|
|
|
41
67
|
</Message>
|
|
42
68
|
</Stack>
|
|
43
69
|
</Stack>
|
|
44
|
-
</
|
|
70
|
+
</AppShell>);
|
|
45
71
|
}
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The agent made a document for the person, such as a plan or a report.
|
|
4
4
|
|
|
5
|
-
**Not built yet:** Scindo's card shows the kind, the title and 'Open' on one line, with no icon and no length. Its reply is not short: it is cut to its first lines.
|
|
6
|
-
|
|
7
5
|
## Do
|
|
8
6
|
|
|
9
7
|
- Keep the reply to one sentence on what the agent made. Then put the card in the reply's `footer`.
|
|
@@ -23,11 +21,16 @@ The agent made a document for the person, such as a plan or a report.
|
|
|
23
21
|
|
|
24
22
|
## Example: In the thread
|
|
25
23
|
|
|
26
|
-
Uses: `
|
|
24
|
+
Uses: `AppShell`, `Grid`, `Heading`, `MenuItem`, `Message`, `Navigation`, `Paragraph`, `SidePane`, `SourceCard`, `Stack`, `Tag`, `TimeStamp`, `UserImage`
|
|
27
25
|
|
|
28
26
|
```tsx
|
|
29
27
|
'use client';
|
|
28
|
+
import { useRef, useState } from 'react';
|
|
30
29
|
import { Bot, FileText } from 'lucide-react';
|
|
30
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
31
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
32
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
33
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
31
34
|
import Message from 'oneslash-design-system/components/message';
|
|
32
35
|
import UserImage from 'oneslash-design-system/components/userImage';
|
|
33
36
|
import Tag from 'oneslash-design-system/components/tag';
|
|
@@ -35,7 +38,7 @@ import TimeStamp from 'oneslash-design-system/components/timeStamp';
|
|
|
35
38
|
import Heading from 'oneslash-design-system/components/heading';
|
|
36
39
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
37
40
|
import SourceCard from 'oneslash-design-system/components/sourceCard';
|
|
38
|
-
import {
|
|
41
|
+
import { Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
39
42
|
|
|
40
43
|
const agentName = 'Acme Agent';
|
|
41
44
|
|
|
@@ -57,13 +60,56 @@ function agentMeta(at: Date) {
|
|
|
57
60
|
);
|
|
58
61
|
}
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
const docParagraphs = [
|
|
64
|
+
'Acme ships the new home page on March 3. Omar Reyes owns the copy and Dana Lee the screens.',
|
|
65
|
+
'Ben Carter writes the announcement once the screens are approved.',
|
|
66
|
+
];
|
|
67
|
+
|
|
68
|
+
// The threads. A real app lets each link go to its page.
|
|
69
|
+
const sidebar = (
|
|
70
|
+
<Navigation aria-label="Main">
|
|
71
|
+
<MenuItem
|
|
72
|
+
size="small"
|
|
73
|
+
label="Launch plan"
|
|
74
|
+
iconName="MessageSquare"
|
|
75
|
+
href="/launch-plan"
|
|
76
|
+
isSelected
|
|
77
|
+
aria-current="page"
|
|
78
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
79
|
+
/>
|
|
80
|
+
</Navigation>
|
|
81
|
+
);
|
|
63
82
|
|
|
64
83
|
export default function ArtifactCardCard() {
|
|
84
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
85
|
+
// The pane opens from the card, so focus moves into it and goes back to the card on close.
|
|
86
|
+
const [open, setOpen] = useState(false);
|
|
87
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
88
|
+
|
|
89
|
+
// Pressed again while the pane is open, the card brings the pane forward instead of opening a second one.
|
|
90
|
+
function openDocument() {
|
|
91
|
+
if (open) pane.current?.focus();
|
|
92
|
+
else setOpen(true);
|
|
93
|
+
}
|
|
94
|
+
|
|
65
95
|
return (
|
|
66
|
-
<
|
|
96
|
+
<AppShell
|
|
97
|
+
title="Launch plan"
|
|
98
|
+
navOpen={navOpen}
|
|
99
|
+
onNavOpenChange={setNavOpen}
|
|
100
|
+
sidebar={sidebar}
|
|
101
|
+
pane={
|
|
102
|
+
open && (
|
|
103
|
+
<SidePane ref={pane} title={doc.title} onClose={() => setOpen(false)}>
|
|
104
|
+
<Stack gap="medium">
|
|
105
|
+
{docParagraphs.map((text) => (
|
|
106
|
+
<Paragraph key={text} measure="none">{text}</Paragraph>
|
|
107
|
+
))}
|
|
108
|
+
</Stack>
|
|
109
|
+
</SidePane>
|
|
110
|
+
)
|
|
111
|
+
}
|
|
112
|
+
>
|
|
67
113
|
<Stack gap="large">
|
|
68
114
|
<Heading level={1} size="h5">Launch plan</Heading>
|
|
69
115
|
{/* A real app gives the list that holds the rows role="log". */}
|
|
@@ -91,7 +137,7 @@ export default function ArtifactCardCard() {
|
|
|
91
137
|
</Message>
|
|
92
138
|
</Stack>
|
|
93
139
|
</Stack>
|
|
94
|
-
</
|
|
140
|
+
</AppShell>
|
|
95
141
|
);
|
|
96
142
|
}
|
|
97
143
|
```
|
|
@@ -99,5 +145,3 @@ export default function ArtifactCardCard() {
|
|
|
99
145
|
## Native
|
|
100
146
|
|
|
101
147
|
On Mac the card opens the document in the canvas beside the thread. On iPhone it opens the document in a read-only sheet.
|
|
102
|
-
|
|
103
|
-
Seen in: Scindo.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
The app is checking whether the person is logged in, or running a step such as checking an invite, before it knows what to show.
|
|
4
4
|
|
|
5
|
-
**Not built yet:** Scindo on the web shows 'Please wait' under the step while it checks an invite, and a small spinner instead of `LoadingScreen` while onboarding checks for a workspace.
|
|
6
|
-
|
|
7
5
|
## Do
|
|
8
6
|
|
|
9
7
|
- Show the spinner from the first render, before anything else, as `LoadingScreen` in `Center` with `fill`.
|
|
@@ -66,5 +64,3 @@ export default function AuthGateLoadingSpinnerWithLine() {
|
|
|
66
64
|
## Native
|
|
67
65
|
|
|
68
66
|
On Apple use `ProgressView()` centered in the window, with a label only for a named step that can take longer.
|
|
69
|
-
|
|
70
|
-
Seen in: Commentify admin, Scindo.
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
A person signed up, and the product sent a link to confirm their email.
|
|
4
4
|
|
|
5
|
-
**Not built yet:** Neither Commentify nor Scindo can send the email again from the check-your-email screen. Both show their success Alert above the login form with a close button, and it starts 'Account created.', even for an address that already had an account.
|
|
6
|
-
|
|
7
5
|
## Do
|
|
8
6
|
|
|
9
7
|
- Name the page 'Check your email' in a `Heading` with `level={1}`, with a `Mail` icon above it.
|
|
@@ -180,5 +178,3 @@ export default function CheckYourEmailAlertOnLogin() {
|
|
|
180
178
|
);
|
|
181
179
|
}
|
|
182
180
|
```
|
|
183
|
-
|
|
184
|
-
Seen in: Commentify, Scindo.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function CollapsibleSearchPopover(): import("react").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import TextField from '../../components/textField';
|
|
6
|
+
import IconButton from '../../components/iconButton';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import Tooltip from '../../components/tooltip';
|
|
9
|
+
import Popover from '../../components/popover';
|
|
10
|
+
import Menu from '../../components/menu';
|
|
11
|
+
import List from '../../components/list';
|
|
12
|
+
import Surface from '../../components/surface';
|
|
13
|
+
import EmptyBox from '../../components/emptyBox';
|
|
14
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
15
|
+
// A real app reads these from the server.
|
|
16
|
+
var invoices = ['Northwind, March', 'Harbor Studio, March', 'Lumen Labs, February', 'Northstar Dental, February', 'Pine and Co, January'];
|
|
17
|
+
export default function CollapsibleSearchPopover() {
|
|
18
|
+
// The filter belongs to the page, not to the Popover: it stays when the Popover closes.
|
|
19
|
+
var _a = useState('north'), query = _a[0], setQuery = _a[1];
|
|
20
|
+
var _b = useState(null), anchor = _b[0], setAnchor = _b[1];
|
|
21
|
+
var _c = useState(false), open = _c[0], setOpen = _c[1];
|
|
22
|
+
var trigger = useRef(null);
|
|
23
|
+
var words = query.trim();
|
|
24
|
+
var on = words !== '';
|
|
25
|
+
var found = invoices.filter(function (name) { return name.toLowerCase().includes(words.toLowerCase()); });
|
|
26
|
+
function toggle(anchorEl) {
|
|
27
|
+
setAnchor(anchorEl);
|
|
28
|
+
setOpen(function (o) { return !o; });
|
|
29
|
+
}
|
|
30
|
+
// Escape clears the search and closes. The field handles it before the Popover's own Escape, which only closes.
|
|
31
|
+
// Enter closes and keeps the filter. A click outside and Tab close and keep it too.
|
|
32
|
+
function keyDown(e) {
|
|
33
|
+
if (e.key === 'Escape') {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
setQuery('');
|
|
36
|
+
setOpen(false);
|
|
37
|
+
}
|
|
38
|
+
else if (e.key === 'Enter') {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
setOpen(false);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// The field is closed, so 'Clear Search' clears the filter and focus goes to the search button.
|
|
44
|
+
function clearSearch() {
|
|
45
|
+
var _a;
|
|
46
|
+
setQuery('');
|
|
47
|
+
(_a = trigger.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
48
|
+
}
|
|
49
|
+
return (<Center width="page">
|
|
50
|
+
<Stack gap="large">
|
|
51
|
+
<Cluster gap="small">
|
|
52
|
+
<Heading level={1} size="h5">Invoices</Heading>
|
|
53
|
+
{/* A search that is on shows in a filled button and says what it is looking for. */}
|
|
54
|
+
<Tooltip title={on ? "Search: ".concat(words) : 'Search'}>
|
|
55
|
+
<IconButton ref={trigger} color={on ? 'secondary' : 'iconOnly'} state={open ? 'selected' : 'enabled'} size="small" iconName="Search" ariaLabel={on ? "Search: ".concat(words) : 'Search'} aria-haspopup="dialog" aria-expanded={open} onClick={function (e) { return toggle(e.currentTarget); }}/>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
</Cluster>
|
|
58
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
59
|
+
{on ? "".concat(found.length, " of ").concat(invoices.length, " invoices match \"").concat(words, "\".") : "All ".concat(invoices.length, " invoices.")}
|
|
60
|
+
</Paragraph>
|
|
61
|
+
{found.length > 0 ? (<Surface>
|
|
62
|
+
<List items={found} size="body1"/>
|
|
63
|
+
</Surface>) : (<Surface align="center" minHeight="short">
|
|
64
|
+
<EmptyBox size="large" icon="Search" text={"No invoices match \"".concat(words, "\"")} secondText="Check the spelling, or search for fewer words." action={<Button size="medium" type="secondary" state="enabled" label="Clear Search" onClickButton={clearSearch}/>}/>
|
|
65
|
+
</Surface>)}
|
|
66
|
+
</Stack>
|
|
67
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
68
|
+
{/* Menu gives the Popover its surface and a width. It holds a field here, not items. */}
|
|
69
|
+
<Menu width={288}>
|
|
70
|
+
<TextField id="collapsible-search-query" type="search" size="small" autoFocus aria-label="Search invoices" placeholder="Search invoices" value={query} onChange={function (e) { return setQuery(e.target.value); }} onKeyDown={keyDown}/>
|
|
71
|
+
</Menu>
|
|
72
|
+
</Popover>
|
|
73
|
+
</Center>);
|
|
74
|
+
}
|