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,182 @@
|
|
|
1
|
+
# Payment method
|
|
2
|
+
|
|
3
|
+
A workspace pays by card. The admin sees which card, changes it or removes it.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Show only the brand as text, the last four digits and the expiry: 'Visa ending in 4821' and 'Expires 08/28'. Nothing else about the card is on the page.
|
|
9
|
+
- Make 'Update' and 'Add Payment Method' links to the payment provider's own page: a `Button` with `href`, `openInNewTab` and an external-link `actionIcon`. Name it with where it goes: 'Update Visa ending in 4821, opens in a new tab'.
|
|
10
|
+
- Confirm 'Remove' in a small `Modal` titled 'Remove Card', as the case 'Delete confirm' says: 'This removes Visa ending in 4821 from Acme. Your plan and invoices are not changed.' 'Cancel' comes first, then a danger 'Remove'.
|
|
11
|
+
- Name the card in the Remove Button's `aria-label`: 'Remove Visa ending in 4821'.
|
|
12
|
+
- Show a toast that names the card when it is removed: 'Visa ending in 4821 removed.' Then show the empty state in the same place.
|
|
13
|
+
- Offer no Remove while a paid plan needs a card, and say why in one line: 'Pro needs a card on file. Downgrade to Free to remove it.'
|
|
14
|
+
- Add an inline warning `Alert` above the row a month before the card expires: 'This card expires on 08/28. Update it before then.'
|
|
15
|
+
- Say in one line that there is no card, say whether one is needed, and offer 'Add Payment Method'.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not add a `TextField` for a card number, a security code, a bank account or an address. ODS has no payment form.
|
|
20
|
+
- Do not show a full card number, or part of it beyond the last four digits.
|
|
21
|
+
- Do not name the payment provider, or copy the look or the words of its page.
|
|
22
|
+
- Do not show a card-network logo. The brand is the word.
|
|
23
|
+
- Do not title the Modal 'Are you sure?'. Name the action: 'Remove Card'.
|
|
24
|
+
- Do not remove the card on the first click.
|
|
25
|
+
- Do not offer Remove while a paid plan needs the card.
|
|
26
|
+
- Do not show Update or Remove to a person who cannot change billing.
|
|
27
|
+
|
|
28
|
+
## Option: A card is saved
|
|
29
|
+
|
|
30
|
+
Use when: The workspace has a card on file.
|
|
31
|
+
|
|
32
|
+
Uses: `Alert`, `Button`, `Center`, `Cluster`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Toaster`, `dismissToast`, `toast`
|
|
33
|
+
|
|
34
|
+
```tsx
|
|
35
|
+
'use client';
|
|
36
|
+
import { useEffect, useRef, useState } from 'react';
|
|
37
|
+
import Toaster, { toast, dismissToast } from 'oneslash-design-system/components/toaster';
|
|
38
|
+
import Alert from 'oneslash-design-system/components/alert';
|
|
39
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
40
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
41
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
42
|
+
import Button from 'oneslash-design-system/components/button';
|
|
43
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
44
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
45
|
+
|
|
46
|
+
// A real app reads these from the server. Only the brand, the last four digits and the expiry ever reach the page.
|
|
47
|
+
const card = { brand: 'Visa', last4: '4821', month: 8, year: 2028 };
|
|
48
|
+
const today = { month: 11, year: 2026 };
|
|
49
|
+
const plan: 'Free' | 'Pro' = 'Free';
|
|
50
|
+
|
|
51
|
+
// A paid plan needs a card, so Remove is not offered. The Free plan needs none.
|
|
52
|
+
const planNeedsCard = plan !== 'Free';
|
|
53
|
+
const monthsLeft = (card.year - today.year) * 12 + (card.month - today.month);
|
|
54
|
+
const expiry = `${String(card.month).padStart(2, '0')}/${String(card.year % 100).padStart(2, '0')}`;
|
|
55
|
+
const name = `${card.brand} ending in ${card.last4}`;
|
|
56
|
+
|
|
57
|
+
export default function PaymentMethodOnFile() {
|
|
58
|
+
const [removed, setRemoved] = useState(false);
|
|
59
|
+
const [confirming, setConfirming] = useState(false);
|
|
60
|
+
const [removing, setRemoving] = useState(false);
|
|
61
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
62
|
+
const toastIds = useRef<string[]>([]);
|
|
63
|
+
const addRef = useRef<HTMLButtonElement | HTMLAnchorElement>(null);
|
|
64
|
+
|
|
65
|
+
// On unmount it stops the request and closes every toast it opened.
|
|
66
|
+
useEffect(() => () => {
|
|
67
|
+
clearTimeout(timer.current);
|
|
68
|
+
toastIds.current.forEach((id) => dismissToast(id));
|
|
69
|
+
toastIds.current = [];
|
|
70
|
+
}, []);
|
|
71
|
+
|
|
72
|
+
// The Remove Button is gone with the card, so focus moves to what takes its place.
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (removed) addRef.current?.focus();
|
|
75
|
+
}, [removed]);
|
|
76
|
+
|
|
77
|
+
// Escape, a click outside and Cancel all close it, except while the request runs. The Modal gives focus back to Remove.
|
|
78
|
+
function handleClose() {
|
|
79
|
+
if (removing) return;
|
|
80
|
+
setConfirming(false);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function handleRemove() {
|
|
84
|
+
if (removing) return;
|
|
85
|
+
setRemoving(true);
|
|
86
|
+
// Stands in for the request to the server.
|
|
87
|
+
timer.current = setTimeout(() => {
|
|
88
|
+
setRemoving(false);
|
|
89
|
+
setConfirming(false);
|
|
90
|
+
setRemoved(true);
|
|
91
|
+
toastIds.current.push(toast({ type: 'success', message: `${name} removed.` }));
|
|
92
|
+
}, 1200);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<Center width="page">
|
|
97
|
+
{/* A real app mounts one Toaster near its root. */}
|
|
98
|
+
<Toaster />
|
|
99
|
+
<SettingsSection title="Payment method" description="Pays for Acme's plan.">
|
|
100
|
+
{removed ? (
|
|
101
|
+
<Stack gap="medium" align="start">
|
|
102
|
+
<Paragraph measure="none">No payment method.</Paragraph>
|
|
103
|
+
{/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
|
|
104
|
+
<Button ref={addRef} size="small" type="secondary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab />
|
|
105
|
+
</Stack>
|
|
106
|
+
) : (
|
|
107
|
+
<Stack gap="medium">
|
|
108
|
+
{/* A month ahead of the expiry, the page says so. */}
|
|
109
|
+
{monthsLeft <= 1 && monthsLeft >= 0 && (
|
|
110
|
+
<Alert type="warning" variant="inline" autoDismiss={false} message={`This card expires on ${expiry}. Update it before then.`} />
|
|
111
|
+
)}
|
|
112
|
+
<Surface padding="small">
|
|
113
|
+
<Cluster justify="between" gap="medium">
|
|
114
|
+
<Stack gap="small">
|
|
115
|
+
<Paragraph measure="none">{name}</Paragraph>
|
|
116
|
+
<Paragraph tone="secondary" size="body2" measure="none">{`Expires ${expiry}`}</Paragraph>
|
|
117
|
+
</Stack>
|
|
118
|
+
<Cluster gap="small">
|
|
119
|
+
{/* Updating the card happens on the provider's page, so Update is a link out. */}
|
|
120
|
+
<Button size="small" type="tertiary" state="enabled" label="Update" aria-label={`Update ${name}, opens in a new tab`} actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab />
|
|
121
|
+
{!planNeedsCard && (
|
|
122
|
+
<Button size="small" type="tertiary" state="enabled" label="Remove" aria-label={`Remove ${name}`} onClickButton={() => setConfirming(true)} />
|
|
123
|
+
)}
|
|
124
|
+
</Cluster>
|
|
125
|
+
</Cluster>
|
|
126
|
+
</Surface>
|
|
127
|
+
{planNeedsCard && <Paragraph tone="secondary" size="body2" measure="none">Pro needs a card on file. Downgrade to Free to remove it.</Paragraph>}
|
|
128
|
+
</Stack>
|
|
129
|
+
)}
|
|
130
|
+
</SettingsSection>
|
|
131
|
+
{/* One card is not a dense list, so the confirm is a small Modal. */}
|
|
132
|
+
<Modal
|
|
133
|
+
isOpen={confirming}
|
|
134
|
+
size="small"
|
|
135
|
+
title="Remove Card"
|
|
136
|
+
onClose={handleClose}
|
|
137
|
+
actions={
|
|
138
|
+
<>
|
|
139
|
+
<Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
140
|
+
<Button size="small" type="primary" color="danger" state="enabled" label="Remove" loading={removing} onClickButton={handleRemove} />
|
|
141
|
+
</>
|
|
142
|
+
}
|
|
143
|
+
>
|
|
144
|
+
<Paragraph measure="none">{`This removes ${name} from Acme. Your plan and invoices are not changed.`}</Paragraph>
|
|
145
|
+
</Modal>
|
|
146
|
+
</Center>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Option: No card yet
|
|
152
|
+
|
|
153
|
+
Use when: The workspace has never added a card, or removed it.
|
|
154
|
+
|
|
155
|
+
Uses: `Button`, `Center`, `Paragraph`, `SettingsSection`, `Stack`
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
'use client';
|
|
159
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
160
|
+
import Button from 'oneslash-design-system/components/button';
|
|
161
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
162
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
163
|
+
|
|
164
|
+
export default function PaymentMethodNone() {
|
|
165
|
+
return (
|
|
166
|
+
<Center width="page">
|
|
167
|
+
<SettingsSection title="Payment method" description="Pays for Acme's plan.">
|
|
168
|
+
<Stack gap="medium" align="start">
|
|
169
|
+
<Paragraph measure="none">No payment method.</Paragraph>
|
|
170
|
+
<Paragraph tone="secondary" size="body2" measure="none">Acme is on Free, so it needs none. Add one to upgrade.</Paragraph>
|
|
171
|
+
{/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
|
|
172
|
+
<Button size="small" type="secondary" state="enabled" label="Add Payment Method" aria-label="Add payment method, opens in a new tab" actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab />
|
|
173
|
+
</Stack>
|
|
174
|
+
</SettingsSection>
|
|
175
|
+
</Center>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Native
|
|
181
|
+
|
|
182
|
+
On Apple a plan bought in the app has no card on the page: open the system subscription sheet. For a web card, show the same text and a `Link` out.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# On a phone, a sidebar opens as a drawer and a list opens its detail
|
|
2
|
+
|
|
3
|
+
A layout with a sidebar, a list beside its detail, or a side pane meets a phone screen.
|
|
4
|
+
|
|
5
|
+
## Answer
|
|
6
|
+
|
|
7
|
+
An app's sidebar opens in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. `AppShell` does this. The Drawer closes on a choice, on Close, on Escape, on the scrim and when the window widens. A list beside its detail becomes two screens: the list, then the detail with a Back Button named for the list, as `SettingsLayout` does. A settings nav is such a list. A side pane takes the whole content area and has Close. It is never squeezed beside the content. A site's links go into the same kind of menu, and one main action may stay in the bar. Nothing is hidden on a phone without a way to reach it. There is no bottom tab bar on the web.
|
|
8
|
+
|
|
9
|
+
## Why
|
|
10
|
+
|
|
11
|
+
A drawer opens over the page, so the person still sees where they are, and closing it puts them back on the same page. One drawer, built into `AppShell`, works the same way in every app.
|
|
12
|
+
|
|
13
|
+
## Do
|
|
14
|
+
|
|
15
|
+
- Open the sidebar in a `Drawer` from the start side, from a 'Menu' `IconButton` at the start of a top bar that names the place. Use `AppShell`.
|
|
16
|
+
- Close the drawer on a choice, Close, Escape, the scrim and when the window widens past `md`.
|
|
17
|
+
- Turn a list beside its detail into two screens on a phone: the list first, then the detail with a Back Button named for the list.
|
|
18
|
+
- Let a side pane take the whole content area on a phone, with a Close button.
|
|
19
|
+
- Put a site's links in the same kind of menu, and keep at most one main action in the bar.
|
|
20
|
+
- Give every place a way to be reached on a phone, even one that is only a link.
|
|
21
|
+
|
|
22
|
+
## Don't
|
|
23
|
+
|
|
24
|
+
- Do not hide a link on a phone without a menu that holds it.
|
|
25
|
+
- Do not show a sidebar beside the page on a phone, or squeeze a side pane beside the content.
|
|
26
|
+
- Do not replace the page with the app's sidebar. Open the drawer over it. A settings nav is a list beside its detail, so it is the first screen on a phone.
|
|
27
|
+
- Do not add a bottom tab bar on the web.
|
|
28
|
+
- Do not leave a drawer that Escape and a tap outside cannot close.
|
|
29
|
+
|
|
30
|
+
## Native
|
|
31
|
+
|
|
32
|
+
On iPhone use a `TabView` or a `NavigationStack` that pushes the detail with the system back button, and a `.sheet` for a short task. On Android use a navigation drawer or a bottom bar, and push the detail with the system back.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanChangeConfirmBlocked(): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import List from '../../components/list';
|
|
7
|
+
import Link from '../../components/link';
|
|
8
|
+
import Button from '../../components/button';
|
|
9
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
10
|
+
// A real app counts these on the server. Free allows 3 members and 1 connected repository.
|
|
11
|
+
var exceeded = [
|
|
12
|
+
{ id: 'members', text: 'Free allows 3 members. Acme has 7.', fix: 'Manage Members', href: '/settings/members' },
|
|
13
|
+
{ id: 'repos', text: 'Free allows 1 connected repository. Acme has 2.', fix: 'Manage Repositories', href: '/settings/repositories' },
|
|
14
|
+
];
|
|
15
|
+
export default function PlanChangeConfirmBlocked() {
|
|
16
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
17
|
+
var _b = useState(false), checking = _b[0], setChecking = _b[1];
|
|
18
|
+
var timer = useRef();
|
|
19
|
+
// Stops the check if the example goes away before it ends.
|
|
20
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
21
|
+
// The limits are checked before the Modal opens, so the person never reads 'Downgrade' and then a refusal.
|
|
22
|
+
function handleCheck() {
|
|
23
|
+
if (checking)
|
|
24
|
+
return;
|
|
25
|
+
setChecking(true);
|
|
26
|
+
// Stands in for the request to the server.
|
|
27
|
+
timer.current = setTimeout(function () {
|
|
28
|
+
setChecking(false);
|
|
29
|
+
setOpen(true);
|
|
30
|
+
}, 600);
|
|
31
|
+
}
|
|
32
|
+
return (<Center width="page">
|
|
33
|
+
<Stack gap="medium">
|
|
34
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
35
|
+
<Paragraph tone="secondary" size="body2" measure="none">Acme is on Pro.</Paragraph>
|
|
36
|
+
<Cluster>
|
|
37
|
+
<Button size="small" type="tertiary" state="enabled" label="Downgrade to Free" loading={checking} onClickButton={handleCheck}/>
|
|
38
|
+
</Cluster>
|
|
39
|
+
</Stack>
|
|
40
|
+
<Modal isOpen={open} size="small" title="Downgrade to Free" onClose={function () { return setOpen(false); }} actions={<Button size="small" type="tertiary" state="enabled" label="Cancel" onClickButton={function () { return setOpen(false); }}/>}>
|
|
41
|
+
<Paragraph measure="none">Acme cannot move to Free yet. It is over two limits.</Paragraph>
|
|
42
|
+
<List size="body2" marker="dot" items={exceeded.map(function (e) { return (<Stack key={e.id} gap="small" align="start">
|
|
43
|
+
<Paragraph size="body2" measure="none">{e.text}</Paragraph>
|
|
44
|
+
<Link href={e.href} size="body2">{e.fix}</Link>
|
|
45
|
+
</Stack>); })}/>
|
|
46
|
+
</Modal>
|
|
47
|
+
</Center>);
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanChangeConfirmDowngrade(): import("react").JSX.Element;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import List from '../../components/list';
|
|
7
|
+
import Button from '../../components/button';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
export default function PlanChangeConfirmDowngrade() {
|
|
10
|
+
// Opens on the confirm, as if the person just chose Downgrade to Free.
|
|
11
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
12
|
+
var _b = useState(false), downgrading = _b[0], setDowngrading = _b[1];
|
|
13
|
+
var _c = useState(false), scheduled = _c[0], setScheduled = _c[1];
|
|
14
|
+
var timer = useRef();
|
|
15
|
+
// Stops the request if the example goes away before it ends.
|
|
16
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
17
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
18
|
+
function handleClose() {
|
|
19
|
+
if (downgrading)
|
|
20
|
+
return;
|
|
21
|
+
setOpen(false);
|
|
22
|
+
}
|
|
23
|
+
function handleDowngrade() {
|
|
24
|
+
if (downgrading)
|
|
25
|
+
return;
|
|
26
|
+
setDowngrading(true);
|
|
27
|
+
// Stands in for the request to the server. Nothing is charged or lost today.
|
|
28
|
+
timer.current = setTimeout(function () {
|
|
29
|
+
setDowngrading(false);
|
|
30
|
+
setOpen(false);
|
|
31
|
+
setScheduled(true);
|
|
32
|
+
}, 1200);
|
|
33
|
+
}
|
|
34
|
+
return (<Center width="page">
|
|
35
|
+
<Stack gap="medium">
|
|
36
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
37
|
+
{/* The change starts later, so the page says when. A toast would be gone before Dec 1. */}
|
|
38
|
+
<Paragraph tone="secondary" size="body2" measure="none">{scheduled ? 'Acme is on Pro until Dec 1, 2026, then Free.' : 'Acme is on Pro.'}</Paragraph>
|
|
39
|
+
{!scheduled && (<Cluster>
|
|
40
|
+
<Button size="small" type="tertiary" state="enabled" label="Downgrade to Free" onClickButton={function () { return setOpen(true); }}/>
|
|
41
|
+
</Cluster>)}
|
|
42
|
+
</Stack>
|
|
43
|
+
<Modal isOpen={open} size="small" title="Downgrade to Free" onClose={handleClose} actions={<>
|
|
44
|
+
<Button size="small" type="tertiary" state={downgrading ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
45
|
+
<Button size="small" type="primary" state="enabled" label="Downgrade to Free" loading={downgrading} onClickButton={handleDowngrade}/>
|
|
46
|
+
</>}>
|
|
47
|
+
<Paragraph measure="none">Pro stays on until Dec 1, 2026. Acme is not charged again.</Paragraph>
|
|
48
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
49
|
+
<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.']}/>
|
|
50
|
+
</Modal>
|
|
51
|
+
</Center>);
|
|
52
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanChangeConfirmUpgrade(): import("react").JSX.Element;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
export default function PlanChangeConfirmUpgrade() {
|
|
10
|
+
// Opens on the confirm, as if the person just chose Upgrade to Pro.
|
|
11
|
+
var _a = useState(true), open = _a[0], setOpen = _a[1];
|
|
12
|
+
var _b = useState(false), upgrading = _b[0], setUpgrading = _b[1];
|
|
13
|
+
var _c = useState('Free'), plan = _c[0], setPlan = _c[1];
|
|
14
|
+
var timer = useRef();
|
|
15
|
+
// On unmount it stops the request.
|
|
16
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
17
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
18
|
+
function handleClose() {
|
|
19
|
+
if (upgrading)
|
|
20
|
+
return;
|
|
21
|
+
setOpen(false);
|
|
22
|
+
}
|
|
23
|
+
function handleUpgrade() {
|
|
24
|
+
if (upgrading)
|
|
25
|
+
return;
|
|
26
|
+
setUpgrading(true);
|
|
27
|
+
// Stands in for the request to the server. A real app charges the card on file here, never in this page.
|
|
28
|
+
timer.current = setTimeout(function () {
|
|
29
|
+
setUpgrading(false);
|
|
30
|
+
setOpen(false);
|
|
31
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
32
|
+
setPlan('Pro');
|
|
33
|
+
}, 1200);
|
|
34
|
+
}
|
|
35
|
+
return (<Center width="page">
|
|
36
|
+
<Stack gap="medium">
|
|
37
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
38
|
+
<Paragraph tone="secondary" size="body2" measure="none">{"Acme is on ".concat(plan, ".")}</Paragraph>
|
|
39
|
+
{plan === 'Free' && (<Cluster>
|
|
40
|
+
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={function () { return setOpen(true); }}/>
|
|
41
|
+
</Cluster>)}
|
|
42
|
+
</Stack>
|
|
43
|
+
<Modal isOpen={open} size="small" title="Upgrade to Pro" onClose={handleClose} actions={<>
|
|
44
|
+
<Button size="small" type="tertiary" state={upgrading ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
45
|
+
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" loading={upgrading} onClickButton={handleUpgrade}/>
|
|
46
|
+
</>}>
|
|
47
|
+
<Paragraph measure="none">{"You pay ".concat(formatMoney(12), " today for the 15 days left in November, then ").concat(formatMoney(24), " each month.")}</Paragraph>
|
|
48
|
+
<Paragraph tone="secondary" size="body2" measure="none">{"Pro is ".concat(formatMoney(8), " per member per month. The card ending in 4821 pays for it.")}</Paragraph>
|
|
49
|
+
</Modal>
|
|
50
|
+
</Center>);
|
|
51
|
+
}
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# Plan change confirm
|
|
2
|
+
|
|
3
|
+
An admin chose another plan. Before anything changes they need to know what it costs and when it starts.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Follow the rule 'A confirm says exactly what will happen': a `Modal` with `size="small"`, 'Cancel' first, then the action named with the title's verb. The title and the Button are the same words: 'Upgrade to Pro'.
|
|
9
|
+
- Say the amount today and for how long for an upgrade: 'You pay $12.00 today for the 15 days left in November, then $24.00 each month.'
|
|
10
|
+
- Keep the label of the action Button while it runs ('Upgrade to Pro'), as `loading`. When it works, close the Modal and show the new plan where the plan is: 'Acme is on Pro.' Show no toast.
|
|
11
|
+
- Say when a downgrade starts and what stops: 'Pro stays on until Dec 1, 2026.' Then list what Acme loses, each with its number.
|
|
12
|
+
- Show the date on the page after a downgrade, where the plan is: 'Acme is on Pro until Dec 1, 2026, then Free.' A toast would be gone before it starts.
|
|
13
|
+
- Check the smaller plan's limits before the Modal opens. Keep the Button's label while it checks.
|
|
14
|
+
- List each exceeded limit with both numbers: 'Free allows 3 members. Acme has 7.' Put a `Link` to fix it under each, and give the Modal 'Cancel' only.
|
|
15
|
+
- Show the card that pays, by its last four digits only: 'The card ending in 4821 pays for it.'
|
|
16
|
+
- Show these Buttons only to a person who can change the plan, as the case 'Upgrade prompt' says.
|
|
17
|
+
|
|
18
|
+
## Don't
|
|
19
|
+
|
|
20
|
+
- Do not title the Modal 'Switch to Pro' or 'Confirm'. Name the action: 'Upgrade to Pro'.
|
|
21
|
+
- Do not label the action 'Confirm', 'Proceed' or 'Yes, downgrade'.
|
|
22
|
+
- Do not write 'prorated charges' with no amount. Say the amount.
|
|
23
|
+
- Do not change the Button's label while it runs, such as to 'Upgrading...'.
|
|
24
|
+
- Do not open the Modal and then refuse. Check the limits first.
|
|
25
|
+
- Do not offer a disabled action Button in the blocked Modal. Offer only Cancel and the links that fix it.
|
|
26
|
+
- Do not show a card field or a full card number in the confirm.
|
|
27
|
+
- Do not say a downgrade is done today when it starts later.
|
|
28
|
+
|
|
29
|
+
## Option: An upgrade charges now
|
|
30
|
+
|
|
31
|
+
Use when: The new plan costs more and starts at once.
|
|
32
|
+
|
|
33
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Modal`, `Paragraph`, `Stack`, `formatMoney`
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
'use client';
|
|
37
|
+
import { useEffect, useRef, useState } from 'react';
|
|
38
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
39
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
40
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
41
|
+
import Button from 'oneslash-design-system/components/button';
|
|
42
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
43
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
44
|
+
|
|
45
|
+
export default function PlanChangeConfirmUpgrade() {
|
|
46
|
+
// Opens on the confirm, as if the person just chose Upgrade to Pro.
|
|
47
|
+
const [open, setOpen] = useState(true);
|
|
48
|
+
const [upgrading, setUpgrading] = useState(false);
|
|
49
|
+
const [plan, setPlan] = useState('Free');
|
|
50
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
51
|
+
|
|
52
|
+
// On unmount it stops the request.
|
|
53
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
54
|
+
|
|
55
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
56
|
+
function handleClose() {
|
|
57
|
+
if (upgrading) return;
|
|
58
|
+
setOpen(false);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function handleUpgrade() {
|
|
62
|
+
if (upgrading) return;
|
|
63
|
+
setUpgrading(true);
|
|
64
|
+
// Stands in for the request to the server. A real app charges the card on file here, never in this page.
|
|
65
|
+
timer.current = setTimeout(() => {
|
|
66
|
+
setUpgrading(false);
|
|
67
|
+
setOpen(false);
|
|
68
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
69
|
+
setPlan('Pro');
|
|
70
|
+
}, 1200);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Center width="page">
|
|
75
|
+
<Stack gap="medium">
|
|
76
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
77
|
+
<Paragraph tone="secondary" size="body2" measure="none">{`Acme is on ${plan}.`}</Paragraph>
|
|
78
|
+
{plan === 'Free' && (
|
|
79
|
+
<Cluster>
|
|
80
|
+
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" onClickButton={() => setOpen(true)} />
|
|
81
|
+
</Cluster>
|
|
82
|
+
)}
|
|
83
|
+
</Stack>
|
|
84
|
+
<Modal
|
|
85
|
+
isOpen={open}
|
|
86
|
+
size="small"
|
|
87
|
+
title="Upgrade to Pro"
|
|
88
|
+
onClose={handleClose}
|
|
89
|
+
actions={
|
|
90
|
+
<>
|
|
91
|
+
<Button size="small" type="tertiary" state={upgrading ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
92
|
+
<Button size="small" type="primary" state="enabled" label="Upgrade to Pro" loading={upgrading} onClickButton={handleUpgrade} />
|
|
93
|
+
</>
|
|
94
|
+
}
|
|
95
|
+
>
|
|
96
|
+
<Paragraph measure="none">{`You pay ${formatMoney(12)} today for the 15 days left in November, then ${formatMoney(24)} each month.`}</Paragraph>
|
|
97
|
+
<Paragraph tone="secondary" size="body2" measure="none">{`Pro is ${formatMoney(8)} per member per month. The card ending in 4821 pays for it.`}</Paragraph>
|
|
98
|
+
</Modal>
|
|
99
|
+
</Center>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Option: A downgrade waits
|
|
105
|
+
|
|
106
|
+
Use when: The new plan costs less. It starts when the paid period ends, so nothing is lost today.
|
|
107
|
+
|
|
108
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `Stack`
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
'use client';
|
|
112
|
+
import { useEffect, useRef, useState } from 'react';
|
|
113
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
114
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
115
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
116
|
+
import List from 'oneslash-design-system/components/list';
|
|
117
|
+
import Button from 'oneslash-design-system/components/button';
|
|
118
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
119
|
+
|
|
120
|
+
export default function PlanChangeConfirmDowngrade() {
|
|
121
|
+
// Opens on the confirm, as if the person just chose Downgrade to Free.
|
|
122
|
+
const [open, setOpen] = useState(true);
|
|
123
|
+
const [downgrading, setDowngrading] = useState(false);
|
|
124
|
+
const [scheduled, setScheduled] = useState(false);
|
|
125
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
126
|
+
|
|
127
|
+
// Stops the request if the example goes away before it ends.
|
|
128
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
129
|
+
|
|
130
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
131
|
+
function handleClose() {
|
|
132
|
+
if (downgrading) return;
|
|
133
|
+
setOpen(false);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function handleDowngrade() {
|
|
137
|
+
if (downgrading) return;
|
|
138
|
+
setDowngrading(true);
|
|
139
|
+
// Stands in for the request to the server. Nothing is charged or lost today.
|
|
140
|
+
timer.current = setTimeout(() => {
|
|
141
|
+
setDowngrading(false);
|
|
142
|
+
setOpen(false);
|
|
143
|
+
setScheduled(true);
|
|
144
|
+
}, 1200);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<Center width="page">
|
|
149
|
+
<Stack gap="medium">
|
|
150
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
151
|
+
{/* The change starts later, so the page says when. A toast would be gone before Dec 1. */}
|
|
152
|
+
<Paragraph tone="secondary" size="body2" measure="none">{scheduled ? 'Acme is on Pro until Dec 1, 2026, then Free.' : 'Acme is on Pro.'}</Paragraph>
|
|
153
|
+
{!scheduled && (
|
|
154
|
+
<Cluster>
|
|
155
|
+
<Button size="small" type="tertiary" state="enabled" label="Downgrade to Free" onClickButton={() => setOpen(true)} />
|
|
156
|
+
</Cluster>
|
|
157
|
+
)}
|
|
158
|
+
</Stack>
|
|
159
|
+
<Modal
|
|
160
|
+
isOpen={open}
|
|
161
|
+
size="small"
|
|
162
|
+
title="Downgrade to Free"
|
|
163
|
+
onClose={handleClose}
|
|
164
|
+
actions={
|
|
165
|
+
<>
|
|
166
|
+
<Button size="small" type="tertiary" state={downgrading ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
167
|
+
<Button size="small" type="primary" state="enabled" label="Downgrade to Free" loading={downgrading} onClickButton={handleDowngrade} />
|
|
168
|
+
</>
|
|
169
|
+
}
|
|
170
|
+
>
|
|
171
|
+
<Paragraph measure="none">Pro stays on until Dec 1, 2026. Acme is not charged again.</Paragraph>
|
|
172
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
173
|
+
<List
|
|
174
|
+
size="body2"
|
|
175
|
+
marker="dot"
|
|
176
|
+
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.']}
|
|
177
|
+
/>
|
|
178
|
+
</Modal>
|
|
179
|
+
</Center>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Option: The smaller plan does not fit
|
|
185
|
+
|
|
186
|
+
Use when: The workspace is over a limit of the smaller plan, so the downgrade cannot happen until the person fixes it.
|
|
187
|
+
|
|
188
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `Link`, `List`, `Modal`, `Paragraph`, `Stack`
|
|
189
|
+
|
|
190
|
+
```tsx
|
|
191
|
+
'use client';
|
|
192
|
+
import { useEffect, useRef, useState } from 'react';
|
|
193
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
194
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
195
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
196
|
+
import List from 'oneslash-design-system/components/list';
|
|
197
|
+
import Link from 'oneslash-design-system/components/link';
|
|
198
|
+
import Button from 'oneslash-design-system/components/button';
|
|
199
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
200
|
+
|
|
201
|
+
// A real app counts these on the server. Free allows 3 members and 1 connected repository.
|
|
202
|
+
const exceeded = [
|
|
203
|
+
{ id: 'members', text: 'Free allows 3 members. Acme has 7.', fix: 'Manage Members', href: '/settings/members' },
|
|
204
|
+
{ id: 'repos', text: 'Free allows 1 connected repository. Acme has 2.', fix: 'Manage Repositories', href: '/settings/repositories' },
|
|
205
|
+
];
|
|
206
|
+
|
|
207
|
+
export default function PlanChangeConfirmBlocked() {
|
|
208
|
+
const [open, setOpen] = useState(true);
|
|
209
|
+
const [checking, setChecking] = useState(false);
|
|
210
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
211
|
+
|
|
212
|
+
// Stops the check if the example goes away before it ends.
|
|
213
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
214
|
+
|
|
215
|
+
// The limits are checked before the Modal opens, so the person never reads 'Downgrade' and then a refusal.
|
|
216
|
+
function handleCheck() {
|
|
217
|
+
if (checking) return;
|
|
218
|
+
setChecking(true);
|
|
219
|
+
// Stands in for the request to the server.
|
|
220
|
+
timer.current = setTimeout(() => {
|
|
221
|
+
setChecking(false);
|
|
222
|
+
setOpen(true);
|
|
223
|
+
}, 600);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<Center width="page">
|
|
228
|
+
<Stack gap="medium">
|
|
229
|
+
<Heading level={2} size="h5">Plan</Heading>
|
|
230
|
+
<Paragraph tone="secondary" size="body2" measure="none">Acme is on Pro.</Paragraph>
|
|
231
|
+
<Cluster>
|
|
232
|
+
<Button size="small" type="tertiary" state="enabled" label="Downgrade to Free" loading={checking} onClickButton={handleCheck} />
|
|
233
|
+
</Cluster>
|
|
234
|
+
</Stack>
|
|
235
|
+
<Modal
|
|
236
|
+
isOpen={open}
|
|
237
|
+
size="small"
|
|
238
|
+
title="Downgrade to Free"
|
|
239
|
+
onClose={() => setOpen(false)}
|
|
240
|
+
actions={<Button size="small" type="tertiary" state="enabled" label="Cancel" onClickButton={() => setOpen(false)} />}
|
|
241
|
+
>
|
|
242
|
+
<Paragraph measure="none">Acme cannot move to Free yet. It is over two limits.</Paragraph>
|
|
243
|
+
<List
|
|
244
|
+
size="body2"
|
|
245
|
+
marker="dot"
|
|
246
|
+
items={exceeded.map((e) => (
|
|
247
|
+
<Stack key={e.id} gap="small" align="start">
|
|
248
|
+
<Paragraph size="body2" measure="none">{e.text}</Paragraph>
|
|
249
|
+
<Link href={e.href} size="body2">{e.fix}</Link>
|
|
250
|
+
</Stack>
|
|
251
|
+
))}
|
|
252
|
+
/>
|
|
253
|
+
</Modal>
|
|
254
|
+
</Center>
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Native
|
|
260
|
+
|
|
261
|
+
On Apple use the system purchase sheet for an upgrade and a `confirmationDialog` for a downgrade that waits. The sheet shows the price, so the dialog states the date.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanPickerCards(): import("react").JSX.Element;
|