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,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import Tag from '../../components/tag';
|
|
4
|
+
import TableContainer from '../../components/tableContainer';
|
|
5
|
+
import TableHeader from '../../components/tableHeader';
|
|
6
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
7
|
+
import TableRow from '../../components/tableRow';
|
|
8
|
+
import TableCell from '../../components/tableCell';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import { Center, Stack } from '../../components/layout';
|
|
11
|
+
// A real app reads these from the server.
|
|
12
|
+
var payments = [
|
|
13
|
+
{ id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
|
|
14
|
+
{ id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
|
|
15
|
+
{ id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
|
|
16
|
+
{ id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
|
|
17
|
+
];
|
|
18
|
+
export default function StatusLabelText() {
|
|
19
|
+
return (<Center width="page">
|
|
20
|
+
<Stack gap="large">
|
|
21
|
+
<Heading level={2} size="h5">Payments</Heading>
|
|
22
|
+
<TableContainer aria-label="Payments" minWidth="480px">
|
|
23
|
+
<TableHeader>
|
|
24
|
+
<TableRow>
|
|
25
|
+
<TableHeaderCell>Date</TableHeaderCell>
|
|
26
|
+
<TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
|
|
27
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
28
|
+
</TableRow>
|
|
29
|
+
</TableHeader>
|
|
30
|
+
{payments.map(function (p) { return (<TableRow key={p.id}>
|
|
31
|
+
<TableCell>{p.date}</TableCell>
|
|
32
|
+
<TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
|
|
33
|
+
<TableCell width="160px">
|
|
34
|
+
{p.status === 'Upcoming' ? (
|
|
35
|
+
// The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
|
|
36
|
+
<Tag variant="dot" size="small" color="info" label={p.status}/>) : (
|
|
37
|
+
// A settled record is a word with no dot and no color.
|
|
38
|
+
<Tag variant="textOnly" size="small" label={p.status}/>)}
|
|
39
|
+
</TableCell>
|
|
40
|
+
</TableRow>); })}
|
|
41
|
+
</TableContainer>
|
|
42
|
+
</Stack>
|
|
43
|
+
</Center>);
|
|
44
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Status in a row
|
|
2
|
+
|
|
3
|
+
A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Use `Tag` for a state in a row, with `size="small"`. ODS has no Badge part: a second part for the same job would mark the same states two ways.
|
|
8
|
+
- Show the word every time. The dot alone means nothing to a screen reader or to a person who cannot tell the colors apart.
|
|
9
|
+
- Use `variant="dot"` for a state that changes and may need the person: 'Past due', 'Canceling', 'Connected'.
|
|
10
|
+
- Give the dot a color only when the state needs action: `color="error"` for 'Past due', `color="warning"` for 'Canceling'. One exception: `color="info"` for a charge that has not happened yet, 'Upcoming', so it does not read as paid. A usual state, such as 'Connected', keeps the grey dot.
|
|
11
|
+
- Use `variant="textOnly"` with no color for a settled record: 'Paid', 'Refunded'.
|
|
12
|
+
- Write one word or two, in sentence case: 'Past due', 'Needs reconnecting'.
|
|
13
|
+
- Put the Tag in a 'Status' column, or at the end of the row's text. It is not clickable.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not show a dot with no word, or a color with no word.
|
|
18
|
+
- Do not color a settled state. A green 'Paid' on every row hides the one red 'Past due'.
|
|
19
|
+
- Do not write the word in Title Case ('Past Due') or as a sentence ('Your payment is late').
|
|
20
|
+
- Do not fill the Tag with `variant="contained"` for a status in a row. A filled Tag is a label the person picks.
|
|
21
|
+
- Do not make the Tag a button. A status that opens something is a row action, in the More menu.
|
|
22
|
+
- Do not draw the dot by hand.
|
|
23
|
+
|
|
24
|
+
## Option: A dot and a word
|
|
25
|
+
|
|
26
|
+
Use when: The state changes and may need the person: Past due, Canceling, Connected.
|
|
27
|
+
|
|
28
|
+
Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
'use client';
|
|
32
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
33
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
34
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
35
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
36
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
37
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
38
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
39
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
40
|
+
|
|
41
|
+
type Color = 'error' | 'warning' | undefined;
|
|
42
|
+
|
|
43
|
+
// A real app reads these from the server.
|
|
44
|
+
const workspaces: { id: string; name: string; plan: string; status: string; color: Color }[] = [
|
|
45
|
+
{ id: 'acme', name: 'Acme', plan: 'Pro', status: 'Past due', color: 'error' },
|
|
46
|
+
{ id: 'acme-labs', name: 'Acme Labs', plan: 'Pro', status: 'Canceling', color: 'warning' },
|
|
47
|
+
{ id: 'acme-studio', name: 'Acme Studio', plan: 'Pro', status: 'Active', color: undefined },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default function StatusLabelDot() {
|
|
51
|
+
return (
|
|
52
|
+
<Center width="page">
|
|
53
|
+
<Stack gap="large">
|
|
54
|
+
<Heading level={2} size="h5">Workspaces</Heading>
|
|
55
|
+
<TableContainer aria-label="Workspaces" minWidth="480px">
|
|
56
|
+
<TableHeader>
|
|
57
|
+
<TableRow>
|
|
58
|
+
<TableHeaderCell>Workspace</TableHeaderCell>
|
|
59
|
+
<TableHeaderCell width="100px">Plan</TableHeaderCell>
|
|
60
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
61
|
+
</TableRow>
|
|
62
|
+
</TableHeader>
|
|
63
|
+
{workspaces.map((w) => (
|
|
64
|
+
<TableRow key={w.id}>
|
|
65
|
+
<TableCell>{w.name}</TableCell>
|
|
66
|
+
<TableCell width="100px">{w.plan}</TableCell>
|
|
67
|
+
<TableCell width="160px">
|
|
68
|
+
{/* The word is always there. Only a state that needs action gets a color: 'Active' keeps the grey dot. */}
|
|
69
|
+
<Tag variant="dot" size="small" color={w.color} label={w.status} />
|
|
70
|
+
</TableCell>
|
|
71
|
+
</TableRow>
|
|
72
|
+
))}
|
|
73
|
+
</TableContainer>
|
|
74
|
+
</Stack>
|
|
75
|
+
</Center>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Option: A word alone
|
|
81
|
+
|
|
82
|
+
Use when: The record is settled and nothing is left to do: Paid, Refunded.
|
|
83
|
+
|
|
84
|
+
Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `formatMoney`
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
'use client';
|
|
88
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
89
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
90
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
91
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
92
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
93
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
94
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
95
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
96
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
97
|
+
|
|
98
|
+
// A real app reads these from the server.
|
|
99
|
+
const payments = [
|
|
100
|
+
{ id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
|
|
101
|
+
{ id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
|
|
102
|
+
{ id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
|
|
103
|
+
{ id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export default function StatusLabelText() {
|
|
107
|
+
return (
|
|
108
|
+
<Center width="page">
|
|
109
|
+
<Stack gap="large">
|
|
110
|
+
<Heading level={2} size="h5">Payments</Heading>
|
|
111
|
+
<TableContainer aria-label="Payments" minWidth="480px">
|
|
112
|
+
<TableHeader>
|
|
113
|
+
<TableRow>
|
|
114
|
+
<TableHeaderCell>Date</TableHeaderCell>
|
|
115
|
+
<TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
|
|
116
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
117
|
+
</TableRow>
|
|
118
|
+
</TableHeader>
|
|
119
|
+
{payments.map((p) => (
|
|
120
|
+
<TableRow key={p.id}>
|
|
121
|
+
<TableCell>{p.date}</TableCell>
|
|
122
|
+
<TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
|
|
123
|
+
<TableCell width="160px">
|
|
124
|
+
{p.status === 'Upcoming' ? (
|
|
125
|
+
// The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
|
|
126
|
+
<Tag variant="dot" size="small" color="info" label={p.status} />
|
|
127
|
+
) : (
|
|
128
|
+
// A settled record is a word with no dot and no color.
|
|
129
|
+
<Tag variant="textOnly" size="small" label={p.status} />
|
|
130
|
+
)}
|
|
131
|
+
</TableCell>
|
|
132
|
+
</TableRow>
|
|
133
|
+
))}
|
|
134
|
+
</TableContainer>
|
|
135
|
+
</Stack>
|
|
136
|
+
</Center>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Native
|
|
142
|
+
|
|
143
|
+
On Apple use a `Label` with a small filled circle as its image and the word, colored with a semantic style only when the state needs action. On Android use a leading dot and the word in a `Text`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ThemeSwitcherMenu(): import("react").JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import IconButton from '../../components/iconButton';
|
|
4
|
+
import Tooltip from '../../components/tooltip';
|
|
5
|
+
import Popover from '../../components/popover';
|
|
6
|
+
import Menu from '../../components/menu';
|
|
7
|
+
import MenuItem from '../../components/menuItem';
|
|
8
|
+
import PageShell from '../../components/pageShell';
|
|
9
|
+
import Heading from '../../components/heading';
|
|
10
|
+
import Paragraph from '../../components/paragraph';
|
|
11
|
+
import Link from '../../components/link';
|
|
12
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
13
|
+
var modes = [
|
|
14
|
+
{ value: 'light', label: 'Light', icon: 'Sun' },
|
|
15
|
+
{ value: 'dark', label: 'Dark', icon: 'Moon' },
|
|
16
|
+
{ value: 'system', label: 'System', icon: 'Monitor' },
|
|
17
|
+
];
|
|
18
|
+
export default function ThemeSwitcherMenu() {
|
|
19
|
+
var _a;
|
|
20
|
+
// The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.
|
|
21
|
+
var _b = useState('system'), mode = _b[0], setMode = _b[1];
|
|
22
|
+
var _c = useState(null), anchor = _c[0], setAnchor = _c[1];
|
|
23
|
+
var _d = useState(false), open = _d[0], setOpen = _d[1];
|
|
24
|
+
var current = (_a = modes.find(function (m) { return m.value === mode; })) !== null && _a !== void 0 ? _a : modes[2];
|
|
25
|
+
return (<PageShell>
|
|
26
|
+
<Stack gap="large">
|
|
27
|
+
<Cluster justify="between">
|
|
28
|
+
<Link href="#top" size="subtitle1">Acme</Link>
|
|
29
|
+
<Tooltip title={"Theme: ".concat(current.label)}>
|
|
30
|
+
<IconButton color="iconOnly" state={open ? 'selected' : 'enabled'} size="medium" iconName={current.icon} ariaLabel={"Theme: ".concat(current.label)} aria-haspopup="menu" aria-expanded={open} onClick={function (e) {
|
|
31
|
+
setAnchor(e.currentTarget);
|
|
32
|
+
setOpen(function (o) { return !o; });
|
|
33
|
+
}}/>
|
|
34
|
+
</Tooltip>
|
|
35
|
+
</Cluster>
|
|
36
|
+
<Heading level={1} size="h5">Welcome back, Dana</Heading>
|
|
37
|
+
<Paragraph tone="secondary" measure="none">
|
|
38
|
+
{mode === 'system' ? 'Acme follows your device.' : "Acme is set to ".concat(mode, ".")} In a real app the page changes now.
|
|
39
|
+
</Paragraph>
|
|
40
|
+
</Stack>
|
|
41
|
+
<Popover open={open} anchorEl={anchor} onClose={function () { return setOpen(false); }} returnFocus>
|
|
42
|
+
<Menu navigable aria-label="Theme" width={180}>
|
|
43
|
+
{modes.map(function (m) { return (<MenuItem key={m.value} size="small" iconName={m.icon} label={m.label} isSelected={m.value === mode} role="menuitemradio" onClick={function () { setMode(m.value); setOpen(false); }}/>); })}
|
|
44
|
+
</Menu>
|
|
45
|
+
</Popover>
|
|
46
|
+
</PageShell>);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ThemeSwitcherSegmented(): import("react").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import SettingsSection from '../../components/settingsSection';
|
|
5
|
+
import SegmentedControl from '../../components/segmentedControl';
|
|
6
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
7
|
+
var options = [
|
|
8
|
+
{ value: 'light', label: 'Light' },
|
|
9
|
+
{ value: 'dark', label: 'Dark' },
|
|
10
|
+
{ value: 'system', label: 'System' },
|
|
11
|
+
];
|
|
12
|
+
export default function ThemeSwitcherSegmented() {
|
|
13
|
+
// The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.
|
|
14
|
+
var _a = useState('system'), mode = _a[0], setMode = _a[1];
|
|
15
|
+
return (<Center width="page">
|
|
16
|
+
<Stack gap="large">
|
|
17
|
+
<Heading level={1} size="h5">Settings</Heading>
|
|
18
|
+
<SettingsSection title="Appearance" description="System follows your device.">
|
|
19
|
+
{/* Kept on the device, so it saves in place and shows nothing: the page changes at once. */}
|
|
20
|
+
<Cluster>
|
|
21
|
+
<SegmentedControl size="small" width="fit" aria-label="Theme" options={options} value={mode} onChange={setMode}/>
|
|
22
|
+
</Cluster>
|
|
23
|
+
</SettingsSection>
|
|
24
|
+
</Stack>
|
|
25
|
+
</Center>);
|
|
26
|
+
}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
# Theme switcher
|
|
2
|
+
|
|
3
|
+
A person chooses between a light page, a dark page, or the one their device uses.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Offer three choices, in this order: 'Light', 'Dark' and 'System'. 'System' follows the device and is the default.
|
|
8
|
+
- Name the menu's `IconButton` for the current choice, in sentence case: 'Theme: Dark'. Show the icon of the current choice: a sun, a moon or a monitor.
|
|
9
|
+
- Open a navigable menu: `<Popover returnFocus>` around `<Menu navigable aria-label="Theme">`. Set `aria-haspopup="menu"` and `aria-expanded` on the button, and `state="selected"` while the menu is open.
|
|
10
|
+
- Give each item `role="menuitemradio"` and `isSelected` on the current one, and close the menu on a choice.
|
|
11
|
+
- Use a `SegmentedControl` named 'Theme' with `width="fit"` in a `SettingsSection` on a settings page. It saves in place and shows nothing, as the rule 'A setting saves in place, or with one Save Button' says.
|
|
12
|
+
- Change the page as soon as a choice is made. A choice kept on the device cannot fail, so show no message and no toast.
|
|
13
|
+
- Keep the choice on the device, such as in a cookie or local storage, and read it before the page paints, so the page never flashes the wrong theme.
|
|
14
|
+
- For 'System', set no class and follow `prefers-color-scheme`, and change the page when the device changes.
|
|
15
|
+
- Set the choice's class on `<html>`. The example keeps the choice in state, because it must not touch the document.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not add a brand theme as a fourth choice. A brand theme is another setting.
|
|
20
|
+
- Do not name the button for the action, such as 'Dark mode'. Name it for what is on.
|
|
21
|
+
- Do not use a toggle that only flips between light and dark. It hides System.
|
|
22
|
+
- Do not mark the current choice with color only.
|
|
23
|
+
- Do not show both the menu and the segmented control on the same page.
|
|
24
|
+
- Do not save the theme to the person's account with this case. A save that can fail follows the rule 'A setting saves in place, or with one Save Button'.
|
|
25
|
+
|
|
26
|
+
## Option: Menu in the header
|
|
27
|
+
|
|
28
|
+
Use when: The site has no settings page, or the person should reach the theme from every page.
|
|
29
|
+
|
|
30
|
+
Uses: `Cluster`, `Heading`, `IconButton`, `Link`, `Menu`, `MenuItem`, `PageShell`, `Paragraph`, `Popover`, `Stack`, `Tooltip`
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
'use client';
|
|
34
|
+
import { useState } from 'react';
|
|
35
|
+
import IconButton from 'oneslash-design-system/components/iconButton';
|
|
36
|
+
import Tooltip from 'oneslash-design-system/components/tooltip';
|
|
37
|
+
import Popover from 'oneslash-design-system/components/popover';
|
|
38
|
+
import Menu from 'oneslash-design-system/components/menu';
|
|
39
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
40
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
41
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
42
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
43
|
+
import Link from 'oneslash-design-system/components/link';
|
|
44
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
45
|
+
|
|
46
|
+
type Mode = 'light' | 'dark' | 'system';
|
|
47
|
+
|
|
48
|
+
const modes: { value: Mode; label: string; icon: 'Sun' | 'Moon' | 'Monitor' }[] = [
|
|
49
|
+
{ value: 'light', label: 'Light', icon: 'Sun' },
|
|
50
|
+
{ value: 'dark', label: 'Dark', icon: 'Moon' },
|
|
51
|
+
{ value: 'system', label: 'System', icon: 'Monitor' },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
export default function ThemeSwitcherMenu() {
|
|
55
|
+
// The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.
|
|
56
|
+
const [mode, setMode] = useState<Mode>('system');
|
|
57
|
+
const [anchor, setAnchor] = useState<HTMLElement | null>(null);
|
|
58
|
+
const [open, setOpen] = useState(false);
|
|
59
|
+
const current = modes.find((m) => m.value === mode) ?? modes[2];
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<PageShell>
|
|
63
|
+
<Stack gap="large">
|
|
64
|
+
<Cluster justify="between">
|
|
65
|
+
<Link href="#top" size="subtitle1">Acme</Link>
|
|
66
|
+
<Tooltip title={`Theme: ${current.label}`}>
|
|
67
|
+
<IconButton
|
|
68
|
+
color="iconOnly"
|
|
69
|
+
state={open ? 'selected' : 'enabled'}
|
|
70
|
+
size="medium"
|
|
71
|
+
iconName={current.icon}
|
|
72
|
+
ariaLabel={`Theme: ${current.label}`}
|
|
73
|
+
aria-haspopup="menu"
|
|
74
|
+
aria-expanded={open}
|
|
75
|
+
onClick={(e: { currentTarget: HTMLElement }) => {
|
|
76
|
+
setAnchor(e.currentTarget);
|
|
77
|
+
setOpen((o) => !o);
|
|
78
|
+
}}
|
|
79
|
+
/>
|
|
80
|
+
</Tooltip>
|
|
81
|
+
</Cluster>
|
|
82
|
+
<Heading level={1} size="h5">Welcome back, Dana</Heading>
|
|
83
|
+
<Paragraph tone="secondary" measure="none">
|
|
84
|
+
{mode === 'system' ? 'Acme follows your device.' : `Acme is set to ${mode}.`} In a real app the page changes now.
|
|
85
|
+
</Paragraph>
|
|
86
|
+
</Stack>
|
|
87
|
+
<Popover open={open} anchorEl={anchor} onClose={() => setOpen(false)} returnFocus>
|
|
88
|
+
<Menu navigable aria-label="Theme" width={180}>
|
|
89
|
+
{modes.map((m) => (
|
|
90
|
+
<MenuItem
|
|
91
|
+
key={m.value}
|
|
92
|
+
size="small"
|
|
93
|
+
iconName={m.icon}
|
|
94
|
+
label={m.label}
|
|
95
|
+
isSelected={m.value === mode}
|
|
96
|
+
role="menuitemradio"
|
|
97
|
+
onClick={() => { setMode(m.value); setOpen(false); }}
|
|
98
|
+
/>
|
|
99
|
+
))}
|
|
100
|
+
</Menu>
|
|
101
|
+
</Popover>
|
|
102
|
+
</PageShell>
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Option: Segmented control on a settings page
|
|
108
|
+
|
|
109
|
+
Use when: The choice is a setting among others, on a settings page.
|
|
110
|
+
|
|
111
|
+
Uses: `Center`, `Cluster`, `Heading`, `SegmentedControl`, `SettingsSection`, `Stack`
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
'use client';
|
|
115
|
+
import { useState } from 'react';
|
|
116
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
117
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
118
|
+
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
119
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
120
|
+
|
|
121
|
+
const options = [
|
|
122
|
+
{ value: 'light', label: 'Light' },
|
|
123
|
+
{ value: 'dark', label: 'Dark' },
|
|
124
|
+
{ value: 'system', label: 'System' },
|
|
125
|
+
];
|
|
126
|
+
|
|
127
|
+
export default function ThemeSwitcherSegmented() {
|
|
128
|
+
// The example keeps the choice in state. A real app keeps it for the person and sets the `dark` class on <html>.
|
|
129
|
+
const [mode, setMode] = useState('system');
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<Center width="page">
|
|
133
|
+
<Stack gap="large">
|
|
134
|
+
<Heading level={1} size="h5">Settings</Heading>
|
|
135
|
+
<SettingsSection title="Appearance" description="System follows your device.">
|
|
136
|
+
{/* Kept on the device, so it saves in place and shows nothing: the page changes at once. */}
|
|
137
|
+
<Cluster>
|
|
138
|
+
<SegmentedControl size="small" width="fit" aria-label="Theme" options={options} value={mode} onChange={setMode} />
|
|
139
|
+
</Cluster>
|
|
140
|
+
</SettingsSection>
|
|
141
|
+
</Stack>
|
|
142
|
+
</Center>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## Native
|
|
148
|
+
|
|
149
|
+
On Apple and Android follow the system appearance and offer no switcher. If the app has one, use a `Picker` of Light, Dark and System in settings.
|
|
@@ -3,6 +3,7 @@ import { useState } from 'react';
|
|
|
3
3
|
import Surface from '../../components/surface';
|
|
4
4
|
import Heading from '../../components/heading';
|
|
5
5
|
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Progress from '../../components/progress';
|
|
6
7
|
import TextField from '../../components/textField';
|
|
7
8
|
import Button from '../../components/button';
|
|
8
9
|
import { Center, Cluster, Stack } from '../../components/layout';
|
|
@@ -27,12 +28,13 @@ export default function UpgradePromptInline() {
|
|
|
27
28
|
<Paragraph measure="none">{m.text}</Paragraph>
|
|
28
29
|
</Stack>); })}
|
|
29
30
|
</Stack>
|
|
31
|
+
<Progress label="AI agent responses" value={50} max={50} unit="responses" aria-describedby={showNotice ? 'upgrade-prompt-notice' : undefined}/>
|
|
30
32
|
{showNotice ? (
|
|
31
33
|
// The notice takes the place of the message box, where the person was about to type.
|
|
32
34
|
<Surface padding="medium">
|
|
33
35
|
<Stack gap="medium">
|
|
34
36
|
<Stack gap="small">
|
|
35
|
-
<Paragraph measure="none">You've used all 50 AI agent responses this month. They start again on
|
|
37
|
+
<Paragraph id="upgrade-prompt-notice" measure="none">You've used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
|
|
36
38
|
<Paragraph tone="secondary" size="body2" measure="none">
|
|
37
39
|
{canChangePlan
|
|
38
40
|
? 'The Pro plan gives Acme Design 1,000 AI agent responses a month.'
|
|
@@ -46,7 +48,7 @@ export default function UpgradePromptInline() {
|
|
|
46
48
|
</Stack>
|
|
47
49
|
</Surface>) : (
|
|
48
50
|
// After 'Not Now' the message box comes back, closed until the replies start again.
|
|
49
|
-
<TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="
|
|
51
|
+
<TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="AI agent responses start again on Dec 1." disabled onChange={function () { }}/>)}
|
|
50
52
|
</Stack>
|
|
51
53
|
</Center>);
|
|
52
54
|
}
|
|
@@ -5,6 +5,7 @@ import Heading from '../../components/heading';
|
|
|
5
5
|
import Paragraph from '../../components/paragraph';
|
|
6
6
|
import Button from '../../components/button';
|
|
7
7
|
import { Center, Cluster, Stack } from '../../components/layout';
|
|
8
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
8
9
|
// A real app passes the router from its framework, such as Next's useRouter().
|
|
9
10
|
var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
|
|
10
11
|
// A real app reads this from the person's role. Only an admin can change the plan.
|
|
@@ -35,7 +36,7 @@ export default function UpgradePromptModal() {
|
|
|
35
36
|
<Paragraph measure="none">Exporting to PDF is part of the Pro plan. Acme Design is on the Free plan.</Paragraph>
|
|
36
37
|
<Paragraph tone="secondary" size="body2" measure="none">
|
|
37
38
|
{canChangePlan
|
|
38
|
-
?
|
|
39
|
+
? "Pro also adds version history and unlimited guests, for ".concat(formatMoney(8), " per member each month.")
|
|
39
40
|
: 'Ask a workspace admin to upgrade Acme Design to Pro.'}
|
|
40
41
|
</Paragraph>
|
|
41
42
|
</Modal>
|
|
@@ -5,12 +5,13 @@ A person reaches something their plan does not include, or a limit of their plan
|
|
|
5
5
|
## Do
|
|
6
6
|
|
|
7
7
|
- Say what is locked and which plan unlocks it: 'Exporting to PDF is part of the Pro plan.'
|
|
8
|
-
- Say which limit was reached, with the number, and when it resets: "You've used all 50 AI agent responses this month. They start again on
|
|
8
|
+
- Say which limit was reached, with the number, and when it resets: "You've used all 50 AI agent responses this month. They start again on Dec 1."
|
|
9
9
|
- Offer 'Not Now' as a tertiary Button, then 'Upgrade to Pro' as a primary Button.
|
|
10
10
|
- Show 'Upgrade to Pro' only to a person who can change the plan. Tell everyone else to ask a workspace admin, and give them only 'Not Now'.
|
|
11
11
|
- Title the Modal 'Upgrade to Pro' only for a person who can upgrade. For everyone else, title it 'Pro Feature'.
|
|
12
12
|
- Follow the rule 'A confirm says exactly what will happen' for the Modal: `size="small"`, and Escape or a click outside means 'Not Now'.
|
|
13
13
|
- Put the notice where the control was, with the same two Buttons, when a limit is reached inside a flow.
|
|
14
|
+
- At a limit, show a `Progress` above the notice that says 'Limit reached', and point it at the notice with `aria-describedby`.
|
|
14
15
|
- Follow the rule 'An agent refuses clearly' too when the agent is the one refused.
|
|
15
16
|
|
|
16
17
|
## Don't
|
|
@@ -25,7 +26,7 @@ A person reaches something their plan does not include, or a limit of their plan
|
|
|
25
26
|
|
|
26
27
|
Use when: The person pressed something their plan does not include.
|
|
27
28
|
|
|
28
|
-
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`
|
|
29
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`, `formatMoney`
|
|
29
30
|
|
|
30
31
|
```tsx
|
|
31
32
|
'use client';
|
|
@@ -35,6 +36,7 @@ import Heading from 'oneslash-design-system/components/heading';
|
|
|
35
36
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
36
37
|
import Button from 'oneslash-design-system/components/button';
|
|
37
38
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
39
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
38
40
|
|
|
39
41
|
// A real app passes the router from its framework, such as Next's useRouter().
|
|
40
42
|
const router = { push: (url: string) => console.info(`Go to ${url}`) };
|
|
@@ -82,7 +84,7 @@ export default function UpgradePromptModal() {
|
|
|
82
84
|
<Paragraph measure="none">Exporting to PDF is part of the Pro plan. Acme Design is on the Free plan.</Paragraph>
|
|
83
85
|
<Paragraph tone="secondary" size="body2" measure="none">
|
|
84
86
|
{canChangePlan
|
|
85
|
-
?
|
|
87
|
+
? `Pro also adds version history and unlimited guests, for ${formatMoney(8)} per member each month.`
|
|
86
88
|
: 'Ask a workspace admin to upgrade Acme Design to Pro.'}
|
|
87
89
|
</Paragraph>
|
|
88
90
|
</Modal>
|
|
@@ -95,7 +97,7 @@ export default function UpgradePromptModal() {
|
|
|
95
97
|
|
|
96
98
|
Use when: A limit was reached inside a flow. The notice takes the place of the control that hit it.
|
|
97
99
|
|
|
98
|
-
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Stack`, `Surface`, `TextField`
|
|
100
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Paragraph`, `Progress`, `Stack`, `Surface`, `TextField`
|
|
99
101
|
|
|
100
102
|
```tsx
|
|
101
103
|
'use client';
|
|
@@ -103,6 +105,7 @@ import { useState } from 'react';
|
|
|
103
105
|
import Surface from 'oneslash-design-system/components/surface';
|
|
104
106
|
import Heading from 'oneslash-design-system/components/heading';
|
|
105
107
|
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
108
|
+
import Progress from 'oneslash-design-system/components/progress';
|
|
106
109
|
import TextField from 'oneslash-design-system/components/textField';
|
|
107
110
|
import Button from 'oneslash-design-system/components/button';
|
|
108
111
|
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
@@ -135,12 +138,13 @@ export default function UpgradePromptInline() {
|
|
|
135
138
|
</Stack>
|
|
136
139
|
))}
|
|
137
140
|
</Stack>
|
|
141
|
+
<Progress label="AI agent responses" value={50} max={50} unit="responses" aria-describedby={showNotice ? 'upgrade-prompt-notice' : undefined} />
|
|
138
142
|
{showNotice ? (
|
|
139
143
|
// The notice takes the place of the message box, where the person was about to type.
|
|
140
144
|
<Surface padding="medium">
|
|
141
145
|
<Stack gap="medium">
|
|
142
146
|
<Stack gap="small">
|
|
143
|
-
<Paragraph measure="none">You've used all 50 AI agent responses this month. They start again on
|
|
147
|
+
<Paragraph id="upgrade-prompt-notice" measure="none">You've used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
|
|
144
148
|
<Paragraph tone="secondary" size="body2" measure="none">
|
|
145
149
|
{canChangePlan
|
|
146
150
|
? 'The Pro plan gives Acme Design 1,000 AI agent responses a month.'
|
|
@@ -157,7 +161,7 @@ export default function UpgradePromptInline() {
|
|
|
157
161
|
</Surface>
|
|
158
162
|
) : (
|
|
159
163
|
// After 'Not Now' the message box comes back, closed until the replies start again.
|
|
160
|
-
<TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="
|
|
164
|
+
<TextField id="upgrade-prompt-message" label="Message the agent" value="" placeholder="AI agent responses start again on Dec 1." disabled onChange={() => {}} />
|
|
161
165
|
)}
|
|
162
166
|
</Stack>
|
|
163
167
|
</Center>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UsageMetersByPerson(): import("react").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Progress from '../../components/progress';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import SettingsSection from '../../components/settingsSection';
|
|
9
|
+
import TableContainer from '../../components/tableContainer';
|
|
10
|
+
import TableHeader from '../../components/tableHeader';
|
|
11
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
12
|
+
import TableRow from '../../components/tableRow';
|
|
13
|
+
import TableCell from '../../components/tableCell';
|
|
14
|
+
import { formatCount } from '../../components/formatNumber';
|
|
15
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
16
|
+
// A real app passes the router from its framework, such as Next's useRouter().
|
|
17
|
+
var router = { push: function (url) { return console.info("Go to ".concat(url)); } };
|
|
18
|
+
// A real app reads this from the person's role. Only an admin can change the plan.
|
|
19
|
+
var canChangePlan = true;
|
|
20
|
+
// A real app counts these on the server, most first. A count can pass its limit by a few: replies that were
|
|
21
|
+
// already running when the limit was reached still finish.
|
|
22
|
+
var people = [
|
|
23
|
+
{ id: 'dana', name: 'Dana Lee', responses: 21 },
|
|
24
|
+
{ id: 'ben', name: 'Ben Carter', responses: 19 },
|
|
25
|
+
{ id: 'omar', name: 'Omar Reyes', responses: 13 },
|
|
26
|
+
];
|
|
27
|
+
var total = people.reduce(function (sum, p) { return sum + p.responses; }, 0);
|
|
28
|
+
export default function UsageMetersByPerson() {
|
|
29
|
+
var _a = useState(true), showNotice = _a[0], setShowNotice = _a[1];
|
|
30
|
+
return (<Center width="page">
|
|
31
|
+
<SettingsSection title="Usage" description="This month, on the Free plan.">
|
|
32
|
+
<Stack gap="large">
|
|
33
|
+
<Stack gap="small">
|
|
34
|
+
<Progress label="AI agent responses" value={total} max={50} unit="responses" aria-describedby={showNotice ? 'usage-meters-person-notice' : undefined}/>
|
|
35
|
+
<Paragraph tone="secondary" size="body2" measure="none">Resets on Dec 1.</Paragraph>
|
|
36
|
+
{showNotice && (<Surface padding="small">
|
|
37
|
+
<Stack gap="medium">
|
|
38
|
+
<Stack gap="small">
|
|
39
|
+
<Paragraph id="usage-meters-person-notice" measure="none">You've used all 50 AI agent responses this month. They start again on Dec 1.</Paragraph>
|
|
40
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
41
|
+
{canChangePlan
|
|
42
|
+
? 'The Pro plan gives Acme 1,000 AI agent responses a month.'
|
|
43
|
+
: 'Ask a workspace admin to upgrade Acme to Pro for more replies.'}
|
|
44
|
+
</Paragraph>
|
|
45
|
+
</Stack>
|
|
46
|
+
<Cluster gap="small">
|
|
47
|
+
<Button size="small" type="tertiary" state="enabled" label="Not Now" onClickButton={function () { return setShowNotice(false); }}/>
|
|
48
|
+
{canChangePlan && (<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return router.push('/settings/billing?plan=pro'); }}/>)}
|
|
49
|
+
</Cluster>
|
|
50
|
+
</Stack>
|
|
51
|
+
</Surface>)}
|
|
52
|
+
</Stack>
|
|
53
|
+
{/* Under the meters: who used it, most first, with exact numbers. */}
|
|
54
|
+
<Stack gap="small">
|
|
55
|
+
<Heading level={3} size="h6">Responses by person</Heading>
|
|
56
|
+
<TableContainer aria-label="Responses by person" minWidth="320px">
|
|
57
|
+
<TableHeader>
|
|
58
|
+
<TableRow>
|
|
59
|
+
<TableHeaderCell>Person</TableHeaderCell>
|
|
60
|
+
<TableHeaderCell width="130px" align="right">Responses</TableHeaderCell>
|
|
61
|
+
</TableRow>
|
|
62
|
+
</TableHeader>
|
|
63
|
+
{people.map(function (p) { return (<TableRow key={p.id}>
|
|
64
|
+
<TableCell>{p.name}</TableCell>
|
|
65
|
+
<TableCell width="130px" align="right">{formatCount(p.responses)}</TableCell>
|
|
66
|
+
</TableRow>); })}
|
|
67
|
+
</TableContainer>
|
|
68
|
+
</Stack>
|
|
69
|
+
</Stack>
|
|
70
|
+
</SettingsSection>
|
|
71
|
+
</Center>);
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function UsageMetersMeters(): import("react").JSX.Element;
|