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.
Files changed (122) hide show
  1. package/README.md +1 -1
  2. package/dist/DESIGN.md +28 -4
  3. package/dist/cases/billing-page/billed-elsewhere.d.ts +1 -0
  4. package/dist/cases/billing-page/billed-elsewhere.jsx +28 -0
  5. package/dist/cases/billing-page/self-serve.d.ts +1 -0
  6. package/dist/cases/billing-page/self-serve.jsx +134 -0
  7. package/dist/cases/billing-page.md +247 -0
  8. package/dist/cases/breakdown-list/bars.d.ts +1 -0
  9. package/dist/cases/breakdown-list/bars.jsx +47 -0
  10. package/dist/cases/breakdown-list/table.d.ts +1 -0
  11. package/dist/cases/breakdown-list/table.jsx +69 -0
  12. package/dist/cases/breakdown-list.md +158 -0
  13. package/dist/cases/composer-limit/notice-with-action.jsx +3 -3
  14. package/dist/cases/composer-limit/notice.jsx +3 -3
  15. package/dist/cases/composer-limit.md +8 -8
  16. package/dist/cases/dashboard/numbers-first.d.ts +1 -0
  17. package/dist/cases/dashboard/numbers-first.jsx +165 -0
  18. package/dist/cases/dashboard/work-first.d.ts +1 -0
  19. package/dist/cases/dashboard/work-first.jsx +165 -0
  20. package/dist/cases/dashboard.md +507 -0
  21. package/dist/cases/data-table-page/all-rows.d.ts +1 -0
  22. package/dist/cases/data-table-page/all-rows.jsx +226 -0
  23. package/dist/cases/data-table-page/paged.d.ts +1 -0
  24. package/dist/cases/data-table-page/paged.jsx +284 -0
  25. package/dist/cases/data-table-page.md +771 -0
  26. package/dist/cases/invoice-list/table.d.ts +1 -0
  27. package/dist/cases/invoice-list/table.jsx +64 -0
  28. package/dist/cases/invoice-list/with-upcoming.d.ts +1 -0
  29. package/dist/cases/invoice-list/with-upcoming.jsx +75 -0
  30. package/dist/cases/invoice-list.md +237 -0
  31. package/dist/cases/load-failure/inline.jsx +2 -2
  32. package/dist/cases/load-failure.md +2 -2
  33. package/dist/cases/members-list/rows.jsx +2 -1
  34. package/dist/cases/members-list/table.jsx +8 -9
  35. package/dist/cases/members-list.md +12 -13
  36. package/dist/cases/number-format.md +36 -0
  37. package/dist/cases/paged-card/pager.d.ts +1 -0
  38. package/dist/cases/paged-card/pager.jsx +41 -0
  39. package/dist/cases/paged-card/see-all.d.ts +1 -0
  40. package/dist/cases/paged-card/see-all.jsx +34 -0
  41. package/dist/cases/paged-card.md +147 -0
  42. package/dist/cases/payment-method/none.d.ts +1 -0
  43. package/dist/cases/payment-method/none.jsx +17 -0
  44. package/dist/cases/payment-method/on-file.d.ts +1 -0
  45. package/dist/cases/payment-method/on-file.jsx +92 -0
  46. package/dist/cases/payment-method.md +182 -0
  47. package/dist/cases/plan-change-confirm/blocked.d.ts +1 -0
  48. package/dist/cases/plan-change-confirm/blocked.jsx +48 -0
  49. package/dist/cases/plan-change-confirm/downgrade.d.ts +1 -0
  50. package/dist/cases/plan-change-confirm/downgrade.jsx +52 -0
  51. package/dist/cases/plan-change-confirm/upgrade.d.ts +1 -0
  52. package/dist/cases/plan-change-confirm/upgrade.jsx +51 -0
  53. package/dist/cases/plan-change-confirm.md +261 -0
  54. package/dist/cases/plan-picker/cards.d.ts +1 -0
  55. package/dist/cases/plan-picker/cards.jsx +97 -0
  56. package/dist/cases/plan-picker/list.d.ts +1 -0
  57. package/dist/cases/plan-picker/list.jsx +103 -0
  58. package/dist/cases/plan-picker.md +297 -0
  59. package/dist/cases/range-switch/segmented.jsx +11 -7
  60. package/dist/cases/range-switch.md +16 -11
  61. package/dist/cases/settings-page/top-tabs.jsx +4 -3
  62. package/dist/cases/settings-page.md +5 -4
  63. package/dist/cases/stat-row/featured.d.ts +1 -0
  64. package/dist/cases/stat-row/featured.jsx +17 -0
  65. package/dist/cases/stat-row/tiles.d.ts +1 -0
  66. package/dist/cases/stat-row/tiles.jsx +34 -0
  67. package/dist/cases/stat-row.md +104 -0
  68. package/dist/cases/status-label/dot.d.ts +1 -0
  69. package/dist/cases/status-label/dot.jsx +39 -0
  70. package/dist/cases/status-label/text.d.ts +1 -0
  71. package/dist/cases/status-label/text.jsx +44 -0
  72. package/dist/cases/status-label.md +143 -0
  73. package/dist/cases/upgrade-prompt/inline.jsx +4 -2
  74. package/dist/cases/upgrade-prompt/modal.jsx +2 -1
  75. package/dist/cases/upgrade-prompt.md +10 -6
  76. package/dist/cases/usage-meters/by-person.d.ts +1 -0
  77. package/dist/cases/usage-meters/by-person.jsx +72 -0
  78. package/dist/cases/usage-meters/meters.d.ts +1 -0
  79. package/dist/cases/usage-meters/meters.jsx +49 -0
  80. package/dist/cases/usage-meters/with-cap.d.ts +1 -0
  81. package/dist/cases/usage-meters/with-cap.jsx +73 -0
  82. package/dist/cases/usage-meters.md +303 -0
  83. package/dist/cases.json +956 -19
  84. package/dist/components/button.d.ts +1 -1
  85. package/dist/components/button.jsx +11 -5
  86. package/dist/components/formatNumber.d.ts +25 -0
  87. package/dist/components/formatNumber.js +125 -0
  88. package/dist/components/iconButton.jsx +12 -7
  89. package/dist/components/pagination.d.ts +28 -0
  90. package/dist/components/pagination.jsx +89 -0
  91. package/dist/components/progress.d.ts +33 -0
  92. package/dist/components/progress.jsx +50 -0
  93. package/dist/components/skeleton.d.ts +21 -0
  94. package/dist/components/skeleton.jsx +41 -0
  95. package/dist/components/statTile.d.ts +32 -0
  96. package/dist/components/statTile.jsx +61 -0
  97. package/dist/components/tableContainer.d.ts +5 -1
  98. package/dist/components/tableContainer.jsx +9 -1
  99. package/dist/components/tableHeaderCell.d.ts +3 -1
  100. package/dist/components/tableHeaderCell.jsx +2 -2
  101. package/dist/components/titleBar.d.ts +3 -1
  102. package/dist/components/titleBar.jsx +4 -3
  103. package/dist/index.d.ts +5 -0
  104. package/dist/index.js +5 -0
  105. package/dist/native-mapping.json +26 -2
  106. package/dist/stories/Button.stories.d.ts +1 -0
  107. package/dist/stories/Button.stories.jsx +19 -1
  108. package/dist/stories/Cases.generated.stories.d.ts +26 -0
  109. package/dist/stories/Cases.generated.stories.jsx +52 -0
  110. package/dist/stories/Pagination.stories.d.ts +9 -0
  111. package/dist/stories/Pagination.stories.jsx +75 -0
  112. package/dist/stories/Progress.stories.d.ts +9 -0
  113. package/dist/stories/Progress.stories.jsx +43 -0
  114. package/dist/stories/Skeleton.stories.d.ts +7 -0
  115. package/dist/stories/Skeleton.stories.jsx +27 -0
  116. package/dist/stories/StatTile.stories.d.ts +10 -0
  117. package/dist/stories/StatTile.stories.jsx +55 -0
  118. package/dist/stories/Table.stories.d.ts +1 -0
  119. package/dist/stories/Table.stories.jsx +49 -1
  120. package/dist/stories/TitleBar.stories.d.ts +1 -0
  121. package/dist/stories/TitleBar.stories.jsx +7 -0
  122. package/package.json +5 -1
