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,238 @@
|
|
|
1
|
+
# Side pane
|
|
2
|
+
|
|
3
|
+
A person opens more about the page, such as its members, its history or a document, without leaving the page.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail': on a phone a pane takes the whole content area.
|
|
8
|
+
- Put the pane in the `pane` of `AppShell`, as a `SidePane` with a `title` and `onClose`. Render it only while it is open.
|
|
9
|
+
- Open it from an `IconButton` with a name and `aria-expanded`, and give it `state="selected"` while the pane is open.
|
|
10
|
+
- Show one pane at a time. Opening another replaces the first. Pressing the opener of the open pane calls `focus()` on the pane's ref instead of opening a second one.
|
|
11
|
+
- Let Close and Escape close the pane. Focus goes back to the opener.
|
|
12
|
+
- Open a pane only from the person's own action. It takes focus when it mounts.
|
|
13
|
+
- Make a pane resizable only when it holds a document: pass `width` and `onWidthChange`. The start edge then moves with the pointer and with the arrow keys.
|
|
14
|
+
- Use `Drawer side="end"` with a `title` for a short task. On a phone it is a sheet from the bottom.
|
|
15
|
+
- Give a Drawer `initialFocus="body"` when it holds a control, so focus lands on the control. Keep the Drawer open while its request runs.
|
|
16
|
+
- Show the result of a task in the page behind the Drawer, such as 'Assigned to Ben Carter.' Show no toast.
|
|
17
|
+
- Title a Drawer for its action in Title Case, as a Modal: 'Assign Task'. Title a pane that shows one thing with its name.
|
|
18
|
+
- Put 'Cancel' first and the action last, named with the title's verb: 'Assign Task' has an 'Assign' Button. If the request fails, keep the Drawer open and show an inline error Alert at its top, as the rule 'A form error shows next to the problem' says.
|
|
19
|
+
|
|
20
|
+
## Don't
|
|
21
|
+
|
|
22
|
+
- Do not squeeze a pane beside the page on a phone.
|
|
23
|
+
- Do not open two panes at once.
|
|
24
|
+
- Do not open a pane when the page loads, or from a timer. It takes focus away from the person.
|
|
25
|
+
- Do not make a list of members resizable. Only a document needs room.
|
|
26
|
+
- Do not use a Drawer for something the person reads together with the page.
|
|
27
|
+
|
|
28
|
+
## Option: Pane beside the page
|
|
29
|
+
|
|
30
|
+
Use when: The person reads the pane and the page together, such as members, history or a document.
|
|
31
|
+
|
|
32
|
+
Uses: `AppShell`, `Cluster`, `IconButton`, `MenuItem`, `Navigation`, `NavigationGroup`, `Paragraph`, `SidePane`, `Stack`, `TitleBar`, `Tooltip`, `UserImage`
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
'use client';
|
|
36
|
+
import { useRef, useState } from 'react';
|
|
37
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
38
|
+
import SidePane, { type SidePaneHandle } from 'oneslash-design-system/components/sidePane';
|
|
39
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
40
|
+
import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
|
|
41
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
42
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
43
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
44
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
45
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
46
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
47
|
+
|
|
48
|
+
type PaneId = 'members' | 'brief';
|
|
49
|
+
|
|
50
|
+
const members = [
|
|
51
|
+
{ name: 'Dana Lee', role: 'Owner' },
|
|
52
|
+
{ name: 'Ben Carter', role: 'Editor' },
|
|
53
|
+
{ name: 'Omar Reyes', role: 'Editor' },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const places = [
|
|
57
|
+
{ id: 'inbox', label: 'Inbox', icon: 'Inbox' },
|
|
58
|
+
{ id: 'tasks', label: 'Tasks', icon: 'ListChecks' },
|
|
59
|
+
{ id: 'files', label: 'Files', icon: 'Files' },
|
|
60
|
+
];
|
|
61
|
+
// The projects the person made
|
|
62
|
+
const projects = [
|
|
63
|
+
{ id: 'website', label: 'Website', icon: 'Globe' },
|
|
64
|
+
{ id: 'mobile-app', label: 'Mobile App', icon: 'Smartphone' },
|
|
65
|
+
];
|
|
66
|
+
|
|
67
|
+
export default function SidePaneBeside() {
|
|
68
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
69
|
+
const [placeId, setPlaceId] = useState('tasks');
|
|
70
|
+
// One pane at a time. Opening another replaces it.
|
|
71
|
+
const [open, setOpen] = useState<PaneId | null>(null);
|
|
72
|
+
// Only the pane that holds a document can be resized.
|
|
73
|
+
const [briefWidth, setBriefWidth] = useState(448);
|
|
74
|
+
const pane = useRef<SidePaneHandle>(null);
|
|
75
|
+
|
|
76
|
+
const place = [...places, ...projects].find((p) => p.id === placeId) ?? places[0];
|
|
77
|
+
|
|
78
|
+
// Pressed again while its pane is open, the opener brings the pane forward instead of opening a second one.
|
|
79
|
+
function opener(id: PaneId, label: string, icon: 'Users' | 'FileText') {
|
|
80
|
+
return (
|
|
81
|
+
<Tooltip title={label}>
|
|
82
|
+
<IconButton
|
|
83
|
+
color="iconOnly"
|
|
84
|
+
state={open === id ? 'selected' : 'enabled'}
|
|
85
|
+
size="medium"
|
|
86
|
+
iconName={icon}
|
|
87
|
+
ariaLabel={label}
|
|
88
|
+
aria-expanded={open === id}
|
|
89
|
+
onClick={() => (open === id ? pane.current?.focus() : setOpen(id))}
|
|
90
|
+
/>
|
|
91
|
+
</Tooltip>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const row = (p: { id: string; label: string; icon: string }) => (
|
|
96
|
+
<MenuItem
|
|
97
|
+
key={p.id}
|
|
98
|
+
size="small"
|
|
99
|
+
label={p.label}
|
|
100
|
+
iconName={p.icon}
|
|
101
|
+
href={`/${p.id}`}
|
|
102
|
+
isSelected={p.id === place.id}
|
|
103
|
+
aria-current={p.id === place.id ? 'page' : undefined}
|
|
104
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
105
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
setPlaceId(p.id);
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const sidebar = (
|
|
113
|
+
<Navigation aria-label="Main">
|
|
114
|
+
{places.map(row)}
|
|
115
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
116
|
+
</Navigation>
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<AppShell
|
|
121
|
+
title={place.label}
|
|
122
|
+
navOpen={navOpen}
|
|
123
|
+
onNavOpenChange={setNavOpen}
|
|
124
|
+
sidebar={sidebar}
|
|
125
|
+
pane={
|
|
126
|
+
open && (
|
|
127
|
+
<SidePane
|
|
128
|
+
key={open}
|
|
129
|
+
ref={pane}
|
|
130
|
+
title={open === 'members' ? 'Members' : 'Brief'}
|
|
131
|
+
onClose={() => setOpen(null)}
|
|
132
|
+
width={open === 'brief' ? briefWidth : undefined}
|
|
133
|
+
onWidthChange={open === 'brief' ? setBriefWidth : undefined}
|
|
134
|
+
>
|
|
135
|
+
{open === 'members' ? (
|
|
136
|
+
<Stack gap="medium">
|
|
137
|
+
{members.map((m) => (
|
|
138
|
+
<Cluster key={m.name}>
|
|
139
|
+
<UserImage userHandle={m.name} decorative />
|
|
140
|
+
<Paragraph size="body1" measure="none">{m.name}</Paragraph>
|
|
141
|
+
<Paragraph tone="secondary" size="body2" measure="none">{m.role}</Paragraph>
|
|
142
|
+
</Cluster>
|
|
143
|
+
))}
|
|
144
|
+
</Stack>
|
|
145
|
+
) : (
|
|
146
|
+
<Stack gap="medium">
|
|
147
|
+
<Paragraph measure="none">Acme ships the new home page on Friday. Omar Reyes owns the copy and Dana Lee the screens.</Paragraph>
|
|
148
|
+
<Paragraph tone="secondary" measure="none">The pane stays beside the page, so the task and the brief are read together. Drag its edge, or use the arrow keys on it, to make it wider.</Paragraph>
|
|
149
|
+
</Stack>
|
|
150
|
+
)}
|
|
151
|
+
</SidePane>
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
>
|
|
155
|
+
<Stack gap="large">
|
|
156
|
+
<TitleBar title="Launch plan" actions={<>{opener('members', 'Members', 'Users')}{opener('brief', 'Brief', 'FileText')}</>} />
|
|
157
|
+
<Paragraph tone="secondary" measure="none">Ben Carter is writing the announcement. Omar Reyes is waiting for the new screens.</Paragraph>
|
|
158
|
+
</Stack>
|
|
159
|
+
</AppShell>
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Option: Drawer over the page
|
|
165
|
+
|
|
166
|
+
Use when: The task is short and the page can be hidden for a moment, such as picking a person.
|
|
167
|
+
|
|
168
|
+
Uses: `Button`, `Cluster`, `Drawer`, `PageShell`, `Paragraph`, `RadioGroup`, `Stack`, `TitleBar`
|
|
169
|
+
|
|
170
|
+
```tsx
|
|
171
|
+
'use client';
|
|
172
|
+
import { useEffect, useRef, useState } from 'react';
|
|
173
|
+
import Drawer from 'oneslash-design-system/components/drawer';
|
|
174
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
175
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
176
|
+
import RadioGroup from 'oneslash-design-system/components/radioGroup';
|
|
177
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
178
|
+
import Button from 'oneslash-design-system/components/button';
|
|
179
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
180
|
+
|
|
181
|
+
const people = [
|
|
182
|
+
{ label: 'Dana Lee', value: 'dana' },
|
|
183
|
+
{ label: 'Ben Carter', value: 'ben' },
|
|
184
|
+
{ label: 'Omar Reyes', value: 'omar' },
|
|
185
|
+
];
|
|
186
|
+
|
|
187
|
+
export default function SidePaneOver() {
|
|
188
|
+
const [open, setOpen] = useState(false);
|
|
189
|
+
// The person on the task, and the one picked in the sheet before Assign.
|
|
190
|
+
const [assigned, setAssigned] = useState('');
|
|
191
|
+
const [picked, setPicked] = useState('dana');
|
|
192
|
+
const [saving, setSaving] = useState(false);
|
|
193
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
194
|
+
|
|
195
|
+
// Stops the request if the example goes away before it ends.
|
|
196
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
197
|
+
|
|
198
|
+
// Escape, the scrim, Close and Cancel all close it, except while the request runs.
|
|
199
|
+
function close() {
|
|
200
|
+
if (saving) return;
|
|
201
|
+
setOpen(false);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function assign() {
|
|
205
|
+
if (saving) return;
|
|
206
|
+
setSaving(true);
|
|
207
|
+
// Stands in for the request to the server.
|
|
208
|
+
timer.current = setTimeout(() => {
|
|
209
|
+
setSaving(false);
|
|
210
|
+
setAssigned(people.find((p) => p.value === picked)?.label ?? '');
|
|
211
|
+
setOpen(false);
|
|
212
|
+
}, 1200);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return (
|
|
216
|
+
<PageShell>
|
|
217
|
+
<Stack gap="large">
|
|
218
|
+
<TitleBar title="Launch plan" actions={<Button size="medium" type="secondary" state="enabled" label="Assign" decoIcon="UserPlus" onClickButton={() => setOpen(true)} />} />
|
|
219
|
+
{/* The result shows here, where the person is looking, so there is no toast. */}
|
|
220
|
+
<Paragraph tone="secondary" measure="none">{assigned ? `Assigned to ${assigned}.` : 'Nobody is assigned yet.'}</Paragraph>
|
|
221
|
+
</Stack>
|
|
222
|
+
<Drawer isOpen={open} onClose={close} side="end" size="small" title="Assign Task" initialFocus="body">
|
|
223
|
+
<Stack gap="large">
|
|
224
|
+
<RadioGroup aria-label="Person" options={people} selectedValue={picked} disabled={saving} onChange={setPicked} />
|
|
225
|
+
<Cluster justify="end">
|
|
226
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={close} />
|
|
227
|
+
<Button size="small" type="primary" state="enabled" label="Assign" loading={saving} onClickButton={assign} />
|
|
228
|
+
</Cluster>
|
|
229
|
+
</Stack>
|
|
230
|
+
</Drawer>
|
|
231
|
+
</PageShell>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
## Native
|
|
237
|
+
|
|
238
|
+
On Apple use an inspector (`.inspector`) for a pane beside the page, and a `.sheet` with `presentationDetents` for a short task. On Android use a `ModalBottomSheet` for a short task.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SidebarNavFlat(): import("react").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useState } from 'react';
|
|
23
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
24
|
+
import MenuItem from '../../components/menuItem';
|
|
25
|
+
import Paragraph from '../../components/paragraph';
|
|
26
|
+
import { Center, Stack } from '../../components/layout';
|
|
27
|
+
var initialPlaces = [
|
|
28
|
+
{ id: 'inbox', label: 'Inbox', icon: 'Inbox', group: 'Mail' },
|
|
29
|
+
{ id: 'mentions', label: 'Mentions', icon: 'AtSign', group: 'Mail' },
|
|
30
|
+
{ id: 'sent', label: 'Sent', icon: 'Send', group: 'Mail' },
|
|
31
|
+
{ id: 'launch', label: 'Launch plan', icon: 'ListChecks', group: 'Tasks' },
|
|
32
|
+
{ id: 'review', label: 'Design review', icon: 'ListChecks', group: 'Tasks' },
|
|
33
|
+
{ id: 'pricing', label: 'Pricing page', icon: 'ListChecks', group: 'Tasks' },
|
|
34
|
+
];
|
|
35
|
+
var groups = ['Mail', 'Tasks'];
|
|
36
|
+
// What has not been read, by place. A place with none has no entry, and shows no count.
|
|
37
|
+
var initialUnread = { inbox: 3, mentions: 1, launch: 2 };
|
|
38
|
+
export default function SidebarNavFlat() {
|
|
39
|
+
var _a;
|
|
40
|
+
var _b = useState(initialPlaces), places = _b[0], setPlaces = _b[1];
|
|
41
|
+
var _c = useState('sent'), currentId = _c[0], setCurrentId = _c[1];
|
|
42
|
+
var _d = useState(initialUnread), unread = _d[0], setUnread = _d[1];
|
|
43
|
+
var _e = useState(0), created = _e[0], setCreated = _e[1];
|
|
44
|
+
var current = (_a = places.find(function (p) { return p.id === currentId; })) !== null && _a !== void 0 ? _a : places[0];
|
|
45
|
+
// Opening a place reads it, so its count goes away.
|
|
46
|
+
function open(id) {
|
|
47
|
+
setCurrentId(id);
|
|
48
|
+
setUnread(function (u) {
|
|
49
|
+
var _a;
|
|
50
|
+
return (__assign(__assign({}, u), (_a = {}, _a[id] = 0, _a)));
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
// The new task goes to the top of its group, and opens.
|
|
54
|
+
function newTask() {
|
|
55
|
+
var id = "new-".concat(created + 1);
|
|
56
|
+
setCreated(created + 1);
|
|
57
|
+
setPlaces(function (all) { return __spreadArray([{ id: id, label: "New task ".concat(created + 1), icon: 'ListChecks', group: 'Tasks' }], all, true); });
|
|
58
|
+
setCurrentId(id);
|
|
59
|
+
}
|
|
60
|
+
return (<Center>
|
|
61
|
+
<Stack gap="large">
|
|
62
|
+
<Navigation aria-label="Main">
|
|
63
|
+
{groups.map(function (group) { return (<NavigationGroup key={group} label={group}>
|
|
64
|
+
{group === 'Tasks' && <MenuItem size="small" iconName="Plus" label="New Task" role="button" onClick={newTask}/>}
|
|
65
|
+
{places.filter(function (p) { return p.group === group; }).map(function (p) {
|
|
66
|
+
var _a;
|
|
67
|
+
var count = (_a = unread[p.id]) !== null && _a !== void 0 ? _a : 0;
|
|
68
|
+
return (<MenuItem key={p.id} size="small" label={p.label} iconName={p.icon} href={"/".concat(p.id)} isSelected={p.id === current.id} aria-current={p.id === current.id ? 'page' : undefined}
|
|
69
|
+
// A count is what has not been read, as quiet text. Nothing shows at zero, and the name says the count.
|
|
70
|
+
tag={count > 0 ? { label: String(count), variant: 'textOnly' } : undefined} aria-label={count > 0 ? "".concat(p.label, ", ").concat(count, " unread") : undefined} onClick={function (event) {
|
|
71
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
open(p.id);
|
|
74
|
+
}}/>);
|
|
75
|
+
})}
|
|
76
|
+
</NavigationGroup>); })}
|
|
77
|
+
</Navigation>
|
|
78
|
+
<Paragraph tone="secondary" size="body2" measure="none">You are in {current.label}.</Paragraph>
|
|
79
|
+
</Stack>
|
|
80
|
+
</Center>);
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SidebarNavNested(): import("react").JSX.Element;
|
|
@@ -0,0 +1,122 @@
|
|
|
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
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useEffect, useState } from 'react';
|
|
23
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
24
|
+
import MenuItem from '../../components/menuItem';
|
|
25
|
+
import Paragraph from '../../components/paragraph';
|
|
26
|
+
import { Center, Stack } from '../../components/layout';
|
|
27
|
+
var initialWorkspaces = [
|
|
28
|
+
{
|
|
29
|
+
id: 'acme',
|
|
30
|
+
name: 'Acme',
|
|
31
|
+
tasks: [
|
|
32
|
+
{ id: 'launch', label: 'Launch plan' },
|
|
33
|
+
{ id: 'pricing', label: 'Pricing page' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'studio',
|
|
38
|
+
name: 'Side Studio',
|
|
39
|
+
tasks: [
|
|
40
|
+
{ id: 'logo', label: 'New logo' },
|
|
41
|
+
{ id: 'site', label: 'Landing page' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
// What has not been read, by place. A place with none has no entry, and shows no count.
|
|
46
|
+
var initialUnread = { pricing: 2, site: 1 };
|
|
47
|
+
var STORAGE_KEY = 'sidebar-nav-hidden-groups';
|
|
48
|
+
export default function SidebarNavNested() {
|
|
49
|
+
var _a, _b;
|
|
50
|
+
var _c = useState(initialWorkspaces), workspaces = _c[0], setWorkspaces = _c[1];
|
|
51
|
+
var _d = useState('launch'), currentId = _d[0], setCurrentId = _d[1];
|
|
52
|
+
var _e = useState(initialUnread), unread = _e[0], setUnread = _e[1];
|
|
53
|
+
var _f = useState(0), created = _f[0], setCreated = _f[1];
|
|
54
|
+
// The groups the person hid. They stay hidden when the person comes back, so a real app saves them per person.
|
|
55
|
+
var _g = useState([]), hiddenGroups = _g[0], setHiddenGroups = _g[1];
|
|
56
|
+
// Read after the first render, so the server and the browser start from the same page.
|
|
57
|
+
useEffect(function () {
|
|
58
|
+
var _a;
|
|
59
|
+
try {
|
|
60
|
+
var saved = JSON.parse((_a = localStorage.getItem(STORAGE_KEY)) !== null && _a !== void 0 ? _a : '[]');
|
|
61
|
+
if (Array.isArray(saved))
|
|
62
|
+
setHiddenGroups(saved.filter(function (id) { return typeof id === 'string'; }));
|
|
63
|
+
}
|
|
64
|
+
catch (_b) {
|
|
65
|
+
// Storage can be blocked. The groups then start shown.
|
|
66
|
+
}
|
|
67
|
+
}, []);
|
|
68
|
+
function toggleGroup(id) {
|
|
69
|
+
var next = hiddenGroups.includes(id) ? hiddenGroups.filter(function (g) { return g !== id; }) : __spreadArray(__spreadArray([], hiddenGroups, true), [id], false);
|
|
70
|
+
setHiddenGroups(next);
|
|
71
|
+
try {
|
|
72
|
+
localStorage.setItem(STORAGE_KEY, JSON.stringify(next));
|
|
73
|
+
}
|
|
74
|
+
catch (_a) {
|
|
75
|
+
// Storage can be blocked. The choice then lasts until the page closes.
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function open(id) {
|
|
79
|
+
setCurrentId(id);
|
|
80
|
+
setUnread(function (u) {
|
|
81
|
+
var _a;
|
|
82
|
+
return (__assign(__assign({}, u), (_a = {}, _a[id] = 0, _a)));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
// The new task goes to the top of its group, and opens.
|
|
86
|
+
function newTask(workspaceId) {
|
|
87
|
+
var id = "new-".concat(created + 1);
|
|
88
|
+
setCreated(created + 1);
|
|
89
|
+
setWorkspaces(function (all) { return all.map(function (w) { return (w.id === workspaceId ? __assign(__assign({}, w), { tasks: __spreadArray([{ id: id, label: "New task ".concat(created + 1) }], w.tasks, true) }) : w); }); });
|
|
90
|
+
setCurrentId(id);
|
|
91
|
+
}
|
|
92
|
+
var currentName = (_b = (_a = workspaces.flatMap(function (w) { return w.tasks; }).find(function (t) { return t.id === currentId; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '';
|
|
93
|
+
return (<Center>
|
|
94
|
+
<Stack gap="large">
|
|
95
|
+
<Navigation aria-label="Main">
|
|
96
|
+
<NavigationGroup label="Workspaces">
|
|
97
|
+
{workspaces.map(function (w) {
|
|
98
|
+
var hidden = hiddenGroups.includes(w.id);
|
|
99
|
+
// A closed place keeps its count, on its own row, so nothing unread is out of sight.
|
|
100
|
+
var hiddenUnread = hidden ? w.tasks.reduce(function (sum, t) { var _a; return sum + ((_a = unread[t.id]) !== null && _a !== void 0 ? _a : 0); }, 0) : 0;
|
|
101
|
+
return (<Stack key={w.id} gap="small">
|
|
102
|
+
{/* The row that holds the others shows or hides them. It keeps its name; aria-expanded says which. */}
|
|
103
|
+
<MenuItem size="small" label={w.name} iconName="Building2" iconRight={hidden ? 'ChevronRight' : 'ChevronDown'} role="button" aria-expanded={!hidden}
|
|
104
|
+
// A closed place keeps its count here, and the name says it.
|
|
105
|
+
tag={hiddenUnread > 0 ? { label: String(hiddenUnread), variant: 'textOnly' } : undefined} aria-label={hiddenUnread > 0 ? "".concat(w.name, ", ").concat(hiddenUnread, " unread") : undefined} onClick={function () { return toggleGroup(w.id); }}/>
|
|
106
|
+
{/* Each workspace has its own New Task, so its name says which. In a phone menu, close the menu in this onClick. */}
|
|
107
|
+
{!hidden && <MenuItem size="small" level={2} iconName="Plus" label="New Task" aria-label={"New task in ".concat(w.name)} role="button" onClick={function () { return newTask(w.id); }}/>}
|
|
108
|
+
{!hidden && w.tasks.map(function (t) {
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return (<MenuItem key={t.id} size="small" label={t.label} level={2} iconName="ListChecks" href={"/".concat(w.id, "/").concat(t.id)} isSelected={t.id === currentId} aria-current={t.id === currentId ? 'page' : undefined} tag={((_a = unread[t.id]) !== null && _a !== void 0 ? _a : 0) > 0 ? { label: String(unread[t.id]), variant: 'textOnly' } : undefined} aria-label={((_b = unread[t.id]) !== null && _b !== void 0 ? _b : 0) > 0 ? "".concat(t.label, ", ").concat(unread[t.id], " unread") : undefined} onClick={function (event) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
open(t.id);
|
|
113
|
+
}}/>);
|
|
114
|
+
})}
|
|
115
|
+
</Stack>);
|
|
116
|
+
})}
|
|
117
|
+
</NavigationGroup>
|
|
118
|
+
</Navigation>
|
|
119
|
+
<Paragraph tone="secondary" size="body2" measure="none">You are in {currentName}.</Paragraph>
|
|
120
|
+
</Stack>
|
|
121
|
+
</Center>);
|
|
122
|
+
}
|