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,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Surface from '../../components/surface';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import List from '../../components/list';
|
|
8
|
+
import Tag from '../../components/tag';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import SettingsSection from '../../components/settingsSection';
|
|
12
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
13
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
14
|
+
var plans = [
|
|
15
|
+
{ id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
16
|
+
{ id: 'pro', name: 'Pro', price: "".concat(formatMoney(8), " per member per month"), includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
17
|
+
{ id: 'business', name: 'Business', price: "".concat(formatMoney(16), " per member per month"), includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
18
|
+
];
|
|
19
|
+
var rank = { free: 0, pro: 1, business: 2 };
|
|
20
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
21
|
+
function describe(from, to) {
|
|
22
|
+
var name = plans.find(function (p) { return p.id === to; }).name;
|
|
23
|
+
if (rank[to] > rank[from]) {
|
|
24
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
25
|
+
var today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
26
|
+
var monthly = to === 'pro' ? 24 : 48;
|
|
27
|
+
var body = "You pay ".concat(formatMoney(today), " today for the 15 days left in November, then ").concat(formatMoney(monthly), " each month.");
|
|
28
|
+
return { title: "Upgrade to ".concat(name), body: body, detail: false };
|
|
29
|
+
}
|
|
30
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
31
|
+
return { title: "Downgrade to ".concat(name), body: "".concat(plans.find(function (p) { return p.id === from; }).name, " stays on until Dec 1, 2026. Acme is not charged again."), detail: true };
|
|
32
|
+
}
|
|
33
|
+
export default function PlanPickerCards() {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
var _c = useState('free'), current = _c[0], setCurrent = _c[1];
|
|
36
|
+
var _d = useState(null), scheduled = _d[0], setScheduled = _d[1];
|
|
37
|
+
var _e = useState(null), target = _e[0], setTarget = _e[1];
|
|
38
|
+
var _f = useState(false), busy = _f[0], setBusy = _f[1];
|
|
39
|
+
var timer = useRef();
|
|
40
|
+
// On unmount it stops the request.
|
|
41
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
42
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
43
|
+
function handleClose() {
|
|
44
|
+
if (busy)
|
|
45
|
+
return;
|
|
46
|
+
setTarget(null);
|
|
47
|
+
}
|
|
48
|
+
function handleConfirm() {
|
|
49
|
+
if (busy || !target)
|
|
50
|
+
return;
|
|
51
|
+
var to = target;
|
|
52
|
+
setBusy(true);
|
|
53
|
+
// Stands in for the request to the server.
|
|
54
|
+
timer.current = setTimeout(function () {
|
|
55
|
+
setBusy(false);
|
|
56
|
+
setTarget(null);
|
|
57
|
+
if (rank[to] > rank[current]) {
|
|
58
|
+
setCurrent(to);
|
|
59
|
+
setScheduled(null);
|
|
60
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
64
|
+
setScheduled(to);
|
|
65
|
+
}
|
|
66
|
+
}, 1200);
|
|
67
|
+
}
|
|
68
|
+
var copy = target ? describe(current, target) : null;
|
|
69
|
+
var currentName = plans.find(function (p) { return p.id === current; }).name;
|
|
70
|
+
return (<Center width="page">
|
|
71
|
+
<SettingsSection title="Plan" description={scheduled ? "Acme is on ".concat(currentName, " until Dec 1, 2026, then ").concat(plans.find(function (p) { return p.id === scheduled; }).name, ".") : "Acme is on ".concat(currentName, ".")}>
|
|
72
|
+
{/* Two or three plans side by side from md up, stacked on a phone. A card is not itself clickable. */}
|
|
73
|
+
<Grid columns={3}>
|
|
74
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="small">
|
|
75
|
+
<Stack gap="medium">
|
|
76
|
+
<Stack gap="small">
|
|
77
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
78
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
79
|
+
</Stack>
|
|
80
|
+
<List items={p.includes} size="body2" marker="dot"/>
|
|
81
|
+
{p.id === current ? (<Cluster><Tag variant="textOnly" size="small" label="Current plan"/></Cluster>) : p.id === scheduled ? (<Cluster><Tag variant="dot" size="small" label="Starts Dec 1"/></Cluster>) : rank[p.id] > rank[current] ? (<Cluster><Button size="small" type="primary" state="enabled" label={"Upgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/></Cluster>) : (<Cluster><Button size="small" type="tertiary" state="enabled" label={"Downgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/></Cluster>)}
|
|
82
|
+
</Stack>
|
|
83
|
+
</Surface>); })}
|
|
84
|
+
</Grid>
|
|
85
|
+
</SettingsSection>
|
|
86
|
+
<Modal isOpen={target !== null} size="small" title={(_a = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _a !== void 0 ? _a : ''} onClose={handleClose} actions={<>
|
|
87
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
88
|
+
<Button size="small" type="primary" state="enabled" label={(_b = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _b !== void 0 ? _b : ''} loading={busy} onClickButton={handleConfirm}/>
|
|
89
|
+
</>}>
|
|
90
|
+
<Paragraph measure="none">{copy === null || copy === void 0 ? void 0 : copy.body}</Paragraph>
|
|
91
|
+
{(copy === null || copy === void 0 ? void 0 : copy.detail) && (<>
|
|
92
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
93
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']}/>
|
|
94
|
+
</>)}
|
|
95
|
+
</Modal>
|
|
96
|
+
</Center>);
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanPickerList(): import("react").JSX.Element;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Surface from '../../components/surface';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import List from '../../components/list';
|
|
8
|
+
import Tag from '../../components/tag';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import SettingsSection from '../../components/settingsSection';
|
|
12
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
13
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
14
|
+
var plans = [
|
|
15
|
+
{ id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
16
|
+
{ id: 'pro', name: 'Pro', price: "".concat(formatMoney(8), " per member per month"), includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
17
|
+
{ id: 'business', name: 'Business', price: "".concat(formatMoney(16), " per member per month"), includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
18
|
+
];
|
|
19
|
+
var rank = { free: 0, pro: 1, business: 2 };
|
|
20
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
21
|
+
function describe(from, to) {
|
|
22
|
+
var name = plans.find(function (p) { return p.id === to; }).name;
|
|
23
|
+
if (rank[to] > rank[from]) {
|
|
24
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
25
|
+
var today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
26
|
+
var monthly = to === 'pro' ? 24 : 48;
|
|
27
|
+
var body = "You pay ".concat(formatMoney(today), " today for the 15 days left in November, then ").concat(formatMoney(monthly), " each month.");
|
|
28
|
+
return { title: "Upgrade to ".concat(name), body: body, detail: false };
|
|
29
|
+
}
|
|
30
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
31
|
+
return { title: "Downgrade to ".concat(name), body: "".concat(plans.find(function (p) { return p.id === from; }).name, " stays on until Dec 1, 2026. Acme is not charged again."), detail: true };
|
|
32
|
+
}
|
|
33
|
+
export default function PlanPickerList() {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
var _c = useState('pro'), current = _c[0], setCurrent = _c[1];
|
|
36
|
+
var _d = useState(null), scheduled = _d[0], setScheduled = _d[1];
|
|
37
|
+
var _e = useState(null), target = _e[0], setTarget = _e[1];
|
|
38
|
+
var _f = useState(false), busy = _f[0], setBusy = _f[1];
|
|
39
|
+
var timer = useRef();
|
|
40
|
+
// On unmount it stops the request.
|
|
41
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
42
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
43
|
+
function handleClose() {
|
|
44
|
+
if (busy)
|
|
45
|
+
return;
|
|
46
|
+
setTarget(null);
|
|
47
|
+
}
|
|
48
|
+
function handleConfirm() {
|
|
49
|
+
if (busy || !target)
|
|
50
|
+
return;
|
|
51
|
+
var to = target;
|
|
52
|
+
setBusy(true);
|
|
53
|
+
// Stands in for the request to the server.
|
|
54
|
+
timer.current = setTimeout(function () {
|
|
55
|
+
setBusy(false);
|
|
56
|
+
setTarget(null);
|
|
57
|
+
if (rank[to] > rank[current]) {
|
|
58
|
+
setCurrent(to);
|
|
59
|
+
setScheduled(null);
|
|
60
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
64
|
+
setScheduled(to);
|
|
65
|
+
}
|
|
66
|
+
}, 1200);
|
|
67
|
+
}
|
|
68
|
+
var copy = target ? describe(current, target) : null;
|
|
69
|
+
var currentName = plans.find(function (p) { return p.id === current; }).name;
|
|
70
|
+
return (<Center width="page">
|
|
71
|
+
<SettingsSection title="Plan" description={scheduled ? "Acme is on ".concat(currentName, " until Dec 1, 2026, then ").concat(plans.find(function (p) { return p.id === scheduled; }).name, ".") : "Acme is on ".concat(currentName, ".")}>
|
|
72
|
+
{/* Rows in the settings column. The plan and what it includes on the left, the one action on the right. */}
|
|
73
|
+
<Stack gap="medium">
|
|
74
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="small">
|
|
75
|
+
<Cluster justify="between" align="start" gap="medium">
|
|
76
|
+
<Stack gap="small">
|
|
77
|
+
<Cluster gap="small">
|
|
78
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
79
|
+
{p.id === current && <Tag variant="textOnly" size="small" label="Current plan"/>}
|
|
80
|
+
{p.id === scheduled && <Tag variant="dot" size="small" label="Starts Dec 1"/>}
|
|
81
|
+
</Cluster>
|
|
82
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
83
|
+
<List items={p.includes} size="body2" marker="dot"/>
|
|
84
|
+
</Stack>
|
|
85
|
+
{p.id !== current && p.id !== scheduled && (rank[p.id] > rank[current]
|
|
86
|
+
? <Button size="small" type="primary" state="enabled" label={"Upgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/>
|
|
87
|
+
: <Button size="small" type="tertiary" state="enabled" label={"Downgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/>)}
|
|
88
|
+
</Cluster>
|
|
89
|
+
</Surface>); })}
|
|
90
|
+
</Stack>
|
|
91
|
+
</SettingsSection>
|
|
92
|
+
<Modal isOpen={target !== null} size="small" title={(_a = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _a !== void 0 ? _a : ''} onClose={handleClose} actions={<>
|
|
93
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
94
|
+
<Button size="small" type="primary" state="enabled" label={(_b = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _b !== void 0 ? _b : ''} loading={busy} onClickButton={handleConfirm}/>
|
|
95
|
+
</>}>
|
|
96
|
+
<Paragraph measure="none">{copy === null || copy === void 0 ? void 0 : copy.body}</Paragraph>
|
|
97
|
+
{(copy === null || copy === void 0 ? void 0 : copy.detail) && (<>
|
|
98
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
99
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']}/>
|
|
100
|
+
</>)}
|
|
101
|
+
</Modal>
|
|
102
|
+
</Center>);
|
|
103
|
+
}
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
# Plan picker
|
|
2
|
+
|
|
3
|
+
An admin compares the plans a workspace can be on and chooses one.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Make each plan a `Surface` with its name as a heading, its price and a `List` of what it includes. Write each limit as a number with its unit: '3 members', '50 AI agent responses a month'.
|
|
9
|
+
- Put the cards in `Grid columns={3}`, which stacks them on a phone. Put the rows in one column.
|
|
10
|
+
- Mark the current plan with `Tag variant="textOnly"` 'Current plan', and give it no Button.
|
|
11
|
+
- Give every other plan one Button named for the move: 'Upgrade to Pro' as primary, 'Downgrade to Free' as tertiary. It opens the case 'Plan change confirm'.
|
|
12
|
+
- Say a change that starts later with a Tag 'Starts Dec 1' on the new plan, and a line under the heading: 'Acme is on Pro until Dec 1, 2026, then Free.'
|
|
13
|
+
- Open the picker from 'Change Plan' on the case 'Billing page'. Show it only to a person who can change the plan.
|
|
14
|
+
- Add a `SegmentedControl` as the case 'Range switch' says once the plans bill by the year too. Leave it out while every plan bills monthly.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not make a card clickable as a whole. Its Button is the one control, so a keyboard and a screen reader find it.
|
|
19
|
+
- Do not label the Buttons 'Select' or 'Choose'. Say the move: 'Upgrade to Pro'.
|
|
20
|
+
- Do not run the limits together in one line with dots between them. Use a `List`, one limit per item.
|
|
21
|
+
- Do not add a monthly and yearly switch when no plan bills yearly.
|
|
22
|
+
- Do not change a Button label to show it is busy, such as to 'Checking...'.
|
|
23
|
+
- Do not charge or change the plan from this page. The confirm does that.
|
|
24
|
+
|
|
25
|
+
## Option: Cards side by side
|
|
26
|
+
|
|
27
|
+
Use when: Two or three plans are compared at once, on a page with room for columns.
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import { useEffect, useRef, useState } from 'react';
|
|
34
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
35
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
36
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
37
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
38
|
+
import List from 'oneslash-design-system/components/list';
|
|
39
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
40
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
41
|
+
import Button from 'oneslash-design-system/components/button';
|
|
42
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
43
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
44
|
+
|
|
45
|
+
type PlanId = 'free' | 'pro' | 'business';
|
|
46
|
+
|
|
47
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
48
|
+
const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
|
|
49
|
+
{ id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
50
|
+
{ id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
51
|
+
{ id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
|
|
55
|
+
|
|
56
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
57
|
+
function describe(from: PlanId, to: PlanId) {
|
|
58
|
+
const name = plans.find((p) => p.id === to)!.name;
|
|
59
|
+
if (rank[to] > rank[from]) {
|
|
60
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
61
|
+
const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
62
|
+
const monthly = to === 'pro' ? 24 : 48;
|
|
63
|
+
const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
|
|
64
|
+
return { title: `Upgrade to ${name}`, body, detail: false };
|
|
65
|
+
}
|
|
66
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
67
|
+
return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default function PlanPickerCards() {
|
|
71
|
+
const [current, setCurrent] = useState<PlanId>('free');
|
|
72
|
+
const [scheduled, setScheduled] = useState<PlanId | null>(null);
|
|
73
|
+
const [target, setTarget] = useState<PlanId | null>(null);
|
|
74
|
+
const [busy, setBusy] = useState(false);
|
|
75
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
76
|
+
|
|
77
|
+
// On unmount it stops the request.
|
|
78
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
79
|
+
|
|
80
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
81
|
+
function handleClose() {
|
|
82
|
+
if (busy) return;
|
|
83
|
+
setTarget(null);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function handleConfirm() {
|
|
87
|
+
if (busy || !target) return;
|
|
88
|
+
const to = target;
|
|
89
|
+
setBusy(true);
|
|
90
|
+
// Stands in for the request to the server.
|
|
91
|
+
timer.current = setTimeout(() => {
|
|
92
|
+
setBusy(false);
|
|
93
|
+
setTarget(null);
|
|
94
|
+
if (rank[to] > rank[current]) {
|
|
95
|
+
setCurrent(to);
|
|
96
|
+
setScheduled(null);
|
|
97
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
98
|
+
} else {
|
|
99
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
100
|
+
setScheduled(to);
|
|
101
|
+
}
|
|
102
|
+
}, 1200);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const copy = target ? describe(current, target) : null;
|
|
106
|
+
const currentName = plans.find((p) => p.id === current)!.name;
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Center width="page">
|
|
110
|
+
<SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
|
|
111
|
+
{/* Two or three plans side by side from md up, stacked on a phone. A card is not itself clickable. */}
|
|
112
|
+
<Grid columns={3}>
|
|
113
|
+
{plans.map((p) => (
|
|
114
|
+
<Surface key={p.id} padding="small">
|
|
115
|
+
<Stack gap="medium">
|
|
116
|
+
<Stack gap="small">
|
|
117
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
118
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
119
|
+
</Stack>
|
|
120
|
+
<List items={p.includes} size="body2" marker="dot" />
|
|
121
|
+
{p.id === current ? (
|
|
122
|
+
<Cluster><Tag variant="textOnly" size="small" label="Current plan" /></Cluster>
|
|
123
|
+
) : p.id === scheduled ? (
|
|
124
|
+
<Cluster><Tag variant="dot" size="small" label="Starts Dec 1" /></Cluster>
|
|
125
|
+
) : rank[p.id] > rank[current] ? (
|
|
126
|
+
<Cluster><Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
|
|
127
|
+
) : (
|
|
128
|
+
<Cluster><Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
|
|
129
|
+
)}
|
|
130
|
+
</Stack>
|
|
131
|
+
</Surface>
|
|
132
|
+
))}
|
|
133
|
+
</Grid>
|
|
134
|
+
</SettingsSection>
|
|
135
|
+
<Modal
|
|
136
|
+
isOpen={target !== null}
|
|
137
|
+
size="small"
|
|
138
|
+
title={copy?.title ?? ''}
|
|
139
|
+
onClose={handleClose}
|
|
140
|
+
actions={
|
|
141
|
+
<>
|
|
142
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
143
|
+
<Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
|
|
144
|
+
</>
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
<Paragraph measure="none">{copy?.body}</Paragraph>
|
|
148
|
+
{copy?.detail && (
|
|
149
|
+
<>
|
|
150
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
151
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
|
|
152
|
+
</>
|
|
153
|
+
)}
|
|
154
|
+
</Modal>
|
|
155
|
+
</Center>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Option: Rows in a settings column
|
|
161
|
+
|
|
162
|
+
Use when: The picker sits in a narrow settings column, or the plans have long lists of what they include.
|
|
163
|
+
|
|
164
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
'use client';
|
|
168
|
+
import { useEffect, useRef, useState } from 'react';
|
|
169
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
170
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
171
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
172
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
173
|
+
import List from 'oneslash-design-system/components/list';
|
|
174
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
175
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
176
|
+
import Button from 'oneslash-design-system/components/button';
|
|
177
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
178
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
179
|
+
|
|
180
|
+
type PlanId = 'free' | 'pro' | 'business';
|
|
181
|
+
|
|
182
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
183
|
+
const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
|
|
184
|
+
{ id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
185
|
+
{ id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
186
|
+
{ id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
|
|
190
|
+
|
|
191
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
192
|
+
function describe(from: PlanId, to: PlanId) {
|
|
193
|
+
const name = plans.find((p) => p.id === to)!.name;
|
|
194
|
+
if (rank[to] > rank[from]) {
|
|
195
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
196
|
+
const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
197
|
+
const monthly = to === 'pro' ? 24 : 48;
|
|
198
|
+
const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
|
|
199
|
+
return { title: `Upgrade to ${name}`, body, detail: false };
|
|
200
|
+
}
|
|
201
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
202
|
+
return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default function PlanPickerList() {
|
|
206
|
+
const [current, setCurrent] = useState<PlanId>('pro');
|
|
207
|
+
const [scheduled, setScheduled] = useState<PlanId | null>(null);
|
|
208
|
+
const [target, setTarget] = useState<PlanId | null>(null);
|
|
209
|
+
const [busy, setBusy] = useState(false);
|
|
210
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
211
|
+
|
|
212
|
+
// On unmount it stops the request.
|
|
213
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
214
|
+
|
|
215
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
216
|
+
function handleClose() {
|
|
217
|
+
if (busy) return;
|
|
218
|
+
setTarget(null);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function handleConfirm() {
|
|
222
|
+
if (busy || !target) return;
|
|
223
|
+
const to = target;
|
|
224
|
+
setBusy(true);
|
|
225
|
+
// Stands in for the request to the server.
|
|
226
|
+
timer.current = setTimeout(() => {
|
|
227
|
+
setBusy(false);
|
|
228
|
+
setTarget(null);
|
|
229
|
+
if (rank[to] > rank[current]) {
|
|
230
|
+
setCurrent(to);
|
|
231
|
+
setScheduled(null);
|
|
232
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
233
|
+
} else {
|
|
234
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
235
|
+
setScheduled(to);
|
|
236
|
+
}
|
|
237
|
+
}, 1200);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const copy = target ? describe(current, target) : null;
|
|
241
|
+
const currentName = plans.find((p) => p.id === current)!.name;
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<Center width="page">
|
|
245
|
+
<SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
|
|
246
|
+
{/* Rows in the settings column. The plan and what it includes on the left, the one action on the right. */}
|
|
247
|
+
<Stack gap="medium">
|
|
248
|
+
{plans.map((p) => (
|
|
249
|
+
<Surface key={p.id} padding="small">
|
|
250
|
+
<Cluster justify="between" align="start" gap="medium">
|
|
251
|
+
<Stack gap="small">
|
|
252
|
+
<Cluster gap="small">
|
|
253
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
254
|
+
{p.id === current && <Tag variant="textOnly" size="small" label="Current plan" />}
|
|
255
|
+
{p.id === scheduled && <Tag variant="dot" size="small" label="Starts Dec 1" />}
|
|
256
|
+
</Cluster>
|
|
257
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
258
|
+
<List items={p.includes} size="body2" marker="dot" />
|
|
259
|
+
</Stack>
|
|
260
|
+
{p.id !== current && p.id !== scheduled && (
|
|
261
|
+
rank[p.id] > rank[current]
|
|
262
|
+
? <Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
|
|
263
|
+
: <Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
|
|
264
|
+
)}
|
|
265
|
+
</Cluster>
|
|
266
|
+
</Surface>
|
|
267
|
+
))}
|
|
268
|
+
</Stack>
|
|
269
|
+
</SettingsSection>
|
|
270
|
+
<Modal
|
|
271
|
+
isOpen={target !== null}
|
|
272
|
+
size="small"
|
|
273
|
+
title={copy?.title ?? ''}
|
|
274
|
+
onClose={handleClose}
|
|
275
|
+
actions={
|
|
276
|
+
<>
|
|
277
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
278
|
+
<Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
|
|
279
|
+
</>
|
|
280
|
+
}
|
|
281
|
+
>
|
|
282
|
+
<Paragraph measure="none">{copy?.body}</Paragraph>
|
|
283
|
+
{copy?.detail && (
|
|
284
|
+
<>
|
|
285
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
286
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
|
|
287
|
+
</>
|
|
288
|
+
)}
|
|
289
|
+
</Modal>
|
|
290
|
+
</Center>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Native
|
|
296
|
+
|
|
297
|
+
On Apple use a `List` of plans with the system purchase sheet, and mark the current plan with a checkmark and the words 'Current plan'. Never build a card by hand.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import Heading from '../../components/heading';
|
|
4
|
-
import
|
|
4
|
+
import StatTile from '../../components/statTile';
|
|
5
5
|
import SegmentedControl from '../../components/segmentedControl';
|
|
6
|
-
import { Center, Cluster, Stack } from '../../components/layout';
|
|
6
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
7
7
|
// A real app counts these on the server.
|
|
8
8
|
var ranges = [
|
|
9
|
-
{ value: 'week', label: 'Week',
|
|
10
|
-
{ value: 'month', label: 'Month',
|
|
11
|
-
{ value: 'quarter', label: 'Quarter',
|
|
9
|
+
{ value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
|
|
10
|
+
{ value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
|
|
11
|
+
{ value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
|
|
12
12
|
];
|
|
13
13
|
export default function RangeSwitchSegmented() {
|
|
14
14
|
var _a;
|
|
@@ -23,8 +23,12 @@ export default function RangeSwitchSegmented() {
|
|
|
23
23
|
return ({ value: value, label: label });
|
|
24
24
|
})} value={range} onChange={setRange}/>
|
|
25
25
|
</Cluster>
|
|
26
|
-
{/* The
|
|
27
|
-
<
|
|
26
|
+
{/* The numbers change with the range. This page stays the same. */}
|
|
27
|
+
<Grid compact columns={3}>
|
|
28
|
+
<StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period}/>
|
|
29
|
+
<StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period}/>
|
|
30
|
+
<StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period}/>
|
|
31
|
+
</Grid>
|
|
28
32
|
</Stack>
|
|
29
33
|
</Center>);
|
|
30
34
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Range switch
|
|
2
2
|
|
|
3
|
-
A person changes the time range of
|
|
3
|
+
A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter.
|
|
4
4
|
|
|
5
5
|
## Do
|
|
6
6
|
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
7
8
|
- Use `SegmentedControl` with `size="small"` and `aria-label="Range"`: 'Week', 'Month', 'Quarter'.
|
|
8
|
-
- Put it beside the heading of the
|
|
9
|
+
- Put it beside the heading of the numbers or list it changes, with `width="fit"` so it is as wide as its options.
|
|
9
10
|
- Keep one option on at all times. Start on 'Week', the newest numbers, unless the page is about a longer period.
|
|
10
11
|
- Change the numbers in place and keep the page, the heading and the scroll position.
|
|
11
12
|
- Move between options with the arrow keys. They select as they move.
|
|
@@ -19,21 +20,21 @@ A person changes the time range of a chart or a list on the same page, such as W
|
|
|
19
20
|
|
|
20
21
|
## Example: Segmented control
|
|
21
22
|
|
|
22
|
-
Uses: `Center`, `Cluster`, `
|
|
23
|
+
Uses: `Center`, `Cluster`, `Grid`, `Heading`, `SegmentedControl`, `Stack`, `StatTile`
|
|
23
24
|
|
|
24
25
|
```tsx
|
|
25
26
|
'use client';
|
|
26
27
|
import { useState } from 'react';
|
|
27
28
|
import Heading from 'oneslash-design-system/components/heading';
|
|
28
|
-
import
|
|
29
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
29
30
|
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
30
|
-
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
31
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
31
32
|
|
|
32
33
|
// A real app counts these on the server.
|
|
33
|
-
const ranges = [
|
|
34
|
-
{ value: 'week', label: 'Week',
|
|
35
|
-
{ value: 'month', label: 'Month',
|
|
36
|
-
{ value: 'quarter', label: 'Quarter',
|
|
34
|
+
const ranges: { value: string; label: string; period: 'week' | 'month' | 'quarter'; comments: number[]; done: number[]; people: number[] }[] = [
|
|
35
|
+
{ value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
|
|
36
|
+
{ value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
|
|
37
|
+
{ value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
|
|
37
38
|
];
|
|
38
39
|
|
|
39
40
|
export default function RangeSwitchSegmented() {
|
|
@@ -54,8 +55,12 @@ export default function RangeSwitchSegmented() {
|
|
|
54
55
|
onChange={setRange}
|
|
55
56
|
/>
|
|
56
57
|
</Cluster>
|
|
57
|
-
{/* The
|
|
58
|
-
<
|
|
58
|
+
{/* The numbers change with the range. This page stays the same. */}
|
|
59
|
+
<Grid compact columns={3}>
|
|
60
|
+
<StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period} />
|
|
61
|
+
<StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period} />
|
|
62
|
+
<StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period} />
|
|
63
|
+
</Grid>
|
|
59
64
|
</Stack>
|
|
60
65
|
</Center>
|
|
61
66
|
);
|