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
package/dist/cases/error-page.md
CHANGED
|
@@ -51,40 +51,61 @@ export default function ErrorPageFullPage() {
|
|
|
51
51
|
|
|
52
52
|
Use when: One route failed and the navigation still works.
|
|
53
53
|
|
|
54
|
-
Uses: `Button`, `Cluster`, `Heading`, `
|
|
54
|
+
Uses: `AppShell`, `Button`, `Cluster`, `Heading`, `MenuItem`, `Navigation`, `NavigationGroup`, `Paragraph`, `Stack`, `Surface`
|
|
55
55
|
|
|
56
56
|
```tsx
|
|
57
57
|
'use client';
|
|
58
|
-
import
|
|
59
|
-
import
|
|
60
|
-
import
|
|
58
|
+
import { useState } from 'react';
|
|
59
|
+
import AppShell from 'oneslash-design-system/components/appShell';
|
|
60
|
+
import Navigation, { NavigationGroup } from 'oneslash-design-system/components/navigation';
|
|
61
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
61
62
|
import Surface from 'oneslash-design-system/components/surface';
|
|
62
63
|
import Heading from 'oneslash-design-system/components/heading';
|
|
63
64
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
64
65
|
import Button from 'oneslash-design-system/components/button';
|
|
65
66
|
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
66
67
|
|
|
67
|
-
// The product's mark. A real app passes its own file.
|
|
68
|
-
const productMark =
|
|
69
|
-
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect width='40' height='40' rx='10' fill='%232f6b4f'/%3E%3Cpath d='M20 9 31 31h-6l-5-11-5 11H9z' fill='%23fff'/%3E%3C/svg%3E";
|
|
70
|
-
|
|
71
|
-
// A real app passes the router from its framework, such as Next's useRouter().
|
|
72
|
-
const router = { push: (url: string) => console.info(`Go to ${url}`) };
|
|
73
|
-
|
|
74
68
|
// A real app passes the reset() its framework gives the error page, such as Next's error.tsx.
|
|
75
69
|
const reset = () => console.info('Render the page again');
|
|
76
70
|
|
|
71
|
+
// The places, and the projects the person made. The page that failed or loads is the current one.
|
|
72
|
+
const places = [
|
|
73
|
+
{ label: 'Home', icon: 'House', href: '/' },
|
|
74
|
+
{ label: 'Settings', icon: 'Settings', href: '/settings' },
|
|
75
|
+
];
|
|
76
|
+
const projects = [
|
|
77
|
+
{ label: 'Website', icon: 'Globe', href: '/projects/website' },
|
|
78
|
+
{ label: 'Mobile App', icon: 'Smartphone', href: '/projects/mobile-app' },
|
|
79
|
+
];
|
|
80
|
+
const current = '/projects/website';
|
|
81
|
+
|
|
82
|
+
const row = (p: { label: string; icon: string; href: string }) => (
|
|
83
|
+
<MenuItem
|
|
84
|
+
key={p.href}
|
|
85
|
+
size="small"
|
|
86
|
+
label={p.label}
|
|
87
|
+
iconName={p.icon}
|
|
88
|
+
href={p.href}
|
|
89
|
+
isSelected={p.href === current}
|
|
90
|
+
aria-current={p.href === current ? 'page' : undefined}
|
|
91
|
+
// A real app lets the link go to its page.
|
|
92
|
+
onClick={(event: { preventDefault: () => void }) => event.preventDefault()}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
const sidebar = (
|
|
97
|
+
<Navigation aria-label="Main">
|
|
98
|
+
<Paragraph size="body1" measure="none">Acme</Paragraph>
|
|
99
|
+
{places.map(row)}
|
|
100
|
+
<NavigationGroup label="Projects">{projects.map(row)}</NavigationGroup>
|
|
101
|
+
</Navigation>
|
|
102
|
+
);
|
|
103
|
+
|
|
77
104
|
export default function ErrorPageInShell() {
|
|
105
|
+
// Below md the sidebar is a Drawer; this says whether it is open.
|
|
106
|
+
const [navOpen, setNavOpen] = useState(false);
|
|
78
107
|
return (
|
|
79
|
-
<
|
|
80
|
-
<Cluster gap="large">
|
|
81
|
-
<Image src={productMark} alt="Acme" width={32} height={32} />
|
|
82
|
-
<TabsContainer>
|
|
83
|
-
<Tab label="Home" isSelected={false} href="/" router={router} onClickTab={() => {}} />
|
|
84
|
-
<Tab label="Projects" isSelected href="/projects" router={router} onClickTab={() => {}} />
|
|
85
|
-
<Tab label="Settings" isSelected={false} href="/settings" router={router} onClickTab={() => {}} />
|
|
86
|
-
</TabsContainer>
|
|
87
|
-
</Cluster>
|
|
108
|
+
<AppShell title="Website" navOpen={navOpen} onNavOpenChange={setNavOpen} sidebar={sidebar}>
|
|
88
109
|
<Surface minHeight="tall" align="center">
|
|
89
110
|
<Stack gap="xlarge">
|
|
90
111
|
<Stack gap="medium">
|
|
@@ -97,7 +118,7 @@ export default function ErrorPageInShell() {
|
|
|
97
118
|
</Cluster>
|
|
98
119
|
</Stack>
|
|
99
120
|
</Surface>
|
|
100
|
-
</
|
|
121
|
+
</AppShell>
|
|
101
122
|
);
|
|
102
123
|
}
|
|
103
124
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MasterDetailListThenPage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Navigation from '../../components/navigation';
|
|
4
|
+
import MenuItem from '../../components/menuItem';
|
|
5
|
+
import TitleBar from '../../components/titleBar';
|
|
6
|
+
import Heading from '../../components/heading';
|
|
7
|
+
import Paragraph from '../../components/paragraph';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import PageShell from '../../components/pageShell';
|
|
10
|
+
import { Stack } from '../../components/layout';
|
|
11
|
+
var reports = [
|
|
12
|
+
{
|
|
13
|
+
id: 'q3-review',
|
|
14
|
+
title: 'Q3 review',
|
|
15
|
+
summary: 'Revenue, churn and what changed since June.',
|
|
16
|
+
body: [
|
|
17
|
+
'Revenue grew 12 percent over the quarter, led by the new team plan. Churn fell to 2.1 percent.',
|
|
18
|
+
'Support tickets about sign-up dropped by a third after the new form shipped in August.',
|
|
19
|
+
'The main risk is the pricing page, which still sends people to a contact form. Ben Carter owns the fix.',
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
id: 'hiring-plan',
|
|
24
|
+
title: 'Hiring plan',
|
|
25
|
+
summary: 'Roles to open next half, and why.',
|
|
26
|
+
body: [
|
|
27
|
+
'Two roles open in January: a designer for the web app and a support lead.',
|
|
28
|
+
'Omar Reyes will write both job posts. Dana Lee approves the budget on Monday.',
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
id: 'roadmap',
|
|
33
|
+
title: 'Roadmap',
|
|
34
|
+
summary: 'What ships, in order, through March.',
|
|
35
|
+
body: [
|
|
36
|
+
'The mobile app and the new billing page ship first. Integrations follow in February.',
|
|
37
|
+
'Each item lists its owner, its date and what must be true before it starts.',
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
export default function MasterDetailListThenPage() {
|
|
42
|
+
var _a = useState(null), openId = _a[0], setOpenId = _a[1];
|
|
43
|
+
var report = reports.find(function (r) { return r.id === openId; });
|
|
44
|
+
// A real app goes to the page's address. Back calls the router's back() when the person came from the list, so the list keeps its scroll,
|
|
45
|
+
// and otherwise links to the list's address. The example swaps the view.
|
|
46
|
+
if (report) {
|
|
47
|
+
return (<PageShell>
|
|
48
|
+
<Stack gap="large">
|
|
49
|
+
<TitleBar title={report.title} back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Reports" onClickButton={function () { return setOpenId(null); }}/>}/>
|
|
50
|
+
{report.body.map(function (paragraph) { return (<Paragraph key={paragraph} measure="body">{paragraph}</Paragraph>); })}
|
|
51
|
+
</Stack>
|
|
52
|
+
</PageShell>);
|
|
53
|
+
}
|
|
54
|
+
return (<PageShell>
|
|
55
|
+
<Stack gap="large">
|
|
56
|
+
<Heading level={1} size="h5">Reports</Heading>
|
|
57
|
+
<Navigation aria-label="Reports">
|
|
58
|
+
{reports.map(function (r) { return (<MenuItem key={r.id} size="medium" label={r.title} secondLabel={r.summary} iconRight="ChevronRight" href={"/reports/".concat(r.id)} onClick={function (event) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
setOpenId(r.id);
|
|
61
|
+
}}/>); })}
|
|
62
|
+
</Navigation>
|
|
63
|
+
</Stack>
|
|
64
|
+
</PageShell>);
|
|
65
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MasterDetailSplit(): import("react").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Navigation from '../../components/navigation';
|
|
4
|
+
import MenuItem from '../../components/menuItem';
|
|
5
|
+
import { SettingsLayout } from '../../components/settingsSection';
|
|
6
|
+
import Heading from '../../components/heading';
|
|
7
|
+
import Paragraph from '../../components/paragraph';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import PageShell from '../../components/pageShell';
|
|
10
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
11
|
+
var messages = [
|
|
12
|
+
{ id: 'launch-plan', from: 'Ben Carter', subject: 'Launch plan is ready', time: '9:12 AM', body: ['The plan is in the shared folder. It covers the announcement, the pricing page and the support hand-off.', 'Can you read the pricing part before noon? Omar Reyes is waiting on it.'] },
|
|
13
|
+
{ id: 'new-screens', from: 'Omar Reyes', subject: 'New screens for Friday', time: '8:40 AM', body: ['I added the new home page screens. The sign-up form now sits above the pricing table.', 'Tell me what to change by Thursday.'] },
|
|
14
|
+
{ id: 'invoice', from: 'Ben Carter', subject: 'Invoice for October', time: 'Yesterday', body: ['The invoice for October is attached. It includes the three new seats.'] },
|
|
15
|
+
{ id: 'offsite', from: 'Omar Reyes', subject: 'Team offsite in March', time: 'Monday', body: ['I found two dates for the offsite. Please say which one works for you.'] },
|
|
16
|
+
];
|
|
17
|
+
export default function MasterDetailSplit() {
|
|
18
|
+
var _a;
|
|
19
|
+
// One message is always open, the first at the start.
|
|
20
|
+
var _b = useState(messages[0].id), openId = _b[0], setOpenId = _b[1];
|
|
21
|
+
// On a phone the list is the screen until a message is chosen, and Back returns to it.
|
|
22
|
+
var _c = useState(false), showDetail = _c[0], setShowDetail = _c[1];
|
|
23
|
+
var message = (_a = messages.find(function (m) { return m.id === openId; })) !== null && _a !== void 0 ? _a : messages[0];
|
|
24
|
+
var list = (<Navigation aria-label="Messages">
|
|
25
|
+
{messages.map(function (m) { return (<MenuItem key={m.id} size="medium" label={m.from} secondLabel={m.subject} href={"/inbox/".concat(m.id)} isSelected={m.id === message.id} aria-current={m.id === message.id ? 'page' : undefined} onClick={function (event) {
|
|
26
|
+
// A real app lets the link go to the message's own address, so it can be shared and reloaded. The example keeps the choice in state.
|
|
27
|
+
event.preventDefault();
|
|
28
|
+
setOpenId(m.id);
|
|
29
|
+
setShowDetail(true);
|
|
30
|
+
}}/>); })}
|
|
31
|
+
</Navigation>);
|
|
32
|
+
return (<PageShell>
|
|
33
|
+
<Stack gap="xlarge">
|
|
34
|
+
<Heading level={1} size="h5">Inbox</Heading>
|
|
35
|
+
<SettingsLayout navWidth="wide" nav={list} showContent={showDetail} back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Inbox" onClickButton={function () { return setShowDetail(false); }}/>}>
|
|
36
|
+
<Stack gap="small">
|
|
37
|
+
<Heading level={2} size="h6">{message.subject}</Heading>
|
|
38
|
+
<Paragraph tone="secondary" size="body2" measure="none">{message.from}, {message.time}</Paragraph>
|
|
39
|
+
</Stack>
|
|
40
|
+
<Stack gap="medium">
|
|
41
|
+
{message.body.map(function (paragraph) { return (<Paragraph key={paragraph} measure="none">{paragraph}</Paragraph>); })}
|
|
42
|
+
</Stack>
|
|
43
|
+
<Cluster>
|
|
44
|
+
<Button size="medium" type="primary" state="enabled" label="Reply" decoIcon="Reply"/>
|
|
45
|
+
</Cluster>
|
|
46
|
+
</SettingsLayout>
|
|
47
|
+
</Stack>
|
|
48
|
+
</PageShell>);
|
|
49
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
# List and detail
|
|
2
|
+
|
|
3
|
+
A person opens an item from a list, such as a message or a report, and reads or acts on 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 `SettingsLayout` with `navWidth="wide"` for a list beside its detail. The list is a `Navigation` of `MenuItem` rows.
|
|
9
|
+
- Make each row a link with an `href`, so the open item has an address that can be shared and reloaded. Mark the open row with `isSelected` and `aria-current="page"`.
|
|
10
|
+
- Keep one item open at all times from `md` up, the first at the start.
|
|
11
|
+
- Name the row with the sender or the title, and put the subject or the summary in `secondLabel`.
|
|
12
|
+
- Show the list first on a phone, then the detail alone with a Back Button named for the list: 'Back to Inbox'. Pass it as `back` of `SettingsLayout`.
|
|
13
|
+
- Title the page with a level 1 heading, such as 'Inbox'. The open item's title is a level 2 heading.
|
|
14
|
+
- Make each row of a list of long items a link to a page of its own. Put 'Back to Reports' in the page's `TitleBar` as `back`.
|
|
15
|
+
- Let 'Back to Reports' call the router's `back()` when the person came from the list, so the list keeps its scroll. Otherwise link to the list's address.
|
|
16
|
+
- After the person acts on an item, such as Archive, open the next one.
|
|
17
|
+
|
|
18
|
+
## Don't
|
|
19
|
+
|
|
20
|
+
- Do not show the list and the detail together on a phone.
|
|
21
|
+
- Do not leave the detail empty with nothing open on a wide screen. Open the first item.
|
|
22
|
+
- Do not keep the open item only in state. Give it an address.
|
|
23
|
+
- Do not name the Back Button 'Back'. Name the list it goes to.
|
|
24
|
+
- Do not use a split for long items that need the whole width.
|
|
25
|
+
|
|
26
|
+
## Option: List beside the detail
|
|
27
|
+
|
|
28
|
+
Use when: The person works down the list, one item after another, such as an inbox.
|
|
29
|
+
|
|
30
|
+
Uses: `Button`, `Cluster`, `Heading`, `MenuItem`, `Navigation`, `PageShell`, `Paragraph`, `SettingsLayout`, `Stack`
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
'use client';
|
|
34
|
+
import { useState } from 'react';
|
|
35
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
36
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
37
|
+
import { SettingsLayout } from 'oneslash-design-system/components/settingsSection';
|
|
38
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
39
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
40
|
+
import Button from 'oneslash-design-system/components/button';
|
|
41
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
42
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
43
|
+
|
|
44
|
+
type Message = { id: string; from: string; subject: string; time: string; body: string[] };
|
|
45
|
+
|
|
46
|
+
const messages: Message[] = [
|
|
47
|
+
{ id: 'launch-plan', from: 'Ben Carter', subject: 'Launch plan is ready', time: '9:12 AM', body: ['The plan is in the shared folder. It covers the announcement, the pricing page and the support hand-off.', 'Can you read the pricing part before noon? Omar Reyes is waiting on it.'] },
|
|
48
|
+
{ id: 'new-screens', from: 'Omar Reyes', subject: 'New screens for Friday', time: '8:40 AM', body: ['I added the new home page screens. The sign-up form now sits above the pricing table.', 'Tell me what to change by Thursday.'] },
|
|
49
|
+
{ id: 'invoice', from: 'Ben Carter', subject: 'Invoice for October', time: 'Yesterday', body: ['The invoice for October is attached. It includes the three new seats.'] },
|
|
50
|
+
{ id: 'offsite', from: 'Omar Reyes', subject: 'Team offsite in March', time: 'Monday', body: ['I found two dates for the offsite. Please say which one works for you.'] },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export default function MasterDetailSplit() {
|
|
54
|
+
// One message is always open, the first at the start.
|
|
55
|
+
const [openId, setOpenId] = useState(messages[0].id);
|
|
56
|
+
// On a phone the list is the screen until a message is chosen, and Back returns to it.
|
|
57
|
+
const [showDetail, setShowDetail] = useState(false);
|
|
58
|
+
|
|
59
|
+
const message = messages.find((m) => m.id === openId) ?? messages[0];
|
|
60
|
+
|
|
61
|
+
const list = (
|
|
62
|
+
<Navigation aria-label="Messages">
|
|
63
|
+
{messages.map((m) => (
|
|
64
|
+
<MenuItem
|
|
65
|
+
key={m.id}
|
|
66
|
+
size="medium"
|
|
67
|
+
label={m.from}
|
|
68
|
+
secondLabel={m.subject}
|
|
69
|
+
href={`/inbox/${m.id}`}
|
|
70
|
+
isSelected={m.id === message.id}
|
|
71
|
+
aria-current={m.id === message.id ? 'page' : undefined}
|
|
72
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
73
|
+
// A real app lets the link go to the message's own address, so it can be shared and reloaded. The example keeps the choice in state.
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
setOpenId(m.id);
|
|
76
|
+
setShowDetail(true);
|
|
77
|
+
}}
|
|
78
|
+
/>
|
|
79
|
+
))}
|
|
80
|
+
</Navigation>
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<PageShell>
|
|
85
|
+
<Stack gap="xlarge">
|
|
86
|
+
<Heading level={1} size="h5">Inbox</Heading>
|
|
87
|
+
<SettingsLayout
|
|
88
|
+
navWidth="wide"
|
|
89
|
+
nav={list}
|
|
90
|
+
showContent={showDetail}
|
|
91
|
+
back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Inbox" onClickButton={() => setShowDetail(false)} />}
|
|
92
|
+
>
|
|
93
|
+
<Stack gap="small">
|
|
94
|
+
<Heading level={2} size="h6">{message.subject}</Heading>
|
|
95
|
+
<Paragraph tone="secondary" size="body2" measure="none">{message.from}, {message.time}</Paragraph>
|
|
96
|
+
</Stack>
|
|
97
|
+
<Stack gap="medium">
|
|
98
|
+
{message.body.map((paragraph) => (
|
|
99
|
+
<Paragraph key={paragraph} measure="none">{paragraph}</Paragraph>
|
|
100
|
+
))}
|
|
101
|
+
</Stack>
|
|
102
|
+
<Cluster>
|
|
103
|
+
<Button size="medium" type="primary" state="enabled" label="Reply" decoIcon="Reply" />
|
|
104
|
+
</Cluster>
|
|
105
|
+
</SettingsLayout>
|
|
106
|
+
</Stack>
|
|
107
|
+
</PageShell>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Option: List, then a page for each item
|
|
113
|
+
|
|
114
|
+
Use when: Each item is long and has its own address, such as a report.
|
|
115
|
+
|
|
116
|
+
Uses: `Button`, `Heading`, `MenuItem`, `Navigation`, `PageShell`, `Paragraph`, `Stack`, `TitleBar`
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
'use client';
|
|
120
|
+
import { useState } from 'react';
|
|
121
|
+
import Navigation from 'oneslash-design-system/components/navigation';
|
|
122
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
123
|
+
import TitleBar from 'oneslash-design-system/components/titleBar';
|
|
124
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
125
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
126
|
+
import Button from 'oneslash-design-system/components/button';
|
|
127
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
128
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
129
|
+
|
|
130
|
+
type Report = { id: string; title: string; summary: string; body: string[] };
|
|
131
|
+
|
|
132
|
+
const reports: Report[] = [
|
|
133
|
+
{
|
|
134
|
+
id: 'q3-review',
|
|
135
|
+
title: 'Q3 review',
|
|
136
|
+
summary: 'Revenue, churn and what changed since June.',
|
|
137
|
+
body: [
|
|
138
|
+
'Revenue grew 12 percent over the quarter, led by the new team plan. Churn fell to 2.1 percent.',
|
|
139
|
+
'Support tickets about sign-up dropped by a third after the new form shipped in August.',
|
|
140
|
+
'The main risk is the pricing page, which still sends people to a contact form. Ben Carter owns the fix.',
|
|
141
|
+
],
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: 'hiring-plan',
|
|
145
|
+
title: 'Hiring plan',
|
|
146
|
+
summary: 'Roles to open next half, and why.',
|
|
147
|
+
body: [
|
|
148
|
+
'Two roles open in January: a designer for the web app and a support lead.',
|
|
149
|
+
'Omar Reyes will write both job posts. Dana Lee approves the budget on Monday.',
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
id: 'roadmap',
|
|
154
|
+
title: 'Roadmap',
|
|
155
|
+
summary: 'What ships, in order, through March.',
|
|
156
|
+
body: [
|
|
157
|
+
'The mobile app and the new billing page ship first. Integrations follow in February.',
|
|
158
|
+
'Each item lists its owner, its date and what must be true before it starts.',
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
];
|
|
162
|
+
|
|
163
|
+
export default function MasterDetailListThenPage() {
|
|
164
|
+
const [openId, setOpenId] = useState<string | null>(null);
|
|
165
|
+
const report = reports.find((r) => r.id === openId);
|
|
166
|
+
|
|
167
|
+
// A real app goes to the page's address. Back calls the router's back() when the person came from the list, so the list keeps its scroll,
|
|
168
|
+
// and otherwise links to the list's address. The example swaps the view.
|
|
169
|
+
if (report) {
|
|
170
|
+
return (
|
|
171
|
+
<PageShell>
|
|
172
|
+
<Stack gap="large">
|
|
173
|
+
<TitleBar
|
|
174
|
+
title={report.title}
|
|
175
|
+
back={<Button size="small" type="tertiary" state="enabled" decoIcon="ChevronLeft" label="Back to Reports" onClickButton={() => setOpenId(null)} />}
|
|
176
|
+
/>
|
|
177
|
+
{report.body.map((paragraph) => (
|
|
178
|
+
<Paragraph key={paragraph} measure="body">{paragraph}</Paragraph>
|
|
179
|
+
))}
|
|
180
|
+
</Stack>
|
|
181
|
+
</PageShell>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<PageShell>
|
|
187
|
+
<Stack gap="large">
|
|
188
|
+
<Heading level={1} size="h5">Reports</Heading>
|
|
189
|
+
<Navigation aria-label="Reports">
|
|
190
|
+
{reports.map((r) => (
|
|
191
|
+
<MenuItem
|
|
192
|
+
key={r.id}
|
|
193
|
+
size="medium"
|
|
194
|
+
label={r.title}
|
|
195
|
+
secondLabel={r.summary}
|
|
196
|
+
iconRight="ChevronRight"
|
|
197
|
+
href={`/reports/${r.id}`}
|
|
198
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
199
|
+
event.preventDefault();
|
|
200
|
+
setOpenId(r.id);
|
|
201
|
+
}}
|
|
202
|
+
/>
|
|
203
|
+
))}
|
|
204
|
+
</Navigation>
|
|
205
|
+
</Stack>
|
|
206
|
+
</PageShell>
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Native
|
|
212
|
+
|
|
213
|
+
On Apple use a `NavigationSplitView` with a list and a detail. On iPhone it shows the list, then pushes the detail with the system back button. On Android use a list-detail layout that shows one pane on a phone.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MobileMenuLinks(): import("react").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import SiteHeader from '../../components/siteHeader';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import Button from '../../components/button';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import { Stack } from '../../components/layout';
|
|
8
|
+
var links = [
|
|
9
|
+
{ label: 'Features', href: '#features', current: true },
|
|
10
|
+
{ label: 'Pricing', href: '#pricing' },
|
|
11
|
+
{ label: 'Docs', href: '#docs' },
|
|
12
|
+
];
|
|
13
|
+
export default function MobileMenuLinks() {
|
|
14
|
+
return (<>
|
|
15
|
+
{/* Below md the Menu IconButton opens a Drawer: the links first, then 'Log In'. Choosing one closes it. 'Sign Up' stays in the bar. */}
|
|
16
|
+
<SiteHeader brand={{ href: '#top', name: 'Acme' }} links={links} actions={<Button size="medium" type="tertiary" state="enabled" label="Log In" href="#log-in"/>} phoneAction={<Button size="medium" type="primary" state="enabled" label="Sign Up" href="#sign-up"/>} mainId="mobile-menu-links-main"/>
|
|
17
|
+
<PageShell id="mobile-menu-links-main" tabIndex={-1}>
|
|
18
|
+
<Stack gap="large">
|
|
19
|
+
<Heading level={1} size="h5">Features</Heading>
|
|
20
|
+
<Paragraph tone="secondary" measure="none">On a phone, open Menu to reach every page. It closes when you choose one.</Paragraph>
|
|
21
|
+
</Stack>
|
|
22
|
+
</PageShell>
|
|
23
|
+
</>);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function MobileMenuSections(): import("react").JSX.Element;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Drawer from '../../components/drawer';
|
|
4
|
+
import IconButton from '../../components/iconButton';
|
|
5
|
+
import TabsContainer from '../../components/tabsContainer';
|
|
6
|
+
import Tab from '../../components/tab';
|
|
7
|
+
import Navigation from '../../components/navigation';
|
|
8
|
+
import MenuItem from '../../components/menuItem';
|
|
9
|
+
import PageShell from '../../components/pageShell';
|
|
10
|
+
import Heading from '../../components/heading';
|
|
11
|
+
import Paragraph from '../../components/paragraph';
|
|
12
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
13
|
+
// Four sections, one short word each. A real site reads these from its navigation.
|
|
14
|
+
var sections = [
|
|
15
|
+
{ id: 'start', label: 'Start', pages: [{ id: 'install', label: 'Install' }, { id: 'first-steps', label: 'First steps' }] },
|
|
16
|
+
{ id: 'guides', label: 'Guides', pages: [{ id: 'sharing', label: 'Share a folder' }, { id: 'roles', label: 'Roles and access' }, { id: 'billing', label: 'Billing' }] },
|
|
17
|
+
{ id: 'reference', label: 'API', pages: [{ id: 'api', label: 'Endpoints' }, { id: 'limits', label: 'Limits' }] },
|
|
18
|
+
{ id: 'updates', label: 'News', pages: [{ id: 'changelog', label: 'Changelog' }] },
|
|
19
|
+
];
|
|
20
|
+
var drawerId = 'mobile-menu-sections-drawer';
|
|
21
|
+
export default function MobileMenuSections() {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
var _d = useState(false), open = _d[0], setOpen = _d[1];
|
|
24
|
+
var _e = useState('sharing'), pageId = _e[0], setPageId = _e[1];
|
|
25
|
+
var currentSection = (_a = sections.find(function (s) { return s.pages.some(function (p) { return p.id === pageId; }); })) !== null && _a !== void 0 ? _a : sections[0];
|
|
26
|
+
// The tabs show the section of the current page each time the menu opens.
|
|
27
|
+
var _f = useState(currentSection.id), sectionId = _f[0], setSectionId = _f[1];
|
|
28
|
+
var shown = (_b = sections.find(function (s) { return s.id === sectionId; })) !== null && _b !== void 0 ? _b : sections[0];
|
|
29
|
+
var page = (_c = currentSection.pages.find(function (p) { return p.id === pageId; })) !== null && _c !== void 0 ? _c : currentSection.pages[0];
|
|
30
|
+
function openMenu() {
|
|
31
|
+
setSectionId(currentSection.id);
|
|
32
|
+
setOpen(true);
|
|
33
|
+
}
|
|
34
|
+
return (<PageShell>
|
|
35
|
+
<Stack gap="large">
|
|
36
|
+
<Cluster gap="small">
|
|
37
|
+
{/* A real site shows this IconButton only below md, where the links are not in the bar. */}
|
|
38
|
+
<IconButton color="iconOnly" state="enabled" size="medium" iconName="Menu" ariaLabel="Menu" aria-expanded={open} aria-controls={drawerId} onClick={openMenu}/>
|
|
39
|
+
<Paragraph size="body1" measure="none">Acme Docs</Paragraph>
|
|
40
|
+
</Cluster>
|
|
41
|
+
<Heading level={1} size="h5">{page.label}</Heading>
|
|
42
|
+
<Paragraph tone="secondary" measure="none">This page is in {currentSection.label}. Open Menu to move to another section.</Paragraph>
|
|
43
|
+
</Stack>
|
|
44
|
+
{/* Section tabs at the top, the section's pages under them, the current page marked. A choice closes the Drawer. */}
|
|
45
|
+
<Drawer id={drawerId} isOpen={open} onClose={function () { return setOpen(false); }} aria-label="Menu" side="start" size="small" closeFrom="md">
|
|
46
|
+
<Stack gap="large">
|
|
47
|
+
<TabsContainer fill>
|
|
48
|
+
{sections.map(function (s) { return (<Tab key={s.id} label={s.label} size="small" isSelected={s.id === shown.id} onClickTab={function () { return setSectionId(s.id); }}/>); })}
|
|
49
|
+
</TabsContainer>
|
|
50
|
+
<Navigation aria-label={"".concat(shown.label, " pages")}>
|
|
51
|
+
{shown.pages.map(function (p) { return (<MenuItem key={p.id} size="small" label={p.label} href={"/".concat(shown.id, "/").concat(p.id)} isSelected={p.id === pageId} aria-current={p.id === pageId ? 'page' : undefined} onClick={function (event) {
|
|
52
|
+
// A real app lets the link go to its page. The example keeps the choice in state.
|
|
53
|
+
event.preventDefault();
|
|
54
|
+
setPageId(p.id);
|
|
55
|
+
setOpen(false);
|
|
56
|
+
}}/>); })}
|
|
57
|
+
</Navigation>
|
|
58
|
+
</Stack>
|
|
59
|
+
</Drawer>
|
|
60
|
+
</PageShell>);
|
|
61
|
+
}
|