oneslash-design-system 2.18.0 → 2.20.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 +54 -5
- 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/billing-page/billed-elsewhere.d.ts +1 -0
- package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
- package/dist/cases/billing-page/self-serve.d.ts +1 -0
- package/dist/cases/billing-page/self-serve.jsx +134 -0
- package/dist/cases/billing-page.md +247 -0
- package/dist/cases/breakdown-list/bars.d.ts +1 -0
- package/dist/cases/breakdown-list/bars.jsx +47 -0
- package/dist/cases/breakdown-list/table.d.ts +1 -0
- package/dist/cases/breakdown-list/table.jsx +69 -0
- package/dist/cases/breakdown-list.md +158 -0
- package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
- package/dist/cases/composer-limit/notice.jsx +3 -3
- package/dist/cases/composer-limit.md +8 -8
- package/dist/cases/dashboard/numbers-first.d.ts +1 -0
- package/dist/cases/dashboard/numbers-first.jsx +165 -0
- package/dist/cases/dashboard/work-first.d.ts +1 -0
- package/dist/cases/dashboard/work-first.jsx +165 -0
- package/dist/cases/dashboard.md +507 -0
- package/dist/cases/data-table-page/all-rows.d.ts +1 -0
- package/dist/cases/data-table-page/all-rows.jsx +226 -0
- package/dist/cases/data-table-page/paged.d.ts +1 -0
- package/dist/cases/data-table-page/paged.jsx +284 -0
- package/dist/cases/data-table-page.md +771 -0
- package/dist/cases/error-page/in-shell.jsx +26 -17
- package/dist/cases/error-page.md +42 -21
- package/dist/cases/invoice-list/table.d.ts +1 -0
- package/dist/cases/invoice-list/table.jsx +64 -0
- package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
- package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
- package/dist/cases/invoice-list.md +237 -0
- package/dist/cases/load-failure/inline.jsx +2 -2
- package/dist/cases/load-failure.md +2 -2
- package/dist/cases/master-detail/list-then-page.d.ts +1 -0
- package/dist/cases/master-detail/list-then-page.jsx +65 -0
- package/dist/cases/master-detail/split.d.ts +1 -0
- package/dist/cases/master-detail/split.jsx +49 -0
- package/dist/cases/master-detail.md +213 -0
- package/dist/cases/members-list/rows.jsx +2 -1
- package/dist/cases/members-list/table.jsx +8 -9
- package/dist/cases/members-list.md +12 -13
- 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/number-format.md +36 -0
- package/dist/cases/on-this-page/aside.d.ts +1 -0
- package/dist/cases/on-this-page/aside.jsx +39 -0
- package/dist/cases/on-this-page.md +80 -0
- package/dist/cases/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/paged-card/pager.d.ts +1 -0
- package/dist/cases/paged-card/pager.jsx +41 -0
- package/dist/cases/paged-card/see-all.d.ts +1 -0
- package/dist/cases/paged-card/see-all.jsx +34 -0
- package/dist/cases/paged-card.md +147 -0
- package/dist/cases/payment-method/none.d.ts +1 -0
- package/dist/cases/payment-method/none.jsx +17 -0
- package/dist/cases/payment-method/on-file.d.ts +1 -0
- package/dist/cases/payment-method/on-file.jsx +92 -0
- package/dist/cases/payment-method.md +182 -0
- package/dist/cases/phone-navigation.md +32 -0
- package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
- package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
- package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
- package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
- package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
- package/dist/cases/plan-change-confirm.md +261 -0
- package/dist/cases/plan-picker/cards.d.ts +1 -0
- package/dist/cases/plan-picker/cards.jsx +97 -0
- package/dist/cases/plan-picker/list.d.ts +1 -0
- package/dist/cases/plan-picker/list.jsx +103 -0
- package/dist/cases/plan-picker.md +297 -0
- package/dist/cases/range-switch/segmented.jsx +11 -7
- package/dist/cases/range-switch.md +16 -11
- package/dist/cases/route-loading/region.jsx +27 -18
- package/dist/cases/route-loading.md +42 -21
- package/dist/cases/settings-page/top-tabs.jsx +4 -3
- package/dist/cases/settings-page.md +5 -4
- 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/stat-row/featured.d.ts +1 -0
- package/dist/cases/stat-row/featured.jsx +17 -0
- package/dist/cases/stat-row/tiles.d.ts +1 -0
- package/dist/cases/stat-row/tiles.jsx +34 -0
- package/dist/cases/stat-row.md +104 -0
- package/dist/cases/status-label/dot.d.ts +1 -0
- package/dist/cases/status-label/dot.jsx +39 -0
- package/dist/cases/status-label/text.d.ts +1 -0
- package/dist/cases/status-label/text.jsx +44 -0
- package/dist/cases/status-label.md +143 -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/upgrade-prompt/inline.jsx +4 -2
- package/dist/cases/upgrade-prompt/modal.jsx +2 -1
- package/dist/cases/upgrade-prompt.md +10 -6
- package/dist/cases/usage-meters/by-person.d.ts +1 -0
- package/dist/cases/usage-meters/by-person.jsx +72 -0
- package/dist/cases/usage-meters/meters.d.ts +1 -0
- package/dist/cases/usage-meters/meters.jsx +49 -0
- package/dist/cases/usage-meters/with-cap.d.ts +1 -0
- package/dist/cases/usage-meters/with-cap.jsx +73 -0
- package/dist/cases/usage-meters.md +303 -0
- package/dist/cases.json +1756 -172
- package/dist/components/appShell.d.ts +44 -0
- package/dist/components/appShell.jsx +121 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.jsx +11 -5
- package/dist/components/drawer.d.ts +31 -0
- package/dist/components/drawer.jsx +121 -0
- package/dist/components/formatNumber.d.ts +25 -0
- package/dist/components/formatNumber.js +125 -0
- package/dist/components/heading.d.ts +3 -1
- package/dist/components/heading.jsx +2 -2
- package/dist/components/iconButton.jsx +12 -7
- 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/pagination.d.ts +28 -0
- package/dist/components/pagination.jsx +89 -0
- package/dist/components/popover.jsx +4 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.jsx +50 -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/skeleton.d.ts +21 -0
- package/dist/components/skeleton.jsx +41 -0
- package/dist/components/statTile.d.ts +32 -0
- package/dist/components/statTile.jsx +61 -0
- package/dist/components/tableContainer.d.ts +5 -1
- package/dist/components/tableContainer.jsx +9 -1
- package/dist/components/tableHeaderCell.d.ts +3 -1
- package/dist/components/tableHeaderCell.jsx +2 -2
- package/dist/components/titleBar.d.ts +19 -0
- package/dist/components/titleBar.jsx +18 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +12 -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 +69 -3
- package/dist/stories/AppShell.stories.d.ts +15 -0
- package/dist/stories/AppShell.stories.jsx +137 -0
- package/dist/stories/Button.stories.d.ts +1 -0
- package/dist/stories/Button.stories.jsx +19 -1
- package/dist/stories/Cases.generated.stories.d.ts +45 -0
- package/dist/stories/Cases.generated.stories.jsx +90 -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/Pagination.stories.d.ts +9 -0
- package/dist/stories/Pagination.stories.jsx +75 -0
- package/dist/stories/Progress.stories.d.ts +9 -0
- package/dist/stories/Progress.stories.jsx +43 -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/Skeleton.stories.d.ts +7 -0
- package/dist/stories/Skeleton.stories.jsx +27 -0
- package/dist/stories/StatTile.stories.d.ts +10 -0
- package/dist/stories/StatTile.stories.jsx +55 -0
- package/dist/stories/Table.stories.d.ts +1 -0
- package/dist/stories/Table.stories.jsx +49 -1
- package/dist/stories/TitleBar.stories.d.ts +7 -0
- package/dist/stories/TitleBar.stories.jsx +41 -0
- package/package.json +5 -1
|
@@ -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.
|
|
@@ -35,6 +35,7 @@ import Tag from '../../components/tag';
|
|
|
35
35
|
import Button from '../../components/button';
|
|
36
36
|
import UserImage from '../../components/userImage';
|
|
37
37
|
import { Center, Cluster, Stack } from '../../components/layout';
|
|
38
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
38
39
|
// A real app reads these from the signed-in person and the plan.
|
|
39
40
|
var youId = 'dana';
|
|
40
41
|
var canManage = true;
|
|
@@ -312,7 +313,7 @@ export default function MembersListRows() {
|
|
|
312
313
|
<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setUpgradeOpen(false); }}/>
|
|
313
314
|
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return setUpgradeOpen(false); }}/>
|
|
314
315
|
</>}>
|
|
315
|
-
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for
|
|
316
|
+
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for {formatMoney(8)} per member each month.</Paragraph>
|
|
316
317
|
</Modal>
|
|
317
318
|
</Center>);
|
|
318
319
|
}
|
|
@@ -37,6 +37,7 @@ import Tag from '../../components/tag';
|
|
|
37
37
|
import Button from '../../components/button';
|
|
38
38
|
import UserImage from '../../components/userImage';
|
|
39
39
|
import { Center, Cluster, Stack } from '../../components/layout';
|
|
40
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
40
41
|
// A real app reads these from the signed-in person and the plan.
|
|
41
42
|
var youId = 'dana';
|
|
42
43
|
var canManage = true;
|
|
@@ -124,12 +125,10 @@ export default function MembersListTable() {
|
|
|
124
125
|
var order = sort.by === 'name' ? byName : roleRank(roles[a.id]) - roleRank(roles[b.id]) || byName;
|
|
125
126
|
return sort.dir === 'ascending' ? order : -order;
|
|
126
127
|
});
|
|
127
|
-
// The header cell has
|
|
128
|
+
// The sorted column's header cell has `sort`; the other cells leave it unset. The Button is named by its label alone.
|
|
128
129
|
function sortButton(by, label) {
|
|
129
130
|
var active = sort.by === by;
|
|
130
|
-
|
|
131
|
-
var now = active ? "sorted ".concat(sort.dir) : 'not sorted';
|
|
132
|
-
return (<Button size="small" type="tertiary" state={active ? 'selected' : 'enabled'} label={label} aria-label={"".concat(label, ", ").concat(now, ". Sort ").concat(next, ".")} decoIcon={active ? (sort.dir === 'ascending' ? 'ArrowUp' : 'ArrowDown') : undefined} onClickButton={function () { return handleSort(by); }}/>);
|
|
131
|
+
return (<Button size="small" type="tertiary" state={active ? 'selected' : 'enabled'} label={label} decoIcon={active ? (sort.dir === 'ascending' ? 'ArrowUp' : 'ArrowDown') : undefined} onClickButton={function () { return handleSort(by); }}/>);
|
|
133
132
|
}
|
|
134
133
|
// The role is one control on its own, so it saves as soon as it changes. Nothing shows when it works.
|
|
135
134
|
function handleRoleChange(member, next) {
|
|
@@ -259,11 +258,11 @@ export default function MembersListTable() {
|
|
|
259
258
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
260
259
|
</Stack>
|
|
261
260
|
|
|
262
|
-
<TableContainer>
|
|
261
|
+
<TableContainer aria-label="Members" minWidth="720px">
|
|
263
262
|
<TableHeader>
|
|
264
263
|
<TableRow>
|
|
265
|
-
<TableHeaderCell>{sortButton('name', 'Name')}</TableHeaderCell>
|
|
266
|
-
<TableHeaderCell width="170px">{sortButton('role', 'Role')}</TableHeaderCell>
|
|
264
|
+
<TableHeaderCell sort={sort.by === 'name' ? sort.dir : undefined}>{sortButton('name', 'Name')}</TableHeaderCell>
|
|
265
|
+
<TableHeaderCell width="170px" sort={sort.by === 'role' ? sort.dir : undefined}>{sortButton('role', 'Role')}</TableHeaderCell>
|
|
267
266
|
<TableHeaderCell width="340px">Actions</TableHeaderCell>
|
|
268
267
|
</TableRow>
|
|
269
268
|
</TableHeader>
|
|
@@ -304,7 +303,7 @@ export default function MembersListTable() {
|
|
|
304
303
|
|
|
305
304
|
{canManage && invites.length > 0 && (<Stack gap="small">
|
|
306
305
|
<Heading level={2} size="subtitle1">Pending invites</Heading>
|
|
307
|
-
<TableContainer>
|
|
306
|
+
<TableContainer aria-label="Pending invites" minWidth="720px">
|
|
308
307
|
{invites.map(function (i) { return (<TableRow key={i.id}>
|
|
309
308
|
<TableCell>
|
|
310
309
|
<Cluster gap="small">
|
|
@@ -345,7 +344,7 @@ export default function MembersListTable() {
|
|
|
345
344
|
<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setUpgradeOpen(false); }}/>
|
|
346
345
|
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return setUpgradeOpen(false); }}/>
|
|
347
346
|
</>}>
|
|
348
|
-
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for
|
|
347
|
+
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for {formatMoney(8)} per member each month.</Paragraph>
|
|
349
348
|
</Modal>
|
|
350
349
|
</Center>);
|
|
351
350
|
}
|
|
@@ -17,7 +17,7 @@ An admin sees who is in the workspace, changes their roles, removes people and i
|
|
|
17
17
|
- Open the Modal of the case 'Member invite' from an 'Invite Member' Button. Count a pending invite as a seat, because it holds one until it is accepted or revoked.
|
|
18
18
|
- Keep 'Invite Member' pressable at the seat limit. Open the Modal of the case 'Upgrade prompt', titled 'Upgrade to Pro', that says all the seats are filled.
|
|
19
19
|
- Say how many seats are used under the title: '7 of 8 seats used on the Free plan.'
|
|
20
|
-
- Sort a table by a Button in the header cell. `
|
|
20
|
+
- Sort a table by a Button in the header cell. Set `sort` on the `TableHeaderCell` of the sorted column only, and leave it unset on the others. The Button is named by its label alone: 'Name'.
|
|
21
21
|
- Use `state="selected"` and an arrow on the Button of the column that is sorted. The first press sorts A to Z and the next one reverses it.
|
|
22
22
|
|
|
23
23
|
## Don't
|
|
@@ -34,7 +34,7 @@ An admin sees who is in the workspace, changes their roles, removes people and i
|
|
|
34
34
|
|
|
35
35
|
Use when: A workspace of a few dozen people, so the whole list fits and a person finds someone by looking.
|
|
36
36
|
|
|
37
|
-
Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Modal`, `Paragraph`, `Select`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `Tag`, `TextField`, `Toaster`, `UserImage`, `dismissToast`, `toast`
|
|
37
|
+
Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Modal`, `Paragraph`, `Select`, `Stack`, `TableCell`, `TableContainer`, `TableRow`, `Tag`, `TextField`, `Toaster`, `UserImage`, `dismissToast`, `formatMoney`, `toast`
|
|
38
38
|
|
|
39
39
|
```tsx
|
|
40
40
|
'use client';
|
|
@@ -54,6 +54,7 @@ import Tag from 'oneslash-design-system/components/tag';
|
|
|
54
54
|
import Button from 'oneslash-design-system/components/button';
|
|
55
55
|
import UserImage from 'oneslash-design-system/components/userImage';
|
|
56
56
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
57
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
57
58
|
|
|
58
59
|
type Member = { id: string; name: string; email: string; role: string };
|
|
59
60
|
type Invite = { id: string; email: string; sent: string; link: string };
|
|
@@ -382,7 +383,7 @@ export default function MembersListRows() {
|
|
|
382
383
|
</>
|
|
383
384
|
}
|
|
384
385
|
>
|
|
385
|
-
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for
|
|
386
|
+
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for {formatMoney(8)} per member each month.</Paragraph>
|
|
386
387
|
</Modal>
|
|
387
388
|
</Center>
|
|
388
389
|
);
|
|
@@ -393,7 +394,7 @@ export default function MembersListRows() {
|
|
|
393
394
|
|
|
394
395
|
Use when: More people than a person can scan. The columns Name and Role sort.
|
|
395
396
|
|
|
396
|
-
Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Modal`, `Paragraph`, `Select`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `TextField`, `Toaster`, `UserImage`, `dismissToast`, `toast`
|
|
397
|
+
Uses: `Alert`, `Button`, `Center`, `Cluster`, `Form`, `Heading`, `Modal`, `Paragraph`, `Select`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `TextField`, `Toaster`, `UserImage`, `dismissToast`, `formatMoney`, `toast`
|
|
397
398
|
|
|
398
399
|
```tsx
|
|
399
400
|
'use client';
|
|
@@ -415,6 +416,7 @@ import Tag from 'oneslash-design-system/components/tag';
|
|
|
415
416
|
import Button from 'oneslash-design-system/components/button';
|
|
416
417
|
import UserImage from 'oneslash-design-system/components/userImage';
|
|
417
418
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
419
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
418
420
|
|
|
419
421
|
type Member = { id: string; name: string; email: string; role: string };
|
|
420
422
|
type Invite = { id: string; email: string; sent: string; link: string };
|
|
@@ -520,18 +522,15 @@ export default function MembersListTable() {
|
|
|
520
522
|
return sort.dir === 'ascending' ? order : -order;
|
|
521
523
|
});
|
|
522
524
|
|
|
523
|
-
// The header cell has
|
|
525
|
+
// The sorted column's header cell has `sort`; the other cells leave it unset. The Button is named by its label alone.
|
|
524
526
|
function sortButton(by: 'name' | 'role', label: string) {
|
|
525
527
|
const active = sort.by === by;
|
|
526
|
-
const next = active && sort.dir === 'ascending' ? 'descending' : 'ascending';
|
|
527
|
-
const now = active ? `sorted ${sort.dir}` : 'not sorted';
|
|
528
528
|
return (
|
|
529
529
|
<Button
|
|
530
530
|
size="small"
|
|
531
531
|
type="tertiary"
|
|
532
532
|
state={active ? 'selected' : 'enabled'}
|
|
533
533
|
label={label}
|
|
534
|
-
aria-label={`${label}, ${now}. Sort ${next}.`}
|
|
535
534
|
decoIcon={active ? (sort.dir === 'ascending' ? 'ArrowUp' : 'ArrowDown') : undefined}
|
|
536
535
|
onClickButton={() => handleSort(by)}
|
|
537
536
|
/>
|
|
@@ -656,11 +655,11 @@ export default function MembersListTable() {
|
|
|
656
655
|
{!canManage && <Paragraph tone="secondary" size="body2" measure="none">Only admins can change this.</Paragraph>}
|
|
657
656
|
</Stack>
|
|
658
657
|
|
|
659
|
-
<TableContainer>
|
|
658
|
+
<TableContainer aria-label="Members" minWidth="720px">
|
|
660
659
|
<TableHeader>
|
|
661
660
|
<TableRow>
|
|
662
|
-
<TableHeaderCell>{sortButton('name', 'Name')}</TableHeaderCell>
|
|
663
|
-
<TableHeaderCell width="170px">{sortButton('role', 'Role')}</TableHeaderCell>
|
|
661
|
+
<TableHeaderCell sort={sort.by === 'name' ? sort.dir : undefined}>{sortButton('name', 'Name')}</TableHeaderCell>
|
|
662
|
+
<TableHeaderCell width="170px" sort={sort.by === 'role' ? sort.dir : undefined}>{sortButton('role', 'Role')}</TableHeaderCell>
|
|
664
663
|
<TableHeaderCell width="340px">Actions</TableHeaderCell>
|
|
665
664
|
</TableRow>
|
|
666
665
|
</TableHeader>
|
|
@@ -722,7 +721,7 @@ export default function MembersListTable() {
|
|
|
722
721
|
{canManage && invites.length > 0 && (
|
|
723
722
|
<Stack gap="small">
|
|
724
723
|
<Heading level={2} size="subtitle1">Pending invites</Heading>
|
|
725
|
-
<TableContainer>
|
|
724
|
+
<TableContainer aria-label="Pending invites" minWidth="720px">
|
|
726
725
|
{invites.map((i) => (
|
|
727
726
|
<TableRow key={i.id}>
|
|
728
727
|
<TableCell>
|
|
@@ -787,7 +786,7 @@ export default function MembersListTable() {
|
|
|
787
786
|
</>
|
|
788
787
|
}
|
|
789
788
|
>
|
|
790
|
-
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for
|
|
789
|
+
<Paragraph measure="none">All {seatLimit} seats on the Free plan are filled. Pro adds seats for {formatMoney(8)} per member each month.</Paragraph>
|
|
791
790
|
</Modal>
|
|
792
791
|
</Center>
|
|
793
792
|
);
|
|
@@ -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
|
+
}
|