oneslash-design-system 2.19.0 → 2.21.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 +62 -5
- package/dist/cases/about-page/profile.d.ts +1 -0
- package/dist/cases/about-page/profile.jsx +64 -0
- package/dist/cases/about-page.md +114 -0
- package/dist/cases/admin-inbox/list.d.ts +1 -0
- package/dist/cases/admin-inbox/list.jsx +104 -0
- package/dist/cases/admin-inbox/split.d.ts +1 -0
- package/dist/cases/admin-inbox/split.jsx +68 -0
- package/dist/cases/admin-inbox.md +254 -0
- package/dist/cases/api-keys.md +1 -1
- 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/blog-index/cards.d.ts +1 -0
- package/dist/cases/blog-index/cards.jsx +45 -0
- package/dist/cases/blog-index/list.d.ts +1 -0
- package/dist/cases/blog-index/list.jsx +46 -0
- package/dist/cases/blog-index.md +160 -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/changelog/by-month.d.ts +1 -0
- package/dist/cases/changelog/by-month.jsx +70 -0
- package/dist/cases/changelog/one-page.d.ts +1 -0
- package/dist/cases/changelog/one-page.jsx +70 -0
- package/dist/cases/changelog.md +200 -0
- package/dist/cases/code-sample/block.d.ts +1 -0
- package/dist/cases/code-sample/block.jsx +19 -0
- package/dist/cases/code-sample/command.d.ts +1 -0
- package/dist/cases/code-sample/command.jsx +17 -0
- package/dist/cases/code-sample.md +96 -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/contact-page/form.d.ts +1 -0
- package/dist/cases/contact-page/form.jsx +83 -0
- package/dist/cases/contact-page/links.d.ts +1 -0
- package/dist/cases/contact-page/links.jsx +19 -0
- package/dist/cases/contact-page.md +142 -0
- 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/docs-component-page/reference.d.ts +1 -0
- package/dist/cases/docs-component-page/reference.jsx +93 -0
- package/dist/cases/docs-component-page.md +144 -0
- package/dist/cases/faq/accordion.d.ts +1 -0
- package/dist/cases/faq/accordion.jsx +25 -0
- package/dist/cases/faq/open-list.d.ts +1 -0
- package/dist/cases/faq/open-list.jsx +27 -0
- package/dist/cases/faq.md +110 -0
- package/dist/cases/feature-grid/cards.d.ts +1 -0
- package/dist/cases/feature-grid/cards.jsx +33 -0
- package/dist/cases/feature-grid/rows.d.ts +1 -0
- package/dist/cases/feature-grid/rows.jsx +30 -0
- package/dist/cases/feature-grid.md +132 -0
- package/dist/cases/image-viewer/gallery.d.ts +1 -0
- package/dist/cases/image-viewer/gallery.jsx +32 -0
- package/dist/cases/image-viewer/single.d.ts +1 -0
- package/dist/cases/image-viewer/single.jsx +25 -0
- package/dist/cases/image-viewer.md +123 -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/landing-hero/centered.d.ts +1 -0
- package/dist/cases/landing-hero/centered.jsx +22 -0
- package/dist/cases/landing-hero/split.d.ts +1 -0
- package/dist/cases/landing-hero/split.jsx +30 -0
- package/dist/cases/landing-hero.md +114 -0
- package/dist/cases/legal-page/sections.d.ts +1 -0
- package/dist/cases/legal-page/sections.jsx +61 -0
- package/dist/cases/legal-page.md +96 -0
- package/dist/cases/load-failure/inline.jsx +2 -2
- package/dist/cases/load-failure.md +2 -2
- package/dist/cases/long-form-page/article.d.ts +1 -0
- package/dist/cases/long-form-page/article.jsx +58 -0
- package/dist/cases/long-form-page/with-contents.d.ts +1 -0
- package/dist/cases/long-form-page/with-contents.jsx +41 -0
- package/dist/cases/long-form-page.md +170 -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/message-actions/hover-toolbar.jsx +11 -8
- package/dist/cases/message-actions/menu.jsx +10 -7
- package/dist/cases/message-actions.md +19 -13
- package/dist/cases/message-attachments/in-composer.jsx +2 -2
- package/dist/cases/message-attachments/in-message.jsx +16 -11
- package/dist/cases/message-attachments.md +29 -17
- package/dist/cases/number-format.md +36 -0
- package/dist/cases/one-main-action.md +33 -0
- package/dist/cases/overflow-menu/in-a-header.jsx +9 -6
- package/dist/cases/overflow-menu/on-a-row.jsx +9 -6
- package/dist/cases/overflow-menu.md +16 -10
- package/dist/cases/page-end/cta-band.d.ts +1 -0
- package/dist/cases/page-end/cta-band.jsx +24 -0
- package/dist/cases/page-end/next-link.d.ts +1 -0
- package/dist/cases/page-end/next-link.jsx +18 -0
- package/dist/cases/page-end.md +88 -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/password-gate/inline.d.ts +1 -0
- package/dist/cases/password-gate/inline.jsx +94 -0
- package/dist/cases/password-gate/modal.d.ts +1 -0
- package/dist/cases/password-gate/modal.jsx +81 -0
- package/dist/cases/password-gate/page.d.ts +1 -0
- package/dist/cases/password-gate/page.jsx +82 -0
- package/dist/cases/password-gate.md +351 -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/pricing-section/cards.d.ts +1 -0
- package/dist/cases/pricing-section/cards.jsx +40 -0
- package/dist/cases/pricing-section.md +85 -0
- package/dist/cases/product-cards/grid.d.ts +1 -0
- package/dist/cases/product-cards/grid.jsx +20 -0
- package/dist/cases/product-cards.md +71 -0
- package/dist/cases/range-switch/segmented.jsx +11 -7
- package/dist/cases/range-switch.md +16 -11
- package/dist/cases/reply-feedback/thumbs.jsx +11 -8
- package/dist/cases/reply-feedback/with-reason.jsx +11 -8
- package/dist/cases/reply-feedback.md +20 -14
- package/dist/cases/section-index/cards.d.ts +1 -0
- package/dist/cases/section-index/cards.jsx +25 -0
- package/dist/cases/section-index/list.d.ts +1 -0
- package/dist/cases/section-index/list.jsx +56 -0
- package/dist/cases/section-index.md +140 -0
- package/dist/cases/settings-page/top-tabs.jsx +4 -3
- package/dist/cases/settings-page.md +5 -4
- package/dist/cases/site-header.md +1 -1
- package/dist/cases/site-search/dialog.d.ts +1 -0
- package/dist/cases/site-search/dialog.jsx +131 -0
- package/dist/cases/site-search.md +176 -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/tabbed-panels/tabs.d.ts +1 -0
- package/dist/cases/tabbed-panels/tabs.jsx +40 -0
- package/dist/cases/tabbed-panels.md +81 -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 +2178 -97
- package/dist/components/accordion.d.ts +31 -0
- package/dist/components/accordion.jsx +103 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.jsx +11 -5
- package/dist/components/codeBlock.d.ts +26 -0
- package/dist/components/codeBlock.jsx +101 -0
- 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/lightbox.d.ts +31 -0
- package/dist/components/lightbox.jsx +161 -0
- package/dist/components/linkCard.d.ts +10 -1
- package/dist/components/linkCard.jsx +32 -6
- package/dist/components/modal.d.ts +10 -2
- package/dist/components/modal.jsx +17 -12
- package/dist/components/pageHeader.jsx +1 -1
- 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/searchDialog.d.ts +44 -0
- package/dist/components/searchDialog.jsx +152 -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/tab.d.ts +5 -1
- package/dist/components/tab.jsx +2 -2
- package/dist/components/tabPanel.d.ts +16 -0
- package/dist/components/tabPanel.jsx +12 -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/tabsContainer.d.ts +5 -1
- package/dist/components/tabsContainer.jsx +2 -2
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +4 -3
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/internal/accordion.d.ts +4 -0
- package/dist/internal/accordion.js +53 -0
- package/dist/internal/combobox.d.ts +20 -0
- package/dist/internal/combobox.js +28 -0
- package/dist/internal/highlight.d.ts +5 -0
- package/dist/internal/highlight.js +18 -0
- package/dist/native-mapping.json +57 -3
- package/dist/stories/Accordion.stories.d.ts +11 -0
- package/dist/stories/Accordion.stories.jsx +93 -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 +60 -0
- package/dist/stories/Cases.generated.stories.jsx +120 -0
- package/dist/stories/CodeBlock.stories.d.ts +12 -0
- package/dist/stories/CodeBlock.stories.jsx +65 -0
- package/dist/stories/Lightbox.stories.d.ts +8 -0
- package/dist/stories/Lightbox.stories.jsx +40 -0
- package/dist/stories/LinkCard.stories.d.ts +6 -0
- package/dist/stories/LinkCard.stories.jsx +17 -0
- package/dist/stories/PageHeader.stories.d.ts +2 -0
- package/dist/stories/PageHeader.stories.jsx +13 -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/SearchDialog.stories.d.ts +17 -0
- package/dist/stories/SearchDialog.stories.jsx +111 -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/TabPanel.stories.d.ts +7 -0
- package/dist/stories/TabPanel.stories.jsx +31 -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,297 @@
|
|
|
1
|
+
# Plan picker
|
|
2
|
+
|
|
3
|
+
An admin compares the plans a workspace can be on and chooses one.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Make each plan a `Surface` with its name as a heading, its price and a `List` of what it includes. Write each limit as a number with its unit: '3 members', '50 AI agent responses a month'.
|
|
9
|
+
- Put the cards in `Grid columns={3}`, which stacks them on a phone. Put the rows in one column.
|
|
10
|
+
- Mark the current plan with `Tag variant="textOnly"` 'Current plan', and give it no Button.
|
|
11
|
+
- Give every other plan one Button named for the move: 'Upgrade to Pro' as primary, 'Downgrade to Free' as tertiary. It opens the case 'Plan change confirm'.
|
|
12
|
+
- Say a change that starts later with a Tag 'Starts Dec 1' on the new plan, and a line under the heading: 'Acme is on Pro until Dec 1, 2026, then Free.'
|
|
13
|
+
- Open the picker from 'Change Plan' on the case 'Billing page'. Show it only to a person who can change the plan.
|
|
14
|
+
- Add a `SegmentedControl` as the case 'Range switch' says once the plans bill by the year too. Leave it out while every plan bills monthly.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not make a card clickable as a whole. Its Button is the one control, so a keyboard and a screen reader find it.
|
|
19
|
+
- Do not label the Buttons 'Select' or 'Choose'. Say the move: 'Upgrade to Pro'.
|
|
20
|
+
- Do not run the limits together in one line with dots between them. Use a `List`, one limit per item.
|
|
21
|
+
- Do not add a monthly and yearly switch when no plan bills yearly.
|
|
22
|
+
- Do not change a Button label to show it is busy, such as to 'Checking...'.
|
|
23
|
+
- Do not charge or change the plan from this page. The confirm does that.
|
|
24
|
+
|
|
25
|
+
## Option: Cards side by side
|
|
26
|
+
|
|
27
|
+
Use when: Two or three plans are compared at once, on a page with room for columns.
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import { useEffect, useRef, useState } from 'react';
|
|
34
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
35
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
36
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
37
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
38
|
+
import List from 'oneslash-design-system/components/list';
|
|
39
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
40
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
41
|
+
import Button from 'oneslash-design-system/components/button';
|
|
42
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
43
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
44
|
+
|
|
45
|
+
type PlanId = 'free' | 'pro' | 'business';
|
|
46
|
+
|
|
47
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
48
|
+
const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
|
|
49
|
+
{ id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
50
|
+
{ id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
51
|
+
{ id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
|
|
55
|
+
|
|
56
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
57
|
+
function describe(from: PlanId, to: PlanId) {
|
|
58
|
+
const name = plans.find((p) => p.id === to)!.name;
|
|
59
|
+
if (rank[to] > rank[from]) {
|
|
60
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
61
|
+
const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
62
|
+
const monthly = to === 'pro' ? 24 : 48;
|
|
63
|
+
const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
|
|
64
|
+
return { title: `Upgrade to ${name}`, body, detail: false };
|
|
65
|
+
}
|
|
66
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
67
|
+
return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export default function PlanPickerCards() {
|
|
71
|
+
const [current, setCurrent] = useState<PlanId>('free');
|
|
72
|
+
const [scheduled, setScheduled] = useState<PlanId | null>(null);
|
|
73
|
+
const [target, setTarget] = useState<PlanId | null>(null);
|
|
74
|
+
const [busy, setBusy] = useState(false);
|
|
75
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
76
|
+
|
|
77
|
+
// On unmount it stops the request.
|
|
78
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
79
|
+
|
|
80
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
81
|
+
function handleClose() {
|
|
82
|
+
if (busy) return;
|
|
83
|
+
setTarget(null);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function handleConfirm() {
|
|
87
|
+
if (busy || !target) return;
|
|
88
|
+
const to = target;
|
|
89
|
+
setBusy(true);
|
|
90
|
+
// Stands in for the request to the server.
|
|
91
|
+
timer.current = setTimeout(() => {
|
|
92
|
+
setBusy(false);
|
|
93
|
+
setTarget(null);
|
|
94
|
+
if (rank[to] > rank[current]) {
|
|
95
|
+
setCurrent(to);
|
|
96
|
+
setScheduled(null);
|
|
97
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
98
|
+
} else {
|
|
99
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
100
|
+
setScheduled(to);
|
|
101
|
+
}
|
|
102
|
+
}, 1200);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const copy = target ? describe(current, target) : null;
|
|
106
|
+
const currentName = plans.find((p) => p.id === current)!.name;
|
|
107
|
+
|
|
108
|
+
return (
|
|
109
|
+
<Center width="page">
|
|
110
|
+
<SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
|
|
111
|
+
{/* Two or three plans side by side from md up, stacked on a phone. A card is not itself clickable. */}
|
|
112
|
+
<Grid columns={3}>
|
|
113
|
+
{plans.map((p) => (
|
|
114
|
+
<Surface key={p.id} padding="small">
|
|
115
|
+
<Stack gap="medium">
|
|
116
|
+
<Stack gap="small">
|
|
117
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
118
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
119
|
+
</Stack>
|
|
120
|
+
<List items={p.includes} size="body2" marker="dot" />
|
|
121
|
+
{p.id === current ? (
|
|
122
|
+
<Cluster><Tag variant="textOnly" size="small" label="Current plan" /></Cluster>
|
|
123
|
+
) : p.id === scheduled ? (
|
|
124
|
+
<Cluster><Tag variant="dot" size="small" label="Starts Dec 1" /></Cluster>
|
|
125
|
+
) : rank[p.id] > rank[current] ? (
|
|
126
|
+
<Cluster><Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
|
|
127
|
+
) : (
|
|
128
|
+
<Cluster><Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} /></Cluster>
|
|
129
|
+
)}
|
|
130
|
+
</Stack>
|
|
131
|
+
</Surface>
|
|
132
|
+
))}
|
|
133
|
+
</Grid>
|
|
134
|
+
</SettingsSection>
|
|
135
|
+
<Modal
|
|
136
|
+
isOpen={target !== null}
|
|
137
|
+
size="small"
|
|
138
|
+
title={copy?.title ?? ''}
|
|
139
|
+
onClose={handleClose}
|
|
140
|
+
actions={
|
|
141
|
+
<>
|
|
142
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
143
|
+
<Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
|
|
144
|
+
</>
|
|
145
|
+
}
|
|
146
|
+
>
|
|
147
|
+
<Paragraph measure="none">{copy?.body}</Paragraph>
|
|
148
|
+
{copy?.detail && (
|
|
149
|
+
<>
|
|
150
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
151
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
|
|
152
|
+
</>
|
|
153
|
+
)}
|
|
154
|
+
</Modal>
|
|
155
|
+
</Center>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Option: Rows in a settings column
|
|
161
|
+
|
|
162
|
+
Use when: The picker sits in a narrow settings column, or the plans have long lists of what they include.
|
|
163
|
+
|
|
164
|
+
Uses: `Button`, `Center`, `Cluster`, `Heading`, `List`, `Modal`, `Paragraph`, `SettingsSection`, `Stack`, `Surface`, `Tag`, `formatMoney`
|
|
165
|
+
|
|
166
|
+
```tsx
|
|
167
|
+
'use client';
|
|
168
|
+
import { useEffect, useRef, useState } from 'react';
|
|
169
|
+
import Modal from 'oneslash-design-system/components/modal';
|
|
170
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
171
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
172
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
173
|
+
import List from 'oneslash-design-system/components/list';
|
|
174
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
175
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
176
|
+
import Button from 'oneslash-design-system/components/button';
|
|
177
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
178
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
179
|
+
|
|
180
|
+
type PlanId = 'free' | 'pro' | 'business';
|
|
181
|
+
|
|
182
|
+
// Made-up plans. A real app reads them from the server, with the limits as numbers.
|
|
183
|
+
const plans: { id: PlanId; name: string; price: string; includes: string[] }[] = [
|
|
184
|
+
{ id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
185
|
+
{ id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
186
|
+
{ id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
187
|
+
];
|
|
188
|
+
|
|
189
|
+
const rank: Record<PlanId, number> = { free: 0, pro: 1, business: 2 };
|
|
190
|
+
|
|
191
|
+
// What the change costs. An upgrade charges now; a downgrade waits for the end of the period. A real app reads the amounts from the server.
|
|
192
|
+
function describe(from: PlanId, to: PlanId) {
|
|
193
|
+
const name = plans.find((p) => p.id === to)!.name;
|
|
194
|
+
if (rank[to] > rank[from]) {
|
|
195
|
+
// Three members, 15 of 30 days left in November: half of the first month today.
|
|
196
|
+
const today = to === 'pro' ? 12 : from === 'free' ? 24 : 12;
|
|
197
|
+
const monthly = to === 'pro' ? 24 : 48;
|
|
198
|
+
const body = `You pay ${formatMoney(today)} today for the 15 days left in November, then ${formatMoney(monthly)} each month.`;
|
|
199
|
+
return { title: `Upgrade to ${name}`, body, detail: false };
|
|
200
|
+
}
|
|
201
|
+
// A downgrade changes nothing today. It says when it starts and what stops.
|
|
202
|
+
return { title: `Downgrade to ${name}`, body: `${plans.find((p) => p.id === from)!.name} stays on until Dec 1, 2026. Acme is not charged again.`, detail: true };
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export default function PlanPickerList() {
|
|
206
|
+
const [current, setCurrent] = useState<PlanId>('pro');
|
|
207
|
+
const [scheduled, setScheduled] = useState<PlanId | null>(null);
|
|
208
|
+
const [target, setTarget] = useState<PlanId | null>(null);
|
|
209
|
+
const [busy, setBusy] = useState(false);
|
|
210
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
211
|
+
|
|
212
|
+
// On unmount it stops the request.
|
|
213
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
214
|
+
|
|
215
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
216
|
+
function handleClose() {
|
|
217
|
+
if (busy) return;
|
|
218
|
+
setTarget(null);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function handleConfirm() {
|
|
222
|
+
if (busy || !target) return;
|
|
223
|
+
const to = target;
|
|
224
|
+
setBusy(true);
|
|
225
|
+
// Stands in for the request to the server.
|
|
226
|
+
timer.current = setTimeout(() => {
|
|
227
|
+
setBusy(false);
|
|
228
|
+
setTarget(null);
|
|
229
|
+
if (rank[to] > rank[current]) {
|
|
230
|
+
setCurrent(to);
|
|
231
|
+
setScheduled(null);
|
|
232
|
+
// The plan line on the page says it: 'Acme is on Pro.' No toast.
|
|
233
|
+
} else {
|
|
234
|
+
// A downgrade changes nothing today, so the page says when it starts.
|
|
235
|
+
setScheduled(to);
|
|
236
|
+
}
|
|
237
|
+
}, 1200);
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const copy = target ? describe(current, target) : null;
|
|
241
|
+
const currentName = plans.find((p) => p.id === current)!.name;
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<Center width="page">
|
|
245
|
+
<SettingsSection title="Plan" description={scheduled ? `Acme is on ${currentName} until Dec 1, 2026, then ${plans.find((p) => p.id === scheduled)!.name}.` : `Acme is on ${currentName}.`}>
|
|
246
|
+
{/* Rows in the settings column. The plan and what it includes on the left, the one action on the right. */}
|
|
247
|
+
<Stack gap="medium">
|
|
248
|
+
{plans.map((p) => (
|
|
249
|
+
<Surface key={p.id} padding="small">
|
|
250
|
+
<Cluster justify="between" align="start" gap="medium">
|
|
251
|
+
<Stack gap="small">
|
|
252
|
+
<Cluster gap="small">
|
|
253
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
254
|
+
{p.id === current && <Tag variant="textOnly" size="small" label="Current plan" />}
|
|
255
|
+
{p.id === scheduled && <Tag variant="dot" size="small" label="Starts Dec 1" />}
|
|
256
|
+
</Cluster>
|
|
257
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
258
|
+
<List items={p.includes} size="body2" marker="dot" />
|
|
259
|
+
</Stack>
|
|
260
|
+
{p.id !== current && p.id !== scheduled && (
|
|
261
|
+
rank[p.id] > rank[current]
|
|
262
|
+
? <Button size="small" type="primary" state="enabled" label={`Upgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
|
|
263
|
+
: <Button size="small" type="tertiary" state="enabled" label={`Downgrade to ${p.name}`} onClickButton={() => setTarget(p.id)} />
|
|
264
|
+
)}
|
|
265
|
+
</Cluster>
|
|
266
|
+
</Surface>
|
|
267
|
+
))}
|
|
268
|
+
</Stack>
|
|
269
|
+
</SettingsSection>
|
|
270
|
+
<Modal
|
|
271
|
+
isOpen={target !== null}
|
|
272
|
+
size="small"
|
|
273
|
+
title={copy?.title ?? ''}
|
|
274
|
+
onClose={handleClose}
|
|
275
|
+
actions={
|
|
276
|
+
<>
|
|
277
|
+
<Button size="small" type="tertiary" state={busy ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose} />
|
|
278
|
+
<Button size="small" type="primary" state="enabled" label={copy?.title ?? ''} loading={busy} onClickButton={handleConfirm} />
|
|
279
|
+
</>
|
|
280
|
+
}
|
|
281
|
+
>
|
|
282
|
+
<Paragraph measure="none">{copy?.body}</Paragraph>
|
|
283
|
+
{copy?.detail && (
|
|
284
|
+
<>
|
|
285
|
+
<Paragraph tone="secondary" size="body2" measure="none">On Dec 1, 2026, Acme loses:</Paragraph>
|
|
286
|
+
<List size="body2" marker="dot" items={['More than 3 members.', 'More than 50 AI agent responses a month. Pro gives 1,000.', 'More than 1 GB of storage. Pro gives 50 GB.', 'Export to PDF.']} />
|
|
287
|
+
</>
|
|
288
|
+
)}
|
|
289
|
+
</Modal>
|
|
290
|
+
</Center>
|
|
291
|
+
);
|
|
292
|
+
}
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
## Native
|
|
296
|
+
|
|
297
|
+
On Apple use a `List` of plans with the system purchase sheet, and mark the current plan with a checkmark and the words 'Current plan'. Never build a card by hand.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PricingSectionCards(): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import PageShell from '../../components/pageShell';
|
|
3
|
+
import SectionIntro from '../../components/sectionIntro';
|
|
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 Button from '../../components/button';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import { Grid, PageSection, Stack } from '../../components/layout';
|
|
11
|
+
// The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.
|
|
12
|
+
var plans = [
|
|
13
|
+
{ id: 'free', name: 'Free', price: "".concat(formatMoney(0), " per month"), includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
14
|
+
{ 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'] },
|
|
15
|
+
{ 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'] },
|
|
16
|
+
];
|
|
17
|
+
export default function PricingSectionCards() {
|
|
18
|
+
return (<PageShell>
|
|
19
|
+
<PageSection gap="xxlarge">
|
|
20
|
+
<SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team."/>
|
|
21
|
+
<Stack gap="medium">
|
|
22
|
+
{/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
|
|
23
|
+
<Grid columns={3}>
|
|
24
|
+
{plans.map(function (p) { return (<Surface key={p.id} padding="medium">
|
|
25
|
+
<Stack gap="large">
|
|
26
|
+
<Stack gap="small">
|
|
27
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
28
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
29
|
+
</Stack>
|
|
30
|
+
<List items={p.includes} size="body2" marker="dot"/>
|
|
31
|
+
{/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}
|
|
32
|
+
<Button size="medium" type={p.id === 'pro' ? 'primary' : 'secondary'} state="enabled" label={"Sign Up for ".concat(p.name)} href={"https://acme.example/sign-up?plan=".concat(p.id)}/>
|
|
33
|
+
</Stack>
|
|
34
|
+
</Surface>); })}
|
|
35
|
+
</Grid>
|
|
36
|
+
<Paragraph tone="secondary" size="body2" measure="none">Prices in USD. Pro and Business bill each member monthly.</Paragraph>
|
|
37
|
+
</Stack>
|
|
38
|
+
</PageSection>
|
|
39
|
+
</PageShell>);
|
|
40
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Pricing section
|
|
2
|
+
|
|
3
|
+
A visitor to the public site compares the plans and signs up for one.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A marketing page asks for one main action, in the same words everywhere'.
|
|
8
|
+
- Show the same plans as the case 'Plan picker', word for word: the names, the prices and what each includes. A price comes from `formatMoney`, as the rule 'A number shows its unit and never shows 0 for unknown' says.
|
|
9
|
+
- Make each plan a `Surface` with its name as a level 3 heading, its price, a `List` of what it includes and one `Button`. Put them in `Grid columns={3}`, which stacks them on a phone.
|
|
10
|
+
- Name each Button for the plan: 'Sign Up for Free', 'Sign Up for Pro', 'Sign Up for Business'. Give it an `href` to the sign-up page with the plan in the address, so it works as a link.
|
|
11
|
+
- Make the Button of the plan most visitors start on primary, and the others secondary. A visitor has no current plan, so no card carries 'Current plan'.
|
|
12
|
+
- Put the section's name in `SectionIntro`, so the section has a level 2 heading and a link of its own.
|
|
13
|
+
- Put one line under the cards that says what the prices are in and who pays: 'Prices in USD. Pro and Business bill each member monthly.'
|
|
14
|
+
- Add a `SegmentedControl` for monthly and yearly as the case 'Range switch' says once a plan bills by the year. Leave it out while every plan bills monthly.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not name a Button 'Get Started', 'Choose' or 'Select'. Name the plan it signs up for.
|
|
19
|
+
- Do not open the sign-up page in a new tab.
|
|
20
|
+
- Do not give two plans a primary Button.
|
|
21
|
+
- Do not change a price or a limit here without changing it in the case 'Plan picker' too. A visitor sees one set of plans.
|
|
22
|
+
- Do not make a card clickable as a whole. Its Button is the one control.
|
|
23
|
+
|
|
24
|
+
## Example: Plan cards side by side
|
|
25
|
+
|
|
26
|
+
Uses: `Button`, `Grid`, `Heading`, `List`, `PageSection`, `PageShell`, `Paragraph`, `SectionIntro`, `Stack`, `Surface`, `formatMoney`
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
'use client';
|
|
30
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
31
|
+
import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
32
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
33
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
34
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
35
|
+
import List from 'oneslash-design-system/components/list';
|
|
36
|
+
import Button from 'oneslash-design-system/components/button';
|
|
37
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
38
|
+
import { Grid, PageSection, Stack } from 'oneslash-design-system/components/layout';
|
|
39
|
+
|
|
40
|
+
// The same plans as the case 'Plan picker': names, prices and what each includes. A real site reads them from one place.
|
|
41
|
+
const plans = [
|
|
42
|
+
{ id: 'free', name: 'Free', price: `${formatMoney(0)} per month`, includes: ['3 members', '50 AI agent responses a month', '1 GB of storage'] },
|
|
43
|
+
{ id: 'pro', name: 'Pro', price: `${formatMoney(8)} per member per month`, includes: ['Unlimited members', '1,000 AI agent responses a month', '50 GB of storage', 'Export to PDF'] },
|
|
44
|
+
{ id: 'business', name: 'Business', price: `${formatMoney(16)} per member per month`, includes: ['Unlimited members', '10,000 AI agent responses a month', '500 GB of storage', 'Export to PDF', 'Priority support'] },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
export default function PricingSectionCards() {
|
|
48
|
+
return (
|
|
49
|
+
<PageShell>
|
|
50
|
+
<PageSection gap="xxlarge">
|
|
51
|
+
<SectionIntro id="pricing" name="Pricing" statement="Pick the plan that fits your team." />
|
|
52
|
+
<Stack gap="medium">
|
|
53
|
+
{/* Three across from md, stacked on a phone. A visitor has no current plan, so each plan asks to sign up. */}
|
|
54
|
+
<Grid columns={3}>
|
|
55
|
+
{plans.map((p) => (
|
|
56
|
+
<Surface key={p.id} padding="medium">
|
|
57
|
+
<Stack gap="large">
|
|
58
|
+
<Stack gap="small">
|
|
59
|
+
<Heading level={3} size="h6">{p.name}</Heading>
|
|
60
|
+
<Paragraph tone="secondary" size="body2" measure="none">{p.price}</Paragraph>
|
|
61
|
+
</Stack>
|
|
62
|
+
<List items={p.includes} size="body2" marker="dot" />
|
|
63
|
+
{/* The one primary Button is the plan to start with. Each is a link, so it works without a script. */}
|
|
64
|
+
<Button
|
|
65
|
+
size="medium"
|
|
66
|
+
type={p.id === 'pro' ? 'primary' : 'secondary'}
|
|
67
|
+
state="enabled"
|
|
68
|
+
label={`Sign Up for ${p.name}`}
|
|
69
|
+
href={`https://acme.example/sign-up?plan=${p.id}`}
|
|
70
|
+
/>
|
|
71
|
+
</Stack>
|
|
72
|
+
</Surface>
|
|
73
|
+
))}
|
|
74
|
+
</Grid>
|
|
75
|
+
<Paragraph tone="secondary" size="body2" measure="none">Prices in USD. Pro and Business bill each member monthly.</Paragraph>
|
|
76
|
+
</Stack>
|
|
77
|
+
</PageSection>
|
|
78
|
+
</PageShell>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Native
|
|
84
|
+
|
|
85
|
+
On Apple an app has no pricing section. The plans are in the app as a `List` with the system purchase sheet, as the case 'Plan picker' says.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ProductCardsGrid(): import("react").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import PageShell from '../../components/pageShell';
|
|
3
|
+
import SectionIntro from '../../components/sectionIntro';
|
|
4
|
+
import LinkCard from '../../components/linkCard';
|
|
5
|
+
import { Grid, PageSection } from '../../components/layout';
|
|
6
|
+
// Stand-ins for a picture of each product. A real page passes a screenshot or the product's mark.
|
|
7
|
+
var notesPicture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23efe9df'/%3E%3Crect x='200' y='50' width='240' height='260' rx='14' fill='%23ffffff'/%3E%3Crect x='224' y='84' width='120' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='224' y='116' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='142' width='170' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='168' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='194' width='110' height='10' rx='5' fill='%23dfe7ef'/%3E%3C/svg%3E";
|
|
8
|
+
var tasksPicture = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23e6efe9'/%3E%3Crect x='180' y='60' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='134' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='208' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='198' y='78' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='152' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='226' width='16' height='16' rx='4' fill='%23aab8c6'/%3E%3Crect x='230' y='82' width='160' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='156' width='120' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='230' width='140' height='8' rx='4' fill='%23dfe7ef'/%3E%3C/svg%3E";
|
|
9
|
+
export default function ProductCardsGrid() {
|
|
10
|
+
return (<PageShell>
|
|
11
|
+
<PageSection gap="xxlarge">
|
|
12
|
+
<SectionIntro id="products" name="Products" statement="Apps from Acme, each with its own site."/>
|
|
13
|
+
{/* Two across from md, one on a phone. Each card is one link to the product's own site, in a new tab, and says so to a screen reader. */}
|
|
14
|
+
<Grid columns={2}>
|
|
15
|
+
<LinkCard href="https://notes.acme.example" title="Acme Notes" description="Write a thing down once and find it again." caption="Notes app" image={{ src: notesPicture, alt: '' }} external/>
|
|
16
|
+
<LinkCard href="https://tasks.acme.example" title="Acme Tasks" description="A short list for today, and a long one for later." caption="Task app" image={{ src: tasksPicture, alt: '' }} external/>
|
|
17
|
+
</Grid>
|
|
18
|
+
</PageSection>
|
|
19
|
+
</PageShell>);
|
|
20
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Product cards
|
|
2
|
+
|
|
3
|
+
A maker lists its products on one page, and each product has its own site.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. A list of products has no main action of its own: each card is a link, not a Button.
|
|
8
|
+
- Use `LinkCard` with `image`, `title`, `description` and `caption`, in `Grid columns={2}`.
|
|
9
|
+
- Pass `external`. The list stays open in its tab while the product opens in another, and a screen reader hears that the link opens in a new tab. This follows the case 'Site footer': a link to another site opens in a new tab and says so.
|
|
10
|
+
- Give each product a title that is its name, a description of one short line, and a caption that says what kind of product it is.
|
|
11
|
+
- Pass `alt: ''` for the picture when the title names the product, so a screen reader does not say it twice. Otherwise say what the picture shows.
|
|
12
|
+
- Open the section with `SectionIntro`, such as 'Products'.
|
|
13
|
+
- Keep to six cards or fewer.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not put a Button inside a card. The card is the link.
|
|
18
|
+
- Do not link only the title or only the picture.
|
|
19
|
+
- Do not name the link 'Learn more'. The title is the name.
|
|
20
|
+
- Do not open a link to a page of your own site in a new tab.
|
|
21
|
+
|
|
22
|
+
## Example: Cards in a grid
|
|
23
|
+
|
|
24
|
+
Uses: `Grid`, `LinkCard`, `PageSection`, `PageShell`, `SectionIntro`
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
'use client';
|
|
28
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
29
|
+
import SectionIntro from 'oneslash-design-system/components/sectionIntro';
|
|
30
|
+
import LinkCard from 'oneslash-design-system/components/linkCard';
|
|
31
|
+
import { Grid, PageSection } from 'oneslash-design-system/components/layout';
|
|
32
|
+
|
|
33
|
+
// Stand-ins for a picture of each product. A real page passes a screenshot or the product's mark.
|
|
34
|
+
const notesPicture =
|
|
35
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23efe9df'/%3E%3Crect x='200' y='50' width='240' height='260' rx='14' fill='%23ffffff'/%3E%3Crect x='224' y='84' width='120' height='12' rx='6' fill='%23aab8c6'/%3E%3Crect x='224' y='116' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='142' width='170' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='168' width='190' height='10' rx='5' fill='%23dfe7ef'/%3E%3Crect x='224' y='194' width='110' height='10' rx='5' fill='%23dfe7ef'/%3E%3C/svg%3E";
|
|
36
|
+
const tasksPicture =
|
|
37
|
+
"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 640 360'%3E%3Crect width='640' height='360' fill='%23e6efe9'/%3E%3Crect x='180' y='60' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='134' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='180' y='208' width='280' height='52' rx='12' fill='%23ffffff'/%3E%3Crect x='198' y='78' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='152' width='16' height='16' rx='4' fill='%232f6b4f'/%3E%3Crect x='198' y='226' width='16' height='16' rx='4' fill='%23aab8c6'/%3E%3Crect x='230' y='82' width='160' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='156' width='120' height='8' rx='4' fill='%23dfe7ef'/%3E%3Crect x='230' y='230' width='140' height='8' rx='4' fill='%23dfe7ef'/%3E%3C/svg%3E";
|
|
38
|
+
|
|
39
|
+
export default function ProductCardsGrid() {
|
|
40
|
+
return (
|
|
41
|
+
<PageShell>
|
|
42
|
+
<PageSection gap="xxlarge">
|
|
43
|
+
<SectionIntro id="products" name="Products" statement="Apps from Acme, each with its own site." />
|
|
44
|
+
{/* Two across from md, one on a phone. Each card is one link to the product's own site, in a new tab, and says so to a screen reader. */}
|
|
45
|
+
<Grid columns={2}>
|
|
46
|
+
<LinkCard
|
|
47
|
+
href="https://notes.acme.example"
|
|
48
|
+
title="Acme Notes"
|
|
49
|
+
description="Write a thing down once and find it again."
|
|
50
|
+
caption="Notes app"
|
|
51
|
+
image={{ src: notesPicture, alt: '' }}
|
|
52
|
+
external
|
|
53
|
+
/>
|
|
54
|
+
<LinkCard
|
|
55
|
+
href="https://tasks.acme.example"
|
|
56
|
+
title="Acme Tasks"
|
|
57
|
+
description="A short list for today, and a long one for later."
|
|
58
|
+
caption="Task app"
|
|
59
|
+
image={{ src: tasksPicture, alt: '' }}
|
|
60
|
+
external
|
|
61
|
+
/>
|
|
62
|
+
</Grid>
|
|
63
|
+
</PageSection>
|
|
64
|
+
</PageShell>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Native
|
|
70
|
+
|
|
71
|
+
On Apple use a `Link` in a `List` row with an `Image`, which opens Safari. On Android use a card that opens a custom tab.
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import Heading from '../../components/heading';
|
|
4
|
-
import
|
|
4
|
+
import StatTile from '../../components/statTile';
|
|
5
5
|
import SegmentedControl from '../../components/segmentedControl';
|
|
6
|
-
import { Center, Cluster, Stack } from '../../components/layout';
|
|
6
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
7
7
|
// A real app counts these on the server.
|
|
8
8
|
var ranges = [
|
|
9
|
-
{ value: 'week', label: 'Week',
|
|
10
|
-
{ value: 'month', label: 'Month',
|
|
11
|
-
{ value: 'quarter', label: 'Quarter',
|
|
9
|
+
{ value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
|
|
10
|
+
{ value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
|
|
11
|
+
{ value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
|
|
12
12
|
];
|
|
13
13
|
export default function RangeSwitchSegmented() {
|
|
14
14
|
var _a;
|
|
@@ -23,8 +23,12 @@ export default function RangeSwitchSegmented() {
|
|
|
23
23
|
return ({ value: value, label: label });
|
|
24
24
|
})} value={range} onChange={setRange}/>
|
|
25
25
|
</Cluster>
|
|
26
|
-
{/* The
|
|
27
|
-
<
|
|
26
|
+
{/* The numbers change with the range. This page stays the same. */}
|
|
27
|
+
<Grid compact columns={3}>
|
|
28
|
+
<StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period}/>
|
|
29
|
+
<StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period}/>
|
|
30
|
+
<StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period}/>
|
|
31
|
+
</Grid>
|
|
28
32
|
</Stack>
|
|
29
33
|
</Center>);
|
|
30
34
|
}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
# Range switch
|
|
2
2
|
|
|
3
|
-
A person changes the time range of
|
|
3
|
+
A person changes the time range of the numbers or a list on the same page, such as Week, Month or Quarter.
|
|
4
4
|
|
|
5
5
|
## Do
|
|
6
6
|
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
7
8
|
- Use `SegmentedControl` with `size="small"` and `aria-label="Range"`: 'Week', 'Month', 'Quarter'.
|
|
8
|
-
- Put it beside the heading of the
|
|
9
|
+
- Put it beside the heading of the numbers or list it changes, with `width="fit"` so it is as wide as its options.
|
|
9
10
|
- Keep one option on at all times. Start on 'Week', the newest numbers, unless the page is about a longer period.
|
|
10
11
|
- Change the numbers in place and keep the page, the heading and the scroll position.
|
|
11
12
|
- Move between options with the arrow keys. They select as they move.
|
|
@@ -19,21 +20,21 @@ A person changes the time range of a chart or a list on the same page, such as W
|
|
|
19
20
|
|
|
20
21
|
## Example: Segmented control
|
|
21
22
|
|
|
22
|
-
Uses: `Center`, `Cluster`, `
|
|
23
|
+
Uses: `Center`, `Cluster`, `Grid`, `Heading`, `SegmentedControl`, `Stack`, `StatTile`
|
|
23
24
|
|
|
24
25
|
```tsx
|
|
25
26
|
'use client';
|
|
26
27
|
import { useState } from 'react';
|
|
27
28
|
import Heading from 'oneslash-design-system/components/heading';
|
|
28
|
-
import
|
|
29
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
29
30
|
import SegmentedControl from 'oneslash-design-system/components/segmentedControl';
|
|
30
|
-
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
31
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
31
32
|
|
|
32
33
|
// A real app counts these on the server.
|
|
33
|
-
const ranges = [
|
|
34
|
-
{ value: 'week', label: 'Week',
|
|
35
|
-
{ value: 'month', label: 'Month',
|
|
36
|
-
{ value: 'quarter', label: 'Quarter',
|
|
34
|
+
const ranges: { value: string; label: string; period: 'week' | 'month' | 'quarter'; comments: number[]; done: number[]; people: number[] }[] = [
|
|
35
|
+
{ value: 'week', label: 'Week', period: 'week', comments: [18, 15], done: [11, 12], people: [7, 7] },
|
|
36
|
+
{ value: 'month', label: 'Month', period: 'month', comments: [64, 52], done: [40, 41], people: [12, 10] },
|
|
37
|
+
{ value: 'quarter', label: 'Quarter', period: 'quarter', comments: [171, 160], done: [118, 109], people: [19, 21] },
|
|
37
38
|
];
|
|
38
39
|
|
|
39
40
|
export default function RangeSwitchSegmented() {
|
|
@@ -54,8 +55,12 @@ export default function RangeSwitchSegmented() {
|
|
|
54
55
|
onChange={setRange}
|
|
55
56
|
/>
|
|
56
57
|
</Cluster>
|
|
57
|
-
{/* The
|
|
58
|
-
<
|
|
58
|
+
{/* The numbers change with the range. This page stays the same. */}
|
|
59
|
+
<Grid compact columns={3}>
|
|
60
|
+
<StatTile label="New comments" value={current.comments[0]} previous={current.comments[1]} period={current.period} />
|
|
61
|
+
<StatTile label="Marked done" value={current.done[0]} previous={current.done[1]} period={current.period} />
|
|
62
|
+
<StatTile label="People engaged" value={current.people[0]} previous={current.people[1]} period={current.period} />
|
|
63
|
+
</Grid>
|
|
59
64
|
</Stack>
|
|
60
65
|
</Center>
|
|
61
66
|
);
|