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,170 @@
|
|
|
1
|
+
# Menu on a phone
|
|
2
|
+
|
|
3
|
+
A site's links and actions do not fit in the bar on a phone, and the person still needs to reach every one.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'On a phone, a sidebar opens as a drawer and a list opens its detail'. The menu is a `Drawer` from the start side.
|
|
8
|
+
- Open it from an `IconButton` named 'Menu' at the start of the bar, with `aria-expanded` and `aria-controls`.
|
|
9
|
+
- Use the menu that `SiteHeader` builds for a few links. The links come first, then the actions. One main action stays in the bar as `phoneAction`.
|
|
10
|
+
- Build the menu from a `Drawer` for sections: the pages of the open section as `MenuItem` links in a `Navigation`. Put a `TabsContainer` of section `Tab`s above them when the bar does not show the sections.
|
|
11
|
+
- Put the 'Menu' IconButton in a real bar with a skip link, as `SiteHeader` builds.
|
|
12
|
+
- Open the menu on the section of the current page, and mark the current page with `isSelected` and `aria-current="page"`.
|
|
13
|
+
- Close the menu when a page is chosen. A `Drawer` also closes on Close, Escape and the scrim.
|
|
14
|
+
- Close the menu when the window widens past `md`, so the page is never left locked. A `SiteHeader` does it; give your own `Drawer` `closeFrom="md"`.
|
|
15
|
+
- Give the Drawer a name with `aria-label`, the same as the button that opens it.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not leave a link without a way to reach it on a phone.
|
|
20
|
+
- Do not keep the menu open after a page is chosen.
|
|
21
|
+
- Do not put a Button that opens a Modal in the menu. On a phone the menu closes when it is chosen, so the Modal has no Button to give focus back to. Link to a page instead.
|
|
22
|
+
- Do not name the button only by its icon. Name it 'Menu'.
|
|
23
|
+
- Do not use more than four section tabs, or long names. They will not fit on a phone.
|
|
24
|
+
|
|
25
|
+
## Option: Links and actions in one menu
|
|
26
|
+
|
|
27
|
+
Use when: A site has a few links and its actions, such as 'Log In'.
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `Heading`, `PageShell`, `Paragraph`, `SiteHeader`, `Stack`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import SiteHeader from 'oneslash-design-system/components/siteHeader';
|
|
34
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
35
|
+
import Button from 'oneslash-design-system/components/button';
|
|
36
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
37
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
38
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
39
|
+
|
|
40
|
+
const links = [
|
|
41
|
+
{ label: 'Features', href: '#features', current: true },
|
|
42
|
+
{ label: 'Pricing', href: '#pricing' },
|
|
43
|
+
{ label: 'Docs', href: '#docs' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
export default function MobileMenuLinks() {
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
{/* Below md the Menu IconButton opens a Drawer: the links first, then 'Log In'. Choosing one closes it. 'Sign Up' stays in the bar. */}
|
|
50
|
+
<SiteHeader
|
|
51
|
+
brand={{ href: '#top', name: 'Acme' }}
|
|
52
|
+
links={links}
|
|
53
|
+
actions={<Button size="medium" type="tertiary" state="enabled" label="Log In" href="#log-in" />}
|
|
54
|
+
phoneAction={<Button size="medium" type="primary" state="enabled" label="Sign Up" href="#sign-up" />}
|
|
55
|
+
mainId="mobile-menu-links-main"
|
|
56
|
+
/>
|
|
57
|
+
<PageShell id="mobile-menu-links-main" tabIndex={-1}>
|
|
58
|
+
<Stack gap="large">
|
|
59
|
+
<Heading level={1} size="h5">Features</Heading>
|
|
60
|
+
<Paragraph tone="secondary" measure="none">On a phone, open Menu to reach every page. It closes when you choose one.</Paragraph>
|
|
61
|
+
</Stack>
|
|
62
|
+
</PageShell>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Option: Sections with their pages
|
|
69
|
+
|
|
70
|
+
Use when: A site has sections that each hold many pages, and the person picks a section first.
|
|
71
|
+
|
|
72
|
+
Uses: `Cluster`, `Drawer`, `Heading`, `IconButton`, `MenuItem`, `Navigation`, `PageShell`, `Paragraph`, `Stack`, `Tab`, `TabsContainer`
|
|
73
|
+
|
|
74
|
+
```tsx
|
|
75
|
+
'use client';
|
|
76
|
+
import { useState } from 'react';
|
|
77
|
+
import Drawer from 'oneslash-design-system/components/drawer';
|
|
78
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
79
|
+
import TabsContainer from 'oneslash-design-system/components/tabsContainer';
|
|
80
|
+
import Tab from 'oneslash-design-system/components/tab';
|
|
81
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
82
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
83
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
84
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
85
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
86
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
87
|
+
|
|
88
|
+
type Page = { id: string; label: string };
|
|
89
|
+
type Section = { id: string; label: string; pages: Page[] };
|
|
90
|
+
|
|
91
|
+
// Four sections, one short word each. A real site reads these from its navigation.
|
|
92
|
+
const sections: Section[] = [
|
|
93
|
+
{ id: 'start', label: 'Start', pages: [{ id: 'install', label: 'Install' }, { id: 'first-steps', label: 'First steps' }] },
|
|
94
|
+
{ id: 'guides', label: 'Guides', pages: [{ id: 'sharing', label: 'Share a folder' }, { id: 'roles', label: 'Roles and access' }, { id: 'billing', label: 'Billing' }] },
|
|
95
|
+
{ id: 'reference', label: 'API', pages: [{ id: 'api', label: 'Endpoints' }, { id: 'limits', label: 'Limits' }] },
|
|
96
|
+
{ id: 'updates', label: 'News', pages: [{ id: 'changelog', label: 'Changelog' }] },
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
const drawerId = 'mobile-menu-sections-drawer';
|
|
100
|
+
|
|
101
|
+
export default function MobileMenuSections() {
|
|
102
|
+
const [open, setOpen] = useState(false);
|
|
103
|
+
const [pageId, setPageId] = useState('sharing');
|
|
104
|
+
const currentSection = sections.find((s) => s.pages.some((p) => p.id === pageId)) ?? sections[0];
|
|
105
|
+
// The tabs show the section of the current page each time the menu opens.
|
|
106
|
+
const [sectionId, setSectionId] = useState(currentSection.id);
|
|
107
|
+
const shown = sections.find((s) => s.id === sectionId) ?? sections[0];
|
|
108
|
+
const page = currentSection.pages.find((p) => p.id === pageId) ?? currentSection.pages[0];
|
|
109
|
+
|
|
110
|
+
function openMenu() {
|
|
111
|
+
setSectionId(currentSection.id);
|
|
112
|
+
setOpen(true);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return (
|
|
116
|
+
<PageShell>
|
|
117
|
+
<Stack gap="large">
|
|
118
|
+
<Cluster gap="small">
|
|
119
|
+
{/* A real site shows this IconButton only below md, where the links are not in the bar. */}
|
|
120
|
+
<IconButton
|
|
121
|
+
color="iconOnly"
|
|
122
|
+
state="enabled"
|
|
123
|
+
size="medium"
|
|
124
|
+
iconName="Menu"
|
|
125
|
+
ariaLabel="Menu"
|
|
126
|
+
aria-expanded={open}
|
|
127
|
+
aria-controls={drawerId}
|
|
128
|
+
onClick={openMenu}
|
|
129
|
+
/>
|
|
130
|
+
<Paragraph size="body1" measure="none">Acme Docs</Paragraph>
|
|
131
|
+
</Cluster>
|
|
132
|
+
<Heading level={1} size="h5">{page.label}</Heading>
|
|
133
|
+
<Paragraph tone="secondary" measure="none">This page is in {currentSection.label}. Open Menu to move to another section.</Paragraph>
|
|
134
|
+
</Stack>
|
|
135
|
+
{/* Section tabs at the top, the section's pages under them, the current page marked. A choice closes the Drawer. */}
|
|
136
|
+
<Drawer id={drawerId} isOpen={open} onClose={() => setOpen(false)} aria-label="Menu" side="start" size="small" closeFrom="md">
|
|
137
|
+
<Stack gap="large">
|
|
138
|
+
<TabsContainer fill>
|
|
139
|
+
{sections.map((s) => (
|
|
140
|
+
<Tab key={s.id} label={s.label} size="small" isSelected={s.id === shown.id} onClickTab={() => setSectionId(s.id)} />
|
|
141
|
+
))}
|
|
142
|
+
</TabsContainer>
|
|
143
|
+
<Navigation aria-label={`${shown.label} pages`}>
|
|
144
|
+
{shown.pages.map((p) => (
|
|
145
|
+
<MenuItem
|
|
146
|
+
key={p.id}
|
|
147
|
+
size="small"
|
|
148
|
+
label={p.label}
|
|
149
|
+
href={`/${shown.id}/${p.id}`}
|
|
150
|
+
isSelected={p.id === pageId}
|
|
151
|
+
aria-current={p.id === pageId ? 'page' : undefined}
|
|
152
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
153
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
154
|
+
event.preventDefault();
|
|
155
|
+
setPageId(p.id);
|
|
156
|
+
setOpen(false);
|
|
157
|
+
}}
|
|
158
|
+
/>
|
|
159
|
+
))}
|
|
160
|
+
</Navigation>
|
|
161
|
+
</Stack>
|
|
162
|
+
</Drawer>
|
|
163
|
+
</PageShell>
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Native
|
|
169
|
+
|
|
170
|
+
On iPhone use a `TabView` for the main places and a `NavigationStack` for the pages in a section. On Android use a navigation drawer.
|
|
@@ -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';
|
|
5
6
|
import Surface from '../../components/surface';
|
|
6
7
|
import Heading from '../../components/heading';
|
|
7
8
|
import Paragraph from '../../components/paragraph';
|
|
8
9
|
import Button from '../../components/button';
|
|
9
10
|
import { Cluster, Stack } from '../../components/layout';
|
|
10
|
-
// The
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
// The places, and the projects the person made. The page that failed or loads is the current one.
|
|
12
|
+
var places = [
|
|
13
|
+
{ label: 'Home', icon: 'House', href: '/' },
|
|
14
|
+
{ label: 'Settings', icon: 'Settings', href: '/settings' },
|
|
15
|
+
];
|
|
16
|
+
var projects = [
|
|
17
|
+
{ label: 'Website', icon: 'Globe', href: '/projects/website' },
|
|
18
|
+
{ label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },
|
|
19
|
+
];
|
|
20
|
+
var current = '/projects/website';
|
|
21
|
+
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}
|
|
22
|
+
// A real app lets the link go to its page.
|
|
23
|
+
onClick={function (event) { return event.preventDefault(); }}/>); };
|
|
24
|
+
var sidebar = (<Navigation aria-label="Main">
|
|
25
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
26
|
+
{places.map(row)}
|
|
27
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
28
|
+
</Navigation>);
|
|
14
29
|
export default function NotFoundPageInShell() {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<TabsContainer>
|
|
19
|
-
<Tab label="Home" isSelected={false} href="/" router={router} onClickTab={function () { }}/>
|
|
20
|
-
<Tab label="Projects" isSelected href="/projects" router={router} onClickTab={function () { }}/>
|
|
21
|
-
<Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={function () { }}/>
|
|
22
|
-
</TabsContainer>
|
|
23
|
-
</Cluster>
|
|
30
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
31
|
+
var _a = useState(false), navOpen = _a[0], setNavOpen = _a[1];
|
|
32
|
+
return (<AppShell title="Website" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
24
33
|
<Surface minHeight="tall" align="center">
|
|
25
34
|
<Stack gap="xlarge">
|
|
26
35
|
<Stack gap="medium">
|
|
@@ -32,5 +41,5 @@ export default function NotFoundPageInShell() {
|
|
|
32
41
|
</Cluster>
|
|
33
42
|
</Stack>
|
|
34
43
|
</Surface>
|
|
35
|
-
</
|
|
44
|
+
</AppShell>);
|
|
36
45
|
}
|
|
@@ -46,37 +46,58 @@ export default function NotFoundPageFullPage() {
|
|
|
46
46
|
|
|
47
47
|
Use when: The address is inside the app and the navigation still works.
|
|
48
48
|
|
|
49
|
-
Uses: `Button`, `Cluster`, `Heading`, `
|
|
49
|
+
Uses: `AppShell`, `Button`, `Cluster`, `Heading`, `MenuItem`, `Navigation`, `NavigationGroup`, `Paragraph`, `Stack`, `Surface`
|
|
50
50
|
|
|
51
51
|
```tsx
|
|
52
52
|
'use client';
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import
|
|
53
|
+
import { useState } from 'react';
|
|
54
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
55
|
+
import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
|
|
56
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
56
57
|
import Surface from 'oneslash-design-system/components/surface';
|
|
57
58
|
import Heading from 'oneslash-design-system/components/heading';
|
|
58
59
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
59
60
|
import Button from 'oneslash-design-system/components/button';
|
|
60
61
|
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
61
62
|
|
|
62
|
-
// The
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const
|
|
63
|
+
// The places, and the projects the person made. The page that failed or loads is the current one.
|
|
64
|
+
const places = [
|
|
65
|
+
{ label: 'Home', icon: 'House', href: '/' },
|
|
66
|
+
{ label: 'Settings', icon: 'Settings', href: '/settings' },
|
|
67
|
+
];
|
|
68
|
+
const projects = [
|
|
69
|
+
{ label: 'Website', icon: 'Globe', href: '/projects/website' },
|
|
70
|
+
{ label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },
|
|
71
|
+
];
|
|
72
|
+
const current = '/projects/website';
|
|
73
|
+
|
|
74
|
+
const row = (p: { label: string; icon: string; href: string }) => (
|
|
75
|
+
<MenuItem
|
|
76
|
+
key={p.href}
|
|
77
|
+
size="small"
|
|
78
|
+
label={p.label}
|
|
79
|
+
iconName={p.icon}
|
|
80
|
+
href={p.href}
|
|
81
|
+
isSelected={p.href === current}
|
|
82
|
+
aria-current={p.href === current ? 'page' : undefined}
|
|
83
|
+
// A real app lets the link go to its page.
|
|
84
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
85
|
+
/>
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const sidebar = (
|
|
89
|
+
<Navigation aria-label="Main">
|
|
90
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
91
|
+
{places.map(row)}
|
|
92
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
93
|
+
</Navigation>
|
|
94
|
+
);
|
|
68
95
|
|
|
69
96
|
export default function NotFoundPageInShell() {
|
|
97
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
98
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
70
99
|
return (
|
|
71
|
-
<
|
|
72
|
-
<Cluster gap="large">
|
|
73
|
-
<Image src={productMark} alt="Acme" width={32} height={32} />
|
|
74
|
-
<TabsContainer>
|
|
75
|
-
<Tab label="Home" isSelected={false} href="/" router={router} onClickTab={() => {}} />
|
|
76
|
-
<Tab label="Projects" isSelected href="/projects" router={router} onClickTab={() => {}} />
|
|
77
|
-
<Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={() => {}} />
|
|
78
|
-
</TabsContainer>
|
|
79
|
-
</Cluster>
|
|
100
|
+
<AppShell title="Website" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
80
101
|
<Surface minHeight="tall" align="center">
|
|
81
102
|
<Stack gap="xlarge">
|
|
82
103
|
<Stack gap="medium">
|
|
@@ -88,7 +109,7 @@ export default function NotFoundPageInShell() {
|
|
|
88
109
|
</Cluster>
|
|
89
110
|
</Stack>
|
|
90
111
|
</Surface>
|
|
91
|
-
</
|
|
112
|
+
</AppShell>
|
|
92
113
|
);
|
|
93
114
|
}
|
|
94
115
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function OnThisPageAside(): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import SiteHeader from '../../components/siteHeader';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import OnThisPage from '../../components/onThisPage';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import { Stack } from '../../components/layout';
|
|
8
|
+
// The page's level 2 and 3 headings, in page order. A real site builds this from the page.
|
|
9
|
+
var sections = [
|
|
10
|
+
{ id: 'on-this-page-overview', label: 'Overview', level: 2, text: 'Acme keeps your files in folders that the whole team can open. Everyone sees the same files.' },
|
|
11
|
+
{ id: 'on-this-page-sharing', label: 'Sharing', level: 2, text: 'Share a folder with a person or a team. Dana Lee can share any folder she owns.' },
|
|
12
|
+
{ id: 'on-this-page-links', label: 'Share by link', level: 3, text: 'A link opens the folder for anyone who has it. Turn the link off to stop it.' },
|
|
13
|
+
{ id: 'on-this-page-people', label: 'Share with people', level: 3, text: 'Choose people by name. Ben Carter and Omar Reyes can view or edit.' },
|
|
14
|
+
{ id: 'on-this-page-roles', label: 'Roles and access', level: 2, text: 'Owners change who has access. Editors change files. Viewers read them.' },
|
|
15
|
+
{ id: 'on-this-page-limits', label: 'Limits', level: 2, text: 'A free team holds up to 5 GB. Paid teams hold as much as they need.' },
|
|
16
|
+
];
|
|
17
|
+
// Filler for the example, so each section is long enough to scroll.
|
|
18
|
+
var more = 'A change shows for everyone at once, so there is one copy of each file to look after. Older versions stay for 30 days, and an owner can bring one back.';
|
|
19
|
+
var items = sections.map(function (_a) {
|
|
20
|
+
var id = _a.id, label = _a.label, level = _a.level;
|
|
21
|
+
return ({ id: id, label: label, level: level });
|
|
22
|
+
});
|
|
23
|
+
export default function OnThisPageAside() {
|
|
24
|
+
return (<>
|
|
25
|
+
<SiteHeader brand={{ href: '#top', name: 'Acme Docs' }} links={[{ label: 'Guides', href: '#guides', current: true }, { label: 'Reference', href: '#reference' }]} mainId="on-this-page-main"/>
|
|
26
|
+
{/* The list sticks below the header from xl. Below xl the page reads in order without it. */}
|
|
27
|
+
<PageShell id="on-this-page-main" tabIndex={-1} aside={<OnThisPage items={items}/>}>
|
|
28
|
+
<Stack gap="large">
|
|
29
|
+
<Heading level={1} size="h5">Share a folder</Heading>
|
|
30
|
+
{sections.map(function (s) { return (<Stack key={s.id} gap="medium">
|
|
31
|
+
<Heading level={s.level} size={s.level === 2 ? 'h6' : 'subtitle1'} id={s.id}>{s.label}</Heading>
|
|
32
|
+
<Paragraph measure="none">{s.text}</Paragraph>
|
|
33
|
+
<Paragraph tone="secondary" measure="none">{more}</Paragraph>
|
|
34
|
+
<Paragraph tone="secondary" measure="none">{more}</Paragraph>
|
|
35
|
+
</Stack>); })}
|
|
36
|
+
</Stack>
|
|
37
|
+
</PageShell>
|
|
38
|
+
</>);
|
|
39
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# On this page
|
|
2
|
+
|
|
3
|
+
A person reads a long page and wants to see its sections, jump to one and know which one they are in.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Put `OnThisPage` in the `aside` of `PageShell`. It sticks below a `SiteHeader` and shows from `xl`. `PageShell` gives each level 2 and 3 heading with an `id` a scroll margin, so `#sharing` lands below the header.
|
|
8
|
+
- Build `items` from the headings of the page, in page order: the level 2 headings and the level 3 headings under them. Give each heading an `id`.
|
|
9
|
+
- Use it when the page has two items or more. With fewer it renders nothing.
|
|
10
|
+
- Keep the labels the same as the headings, in the same case.
|
|
11
|
+
- Name the nav 'On this page', which is the default, or pass an `aria-label` that fits the page.
|
|
12
|
+
- Let a click scroll the heading to just under the header and keep its item current until the scroll ends. With reduced motion it jumps.
|
|
13
|
+
- Keep the aside to the list. A phone does not show it, so the page must read in order without it. The sections are not places: on a phone the person scrolls to them.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not take the arrow keys to jump between sections. They scroll the page and move the cursor in a field.
|
|
18
|
+
- Do not list a page with one section.
|
|
19
|
+
- Do not add the items by hand for a page whose headings change. Build them from the headings.
|
|
20
|
+
- Do not mark the current item with color only. The bar beside it moves too.
|
|
21
|
+
- Do not put a second contents list in the page.
|
|
22
|
+
|
|
23
|
+
## Example: List of sections beside the page
|
|
24
|
+
|
|
25
|
+
Uses: `Heading`, `OnThisPage`, `PageShell`, `Paragraph`, `SiteHeader`, `Stack`
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
'use client';
|
|
29
|
+
import SiteHeader from 'oneslash-design-system/components/siteHeader';
|
|
30
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
31
|
+
import OnThisPage from 'oneslash-design-system/components/onThisPage';
|
|
32
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
33
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
34
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
35
|
+
|
|
36
|
+
// The page's level 2 and 3 headings, in page order. A real site builds this from the page.
|
|
37
|
+
const sections = [
|
|
38
|
+
{ id: 'on-this-page-overview', label: 'Overview', level: 2 as const, text: 'Acme keeps your files in folders that the whole team can open. Everyone sees the same files.' },
|
|
39
|
+
{ id: 'on-this-page-sharing', label: 'Sharing', level: 2 as const, text: 'Share a folder with a person or a team. Dana Lee can share any folder she owns.' },
|
|
40
|
+
{ id: 'on-this-page-links', label: 'Share by link', level: 3 as const, text: 'A link opens the folder for anyone who has it. Turn the link off to stop it.' },
|
|
41
|
+
{ id: 'on-this-page-people', label: 'Share with people', level: 3 as const, text: 'Choose people by name. Ben Carter and Omar Reyes can view or edit.' },
|
|
42
|
+
{ id: 'on-this-page-roles', label: 'Roles and access', level: 2 as const, text: 'Owners change who has access. Editors change files. Viewers read them.' },
|
|
43
|
+
{ id: 'on-this-page-limits', label: 'Limits', level: 2 as const, text: 'A free team holds up to 5 GB. Paid teams hold as much as they need.' },
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
// Filler for the example, so each section is long enough to scroll.
|
|
47
|
+
const more = 'A change shows for everyone at once, so there is one copy of each file to look after. Older versions stay for 30 days, and an owner can bring one back.';
|
|
48
|
+
|
|
49
|
+
const items = sections.map(({ id, label, level }) => ({ id, label, level }));
|
|
50
|
+
|
|
51
|
+
export default function OnThisPageAside() {
|
|
52
|
+
return (
|
|
53
|
+
<>
|
|
54
|
+
<SiteHeader
|
|
55
|
+
brand={{ href: '#top', name: 'Acme Docs' }}
|
|
56
|
+
links={[{ label: 'Guides', href: '#guides', current: true }, { label: 'Reference', href: '#reference' }]}
|
|
57
|
+
mainId="on-this-page-main"
|
|
58
|
+
/>
|
|
59
|
+
{/* The list sticks below the header from xl. Below xl the page reads in order without it. */}
|
|
60
|
+
<PageShell id="on-this-page-main" tabIndex={-1} aside={<OnThisPage items={items} />}>
|
|
61
|
+
<Stack gap="large">
|
|
62
|
+
<Heading level={1} size="h5">Share a folder</Heading>
|
|
63
|
+
{sections.map((s) => (
|
|
64
|
+
<Stack key={s.id} gap="medium">
|
|
65
|
+
<Heading level={s.level} size={s.level === 2 ? 'h6' : 'subtitle1'} id={s.id}>{s.label}</Heading>
|
|
66
|
+
<Paragraph measure="none">{s.text}</Paragraph>
|
|
67
|
+
<Paragraph tone="secondary" measure="none">{more}</Paragraph>
|
|
68
|
+
<Paragraph tone="secondary" measure="none">{more}</Paragraph>
|
|
69
|
+
</Stack>
|
|
70
|
+
))}
|
|
71
|
+
</Stack>
|
|
72
|
+
</PageShell>
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Native
|
|
79
|
+
|
|
80
|
+
On Apple use a `ScrollViewReader` with a `Menu` or `List` of sections that scrolls to an id. On Android use a `LazyColumn` with a `scrollToItem` list.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PageHeaderActions(): import("react").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import TitleBar from '../../components/titleBar';
|
|
5
|
+
import Button from '../../components/button';
|
|
6
|
+
import IconButton from '../../components/iconButton';
|
|
7
|
+
import Tooltip from '../../components/tooltip';
|
|
8
|
+
import Popover from '../../components/popover';
|
|
9
|
+
import Menu from '../../components/menu';
|
|
10
|
+
import MenuItem from '../../components/menuItem';
|
|
11
|
+
import Line from '../../components/line';
|
|
12
|
+
import Paragraph from '../../components/paragraph';
|
|
13
|
+
import { Stack } from '../../components/layout';
|
|
14
|
+
export default function PageHeaderActions() {
|
|
15
|
+
var _a = useState(null), anchor = _a[0], setAnchor = _a[1];
|
|
16
|
+
// Which More button opened the menu: on a phone the menu also holds Search and Filter.
|
|
17
|
+
var _b = useState('wide'), from = _b[0], setFrom = _b[1];
|
|
18
|
+
var _c = useState(false), open = _c[0], setOpen = _c[1];
|
|
19
|
+
var _d = useState(''), chosen = _d[0], setChosen = _d[1];
|
|
20
|
+
function openMore(kind, el) {
|
|
21
|
+
setFrom(kind);
|
|
22
|
+
setAnchor(el);
|
|
23
|
+
setOpen(function (o) { return !o; });
|
|
24
|
+
}
|
|
25
|
+
// Every item closes the menu. Its Popover gives focus back to the More button.
|
|
26
|
+
function choose(label) {
|
|
27
|
+
setOpen(false);
|
|
28
|
+
setChosen(label);
|
|
29
|
+
}
|
|
30
|
+
var newTask = <Button size="medium" type="primary" state="enabled" label="New Task" decoIcon="Plus" onClickButton={function () { return setChosen('New Task'); }}/>;
|
|
31
|
+
var more = function (kind) { return (<Tooltip title="More">
|
|
32
|
+
<IconButton color="iconOnly" state={open && from === kind ? 'selected' : 'enabled'} size="medium" iconName="Ellipsis" ariaLabel="More actions for Home page" aria-haspopup="menu" aria-expanded={open && from === kind} onClick={function (e) { return openMore(kind, e.currentTarget); }}/>
|
|
33
|
+
</Tooltip>); };
|
|
34
|
+
return (<PageShell>
|
|
35
|
+
<Stack gap="large">
|
|
36
|
+
{/* 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. */}
|
|
37
|
+
<TitleBar title="Home page" actions={<>
|
|
38
|
+
{newTask}
|
|
39
|
+
<Tooltip title="Search">
|
|
40
|
+
<IconButton color="iconOnly" state="enabled" size="medium" iconName="Search" ariaLabel="Search Home page" onClick={function () { return setChosen('Search'); }}/>
|
|
41
|
+
</Tooltip>
|
|
42
|
+
<Tooltip title="Filter">
|
|
43
|
+
<IconButton color="iconOnly" state="enabled" size="medium" iconName="Filter" ariaLabel="Filter Home page" onClick={function () { return setChosen('Filter'); }}/>
|
|
44
|
+
</Tooltip>
|
|
45
|
+
{more('wide')}
|
|
46
|
+
</>} phoneActions={<>
|
|
47
|
+
{newTask}
|
|
48
|
+
{more('phone')}
|
|
49
|
+
</>}/>
|
|
50
|
+
<Paragraph tone="secondary" size="body2" measure="none">{chosen ? "You chose ".concat(chosen, ".") : '12 tasks are open. Updated 2 days ago by Dana Lee.'}</Paragraph>
|
|
51
|
+
</Stack>
|
|
52
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
53
|
+
<Menu navigable aria-label="Actions for Home page" width={200}>
|
|
54
|
+
{from === 'phone' && (<>
|
|
55
|
+
<MenuItem size="small" iconName="Search" label="Search" onClick={function () { return choose('Search'); }}/>
|
|
56
|
+
<MenuItem size="small" iconName="Filter" label="Filter" onClick={function () { return choose('Filter'); }}/>
|
|
57
|
+
<Line />
|
|
58
|
+
</>)}
|
|
59
|
+
<MenuItem size="small" iconName="Pencil" label="Rename" onClick={function () { return choose('Rename'); }}/>
|
|
60
|
+
<MenuItem size="small" iconName="Copy" label="Duplicate" onClick={function () { return choose('Duplicate'); }}/>
|
|
61
|
+
<MenuItem size="small" iconName="Archive" label="Archive" onClick={function () { return choose('Archive'); }}/>
|
|
62
|
+
</Menu>
|
|
63
|
+
</Popover>
|
|
64
|
+
</PageShell>);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PageHeaderSubPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import TitleBar from '../../components/titleBar';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import Navigation from '../../components/navigation';
|
|
8
|
+
import MenuItem from '../../components/menuItem';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import { Stack } from '../../components/layout';
|
|
11
|
+
var taskTitle = 'Move the sign-up form above the pricing table on the home page';
|
|
12
|
+
export default function PageHeaderSubPage() {
|
|
13
|
+
// The task is a page one step down from the project's page.
|
|
14
|
+
var _a = useState('task'), view = _a[0], setView = _a[1];
|
|
15
|
+
var _b = useState(false), done = _b[0], setDone = _b[1];
|
|
16
|
+
if (view === 'project') {
|
|
17
|
+
return (<PageShell>
|
|
18
|
+
<Stack gap="large">
|
|
19
|
+
<Heading level={1} size="h5">Website</Heading>
|
|
20
|
+
<Navigation aria-label="Tasks">
|
|
21
|
+
<MenuItem size="medium" label={taskTitle} secondLabel={done ? 'Done' : 'Open'} iconRight="ChevronRight" href="/website/tasks/sign-up-form" onClick={function (event) {
|
|
22
|
+
// A real app lets the link go to the task's page. The example keeps the choice in state.
|
|
23
|
+
event.preventDefault();
|
|
24
|
+
setView('task');
|
|
25
|
+
}}/>
|
|
26
|
+
</Navigation>
|
|
27
|
+
</Stack>
|
|
28
|
+
</PageShell>);
|
|
29
|
+
}
|
|
30
|
+
return (<PageShell>
|
|
31
|
+
<Stack gap="large">
|
|
32
|
+
{/* Back names the page it goes to. Below md it takes its own line above the title, and a long title wraps. */}
|
|
33
|
+
<TitleBar title={taskTitle} back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Website" onClickButton={function () { return setView('project'); }}/>} actions={<Button size="medium" type="primary" state={done ? 'disabled' : 'enabled'} label="Mark Done" onClickButton={function () { return setDone(true); }}/>}/>
|
|
34
|
+
<Paragraph tone="secondary" size="body2" measure="none">{done ? 'Done. Marked by Dana Lee.' : 'Assigned to Ben Carter. Due on Friday.'}</Paragraph>
|
|
35
|
+
</Stack>
|
|
36
|
+
</PageShell>);
|
|
37
|
+
}
|