@@ -0,0 +1,36 @@
1
+ # A number shows its unit and never shows 0 for unknown
2
+
3
+ A page shows counts, money, sizes, shares or changes.
4
+
5
+ ## Answer
6
+
7
+ Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. A count is whole and grouped: '1,240'. In a tile, a count or an amount from 10,000 up shows its short form: '12.4K', '$12.4K'. A table shows the exact number, right-aligned. Money has its symbol and two decimals: '$1,240.00'. A cost under a cent reads '< $0.01'. A share is a whole percent, and a small one reads '< 1%'. A size is base 1024: '52 MB', '1.2 GB'. A time reads '340 ms', '1.2 s', '2 h 24 min'. The unit is in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'. A bare number is never shown, and a unit is never only in a tooltip. A change says its direction, its size and what it compares with: 'Up 12% from last week'. It reads 'New this week' when there was nothing before. It has no color, because more is not good or bad by itself. Unknown is never 0. `formatNumber` shows '–' for a value it cannot read. `StatTile` shows 'No data yet'. While a number loads, a `Skeleton` holds its place. On a failure, show the case 'Load failure'. A limit is a `Progress`, which says 'Limit reached' in words.
8
+
9
+ ## Why
10
+
11
+ One page that rounds a cost to four decimals and another that rounds it to two make the same bill look like two different amounts. A 0 shown while a number loads reads as a real answer, so the person believes something that is not true.
12
+
13
+ ## Do
14
+
15
+ - Show a count whole and grouped: '1,240'. In a tile, show a count or an amount from 10,000 up in its short form: '12.4K', '$12.4K'.
16
+ - Show the exact number in a table, right-aligned.
17
+ - Show money with its symbol and two decimals, and a cost under a cent as '< $0.01'.
18
+ - Show a time as '340 ms', '1.2 s' or '2 h 24 min'. Show a share as a whole percent, and a small one as '< 1%'. Show a size in base 1024: '52 MB', '1.2 GB'.
19
+ - Put the unit in the label or after the number in words: 'Responses', '7 of 8 seats', '340 responses, no limit'.
20
+ - Match the noun to the count: '1 invoice', '290 invoices'.
21
+ - Say a change's direction, size and comparison: 'Up 12% from last week'. Say 'New this week' when there was nothing before.
22
+ - Show a `Skeleton` while a number loads, 'No data yet' when there is none, and the case 'Load failure' when it could not load.
23
+ - Use the helpers in `formatNumber` (`formatCount`, `formatMoney`, `formatPercent`, `formatBytes`, `formatDuration`), `StatTile` and `Progress`. Do not format a number by hand.
24
+
25
+ ## Don't
26
+
27
+ - Do not show 0 for a number that is loading, missing or failed.
28
+ - Do not show a bare number, or a unit only in a tooltip.
29
+ - Do not round a cost to four decimals in one place and two in another.
30
+ - Do not color a change green or red. More is not good or bad by itself.
31
+ - Do not show the compact form ('12.4K') in a table, or give a screen reader only the compact form.
32
+ - Do not show 100% for a share that is not the whole.
33
+
34
+ ## Native
35
+
36
+ On Apple use `FormatStyle` for numbers, money and percents, and `ByteCountFormatStyle` with the `.memory` style for sizes, which is base 1024. On Android use `NumberFormat`.
@@ -0,0 +1 @@
1
+ export default function PagedCardPager(): import("react").JSX.Element;
@@ -0,0 +1,41 @@
1
+ 'use client';
2
+ import { useState } from 'react';
3
+ import Heading from '../../components/heading';
4
+ import Pagination from '../../components/pagination';
5
+ import MenuItem from '../../components/menuItem';
6
+ import Line from '../../components/line';
7
+ import { formatCount } from '../../components/formatNumber';
8
+ import { Center, Cluster, Stack } from '../../components/layout';
9
+ // A real app reads these from the server.
10
+ var questions = [
11
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
12
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
13
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
14
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
15
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
16
+ { id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
17
+ { id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
18
+ { id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
19
+ ];
20
+ var PER_PAGE = 4;
21
+ export default function PagedCardPager() {
22
+ var _a = useState(1), page = _a[0], setPage = _a[1];
23
+ var pageCount = Math.ceil(questions.length / PER_PAGE);
24
+ var rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
25
+ return (<Center width="page">
26
+ <Stack gap="medium">
27
+ <Line />
28
+ {/* The total is in the title, and the pager is in the title row, named for the card. */}
29
+ <Cluster justify="between">
30
+ <Heading level={2} size="h6">{"".concat(formatCount(questions.length), " ").concat(questions.length === 1 ? 'question' : 'questions', " waiting on you")}</Heading>
31
+ <Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage}/>
32
+ </Cluster>
33
+ <Stack gap="small">
34
+ {rows.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
35
+ // A real app lets the link go to the question's page. The example stays here.
36
+ event.preventDefault();
37
+ }}/>); })}
38
+ </Stack>
39
+ </Stack>
40
+ </Center>);
41
+ }
@@ -0,0 +1 @@
1
+ export default function PagedCardSeeAll(): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+ import Heading from '../../components/heading';
3
+ import Link from '../../components/link';
4
+ import MenuItem from '../../components/menuItem';
5
+ import Line from '../../components/line';
6
+ import { formatCount } from '../../components/formatNumber';
7
+ import { Center, Cluster, Stack } from '../../components/layout';
8
+ // A real app reads these from the server: the newest five, and how many there are in all.
9
+ var total = 142;
10
+ var questions = [
11
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
12
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
13
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
14
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
15
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
16
+ ];
17
+ export default function PagedCardSeeAll() {
18
+ return (<Center width="page">
19
+ <Stack gap="medium">
20
+ <Line />
21
+ <Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
22
+ <Stack gap="small">
23
+ {questions.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
24
+ // A real app lets the link go to the question's page. The example stays here.
25
+ event.preventDefault();
26
+ }}/>); })}
27
+ </Stack>
28
+ {/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
29
+ <Cluster>
30
+ <Link href="#" size="body2">See All Questions</Link>
31
+ </Cluster>
32
+ </Stack>
33
+ </Center>);
34
+ }
@@ -0,0 +1,147 @@
1
+ # Short list on a dashboard
2
+
3
+ A dashboard section lists things that wait on the person, such as questions or comments, and the list may be longer than the section.
4
+
5
+ ## Do
6
+
7
+ - Follow the rule 'A number shows its unit and never shows 0 for unknown'.
8
+ - Say the total in the title, as a number and its unit: '8 questions waiting on you'.
9
+ - Make every row a link to the thing it names, with a second line for when it was asked.
10
+ - Put `Pagination variant="compact"` in the title row when the list pages, named for the card: 'Pages of questions waiting on you'.
11
+ - Keep the page length the same on every page. `Pagination` shows nothing when there is one page.
12
+ - Show five rows and a 'See All Questions' `Link` after them when the list does not page. The link goes to the full list, the case 'Data table page'.
13
+ - Show `EmptyBox size="small"` when the list is empty, such as 'No questions waiting on you', with a `secondText` that says what will appear.
14
+ - Show the card as a hairline, a title and rows. Do not box it.
15
+
16
+ ## Don't
17
+
18
+ - Do not page a long list on the dashboard. Show five rows and a link.
19
+ - Do not leave the pager unnamed. Name it for the card, so a screen reader hears 'Pages of questions waiting on you'.
20
+ - Do not write the page as '1/3'. `Pagination` writes '1 of 3' in a card and 'Page 1 of 3' elsewhere.
21
+ - Do not make a row that is not a link, or a link with no name.
22
+ - Do not scroll a list inside the card.
23
+
24
+ ## Option: Pager in the title row
25
+
26
+ Use when: The list is short and stays on the dashboard, a few rows a page.
27
+
28
+ Uses: `Center`, `Cluster`, `Heading`, `Line`, `MenuItem`, `Pagination`, `Stack`, `formatCount`
29
+
30
+ ```tsx
31
+ 'use client';
32
+ import { useState } from 'react';
33
+ import Heading from 'oneslash-design-system/components/heading';
34
+ import Pagination from 'oneslash-design-system/components/pagination';
35
+ import MenuItem from 'oneslash-design-system/components/menuItem';
36
+ import Line from 'oneslash-design-system/components/line';
37
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
38
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
39
+
40
+ // A real app reads these from the server.
41
+ const questions = [
42
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
43
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
44
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
45
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
46
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
47
+ { id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
48
+ { id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
49
+ { id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
50
+ ];
51
+
52
+ const PER_PAGE = 4;
53
+
54
+ export default function PagedCardPager() {
55
+ const [page, setPage] = useState(1);
56
+ const pageCount = Math.ceil(questions.length / PER_PAGE);
57
+ const rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
58
+
59
+ return (
60
+ <Center width="page">
61
+ <Stack gap="medium">
62
+ <Line />
63
+ {/* The total is in the title, and the pager is in the title row, named for the card. */}
64
+ <Cluster justify="between">
65
+ <Heading level={2} size="h6">{`${formatCount(questions.length)} ${questions.length === 1 ? 'question' : 'questions'} waiting on you`}</Heading>
66
+ <Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage} />
67
+ </Cluster>
68
+ <Stack gap="small">
69
+ {rows.map((q) => (
70
+ <MenuItem
71
+ key={q.id}
72
+ size="medium"
73
+ label={q.text}
74
+ secondLabel={q.when}
75
+ href={`/questions/${q.id}`}
76
+ onClick={(event: { preventDefault: () => void }) => {
77
+ // A real app lets the link go to the question's page. The example stays here.
78
+ event.preventDefault();
79
+ }}
80
+ />
81
+ ))}
82
+ </Stack>
83
+ </Stack>
84
+ </Center>
85
+ );
86
+ }
87
+ ```
88
+
89
+ ## Option: Five rows and See All
90
+
91
+ Use when: The list is long, so the dashboard shows the newest five and a link to the full page.
92
+
93
+ Uses: `Center`, `Cluster`, `Heading`, `Line`, `Link`, `MenuItem`, `Stack`, `formatCount`
94
+
95
+ ```tsx
96
+ 'use client';
97
+ import Heading from 'oneslash-design-system/components/heading';
98
+ import Link from 'oneslash-design-system/components/link';
99
+ import MenuItem from 'oneslash-design-system/components/menuItem';
100
+ import Line from 'oneslash-design-system/components/line';
101
+ import { formatCount } from 'oneslash-design-system/components/formatNumber';
102
+ import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
103
+
104
+ // A real app reads these from the server: the newest five, and how many there are in all.
105
+ const total = 142;
106
+ const questions = [
107
+ { id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
108
+ { id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
109
+ { id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
110
+ { id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
111
+ { id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
112
+ ];
113
+
114
+ export default function PagedCardSeeAll() {
115
+ return (
116
+ <Center width="page">
117
+ <Stack gap="medium">
118
+ <Line />
119
+ <Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
120
+ <Stack gap="small">
121
+ {questions.map((q) => (
122
+ <MenuItem
123
+ key={q.id}
124
+ size="medium"
125
+ label={q.text}
126
+ secondLabel={q.when}
127
+ href={`/questions/${q.id}`}
128
+ onClick={(event: { preventDefault: () => void }) => {
129
+ // A real app lets the link go to the question's page. The example stays here.
130
+ event.preventDefault();
131
+ }}
132
+ />
133
+ ))}
134
+ </Stack>
135
+ {/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
136
+ <Cluster>
137
+ <Link href="#" size="body2">See All Questions</Link>
138
+ </Cluster>
139
+ </Stack>
140
+ </Center>
141
+ );
142
+ }
143
+ ```
144
+
145
+ ## Native
146
+
147
+ On Apple use a `Section` of a `List` with a `NavigationLink` for each row, and a `NavigationLink` named See All for the footer. On Android use a `LazyColumn` of clickable rows.
@@ -0,0 +1 @@
1
+ export default function PaymentMethodNone(): import("react").JSX.Element;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+ import Paragraph from '../../components/paragraph';
3
+ import Button from '../../components/button';
4
+ import SettingsSection from '../../components/settingsSection';
5
+ import { Center, Stack } from '../../components/layout';
6
+ export default function PaymentMethodNone() {
7
+ return (<Center width="page">
8
+ <SettingsSection title="Payment method" description="Pays for Acme's plan.">
9
+ <Stack gap="medium" align="start">
10
+ <Paragraph measure="none">No payment method.</Paragraph>
11
+ <Paragraph tone="secondary" size="body2" measure="none">Acme is on Free, so it needs none. Add one to upgrade.</Paragraph>
12
+ {/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
13
+ <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/>
14
+ </Stack>
15
+ </SettingsSection>
16
+ </Center>);
17
+ }
@@ -0,0 +1 @@
1
+ export default function PaymentMethodOnFile(): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ 'use client';
2
+ import { useEffect, useRef, useState } from 'react';
3
+ import Toaster, { toast, dismissToast } from '../../components/toaster';
4
+ import Alert from '../../components/alert';
5
+ import Modal from '../../components/modal';
6
+ import Surface from '../../components/surface';
7
+ import Paragraph from '../../components/paragraph';
8
+ import Button from '../../components/button';
9
+ import SettingsSection from '../../components/settingsSection';
10
+ import { Center, Cluster, Stack } from '../../components/layout';
11
+ // A real app reads these from the server. Only the brand, the last four digits and the expiry ever reach the page.
12
+ var card = { brand: 'Visa', last4: '4821', month: 8, year: 2028 };
13
+ var today = { month: 11, year: 2026 };
14
+ var plan = 'Free';
15
+ // A paid plan needs a card, so Remove is not offered. The Free plan needs none.
16
+ var planNeedsCard = plan !== 'Free';
17
+ var monthsLeft = (card.year - today.year) * 12 + (card.month - today.month);
18
+ var expiry = "".concat(String(card.month).padStart(2, '0'), "/").concat(String(card.year % 100).padStart(2, '0'));
19
+ var name = "".concat(card.brand, " ending in ").concat(card.last4);
20
+ export default function PaymentMethodOnFile() {
21
+ var _a = useState(false), removed = _a[0], setRemoved = _a[1];
22
+ var _b = useState(false), confirming = _b[0], setConfirming = _b[1];
23
+ var _c = useState(false), removing = _c[0], setRemoving = _c[1];
24
+ var timer = useRef();
25
+ var toastIds = useRef([]);
26
+ var addRef = useRef(null);
27
+ // On unmount it stops the request and closes every toast it opened.
28
+ useEffect(function () { return function () {
29
+ clearTimeout(timer.current);
30
+ toastIds.current.forEach(function (id) { return dismissToast(id); });
31
+ toastIds.current = [];
32
+ }; }, []);
33
+ // The Remove Button is gone with the card, so focus moves to what takes its place.
34
+ useEffect(function () {
35
+ var _a;
36
+ if (removed)
37
+ (_a = addRef.current) === null || _a === void 0 ? void 0 : _a.focus();
38
+ }, [removed]);
39
+ // Escape, a click outside and Cancel all close it, except while the request runs. The Modal gives focus back to Remove.
40
+ function handleClose() {
41
+ if (removing)
42
+ return;
43
+ setConfirming(false);
44
+ }
45
+ function handleRemove() {
46
+ if (removing)
47
+ return;
48
+ setRemoving(true);
49
+ // Stands in for the request to the server.
50
+ timer.current = setTimeout(function () {
51
+ setRemoving(false);
52
+ setConfirming(false);
53
+ setRemoved(true);
54
+ toastIds.current.push(toast({ type: 'success', message: "".concat(name, " removed.") }));
55
+ }, 1200);
56
+ }
57
+ return (<Center width="page">
58
+ {/* A real app mounts one Toaster near its root. */}
59
+ <Toaster />
60
+ <SettingsSection title="Payment method" description="Pays for Acme's plan.">
61
+ {removed ? (<Stack gap="medium" align="start">
62
+ <Paragraph measure="none">No payment method.</Paragraph>
63
+ {/* A real app hands off to its payment provider's own page here. The page never takes card details. */}
64
+ <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/>
65
+ </Stack>) : (<Stack gap="medium">
66
+ {/* A month ahead of the expiry, the page says so. */}
67
+ {monthsLeft <= 1 && monthsLeft >= 0 && (<Alert type="warning" variant="inline" autoDismiss={false} message={"This card expires on ".concat(expiry, ". Update it before then.")}/>)}
68
+ <Surface padding="small">
69
+ <Cluster justify="between" gap="medium">
70
+ <Stack gap="small">
71
+ <Paragraph measure="none">{name}</Paragraph>
72
+ <Paragraph tone="secondary" size="body2" measure="none">{"Expires ".concat(expiry)}</Paragraph>
73
+ </Stack>
74
+ <Cluster gap="small">
75
+ {/* Updating the card happens on the provider's page, so Update is a link out. */}
76
+ <Button size="small" type="tertiary" state="enabled" label="Update" aria-label={"Update ".concat(name, ", opens in a new tab")} actionIcon="ExternalLink" href="https://acme.example/billing/payment-method" openInNewTab/>
77
+ {!planNeedsCard && (<Button size="small" type="tertiary" state="enabled" label="Remove" aria-label={"Remove ".concat(name)} onClickButton={function () { return setConfirming(true); }}/>)}
78
+ </Cluster>
79
+ </Cluster>
80
+ </Surface>
81
+ {planNeedsCard && <Paragraph tone="secondary" size="body2" measure="none">Pro needs a card on file. Downgrade to Free to remove it.</Paragraph>}
82
+ </Stack>)}
83
+ </SettingsSection>
84
+ {/* One card is not a dense list, so the confirm is a small Modal. */}
85
+ <Modal isOpen={confirming} size="small" title="Remove Card" onClose={handleClose} actions={<>
86
+ <Button size="small" type="tertiary" state={removing ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
87
+ <Button size="small" type="primary" color="danger" state="enabled" label="Remove" loading={removing} onClickButton={handleRemove}/>
88
+ </>}>
89
+ <Paragraph measure="none">{"This removes ".concat(name, " from Acme. Your plan and invoices are not changed.")}</Paragraph>
90
+ </Modal>
91
+ </Center>);
92
+ }
@@ -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 @@
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;