oneslash-design-system 2.19.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 +28 -4
- 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/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/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/number-format.md +36 -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/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/settings-page/top-tabs.jsx +4 -3
- package/dist/cases/settings-page.md +5 -4
- 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/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 +956 -19
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.jsx +11 -5
- package/dist/components/formatNumber.d.ts +25 -0
- package/dist/components/formatNumber.js +125 -0
- package/dist/components/iconButton.jsx +12 -7
- package/dist/components/pagination.d.ts +28 -0
- package/dist/components/pagination.jsx +89 -0
- package/dist/components/progress.d.ts +33 -0
- package/dist/components/progress.jsx +50 -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 +3 -1
- package/dist/components/titleBar.jsx +4 -3
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/native-mapping.json +26 -2
- 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 +26 -0
- package/dist/stories/Cases.generated.stories.jsx +52 -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/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 +1 -0
- package/dist/stories/TitleBar.stories.jsx +7 -0
- package/package.json +5 -1
|
@@ -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;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Surface from '../../components/surface';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import List from '../../components/list';
|
|
8
|
+
import Tag from '../../components/tag';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import SettingsSection from '../../components/settingsSection';
|
|
12
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
13
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
14
|
+
var plans = [
|
|
15
|
+
{ id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
16
|
+
{ id: 'pro', name: 'Pro', price: "".concat(formatMoney(8), " per member per month"), includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
17
|
+
{ id: 'business', name: 'Business', price: "".concat(formatMoney(16), " per member per month"), includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
18
|
+
];
|
|
19
|
+
var rank = { free: 0, pro: 1, business: 2 };
|
|
20
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
21
|
+
function describe(from, to) {
|
|
22
|
+
var name = plans.find(function (p) { return p.id === to; }).name;
|
|
23
|
+
if (rank[to] > rank[from]) {
|
|
24
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
25
|
+
var today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
26
|
+
var monthly = to === 'pro' ? 24 : 48;
|
|
27
|
+
var body = "You pay ".concat(formatMoney(today), " today for the 15 days left in November, then ").concat(formatMoney(monthly), " each month.");
|
|
28
|
+
return { title: "Upgrade to ".concat(name), body: body, detail: false };
|
|
29
|
+
}
|
|
30
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
31
|
+
return { title: "Downgrade to ".concat(name), body: "".concat(plans.find(function (p) { return p.id === from; }).name, " stays on until Dec 1, 2026. Acme is not charged again."), detail: true };
|
|
32
|
+
}
|
|
33
|
+
export default function PlanPickerCards() {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
var _c = useState('free'), current = _c[0], setCurrent = _c[1];
|
|
36
|
+
var _d = useState(null), scheduled = _d[0], setScheduled = _d[1];
|
|
37
|
+
var _e = useState(null), target = _e[0], setTarget = _e[1];
|
|
38
|
+
var _f = useState(false), busy = _f[0], setBusy = _f[1];
|
|
39
|
+
var timer = useRef();
|
|
40
|
+
// On unmount it stops the request.
|
|
41
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
42
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
43
|
+
function handleClose() {
|
|
44
|
+
if (busy)
|
|
45
|
+
return;
|
|
46
|
+
setTarget(null);
|
|
47
|
+
}
|
|
48
|
+
function handleConfirm() {
|
|
49
|
+
if (busy || !target)
|
|
50
|
+
return;
|
|
51
|
+
var to = target;
|
|
52
|
+
setBusy(true);
|
|
53
|
+
// Stands in for the request to the server.
|
|
54
|
+
timer.current = setTimeout(function () {
|
|
55
|
+
setBusy(false);
|
|
56
|
+
setTarget(null);
|
|
57
|
+
if (rank[to] > rank[current]) {
|
|
58
|
+
setCurrent(to);
|
|
59
|
+
setScheduled(null);
|
|
60
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
64
|
+
setScheduled(to);
|
|
65
|
+
}
|
|
66
|
+
}, 1200);
|
|
67
|
+
}
|
|
68
|
+
var copy = target ? describe(current, target) : null;
|
|
69
|
+
var currentName = plans.find(function (p) { return p.id === current; }).name;
|
|
70
|
+
return (<Center width="page">
|
|
71
|
+
<SettingsSection title="Plan" description={scheduled ? "Acme is on ".concat(currentName, " until Dec 1, 2026, then ").concat(plans.find(function (p) { return p.id === scheduled; }).name, ".") : "Acme is on ".concat(currentName, ".")}>
|
|
72
|
+
{/* Two or three plans side by side from md up, stacked on a phone. A card is not itself clickable. */}
|
|
73
|
+
<Grid columns={3}>
|
|
74
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="small">
|
|
75
|
+
<Stack gap="medium">
|
|
76
|
+
<Stack gap="small">
|
|
77
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
78
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
79
|
+
</Stack>
|
|
80
|
+
<List items={p.includes} size="body2" marker="dot"/>
|
|
81
|
+
{p.id === current ? (<Cluster><Tag variant="textOnly" size="small" label="Current plan"/></Cluster>) : p.id === scheduled ? (<Cluster><Tag variant="dot" size="small" label="Starts Dec 1"/></Cluster>) : rank[p.id] > rank[current] ? (<Cluster><Button size="small" type="primary" state="enabled" label={"Upgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/></Cluster>) : (<Cluster><Button size="small" type="tertiary" state="enabled" label={"Downgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/></Cluster>)}
|
|
82
|
+
</Stack>
|
|
83
|
+
</Surface>); })}
|
|
84
|
+
</Grid>
|
|
85
|
+
</SettingsSection>
|
|
86
|
+
<Modal isOpen={target !== null} size="small" title={(_a = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _a !== void 0 ? _a : ''} onClose={handleClose} actions={<>
|
|
87
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
88
|
+
<Button size="small" type="primary" state="enabled" label={(_b = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _b !== void 0 ? _b : ''} loading={busy} onClickButton={handleConfirm}/>
|
|
89
|
+
</>}>
|
|
90
|
+
<Paragraph measure="none">{copy === null || copy === void 0 ? void 0 : copy.body}</Paragraph>
|
|
91
|
+
{(copy === null || copy === void 0 ? void 0 : copy.detail) && (<>
|
|
92
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
93
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']}/>
|
|
94
|
+
</>)}
|
|
95
|
+
</Modal>
|
|
96
|
+
</Center>);
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PlanPickerList(): import("react").JSX.Element;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Modal from '../../components/modal';
|
|
4
|
+
import Surface from '../../components/surface';
|
|
5
|
+
import Heading from '../../components/heading';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import List from '../../components/list';
|
|
8
|
+
import Tag from '../../components/tag';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import SettingsSection from '../../components/settingsSection';
|
|
12
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
13
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
14
|
+
var plans = [
|
|
15
|
+
{ id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
16
|
+
{ id: 'pro', name: 'Pro', price: "".concat(formatMoney(8), " per member per month"), includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
17
|
+
{ id: 'business', name: 'Business', price: "".concat(formatMoney(16), " per member per month"), includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
18
|
+
];
|
|
19
|
+
var rank = { free: 0, pro: 1, business: 2 };
|
|
20
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
21
|
+
function describe(from, to) {
|
|
22
|
+
var name = plans.find(function (p) { return p.id === to; }).name;
|
|
23
|
+
if (rank[to] > rank[from]) {
|
|
24
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
25
|
+
var today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
26
|
+
var monthly = to === 'pro' ? 24 : 48;
|
|
27
|
+
var body = "You pay ".concat(formatMoney(today), " today for the 15 days left in November, then ").concat(formatMoney(monthly), " each month.");
|
|
28
|
+
return { title: "Upgrade to ".concat(name), body: body, detail: false };
|
|
29
|
+
}
|
|
30
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
31
|
+
return { title: "Downgrade to ".concat(name), body: "".concat(plans.find(function (p) { return p.id === from; }).name, " stays on until Dec 1, 2026. Acme is not charged again."), detail: true };
|
|
32
|
+
}
|
|
33
|
+
export default function PlanPickerList() {
|
|
34
|
+
var _a, _b;
|
|
35
|
+
var _c = useState('pro'), current = _c[0], setCurrent = _c[1];
|
|
36
|
+
var _d = useState(null), scheduled = _d[0], setScheduled = _d[1];
|
|
37
|
+
var _e = useState(null), target = _e[0], setTarget = _e[1];
|
|
38
|
+
var _f = useState(false), busy = _f[0], setBusy = _f[1];
|
|
39
|
+
var timer = useRef();
|
|
40
|
+
// On unmount it stops the request.
|
|
41
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
42
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
43
|
+
function handleClose() {
|
|
44
|
+
if (busy)
|
|
45
|
+
return;
|
|
46
|
+
setTarget(null);
|
|
47
|
+
}
|
|
48
|
+
function handleConfirm() {
|
|
49
|
+
if (busy || !target)
|
|
50
|
+
return;
|
|
51
|
+
var to = target;
|
|
52
|
+
setBusy(true);
|
|
53
|
+
// Stands in for the request to the server.
|
|
54
|
+
timer.current = setTimeout(function () {
|
|
55
|
+
setBusy(false);
|
|
56
|
+
setTarget(null);
|
|
57
|
+
if (rank[to] > rank[current]) {
|
|
58
|
+
setCurrent(to);
|
|
59
|
+
setScheduled(null);
|
|
60
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
64
|
+
setScheduled(to);
|
|
65
|
+
}
|
|
66
|
+
}, 1200);
|
|
67
|
+
}
|
|
68
|
+
var copy = target ? describe(current, target) : null;
|
|
69
|
+
var currentName = plans.find(function (p) { return p.id === current; }).name;
|
|
70
|
+
return (<Center width="page">
|
|
71
|
+
<SettingsSection title="Plan" description={scheduled ? "Acme is on ".concat(currentName, " until Dec 1, 2026, then ").concat(plans.find(function (p) { return p.id === scheduled; }).name, ".") : "Acme is on ".concat(currentName, ".")}>
|
|
72
|
+
{/* Rows in the settings column. The plan and what it includes on the left, the one action on the right. */}
|
|
73
|
+
<Stack gap="medium">
|
|
74
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="small">
|
|
75
|
+
<Cluster justify="between" align="start" gap="medium">
|
|
76
|
+
<Stack gap="small">
|
|
77
|
+
<Cluster gap="small">
|
|
78
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
79
|
+
{p.id === current && <Tag variant="textOnly" size="small" label="Current plan"/>}
|
|
80
|
+
{p.id === scheduled && <Tag variant="dot" size="small" label="Starts Dec 1"/>}
|
|
81
|
+
</Cluster>
|
|
82
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
83
|
+
<List items={p.includes} size="body2" marker="dot"/>
|
|
84
|
+
</Stack>
|
|
85
|
+
{p.id !== current && p.id !== scheduled && (rank[p.id] > rank[current]
|
|
86
|
+
? <Button size="small" type="primary" state="enabled" label={"Upgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/>
|
|
87
|
+
: <Button size="small" type="tertiary" state="enabled" label={"Downgrade to ".concat(p.name)} onClickButton={function () { return setTarget(p.id); }}/>)}
|
|
88
|
+
</Cluster>
|
|
89
|
+
</Surface>); })}
|
|
90
|
+
</Stack>
|
|
91
|
+
</SettingsSection>
|
|
92
|
+
<Modal isOpen={target !== null} size="small" title={(_a = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _a !== void 0 ? _a : ''} onClose={handleClose} actions={<>
|
|
93
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
94
|
+
<Button size="small" type="primary" state="enabled" label={(_b = copy === null || copy === void 0 ? void 0 : copy.title) !== null && _b !== void 0 ? _b : ''} loading={busy} onClickButton={handleConfirm}/>
|
|
95
|
+
</>}>
|
|
96
|
+
<Paragraph measure="none">{copy === null || copy === void 0 ? void 0 : copy.body}</Paragraph>
|
|
97
|
+
{(copy === null || copy === void 0 ? void 0 : copy.detail) && (<>
|
|
98
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
99
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']}/>
|
|
100
|
+
</>)}
|
|
101
|
+
</Modal>
|
|
102
|
+
</Center>);
|
|
103
|
+
}
|