oneslash-design-system 2.18.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 +1 -1
- package/dist/DESIGN.md +26 -1
- 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 -7
- package/dist/cases/error-page/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -21
- 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/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 -20
- 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/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/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -21
- 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/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/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.json +666 -19
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/heading.d.ts +3 -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/menuItem.d.ts +7 -1
- package/dist/components/menuItem.jsx +4 -3
- package/dist/components/modal.jsx +12 -23
- 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/settingsSection.d.ts +6 -1
- package/dist/components/settingsSection.jsx +10 -3
- 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/titleBar.d.ts +17 -0
- package/dist/components/titleBar.jsx +17 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -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/native-mapping.json +43 -1
- 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 +19 -0
- package/dist/stories/Cases.generated.stories.jsx +38 -0
- package/dist/stories/Drawer.stories.d.ts +10 -0
- package/dist/stories/Drawer.stories.jsx +123 -0
- package/dist/stories/Link.stories.d.ts +1 -0
- package/dist/stories/Link.stories.jsx +8 -0
- package/dist/stories/OnThisPage.stories.d.ts +10 -0
- package/dist/stories/OnThisPage.stories.jsx +105 -0
- package/dist/stories/SettingsSection.stories.d.ts +1 -0
- package/dist/stories/SettingsSection.stories.jsx +27 -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/TitleBar.stories.d.ts +6 -0
- package/dist/stories/TitleBar.stories.jsx +34 -0
- package/package.json +1 -1
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
# Page header with actions
|
|
2
|
+
|
|
3
|
+
A page names itself at the top and offers what the person can do with it.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'.
|
|
8
|
+
- Use `TitleBar` with the page's name as the level 1 heading. Inside `AppShell` the top bar names the place on a phone. When the page is the place, the two are the same.
|
|
9
|
+
- Give the page one primary Button, first in `actions`.
|
|
10
|
+
- Put icon buttons after it, each in a `Tooltip` and named for what they act on: 'Search Home page'.
|
|
11
|
+
- Put a More menu last, as the case 'More menu' says: an `IconButton` with `iconName="Ellipsis"`, `aria-haspopup="menu"` and a name such as 'More actions for Home page'.
|
|
12
|
+
- Pass `phoneActions` with the primary Button and More. Below `md` they replace `actions`.
|
|
13
|
+
- Fold the icon buttons you leave out into the More menu, in the same order, so every action is still there. Put them first, before a `Line`. Keep a frequent action, such as Search, as an icon button in `phoneActions`.
|
|
14
|
+
- Pass `back` on a sub-page, a tertiary Button named for the page it goes to: 'Back to Website'. Below `md` it takes its own line.
|
|
15
|
+
- Let a long title wrap. Never cut it short.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not add a breadcrumb. Back goes one step up, and the title says where the person is.
|
|
20
|
+
- Do not show two primary Buttons.
|
|
21
|
+
- Do not name an icon button only by its icon, or More only by the word.
|
|
22
|
+
- Do not leave an action out on a phone without a way to reach it.
|
|
23
|
+
- Do not name the Back Button 'Back'. Name the page.
|
|
24
|
+
|
|
25
|
+
## Option: The page's own actions
|
|
26
|
+
|
|
27
|
+
Use when: The page is a place of its own, and the person can add to it, search it or change it.
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `IconButton`, `Line`, `Menu`, `MenuItem`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `TitleBar`, `Tooltip`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import { useState } from 'react';
|
|
34
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
35
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
36
|
+
import Button from 'oneslash-design-system/components/button';
|
|
37
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
38
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
39
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
40
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
41
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
42
|
+
import Line from 'oneslash-design-system/components/line';
|
|
43
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
44
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
45
|
+
|
|
46
|
+
export default function PageHeaderActions() {
|
|
47
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
48
|
+
// Which More button opened the menu: on a phone the menu also holds Search and Filter.
|
|
49
|
+
const [from, setFrom] = useState<'wide' | 'phone'>('wide');
|
|
50
|
+
const [open, setOpen] = useState(false);
|
|
51
|
+
const [chosen, setChosen] = useState('');
|
|
52
|
+
|
|
53
|
+
function openMore(kind: 'wide' | 'phone', el: HTMLElement) {
|
|
54
|
+
setFrom(kind);
|
|
55
|
+
setAnchor(el);
|
|
56
|
+
setOpen((o) => !o);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Every item closes the menu. Its Popover gives focus back to the More button.
|
|
60
|
+
function choose(label: string) {
|
|
61
|
+
setOpen(false);
|
|
62
|
+
setChosen(label);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const newTask = <Button size="medium" type="primary" state="enabled" label="New Task" decoIcon="Plus" onClickButton={() => setChosen('New Task')} />;
|
|
66
|
+
|
|
67
|
+
const more = (kind: 'wide' | 'phone') => (
|
|
68
|
+
<Tooltip title="More">
|
|
69
|
+
<IconButton
|
|
70
|
+
color="iconOnly"
|
|
71
|
+
state={open && from === kind ? 'selected' : 'enabled'}
|
|
72
|
+
size="medium"
|
|
73
|
+
iconName="Ellipsis"
|
|
74
|
+
ariaLabel="More actions for Home page"
|
|
75
|
+
aria-haspopup="menu"
|
|
76
|
+
aria-expanded={open && from === kind}
|
|
77
|
+
onClick={(e: { currentTarget: HTMLElement }) => openMore(kind, e.currentTarget)}
|
|
78
|
+
/>
|
|
79
|
+
</Tooltip>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<PageShell>
|
|
84
|
+
<Stack gap="large">
|
|
85
|
+
{/* The title is the page's level 1 heading. One primary Button, then icon buttons, then More last. Below md only the primary and More stay. */}
|
|
86
|
+
<TitleBar
|
|
87
|
+
title="Home page"
|
|
88
|
+
actions={
|
|
89
|
+
<>
|
|
90
|
+
{newTask}
|
|
91
|
+
<Tooltip title="Search">
|
|
92
|
+
<IconButton color="iconOnly" state="enabled" size="medium" iconName="Search" ariaLabel="Search Home page" onClick={() => setChosen('Search')} />
|
|
93
|
+
</Tooltip>
|
|
94
|
+
<Tooltip title="Filter">
|
|
95
|
+
<IconButton color="iconOnly" state="enabled" size="medium" iconName="Filter" ariaLabel="Filter Home page" onClick={() => setChosen('Filter')} />
|
|
96
|
+
</Tooltip>
|
|
97
|
+
{more('wide')}
|
|
98
|
+
</>
|
|
99
|
+
}
|
|
100
|
+
phoneActions={
|
|
101
|
+
<>
|
|
102
|
+
{newTask}
|
|
103
|
+
{more('phone')}
|
|
104
|
+
</>
|
|
105
|
+
}
|
|
106
|
+
/>
|
|
107
|
+
<Paragraph tone="secondary" size="body2" measure="none">{chosen ? `You chose ${chosen}.` : '12 tasks are open. Updated 2 days ago by Dana Lee.'}</Paragraph>
|
|
108
|
+
</Stack>
|
|
109
|
+
<Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
|
|
110
|
+
<Menu navigable aria-label="Actions for Home page" width={200}>
|
|
111
|
+
{from === 'phone' && (
|
|
112
|
+
<>
|
|
113
|
+
<MenuItem size="small" iconName="Search" label="Search" onClick={() => choose('Search')} />
|
|
114
|
+
<MenuItem size="small" iconName="Filter" label="Filter" onClick={() => choose('Filter')} />
|
|
115
|
+
<Line />
|
|
116
|
+
</>
|
|
117
|
+
)}
|
|
118
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={() => choose('Rename')} />
|
|
119
|
+
<MenuItem size="small" iconName="Copy" label="Duplicate" onClick={() => choose('Duplicate')} />
|
|
120
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={() => choose('Archive')} />
|
|
121
|
+
</Menu>
|
|
122
|
+
</Popover>
|
|
123
|
+
</PageShell>
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Option: A page one step down, with Back
|
|
129
|
+
|
|
130
|
+
Use when: The page opens from another page, such as a task from its project.
|
|
131
|
+
|
|
132
|
+
Uses: `Button`, `Heading`, `MenuItem`, `Navigation`, `PageShell`, `Paragraph`, `Stack`, `TitleBar`
|
|
133
|
+
|
|
134
|
+
```tsx
|
|
135
|
+
'use client';
|
|
136
|
+
import { useState } from 'react';
|
|
137
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
138
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
139
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
140
|
+
import Button from 'oneslash-design-system/components/button';
|
|
141
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
142
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
143
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
144
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
145
|
+
|
|
146
|
+
const taskTitle = 'Move the sign-up form above the pricing table on the home page';
|
|
147
|
+
|
|
148
|
+
export default function PageHeaderSubPage() {
|
|
149
|
+
// The task is a page one step down from the project's page.
|
|
150
|
+
const [view, setView] = useState<'task' | 'project'>('task');
|
|
151
|
+
const [done, setDone] = useState(false);
|
|
152
|
+
|
|
153
|
+
if (view === 'project') {
|
|
154
|
+
return (
|
|
155
|
+
<PageShell>
|
|
156
|
+
<Stack gap="large">
|
|
157
|
+
<Heading level={1} size="h5">Website</Heading>
|
|
158
|
+
<Navigation aria-label="Tasks">
|
|
159
|
+
<MenuItem
|
|
160
|
+
size="medium"
|
|
161
|
+
label={taskTitle}
|
|
162
|
+
secondLabel={done ? 'Done' : 'Open'}
|
|
163
|
+
iconRight="ChevronRight"
|
|
164
|
+
href="/website/tasks/sign-up-form"
|
|
165
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
166
|
+
// A real app lets the link go to the task's page. The example keeps the choice in state.
|
|
167
|
+
event.preventDefault();
|
|
168
|
+
setView('task');
|
|
169
|
+
}}
|
|
170
|
+
/>
|
|
171
|
+
</Navigation>
|
|
172
|
+
</Stack>
|
|
173
|
+
</PageShell>
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
<PageShell>
|
|
179
|
+
<Stack gap="large">
|
|
180
|
+
{/* Back names the page it goes to. Below md it takes its own line above the title, and a long title wraps. */}
|
|
181
|
+
<TitleBar
|
|
182
|
+
title={taskTitle}
|
|
183
|
+
back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Website" onClickButton={() => setView('project')} />}
|
|
184
|
+
actions={<Button size="medium" type="primary" state={done ? 'disabled' : 'enabled'} label="Mark Done" onClickButton={() => setDone(true)} />}
|
|
185
|
+
/>
|
|
186
|
+
<Paragraph tone="secondary" size="body2" measure="none">{done ? 'Done. Marked by Dana Lee.' : 'Assigned to Ben Carter. Due on Friday.'}</Paragraph>
|
|
187
|
+
</Stack>
|
|
188
|
+
</PageShell>
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
## Native
|
|
194
|
+
|
|
195
|
+
On Apple use a navigation title with `.toolbar` items: the primary action as a `ToolbarItem`, the rest in a `Menu`. The system back button names the page before it. On Android use a top app bar with an overflow menu.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# On a phone, a sidebar opens as a drawer and a list opens its detail
|
|
2
|
+
|
|
3
|
+
A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.
|
|
4
|
+
|
|
5
|
+
## Answer
|
|
6
|
+
|
|
7
|
+
An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
A drawer opens over the page, so the person still sees where they are, and closing it puts them back on the same page. One drawer, built into `AppShell`, works the same way in every app.
|
|
12
|
+
|
|
13
|
+
## Do
|
|
14
|
+
|
|
15
|
+
- Open the sidebar in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. Use `AppShell`.
|
|
16
|
+
- Close the drawer on a choice, Close, Escape, the scrim and when the window widens past `md`.
|
|
17
|
+
- Turn a list beside its detail into two screens on a phone: the list first, then the detail with a Back Button named for the list.
|
|
18
|
+
- Let a side pane take the whole content area on a phone, with a Close button.
|
|
19
|
+
- Put a site's links in the same kind of menu, and keep at most one main action in the bar.
|
|
20
|
+
- Give every place a way to be reached on a phone, even one that is only a link.
|
|
21
|
+
|
|
22
|
+
## Don't
|
|
23
|
+
|
|
24
|
+
- Do not hide a link on a phone without a menu that holds it.
|
|
25
|
+
- Do not show a sidebar beside the page on a phone, or squeeze a side pane beside the content.
|
|
26
|
+
- Do not replace the page with the app's sidebar. Open the drawer over it. A settings nav is a list beside its detail, so it is the first screen on a phone.
|
|
27
|
+
- Do not add a bottom tab bar on the web.
|
|
28
|
+
- Do not leave a drawer that Escape and a tap outside cannot close.
|
|
29
|
+
|
|
30
|
+
## Native
|
|
31
|
+
|
|
32
|
+
On iPhone use a `TabView` or a `NavigationStack` that pushes the detail with the system back button, and a `.sheet` for a short task. On Android use a navigation drawer or a bottom bar, and push the detail with the system back.
|
|
@@ -1,26 +1,35 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import AppShell from '../../components/appShell';
|
|
4
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
5
|
+
import MenuItem from '../../components/menuItem';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
5
7
|
import Surface from '../../components/surface';
|
|
6
8
|
import LoadingScreen from '../../components/loadingScreen';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
// The places, and the projects the person made. The page that failed or loads is the current one.
|
|
10
|
+
var places = [
|
|
11
|
+
{ label: 'Home', icon: 'House', href: '/' },
|
|
12
|
+
{ label: 'Settings', icon: 'Settings', href: '/settings' },
|
|
13
|
+
];
|
|
14
|
+
var projects = [
|
|
15
|
+
{ label: 'Website', icon: 'Globe', href: '/projects/website' },
|
|
16
|
+
{ label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },
|
|
17
|
+
];
|
|
18
|
+
var current = '/projects/website';
|
|
19
|
+
var row = function (p) { return (<MenuItem key={p.href} size="small" label={p.label} iconName={p.icon} href={p.href} isSelected={p.href === current} aria-current={p.href === current ? 'page' : undefined}
|
|
20
|
+
// A real app lets the link go to its page.
|
|
21
|
+
onClick={function (event) { return event.preventDefault(); }}/>); };
|
|
22
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
23
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
24
|
+
{places.map(row)}
|
|
25
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
26
|
+
</Navigation>);
|
|
12
27
|
export default function RouteLoadingRegion() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
<TabsContainer>
|
|
17
|
-
<Tab label="Home" isSelected={false} href="/" router={router} onClickTab={function () { }}/>
|
|
18
|
-
<Tab label="Projects" isSelected href="/projects" router={router} onClickTab={function () { }}/>
|
|
19
|
-
<Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={function () { }}/>
|
|
20
|
-
</TabsContainer>
|
|
21
|
-
</Cluster>
|
|
28
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
29
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
30
|
+
return (<AppShell title="Website" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
22
31
|
<Surface minHeight="tall" align="center">
|
|
23
32
|
<LoadingScreen />
|
|
24
33
|
</Surface>
|
|
25
|
-
</
|
|
34
|
+
</AppShell>);
|
|
26
35
|
}
|
|
@@ -40,39 +40,60 @@ export default function RouteLoadingFullScreen() {
|
|
|
40
40
|
|
|
41
41
|
Use when: The shell shows and one pane loads.
|
|
42
42
|
|
|
43
|
-
Uses: `
|
|
43
|
+
Uses: `AppShell`, `LoadingScreen`, `MenuItem`, `Navigation`, `NavigationGroup`, `Paragraph`, `Surface`
|
|
44
44
|
|
|
45
45
|
```tsx
|
|
46
46
|
'use client';
|
|
47
|
-
import
|
|
48
|
-
import
|
|
49
|
-
import
|
|
47
|
+
import { useState } from 'react';
|
|
48
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
49
|
+
import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
|
|
50
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
51
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
50
52
|
import Surface from 'oneslash-design-system/components/surface';
|
|
51
53
|
import LoadingScreen from 'oneslash-design-system/components/loadingScreen';
|
|
52
|
-
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
53
54
|
|
|
54
|
-
// The
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
55
|
+
// The places, and the projects the person made. The page that failed or loads is the current one.
|
|
56
|
+
const places = [
|
|
57
|
+
{ label: 'Home', icon: 'House', href: '/' },
|
|
58
|
+
{ label: 'Settings', icon: 'Settings', href: '/settings' },
|
|
59
|
+
];
|
|
60
|
+
const projects = [
|
|
61
|
+
{ label: 'Website', icon: 'Globe', href: '/projects/website' },
|
|
62
|
+
{ label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },
|
|
63
|
+
];
|
|
64
|
+
const current = '/projects/website';
|
|
65
|
+
|
|
66
|
+
const row = (p: { label: string; icon: string; href: string }) => (
|
|
67
|
+
<MenuItem
|
|
68
|
+
key={p.href}
|
|
69
|
+
size="small"
|
|
70
|
+
label={p.label}
|
|
71
|
+
iconName={p.icon}
|
|
72
|
+
href={p.href}
|
|
73
|
+
isSelected={p.href === current}
|
|
74
|
+
aria-current={p.href === current ? 'page' : undefined}
|
|
75
|
+
// A real app lets the link go to its page.
|
|
76
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const sidebar = (
|
|
81
|
+
<Navigation aria-label="Main">
|
|
82
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
83
|
+
{places.map(row)}
|
|
84
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
85
|
+
</Navigation>
|
|
86
|
+
);
|
|
60
87
|
|
|
61
88
|
export default function RouteLoadingRegion() {
|
|
89
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
90
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
62
91
|
return (
|
|
63
|
-
<
|
|
64
|
-
<Cluster gap="large">
|
|
65
|
-
<Image src={productMark} alt="Acme" width={32} height={32} />
|
|
66
|
-
<TabsContainer>
|
|
67
|
-
<Tab label="Home" isSelected={false} href="/" router={router} onClickTab={() => {}} />
|
|
68
|
-
<Tab label="Projects" isSelected href="/projects" router={router} onClickTab={() => {}} />
|
|
69
|
-
<Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={() => {}} />
|
|
70
|
-
</TabsContainer>
|
|
71
|
-
</Cluster>
|
|
92
|
+
<AppShell title="Website" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
72
93
|
<Surface minHeight="tall" align="center">
|
|
73
94
|
<LoadingScreen />
|
|
74
95
|
</Surface>
|
|
75
|
-
</
|
|
96
|
+
</AppShell>
|
|
76
97
|
);
|
|
77
98
|
}
|
|
78
99
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SidePaneBeside(): import("react").JSX.Element;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
import { useRef, useState } from 'react';
|
|
12
|
+
import AppShell from '../../components/appShell';
|
|
13
|
+
import SidePane from '../../components/sidePane';
|
|
14
|
+
import TitleBar from '../../components/titleBar';
|
|
15
|
+
import Navigation, { NavigationGroup } from '../../components/navigation';
|
|
16
|
+
import MenuItem from '../../components/menuItem';
|
|
17
|
+
import IconButton from '../../components/iconButton';
|
|
18
|
+
import Tooltip from '../../components/tooltip';
|
|
19
|
+
import UserImage from '../../components/userImage';
|
|
20
|
+
import Paragraph from '../../components/paragraph';
|
|
21
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
22
|
+
var members = [
|
|
23
|
+
{ name: 'Dana Lee', role: 'Owner' },
|
|
24
|
+
{ name: 'Ben Carter', role: 'Editor' },
|
|
25
|
+
{ name: 'Omar Reyes', role: 'Editor' },
|
|
26
|
+
];
|
|
27
|
+
var places = [
|
|
28
|
+
{ id: 'inbox', label: 'Inbox', icon: 'Inbox' },
|
|
29
|
+
{ id: 'tasks', label: 'Tasks', icon: 'ListChecks' },
|
|
30
|
+
{ id: 'files', label: 'Files', icon: 'Files' },
|
|
31
|
+
];
|
|
32
|
+
// The projects the person made
|
|
33
|
+
var projects = [
|
|
34
|
+
{ id: 'website', label: 'Website', icon: 'Globe' },
|
|
35
|
+
{ id: 'mobile-app', label: 'Mobile App', icon: 'Smartphone' },
|
|
36
|
+
];
|
|
37
|
+
export default function SidePaneBeside() {
|
|
38
|
+
var _a;
|
|
39
|
+
var _b = useState(false), navOpen = _b[0], setNavOpen = _b[1];
|
|
40
|
+
var _c = useState('tasks'), placeId = _c[0], setPlaceId = _c[1];
|
|
41
|
+
// One pane at a time. Opening another replaces it.
|
|
42
|
+
var _d = useState(null), open = _d[0], setOpen = _d[1];
|
|
43
|
+
// Only the pane that holds a document can be resized.
|
|
44
|
+
var _e = useState(448), briefWidth = _e[0], setBriefWidth = _e[1];
|
|
45
|
+
var pane = useRef(null);
|
|
46
|
+
var place = (_a = __spreadArray(__spreadArray([], places, true), projects, true).find(function (p) { return p.id === placeId; })) !== null && _a !== void 0 ? _a : places[0];
|
|
47
|
+
// Pressed again while its pane is open, the opener brings the pane forward instead of opening a second one.
|
|
48
|
+
function opener(id, label, icon) {
|
|
49
|
+
return (<Tooltip title={label}>
|
|
50
|
+
<IconButton color="iconOnly" state={open === id ? 'selected' : 'enabled'} size="medium" iconName={icon} ariaLabel={label} aria-expanded={open === id} onClick={function () { var _a; return (open === id ? (_a = pane.current) === null || _a === void 0 ? void 0 : _a.focus() : setOpen(id)); }}/>
|
|
51
|
+
</Tooltip>);
|
|
52
|
+
}
|
|
53
|
+
var row = function (p) { return (<MenuItem key={p.id} size="small" label={p.label} iconName={p.icon} href={"/".concat(p.id)} isSelected={p.id === place.id} aria-current={p.id === place.id ? 'page' : undefined} onClick={function (event) {
|
|
54
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
setPlaceId(p.id);
|
|
57
|
+
}}/>); };
|
|
58
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
59
|
+
{places.map(row)}
|
|
60
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
61
|
+
</Navigation>);
|
|
62
|
+
return (<AppShell title={place.label} navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar} pane={open && (<SidePane key={open} ref={pane} title={open === 'members' ? 'Members' : 'Brief'} onClose={function () { return setOpen(null); }} width={open === 'brief' ? briefWidth : undefined} onWidthChange={open === 'brief' ? setBriefWidth : undefined}>
|
|
63
|
+
{open === 'members' ? (<Stack gap="medium">
|
|
64
|
+
{members.map(function (m) { return (<Cluster key={m.name}>
|
|
65
|
+
<UserImage userHandle={m.name} decorative/>
|
|
66
|
+
<Paragraph size="body1" measure="none">{m.name}</Paragraph>
|
|
67
|
+
<Paragraph tone="secondary" size="body2" measure="none">{m.role}</Paragraph>
|
|
68
|
+
</Cluster>); })}
|
|
69
|
+
</Stack>) : (<Stack gap="medium">
|
|
70
|
+
<Paragraph measure="none">Acme ships the new home page on Friday. Omar Reyes owns the copy and Dana Lee the screens.</Paragraph>
|
|
71
|
+
<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>
|
|
72
|
+
</Stack>)}
|
|
73
|
+
</SidePane>)}>
|
|
74
|
+
<Stack gap="large">
|
|
75
|
+
<TitleBar title="Launch plan" actions={<>{opener('members', 'Members', 'Users')}{opener('brief', 'Brief', 'FileText')}</>}/>
|
|
76
|
+
<Paragraph tone="secondary" measure="none">Ben Carter is writing the announcement. Omar Reyes is waiting for the new screens.</Paragraph>
|
|
77
|
+
</Stack>
|
|
78
|
+
</AppShell>);
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function SidePaneOver(): import("react").JSX.Element;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Drawer from '../../components/drawer';
|
|
4
|
+
import PageShell from '../../components/pageShell';
|
|
5
|
+
import TitleBar from '../../components/titleBar';
|
|
6
|
+
import RadioGroup from '../../components/radioGroup';
|
|
7
|
+
import Paragraph from '../../components/paragraph';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
10
|
+
var people = [
|
|
11
|
+
{ label: 'Dana Lee', value: 'dana' },
|
|
12
|
+
{ label: 'Ben Carter', value: 'ben' },
|
|
13
|
+
{ label: 'Omar Reyes', value: 'omar' },
|
|
14
|
+
];
|
|
15
|
+
export default function SidePaneOver() {
|
|
16
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
17
|
+
// The person on the task, and the one picked in the sheet before Assign.
|
|
18
|
+
var _b = useState(''), assigned = _b[0], setAssigned = _b[1];
|
|
19
|
+
var _c = useState('dana'), picked = _c[0], setPicked = _c[1];
|
|
20
|
+
var _d = useState(false), saving = _d[0], setSaving = _d[1];
|
|
21
|
+
var timer = useRef();
|
|
22
|
+
// Stops the request if the example goes away before it ends.
|
|
23
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
24
|
+
// Escape, the scrim, Close and Cancel all close it, except while the request runs.
|
|
25
|
+
function close() {
|
|
26
|
+
if (saving)
|
|
27
|
+
return;
|
|
28
|
+
setOpen(false);
|
|
29
|
+
}
|
|
30
|
+
function assign() {
|
|
31
|
+
if (saving)
|
|
32
|
+
return;
|
|
33
|
+
setSaving(true);
|
|
34
|
+
// Stands in for the request to the server.
|
|
35
|
+
timer.current = setTimeout(function () {
|
|
36
|
+
var _a, _b;
|
|
37
|
+
setSaving(false);
|
|
38
|
+
setAssigned((_b = (_a = people.find(function (p) { return p.value === picked; })) === null || _a === void 0 ? void 0 : _a.label) !== null && _b !== void 0 ? _b : '');
|
|
39
|
+
setOpen(false);
|
|
40
|
+
}, 1200);
|
|
41
|
+
}
|
|
42
|
+
return (<PageShell>
|
|
43
|
+
<Stack gap="large">
|
|
44
|
+
<TitleBar title="Launch plan" actions={<Button size="medium" type="secondary" state="enabled" label="Assign" decoIcon="UserPlus" onClickButton={function () { return setOpen(true); }}/>}/>
|
|
45
|
+
{/* The result shows here, where the person is looking, so there is no toast. */}
|
|
46
|
+
<Paragraph tone="secondary" measure="none">{assigned ? "Assigned to ".concat(assigned, ".") : 'Nobody is assigned yet.'}</Paragraph>
|
|
47
|
+
</Stack>
|
|
48
|
+
<Drawer isOpen={open} onClose={close} side="end" size="small" title="Assign Task" initialFocus="body">
|
|
49
|
+
<Stack gap="large">
|
|
50
|
+
<RadioGroup aria-label="Person" options={people} selectedValue={picked} disabled={saving} onChange={setPicked}/>
|
|
51
|
+
<Cluster justify="end">
|
|
52
|
+
<Button size="small" type="tertiary" state={saving ? 'disabled' : 'enabled'} label="Cancel" onClickButton={close}/>
|
|
53
|
+
<Button size="small" type="primary" state="enabled" label="Assign" loading={saving} onClickButton={assign}/>
|
|
54
|
+
</Cluster>
|
|
55
|
+
</Stack>
|
|
56
|
+
</Drawer>
|
|
57
|
+
</PageShell>);
|
|
58
|
+
}
|