oneslash-design-system 2.23.1 → 2.25.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 +20 -5
- package/dist/cases/activity-timeline/activity.d.ts +1 -0
- package/dist/cases/activity-timeline/activity.jsx +43 -0
- package/dist/cases/activity-timeline/versions.d.ts +1 -0
- package/dist/cases/activity-timeline/versions.jsx +130 -0
- package/dist/cases/activity-timeline.md +315 -0
- package/dist/cases/agent-plan-proposal.md +1 -0
- package/dist/cases/ask-page/answered.d.ts +1 -0
- package/dist/cases/ask-page/answered.jsx +248 -0
- package/dist/cases/ask-page/first-visit.d.ts +1 -0
- package/dist/cases/ask-page/first-visit.jsx +118 -0
- package/dist/cases/ask-page.md +551 -0
- package/dist/cases/billing-page/self-serve.jsx +4 -4
- package/dist/cases/billing-page/trial.d.ts +1 -0
- package/dist/cases/billing-page/trial.jsx +115 -0
- package/dist/cases/billing-page.md +166 -5
- package/dist/cases/chart/bars.d.ts +1 -0
- package/dist/cases/chart/bars.jsx +83 -0
- package/dist/cases/chart/lines.d.ts +1 -0
- package/dist/cases/chart/lines.jsx +71 -0
- package/dist/cases/chart.md +258 -0
- package/dist/cases/collapsible-search/popover.jsx +1 -1
- package/dist/cases/collapsible-search.md +2 -2
- package/dist/cases/comment-thread/card.d.ts +1 -0
- package/dist/cases/comment-thread/card.jsx +141 -0
- package/dist/cases/comment-thread/thread.d.ts +1 -0
- package/dist/cases/comment-thread/thread.jsx +87 -0
- package/dist/cases/comment-thread.md +349 -0
- package/dist/cases/cookie-choice/banner.d.ts +1 -0
- package/dist/cases/cookie-choice/banner.jsx +82 -0
- package/dist/cases/cookie-choice/settings.d.ts +1 -0
- package/dist/cases/cookie-choice/settings.jsx +75 -0
- package/dist/cases/cookie-choice.md +234 -0
- package/dist/cases/dashboard/numbers-first.jsx +63 -2
- package/dist/cases/dashboard/work-first.jsx +1 -1
- package/dist/cases/dashboard.md +77 -5
- package/dist/cases/data-table-page/all-rows.jsx +1 -1
- package/dist/cases/data-table-page/paged.jsx +1 -1
- package/dist/cases/data-table-page.md +2 -2
- package/dist/cases/invoice-list/table.jsx +21 -9
- package/dist/cases/invoice-list.md +27 -12
- package/dist/cases/leaderboard/ranked.d.ts +1 -0
- package/dist/cases/leaderboard/ranked.jsx +44 -0
- package/dist/cases/leaderboard/table.d.ts +1 -0
- package/dist/cases/leaderboard/table.jsx +87 -0
- package/dist/cases/leaderboard.md +177 -0
- package/dist/cases/message-reactions/picker.jsx +1 -1
- package/dist/cases/message-reactions.md +2 -2
- package/dist/cases/message-row.md +2 -1
- package/dist/cases/newsletter-signup/inline.d.ts +1 -0
- package/dist/cases/newsletter-signup/inline.jsx +72 -0
- package/dist/cases/newsletter-signup/section.d.ts +1 -0
- package/dist/cases/newsletter-signup/section.jsx +72 -0
- package/dist/cases/newsletter-signup.md +234 -0
- package/dist/cases/number-format.md +9 -3
- package/dist/cases/onboarding/checklist.d.ts +1 -0
- package/dist/cases/onboarding/checklist.jsx +92 -0
- package/dist/cases/onboarding/steps.d.ts +3 -0
- package/dist/cases/onboarding/steps.jsx +177 -0
- package/dist/cases/onboarding.md +368 -0
- package/dist/cases/people-row/stack.jsx +1 -1
- package/dist/cases/people-row.md +2 -2
- package/dist/cases/plan-comparison/table.d.ts +1 -0
- package/dist/cases/plan-comparison/table.jsx +47 -0
- package/dist/cases/plan-comparison.md +94 -0
- package/dist/cases/plan-picker.md +1 -0
- package/dist/cases/plan-sign-off/one-approver.d.ts +1 -0
- package/dist/cases/plan-sign-off/one-approver.jsx +129 -0
- package/dist/cases/plan-sign-off/team.d.ts +1 -0
- package/dist/cases/plan-sign-off/team.jsx +213 -0
- package/dist/cases/plan-sign-off.md +541 -0
- package/dist/cases/pricing-section.md +1 -1
- package/dist/cases/site-footer/columns.jsx +2 -1
- package/dist/cases/site-footer.md +3 -1
- package/dist/cases/stat-row/tiles.jsx +2 -1
- package/dist/cases/stat-row.md +5 -2
- package/dist/cases/task-header/agent-sets-status.d.ts +1 -0
- package/dist/cases/task-header/agent-sets-status.jsx +164 -0
- package/dist/cases/task-header/people-change-status.d.ts +1 -0
- package/dist/cases/task-header/people-change-status.jsx +175 -0
- package/dist/cases/task-header.md +576 -0
- package/dist/cases.json +883 -30
- package/dist/components/alert.d.ts +3 -1
- package/dist/components/alert.jsx +5 -5
- package/dist/components/barChart.d.ts +35 -0
- package/dist/components/barChart.jsx +92 -0
- package/dist/components/dateField.jsx +1 -1
- package/dist/components/formatNumber.d.ts +10 -2
- package/dist/components/formatNumber.js +44 -9
- package/dist/components/heading.d.ts +2 -2
- package/dist/components/heading.jsx +5 -3
- package/dist/components/layout.d.ts +4 -2
- package/dist/components/layout.jsx +13 -2
- package/dist/components/lineChart.d.ts +39 -0
- package/dist/components/lineChart.jsx +128 -0
- package/dist/components/markdown.d.ts +24 -0
- package/dist/components/markdown.jsx +81 -0
- package/dist/components/pageShell.d.ts +3 -3
- package/dist/components/pageShell.jsx +6 -5
- package/dist/components/popover.d.ts +5 -1
- package/dist/components/popover.jsx +3 -2
- package/dist/components/progress.jsx +1 -1
- package/dist/components/select.jsx +5 -2
- package/dist/components/statTile.d.ts +1 -1
- package/dist/components/statTile.jsx +7 -2
- package/dist/components/tableCell.d.ts +4 -3
- package/dist/components/tableCell.jsx +2 -2
- package/dist/components/timeline.d.ts +32 -0
- package/dist/components/timeline.jsx +54 -0
- package/dist/components/titleBar.d.ts +3 -1
- package/dist/components/titleBar.jsx +9 -4
- package/dist/components/toaster.jsx +81 -11
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/chart.d.ts +39 -0
- package/dist/internal/chart.js +110 -0
- package/dist/internal/chartFrame.d.ts +29 -0
- package/dist/internal/chartFrame.jsx +57 -0
- package/dist/internal/markdown.d.ts +40 -0
- package/dist/internal/markdown.js +577 -0
- package/dist/internal/toaster.d.ts +2 -0
- package/dist/internal/toaster.js +8 -0
- package/dist/native-mapping.json +28 -4
- package/dist/stories/BarChart.stories.d.ts +10 -0
- package/dist/stories/BarChart.stories.jsx +104 -0
- package/dist/stories/Cases.generated.stories.d.ts +22 -0
- package/dist/stories/Cases.generated.stories.jsx +44 -0
- package/dist/stories/Heading.stories.d.ts +1 -0
- package/dist/stories/Heading.stories.jsx +17 -0
- package/dist/stories/LineChart.stories.d.ts +9 -0
- package/dist/stories/LineChart.stories.jsx +34 -0
- package/dist/stories/Markdown.stories.d.ts +9 -0
- package/dist/stories/Markdown.stories.jsx +66 -0
- package/dist/stories/Onboarding.probe.stories.d.ts +6 -0
- package/dist/stories/Onboarding.probe.stories.jsx +12 -0
- package/dist/stories/Popover.stories.d.ts +2 -0
- package/dist/stories/Popover.stories.jsx +33 -0
- package/dist/stories/StatTile.stories.d.ts +4 -0
- package/dist/stories/StatTile.stories.jsx +47 -2
- package/dist/stories/Timeline.stories.d.ts +8 -0
- package/dist/stories/Timeline.stories.jsx +49 -0
- package/dist/stories/TitleBar.stories.d.ts +1 -0
- package/dist/stories/TitleBar.stories.jsx +13 -0
- package/dist/stories/Toaster.stories.d.ts +4 -0
- package/dist/stories/Toaster.stories.jsx +30 -0
- package/package.json +1 -1
|
@@ -7,7 +7,9 @@ A billing page lists what the workspace has paid, so an admin can find an invoic
|
|
|
7
7
|
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
8
|
- Show a `TableContainer` named 'Invoices', with `minWidth`, and the columns Date, Description, Amount, Status and Download.
|
|
9
9
|
- Write the amount exactly, with `formatMoney`, in a right-aligned column with a right-aligned header: '$24.00'.
|
|
10
|
-
- Show the status as the case 'Status in a row' says: 'Paid' and '
|
|
10
|
+
- Show the status as the case 'Status in a row' says: 'Paid', 'Refunded' and a refund's 'Issued' as `Tag variant="textOnly"`, and 'Past due' as a dot.
|
|
11
|
+
- Show a refund as its own row: what it refunds, the amount with a minus, and the day it was made. Mark a charge 'Refunded' only when all of it came back.
|
|
12
|
+
- Write a refund row as 'Refund for Pro plan, Aug 2026' with '-$24.00', or 'Refund for 15 days of Pro, Oct 2026' with '-$12.00' while its charge stays 'Paid'. Put it above the charge it refunds.
|
|
11
13
|
- Show the newest first. Add `Pagination` named 'Invoice pages' past 12 invoices, and show none under that.
|
|
12
14
|
- Give each 'Download' link a name with the date: 'Download invoice for Nov 1, 2026, opens in a new tab'. Use `Button` with `type="tertiary"`, `href` and `openInNewTab`, with an external-link `actionIcon`.
|
|
13
15
|
- Put an upcoming charge in the first row with an 'Upcoming' `Tag variant="dot" color="info"`. Give it no Download link, because no invoice exists yet.
|
|
@@ -18,7 +20,7 @@ A billing page lists what the workspace has paid, so an admin can find an invoic
|
|
|
18
20
|
|
|
19
21
|
## Don't
|
|
20
22
|
|
|
21
|
-
- Do not show the amount as '$24' or '24.00'. A table shows the exact amount, with its symbol and
|
|
23
|
+
- Do not show the amount as '$24' or '24.00'. A table shows the exact amount, with its symbol and its currency's decimals.
|
|
22
24
|
- Do not show a card number, even a part of it, in an invoice row.
|
|
23
25
|
- Do not make the upcoming charge look like a paid invoice, or leave it out of the table when it differs from the plan price.
|
|
24
26
|
- Do not name every Download link 'Download'. A screen reader lists the links apart from their rows.
|
|
@@ -48,17 +50,30 @@ import TableCell from 'oneslash-design-system/components/tableCell';
|
|
|
48
50
|
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
49
51
|
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
50
52
|
|
|
51
|
-
|
|
53
|
+
// A refund is a row of its own, with a minus. A charge reads 'Refunded' only when all of it came back.
|
|
54
|
+
type Invoice = { id: string; kind: 'charge' | 'refund'; date: string; description: string; amount: number; status: 'Paid' | 'Refunded' | 'Issued' };
|
|
52
55
|
|
|
53
56
|
// A real app reads these from the server, newest first.
|
|
54
57
|
const months = ['Nov 1, 2026', 'Oct 1, 2026', 'Sep 1, 2026', 'Aug 1, 2026', 'Jul 1, 2026', 'Jun 1, 2026', 'May 1, 2026', 'Apr 1, 2026', 'Mar 1, 2026', 'Feb 1, 2026', 'Jan 1, 2026', 'Dec 1, 2025', 'Nov 1, 2025', 'Oct 1, 2025'];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
date,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// Each refund by the charge it refunds: all of August, and 15 days of October.
|
|
59
|
+
const refunds: Record<string, Invoice> = {
|
|
60
|
+
'Aug 1, 2026': { id: 'ref-0', kind: 'refund', date: 'Aug 6, 2026', description: 'Refund for Pro plan, Aug 2026', amount: -24, status: 'Issued' },
|
|
61
|
+
'Oct 1, 2026': { id: 'ref-1', kind: 'refund', date: 'Oct 16, 2026', description: 'Refund for 15 days of Pro, Oct 2026', amount: -12, status: 'Issued' },
|
|
62
|
+
};
|
|
63
|
+
const invoices: Invoice[] = months.flatMap((date, i): Invoice[] => {
|
|
64
|
+
const amount = 24;
|
|
65
|
+
const charge: Invoice = {
|
|
66
|
+
id: `inv-${i}`,
|
|
67
|
+
kind: 'charge',
|
|
68
|
+
date,
|
|
69
|
+
description: `Pro plan, ${date.split(' ')[0]} ${date.split(', ')[1]}`,
|
|
70
|
+
amount,
|
|
71
|
+
// Refunded in full, or still Paid when only part came back
|
|
72
|
+
status: refunds[date] && -refunds[date].amount === amount ? 'Refunded' : 'Paid',
|
|
73
|
+
};
|
|
74
|
+
// The refund came later, so it sits above its charge
|
|
75
|
+
return refunds[date] ? [refunds[date], charge] : [charge];
|
|
76
|
+
});
|
|
62
77
|
|
|
63
78
|
const PAGE_SIZE = 12;
|
|
64
79
|
|
|
@@ -90,7 +105,7 @@ export default function InvoiceListTable() {
|
|
|
90
105
|
<TableRow key={inv.id}>
|
|
91
106
|
<TableCell width="130px">{inv.date}</TableCell>
|
|
92
107
|
<TableCell>{inv.description}</TableCell>
|
|
93
|
-
{/* A table shows the exact amount, right-aligned. */}
|
|
108
|
+
{/* A table shows the exact amount, right-aligned. A refund has a minus: '-$24.00'. */}
|
|
94
109
|
<TableCell width="100px" align="right">{formatMoney(inv.amount)}</TableCell>
|
|
95
110
|
<TableCell width="110px">
|
|
96
111
|
<Tag variant="textOnly" size="small" label={inv.status} />
|
|
@@ -102,7 +117,7 @@ export default function InvoiceListTable() {
|
|
|
102
117
|
type="tertiary"
|
|
103
118
|
state="enabled"
|
|
104
119
|
label="Download"
|
|
105
|
-
aria-label={`Download invoice for ${inv.date}, opens in a new tab`}
|
|
120
|
+
aria-label={`Download ${inv.kind === 'refund' ? 'refund' : 'invoice'} for ${inv.date}, opens in a new tab`}
|
|
106
121
|
actionIcon="ExternalLink"
|
|
107
122
|
href={`https://acme.example/invoices/${inv.id}.pdf`}
|
|
108
123
|
openInNewTab
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LeaderboardRanked(): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import SettingsSection from '../../components/settingsSection';
|
|
4
|
+
import List from '../../components/list';
|
|
5
|
+
import UserImage from '../../components/userImage';
|
|
6
|
+
import Paragraph from '../../components/paragraph';
|
|
7
|
+
import Link from '../../components/link';
|
|
8
|
+
import { formatChange, formatCount } from '../../components/formatNumber';
|
|
9
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
10
|
+
// A real app counts these on the server, largest first. `previous` is last week's count.
|
|
11
|
+
// The table example has a tie for second; this list has none, since its numbers are the ranks.
|
|
12
|
+
var people = [
|
|
13
|
+
{ name: 'Omar Reyes', comments: 58, previous: 52 },
|
|
14
|
+
{ name: 'Ben Carter', comments: 42, previous: 0 },
|
|
15
|
+
{ name: 'Mia Park', comments: 37, previous: 41 },
|
|
16
|
+
{ name: 'Dana Lee', comments: 30, previous: 30 },
|
|
17
|
+
{ name: 'Leo Grant', comments: 21, previous: 14 },
|
|
18
|
+
{ name: 'Ana Silva', comments: 9, previous: 12 },
|
|
19
|
+
];
|
|
20
|
+
var top = people.slice(0, 5);
|
|
21
|
+
export default function LeaderboardRanked() {
|
|
22
|
+
return (<Center width="page">
|
|
23
|
+
<Stack gap="xlarge">
|
|
24
|
+
<Heading level={1} size="h5">Dashboard</Heading>
|
|
25
|
+
<SettingsSection title="Most active this week" description="Comments each person left from Nov 10 to Nov 16, 2026" id="leaderboard-ranked-people">
|
|
26
|
+
<Stack gap="large">
|
|
27
|
+
{/* The list's numbers are the ranks. The count and the change say the rest, so there are no bars. */}
|
|
28
|
+
<List marker="number" items={top.map(function (p) { return (<Cluster key={p.name} justify="between" gap="small">
|
|
29
|
+
<Cluster gap="small">
|
|
30
|
+
<UserImage userHandle={p.name} decorative size={24}/>
|
|
31
|
+
<Paragraph measure="none">{p.name}</Paragraph>
|
|
32
|
+
</Cluster>
|
|
33
|
+
<Cluster gap="small">
|
|
34
|
+
<Paragraph measure="none">{"".concat(formatCount(p.comments), " ").concat(p.comments === 1 ? 'comment' : 'comments')}</Paragraph>
|
|
35
|
+
<Paragraph size="body2" tone="secondary" measure="none">{formatChange(p.comments, p.previous, 'week').text}</Paragraph>
|
|
36
|
+
</Cluster>
|
|
37
|
+
</Cluster>); })}/>
|
|
38
|
+
{/* A real app goes to the table of everyone. */}
|
|
39
|
+
<Link href="/people" size="body2">See All People</Link>
|
|
40
|
+
</Stack>
|
|
41
|
+
</SettingsSection>
|
|
42
|
+
</Stack>
|
|
43
|
+
</Center>);
|
|
44
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function LeaderboardTable(): import("react").JSX.Element;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
22
|
+
import { useState } from 'react';
|
|
23
|
+
import Heading from '../../components/heading';
|
|
24
|
+
import SettingsSection from '../../components/settingsSection';
|
|
25
|
+
import UserImage from '../../components/userImage';
|
|
26
|
+
import Paragraph from '../../components/paragraph';
|
|
27
|
+
import Pagination from '../../components/pagination';
|
|
28
|
+
import TableContainer from '../../components/tableContainer';
|
|
29
|
+
import TableHeader from '../../components/tableHeader';
|
|
30
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
31
|
+
import TableRow from '../../components/tableRow';
|
|
32
|
+
import TableCell from '../../components/tableCell';
|
|
33
|
+
import { formatChange, formatCount } from '../../components/formatNumber';
|
|
34
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
35
|
+
// A real app counts these on the server. `previous` is last week's count of comments.
|
|
36
|
+
var people = [
|
|
37
|
+
{ name: 'Ben Carter', comments: 42, replies: 31, previous: 0 },
|
|
38
|
+
{ name: 'Omar Reyes', comments: 58, replies: 44, previous: 52 },
|
|
39
|
+
{ name: 'Ana Silva', comments: 9, replies: 15, previous: 12 },
|
|
40
|
+
{ name: 'Mia Park', comments: 42, replies: 18, previous: 40 },
|
|
41
|
+
{ name: 'Leo Grant', comments: 21, replies: 9, previous: 14 },
|
|
42
|
+
{ name: 'Dana Lee', comments: 30, replies: 27, previous: 30 },
|
|
43
|
+
];
|
|
44
|
+
// Sorted by comments, largest first. People with the same count share a rank, and the next rank skips: 1, 2, 2, 4.
|
|
45
|
+
var sorted = __spreadArray([], people, true).sort(function (a, b) { return b.comments - a.comments || a.name.localeCompare(b.name); });
|
|
46
|
+
var ranked = sorted.map(function (p) { return (__assign(__assign({}, p), { rank: sorted.findIndex(function (q) { return q.comments === p.comments; }) + 1 })); });
|
|
47
|
+
var PAGE_SIZE = 25;
|
|
48
|
+
export default function LeaderboardTable() {
|
|
49
|
+
var _a = useState(1), page = _a[0], setPage = _a[1];
|
|
50
|
+
var pageCount = Math.ceil(ranked.length / PAGE_SIZE);
|
|
51
|
+
var rows = ranked.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
|
52
|
+
return (<Center width="page">
|
|
53
|
+
<Stack gap="xlarge">
|
|
54
|
+
<Heading level={1} size="h5">People</Heading>
|
|
55
|
+
<SettingsSection title="Comments by person this week" description="Everyone who commented from Nov 10 to Nov 16, 2026, by comments" id="leaderboard-table-people">
|
|
56
|
+
<Stack gap="large">
|
|
57
|
+
{/* A named table sits in a region that scrolls sideways by itself, so the page never does. */}
|
|
58
|
+
<TableContainer aria-label="Comments by person this week" minWidth="640px">
|
|
59
|
+
<TableHeader>
|
|
60
|
+
<TableRow>
|
|
61
|
+
<TableHeaderCell align="right" width="64px">Rank</TableHeaderCell>
|
|
62
|
+
<TableHeaderCell>Person</TableHeaderCell>
|
|
63
|
+
<TableHeaderCell align="right" width="110px" sort="descending">Comments</TableHeaderCell>
|
|
64
|
+
<TableHeaderCell align="right" width="90px">Replies</TableHeaderCell>
|
|
65
|
+
<TableHeaderCell align="right" width="200px">Change</TableHeaderCell>
|
|
66
|
+
</TableRow>
|
|
67
|
+
</TableHeader>
|
|
68
|
+
{rows.map(function (p) { return (<TableRow key={p.name}>
|
|
69
|
+
<TableCell align="right" width="64px">{String(p.rank)}</TableCell>
|
|
70
|
+
<TableCell>
|
|
71
|
+
<Cluster gap="small">
|
|
72
|
+
<UserImage userHandle={p.name} decorative size={24}/>
|
|
73
|
+
<Paragraph size="body2" measure="none">{p.name}</Paragraph>
|
|
74
|
+
</Cluster>
|
|
75
|
+
</TableCell>
|
|
76
|
+
<TableCell align="right" width="110px">{formatCount(p.comments)}</TableCell>
|
|
77
|
+
<TableCell align="right" width="90px">{formatCount(p.replies)}</TableCell>
|
|
78
|
+
<TableCell align="right" width="200px">{formatChange(p.comments, p.previous, 'week').text}</TableCell>
|
|
79
|
+
</TableRow>); })}
|
|
80
|
+
</TableContainer>
|
|
81
|
+
{/* Past 25 people the table pages. With one page, Pagination draws nothing. */}
|
|
82
|
+
<Pagination page={page} pageCount={pageCount} onPageChange={setPage} aria-label="Pages of people" scrollTargetId="leaderboard-table-people"/>
|
|
83
|
+
</Stack>
|
|
84
|
+
</SettingsSection>
|
|
85
|
+
</Stack>
|
|
86
|
+
</Center>);
|
|
87
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
# Leaderboard
|
|
2
|
+
|
|
3
|
+
A dashboard shows who did the most of something over its range, such as who left the most comments this week.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Say what is counted and over which range, in the title and the description: 'Most active this week', 'Comments each person left from Nov 10 to Nov 16, 2026'.
|
|
9
|
+
- Show the top five in a `SettingsSection` as a `List marker="number"`, so the list's numbers are the ranks.
|
|
10
|
+
- Make each row a `Cluster justify="between"`: the face as `UserImage decorative size={24}` and the name, then the count with its unit, '42 comments', and the change beside it. On a phone they wrap under the name.
|
|
11
|
+
- Write the change in words with `formatChange`: 'Up 12% from last week', 'New this week'.
|
|
12
|
+
- List people with the same count in the top five by name. The table shows the shared rank.
|
|
13
|
+
- Show the person viewing their own row under the list, with their rank, when they are not in the top five.
|
|
14
|
+
- End the list with a `Link` 'See All People' to the table of everyone.
|
|
15
|
+
- Show everyone in a table, as the case 'Breakdown of a total' says: Rank, Person, Comments, Replies and Change. Mark the sorted column with `sort`, and right-align the numbers. Leave out the Total row: a ranking is read by person.
|
|
16
|
+
- Give people with the same count the same rank in the table, and skip the next: '2', '2', '4'.
|
|
17
|
+
- Page the table with `Pagination` past 25 people.
|
|
18
|
+
- Leave out the person viewing only when the heading says so, such as 'Most active this week, besides you'.
|
|
19
|
+
|
|
20
|
+
## Don't
|
|
21
|
+
|
|
22
|
+
- Do not give the top people medals, crowns or their own colors.
|
|
23
|
+
- Do not show the change as an arrow alone, or as a percent with no period.
|
|
24
|
+
- Do not draw a bar against the top person. The rank and the number say it, and a bar with no total reads like a share.
|
|
25
|
+
- Do not show a count with no unit.
|
|
26
|
+
|
|
27
|
+
## Option: Ranked list
|
|
28
|
+
|
|
29
|
+
Use when: The top five or so people, read in order on a dashboard.
|
|
30
|
+
|
|
31
|
+
Uses: `Center`, `Cluster`, `Heading`, `Link`, `List`, `Paragraph`, `SettingsSection`, `Stack`, `UserImage`, `formatChange`, `formatCount`
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
'use client';
|
|
35
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
36
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
37
|
+
import List from 'oneslash-design-system/components/list';
|
|
38
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
39
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
40
|
+
import Link from 'oneslash-design-system/components/link';
|
|
41
|
+
import { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
42
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
43
|
+
|
|
44
|
+
// A real app counts these on the server, largest first. `previous` is last week's count.
|
|
45
|
+
// The table example has a tie for second; this list has none, since its numbers are the ranks.
|
|
46
|
+
const people = [
|
|
47
|
+
{ name: 'Omar Reyes', comments: 58, previous: 52 },
|
|
48
|
+
{ name: 'Ben Carter', comments: 42, previous: 0 },
|
|
49
|
+
{ name: 'Mia Park', comments: 37, previous: 41 },
|
|
50
|
+
{ name: 'Dana Lee', comments: 30, previous: 30 },
|
|
51
|
+
{ name: 'Leo Grant', comments: 21, previous: 14 },
|
|
52
|
+
{ name: 'Ana Silva', comments: 9, previous: 12 },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const top = people.slice(0, 5);
|
|
56
|
+
|
|
57
|
+
export default function LeaderboardRanked() {
|
|
58
|
+
return (
|
|
59
|
+
<Center width="page">
|
|
60
|
+
<Stack gap="xlarge">
|
|
61
|
+
<Heading level={1} size="h5">Dashboard</Heading>
|
|
62
|
+
<SettingsSection title="Most active this week" description="Comments each person left from Nov 10 to Nov 16, 2026" id="leaderboard-ranked-people">
|
|
63
|
+
<Stack gap="large">
|
|
64
|
+
{/* The list's numbers are the ranks. The count and the change say the rest, so there are no bars. */}
|
|
65
|
+
<List
|
|
66
|
+
marker="number"
|
|
67
|
+
items={top.map((p) => (
|
|
68
|
+
<Cluster key={p.name} justify="between" gap="small">
|
|
69
|
+
<Cluster gap="small">
|
|
70
|
+
<UserImage userHandle={p.name} decorative size={24} />
|
|
71
|
+
<Paragraph measure="none">{p.name}</Paragraph>
|
|
72
|
+
</Cluster>
|
|
73
|
+
<Cluster gap="small">
|
|
74
|
+
<Paragraph measure="none">{`${formatCount(p.comments)} ${p.comments === 1 ? 'comment' : 'comments'}`}</Paragraph>
|
|
75
|
+
<Paragraph size="body2" tone="secondary" measure="none">{formatChange(p.comments, p.previous, 'week').text}</Paragraph>
|
|
76
|
+
</Cluster>
|
|
77
|
+
</Cluster>
|
|
78
|
+
))}
|
|
79
|
+
/>
|
|
80
|
+
{/* A real app goes to the table of everyone. */}
|
|
81
|
+
<Link href="/people" size="body2">See All People</Link>
|
|
82
|
+
</Stack>
|
|
83
|
+
</SettingsSection>
|
|
84
|
+
</Stack>
|
|
85
|
+
</Center>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Option: Table of everyone
|
|
91
|
+
|
|
92
|
+
Use when: Everyone, sorted and compared on more than one number.
|
|
93
|
+
|
|
94
|
+
Uses: `Center`, `Cluster`, `Heading`, `Pagination`, `Paragraph`, `SettingsSection`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `UserImage`, `formatChange`, `formatCount`
|
|
95
|
+
|
|
96
|
+
```tsx
|
|
97
|
+
'use client';
|
|
98
|
+
import { useState } from 'react';
|
|
99
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
100
|
+
import SettingsSection from 'oneslash-design-system/components/settingsSection';
|
|
101
|
+
import UserImage from 'oneslash-design-system/components/userImage';
|
|
102
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
103
|
+
import Pagination from 'oneslash-design-system/components/pagination';
|
|
104
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
105
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
106
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
107
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
108
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
109
|
+
import { formatChange, formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
110
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
111
|
+
|
|
112
|
+
// A real app counts these on the server. `previous` is last week's count of comments.
|
|
113
|
+
const people = [
|
|
114
|
+
{ name: 'Ben Carter', comments: 42, replies: 31, previous: 0 },
|
|
115
|
+
{ name: 'Omar Reyes', comments: 58, replies: 44, previous: 52 },
|
|
116
|
+
{ name: 'Ana Silva', comments: 9, replies: 15, previous: 12 },
|
|
117
|
+
{ name: 'Mia Park', comments: 42, replies: 18, previous: 40 },
|
|
118
|
+
{ name: 'Leo Grant', comments: 21, replies: 9, previous: 14 },
|
|
119
|
+
{ name: 'Dana Lee', comments: 30, replies: 27, previous: 30 },
|
|
120
|
+
];
|
|
121
|
+
|
|
122
|
+
// Sorted by comments, largest first. People with the same count share a rank, and the next rank skips: 1, 2, 2, 4.
|
|
123
|
+
const sorted = [...people].sort((a, b) => b.comments - a.comments || a.name.localeCompare(b.name));
|
|
124
|
+
const ranked = sorted.map((p) => ({ ...p, rank: sorted.findIndex((q) => q.comments === p.comments) + 1 }));
|
|
125
|
+
|
|
126
|
+
const PAGE_SIZE = 25;
|
|
127
|
+
|
|
128
|
+
export default function LeaderboardTable() {
|
|
129
|
+
const [page, setPage] = useState(1);
|
|
130
|
+
const pageCount = Math.ceil(ranked.length / PAGE_SIZE);
|
|
131
|
+
const rows = ranked.slice((page - 1) * PAGE_SIZE, page * PAGE_SIZE);
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<Center width="page">
|
|
135
|
+
<Stack gap="xlarge">
|
|
136
|
+
<Heading level={1} size="h5">People</Heading>
|
|
137
|
+
<SettingsSection title="Comments by person this week" description="Everyone who commented from Nov 10 to Nov 16, 2026, by comments" id="leaderboard-table-people">
|
|
138
|
+
<Stack gap="large">
|
|
139
|
+
{/* A named table sits in a region that scrolls sideways by itself, so the page never does. */}
|
|
140
|
+
<TableContainer aria-label="Comments by person this week" minWidth="640px">
|
|
141
|
+
<TableHeader>
|
|
142
|
+
<TableRow>
|
|
143
|
+
<TableHeaderCell align="right" width="64px">Rank</TableHeaderCell>
|
|
144
|
+
<TableHeaderCell>Person</TableHeaderCell>
|
|
145
|
+
<TableHeaderCell align="right" width="110px" sort="descending">Comments</TableHeaderCell>
|
|
146
|
+
<TableHeaderCell align="right" width="90px">Replies</TableHeaderCell>
|
|
147
|
+
<TableHeaderCell align="right" width="200px">Change</TableHeaderCell>
|
|
148
|
+
</TableRow>
|
|
149
|
+
</TableHeader>
|
|
150
|
+
{rows.map((p) => (
|
|
151
|
+
<TableRow key={p.name}>
|
|
152
|
+
<TableCell align="right" width="64px">{String(p.rank)}</TableCell>
|
|
153
|
+
<TableCell>
|
|
154
|
+
<Cluster gap="small">
|
|
155
|
+
<UserImage userHandle={p.name} decorative size={24} />
|
|
156
|
+
<Paragraph size="body2" measure="none">{p.name}</Paragraph>
|
|
157
|
+
</Cluster>
|
|
158
|
+
</TableCell>
|
|
159
|
+
<TableCell align="right" width="110px">{formatCount(p.comments)}</TableCell>
|
|
160
|
+
<TableCell align="right" width="90px">{formatCount(p.replies)}</TableCell>
|
|
161
|
+
<TableCell align="right" width="200px">{formatChange(p.comments, p.previous, 'week').text}</TableCell>
|
|
162
|
+
</TableRow>
|
|
163
|
+
))}
|
|
164
|
+
</TableContainer>
|
|
165
|
+
{/* Past 25 people the table pages. With one page, Pagination draws nothing. */}
|
|
166
|
+
<Pagination page={page} pageCount={pageCount} onPageChange={setPage} aria-label="Pages of people" scrollTargetId="leaderboard-table-people" />
|
|
167
|
+
</Stack>
|
|
168
|
+
</SettingsSection>
|
|
169
|
+
</Stack>
|
|
170
|
+
</Center>
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Native
|
|
176
|
+
|
|
177
|
+
On Apple use a `List` of rows with the rank, a face, the name and the count with `monospacedDigit()`, and a `Table` for everyone on a Mac or iPad. On Android use a `LazyColumn` of rows, and a table screen for everyone.
|
|
@@ -131,7 +131,7 @@ export default function MessageReactionsPicker() {
|
|
|
131
131
|
</Stack>
|
|
132
132
|
</Stack>
|
|
133
133
|
{/* The picker focuses its search. ArrowDown enters the grid; Tab and Shift+Tab move between the search and the grid. */}
|
|
134
|
-
<Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>
|
|
134
|
+
<Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus aria-label="Pick a reaction">
|
|
135
135
|
<EmojiPicker id="message-reactions-picker" aria-label="Add reaction"
|
|
136
136
|
// The emoji the person already used show pressed. Picking one again removes it.
|
|
137
137
|
selected={mine} onPick={function (emoji) {
|
|
@@ -15,7 +15,7 @@ People answer a message with an emoji instead of a reply.
|
|
|
15
15
|
- Close the quick pick when an emoji is picked. Focus goes back to the button that opened it.
|
|
16
16
|
- Move focus to the 'Add reaction' button when the chip that had it disappears, because its count reached 0.
|
|
17
17
|
- Use `quick-pick` when six emoji cover most reactions, and `picker` when people use many. Both name each emoji in words.
|
|
18
|
-
- Open the picker from 'Add reaction' in a `<Popover returnFocus>` around `EmojiPicker`. Pass the person's emoji as `selected`, so they show pressed. A pick adds or removes the reaction and closes the Popover.
|
|
18
|
+
- Open the picker from 'Add reaction' in a `<Popover returnFocus aria-label="Pick a reaction">` around `EmojiPicker`. Pass the person's emoji as `selected`, so they show pressed. A pick adds or removes the reaction and closes the Popover.
|
|
19
19
|
|
|
20
20
|
## Don't
|
|
21
21
|
|
|
@@ -525,7 +525,7 @@ export default function MessageReactionsPicker() {
|
|
|
525
525
|
</Stack>
|
|
526
526
|
</Stack>
|
|
527
527
|
{/* The picker focuses its search. ArrowDown enters the grid; Tab and Shift+Tab move between the search and the grid. */}
|
|
528
|
-
<Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus>
|
|
528
|
+
<Popover open={pickOpen} anchorEl={pickAnchor} onClose={closePick} returnFocus aria-label="Pick a reaction">
|
|
529
529
|
<EmojiPicker
|
|
530
530
|
id="message-reactions-picker"
|
|
531
531
|
aria-label="Add reaction"
|
|
@@ -14,7 +14,8 @@ A thread shows messages from people, and sometimes from an agent.
|
|
|
14
14
|
- Put a date line between days, a `Line` with a `label` that reads 'Today', 'Yesterday', or the full date with the year: 'Monday, January 13, 2025'.
|
|
15
15
|
- Pass an `aria-label` that names the sender on every row, compact ones too: 'Dana Lee', or 'Acme Agent, agent'. The time is in the row.
|
|
16
16
|
- Give the list that holds the rows `role="log"`, so a screen reader reads new messages as they arrive.
|
|
17
|
-
- Write an agent's text as
|
|
17
|
+
- Write an agent's plain text as sentences in `Paragraph`.
|
|
18
|
+
- Render an agent's markdown with `Markdown`, never as raw text with its marks.
|
|
18
19
|
|
|
19
20
|
## Don't
|
|
20
21
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function NewsletterSignupInline(): import("react").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Form from '../../components/form';
|
|
4
|
+
import TextField from '../../components/textField';
|
|
5
|
+
import Button from '../../components/button';
|
|
6
|
+
import Heading from '../../components/heading';
|
|
7
|
+
import SiteFooter from '../../components/siteFooter';
|
|
8
|
+
import { Center, Stack } from '../../components/layout';
|
|
9
|
+
// A small check: some text, an @, then some text.
|
|
10
|
+
function looksLikeEmail(value) {
|
|
11
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
12
|
+
}
|
|
13
|
+
export default function NewsletterSignupInline() {
|
|
14
|
+
var _a = useState(''), email = _a[0], setEmail = _a[1];
|
|
15
|
+
var _b = useState(''), error = _b[0], setError = _b[1];
|
|
16
|
+
var _c = useState(false), sending = _c[0], setSending = _c[1];
|
|
17
|
+
var _d = useState(false), done = _d[0], setDone = _d[1];
|
|
18
|
+
var timer = useRef();
|
|
19
|
+
var doneLine = useRef(null);
|
|
20
|
+
// Stops the request if the example goes away before it ends.
|
|
21
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
22
|
+
// The form is gone, so focus moves to the line that took its place, and a screen reader reads it.
|
|
23
|
+
useEffect(function () {
|
|
24
|
+
var _a;
|
|
25
|
+
if (done)
|
|
26
|
+
(_a = doneLine.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
27
|
+
}, [done]);
|
|
28
|
+
// While it sends, the field is read-only, not disabled, so focus stays in it.
|
|
29
|
+
function handleSubmit() {
|
|
30
|
+
if (sending)
|
|
31
|
+
return;
|
|
32
|
+
// An empty field and a bad address get their own words. The Button stays enabled either way.
|
|
33
|
+
var value = email.trim();
|
|
34
|
+
if (!value) {
|
|
35
|
+
setError('Enter your email.');
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!looksLikeEmail(value)) {
|
|
39
|
+
setError('Enter an email address, like name@example.com.');
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setError('');
|
|
43
|
+
setSending(true);
|
|
44
|
+
// Stands in for the request to the server. It always sends an email: a link to confirm a new address,
|
|
45
|
+
// or a note that an address already on the list is subscribed, with the link to leave.
|
|
46
|
+
// A failed request shows an inline error Alert above the field instead, such as 'Could not subscribe. Try again.'
|
|
47
|
+
timer.current = setTimeout(function () {
|
|
48
|
+
setSending(false);
|
|
49
|
+
// Both get an email, so the same line is true for both, and the form never tells who is subscribed.
|
|
50
|
+
setDone(true);
|
|
51
|
+
}, 1200);
|
|
52
|
+
}
|
|
53
|
+
return (<Stack gap="huge">
|
|
54
|
+
{/* The sign-up sits just above the footer, one field wide. The footer itself holds only links. */}
|
|
55
|
+
<Center width="form">
|
|
56
|
+
<Stack gap="large">
|
|
57
|
+
<Heading level={2} size="subtitle1">Get the Acme newsletter</Heading>
|
|
58
|
+
{done ? (<Heading ref={doneLine} tabIndex={-1} level={3} size="subtitle1">Check your email to confirm.</Heading>) : (<Form aria-label="Get the Acme newsletter" onSubmit={handleSubmit}>
|
|
59
|
+
<TextField id="newsletter-signup-inline-email" label="Email address" type="email" autoComplete="email" value={email} readOnly={sending} error={Boolean(error)} errorText={error} onChange={function (e) { setEmail(e.target.value); setError(''); }}/>
|
|
60
|
+
<Stack align="start">
|
|
61
|
+
<Button size="medium" type="secondary" state="enabled" label="Subscribe" htmlType="submit" loading={sending}/>
|
|
62
|
+
</Stack>
|
|
63
|
+
</Form>)}
|
|
64
|
+
</Stack>
|
|
65
|
+
</Center>
|
|
66
|
+
<SiteFooter brand={{ href: '#top', name: 'Acme' }} links={[
|
|
67
|
+
{ label: 'Pricing', href: '#pricing' },
|
|
68
|
+
{ label: 'Blog', href: '#blog' },
|
|
69
|
+
{ label: 'Privacy', href: '#privacy' },
|
|
70
|
+
]} legal="© 2026 Acme. All rights reserved."/>
|
|
71
|
+
</Stack>);
|
|
72
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function NewsletterSignupSection(): import("react").JSX.Element;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Form from '../../components/form';
|
|
5
|
+
import TextField from '../../components/textField';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import Heading from '../../components/heading';
|
|
8
|
+
import Paragraph from '../../components/paragraph';
|
|
9
|
+
import { Center, Stack } from '../../components/layout';
|
|
10
|
+
// A small check: some text, an @, then some text.
|
|
11
|
+
function looksLikeEmail(value) {
|
|
12
|
+
return /^[^@\s]+@[^@\s]+$/.test(value);
|
|
13
|
+
}
|
|
14
|
+
export default function NewsletterSignupSection() {
|
|
15
|
+
var _a = useState(''), email = _a[0], setEmail = _a[1];
|
|
16
|
+
var _b = useState(''), error = _b[0], setError = _b[1];
|
|
17
|
+
var _c = useState(false), sending = _c[0], setSending = _c[1];
|
|
18
|
+
var _d = useState(false), done = _d[0], setDone = _d[1];
|
|
19
|
+
var timer = useRef();
|
|
20
|
+
var doneLine = useRef(null);
|
|
21
|
+
// Stops the request if the example goes away before it ends.
|
|
22
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
23
|
+
// The form is gone, so focus moves to the line that took its place, and a screen reader reads it.
|
|
24
|
+
useEffect(function () {
|
|
25
|
+
var _a;
|
|
26
|
+
if (done)
|
|
27
|
+
(_a = doneLine.current) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
28
|
+
}, [done]);
|
|
29
|
+
// While it sends, the field is read-only, not disabled, so focus stays in it.
|
|
30
|
+
function handleSubmit() {
|
|
31
|
+
if (sending)
|
|
32
|
+
return;
|
|
33
|
+
// An empty field and a bad address get their own words. The Button stays enabled either way.
|
|
34
|
+
var value = email.trim();
|
|
35
|
+
if (!value) {
|
|
36
|
+
setError('Enter your email.');
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!looksLikeEmail(value)) {
|
|
40
|
+
setError('Enter an email address, like name@example.com.');
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
setError('');
|
|
44
|
+
setSending(true);
|
|
45
|
+
// Stands in for the request to the server. It always sends an email: a link to confirm a new address,
|
|
46
|
+
// or a note that an address already on the list is subscribed, with the link to leave.
|
|
47
|
+
// A failed request shows an inline error Alert above the field instead, such as 'Could not subscribe. Try again.'
|
|
48
|
+
timer.current = setTimeout(function () {
|
|
49
|
+
setSending(false);
|
|
50
|
+
// Both get an email, so the same line is true for both, and the form never tells who is subscribed.
|
|
51
|
+
setDone(true);
|
|
52
|
+
}, 1200);
|
|
53
|
+
}
|
|
54
|
+
return (
|
|
55
|
+
// The end of a post: the section says what comes and how often, then asks for one address.
|
|
56
|
+
<Center width="form">
|
|
57
|
+
<Surface padding="small">
|
|
58
|
+
<Stack gap="large">
|
|
59
|
+
<Stack gap="small">
|
|
60
|
+
<Heading level={2} size="h6">Get the Acme newsletter</Heading>
|
|
61
|
+
<Paragraph tone="secondary" size="body2" measure="none">One email a month with what shipped. Leave any time from the link in each email.</Paragraph>
|
|
62
|
+
</Stack>
|
|
63
|
+
{done ? (<Heading ref={doneLine} tabIndex={-1} level={3} size="subtitle1">Check your email to confirm.</Heading>) : (<Form aria-label="Get the Acme newsletter" onSubmit={handleSubmit}>
|
|
64
|
+
<TextField id="newsletter-signup-section-email" label="Email address" type="email" autoComplete="email" value={email} readOnly={sending} error={Boolean(error)} errorText={error} onChange={function (e) { setEmail(e.target.value); setError(''); }}/>
|
|
65
|
+
<Stack align="start">
|
|
66
|
+
<Button size="medium" type="secondary" state="enabled" label="Subscribe" htmlType="submit" loading={sending}/>
|
|
67
|
+
</Stack>
|
|
68
|
+
</Form>)}
|
|
69
|
+
</Stack>
|
|
70
|
+
</Surface>
|
|
71
|
+
</Center>);
|
|
72
|
+
}
|