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,24 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import PageShell from '../../components/pageShell';
|
|
3
|
+
import Surface from '../../components/surface';
|
|
4
|
+
import Heading from '../../components/heading';
|
|
5
|
+
import Paragraph from '../../components/paragraph';
|
|
6
|
+
import Button from '../../components/button';
|
|
7
|
+
import { Cluster, Stack } from '../../components/layout';
|
|
8
|
+
export default function PageEndCtaBand() {
|
|
9
|
+
return (<PageShell>
|
|
10
|
+
{/* The last block of the page: one statement, one line, and the same actions as the header and the hero. */}
|
|
11
|
+
<Surface padding="xlarge">
|
|
12
|
+
<Stack gap="xlarge">
|
|
13
|
+
<Stack gap="medium">
|
|
14
|
+
<Heading level={2} size="h4">Bring your team and its agent together</Heading>
|
|
15
|
+
<Paragraph tone="secondary" measure="lede">Start on Free with 3 members, and add people when you need them.</Paragraph>
|
|
16
|
+
</Stack>
|
|
17
|
+
<Cluster>
|
|
18
|
+
<Button size="large" type="primary" state="enabled" label="Sign Up" href="#sign-up"/>
|
|
19
|
+
<Button size="large" type="secondary" state="enabled" label="See How It Works" href="#how-it-works"/>
|
|
20
|
+
</Cluster>
|
|
21
|
+
</Stack>
|
|
22
|
+
</Surface>
|
|
23
|
+
</PageShell>);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PageEndNextLink(): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import PageShell from '../../components/pageShell';
|
|
3
|
+
import PageHeader from '../../components/pageHeader';
|
|
4
|
+
import Paragraph from '../../components/paragraph';
|
|
5
|
+
import LinkCard from '../../components/linkCard';
|
|
6
|
+
import { Stack } from '../../components/layout';
|
|
7
|
+
export default function PageEndNextLink() {
|
|
8
|
+
return (<PageShell>
|
|
9
|
+
<Stack gap="giant">
|
|
10
|
+
<Stack gap="xxlarge">
|
|
11
|
+
<PageHeader level={1} title="How channels work" lede="A channel is a place for one subject. Everyone in it sees every message."/>
|
|
12
|
+
<Paragraph tone="secondary">Make a channel for each team or project. Pin the messages people need to find again. Turn a message into a task when it needs an owner.</Paragraph>
|
|
13
|
+
</Stack>
|
|
14
|
+
{/* A reading page ends by pointing to the next page to read, and not to a sign-up. */}
|
|
15
|
+
<LinkCard href="#task-threads" title="Task threads" caption="Next: Task threads"/>
|
|
16
|
+
</Stack>
|
|
17
|
+
</PageShell>);
|
|
18
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# Page end
|
|
2
|
+
|
|
3
|
+
A page has said what it had to say, and its last block decides what the visitor does next.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A marketing page asks for one main action, in the same words everywhere'. The closing block uses the same labels as the header and the hero.
|
|
8
|
+
- Use a `Surface` for `cta-band`, with a level 2 `Heading`, one line of lede and the page's actions: a primary 'Sign Up' and one secondary.
|
|
9
|
+
- Write the heading as a statement the visitor can say yes to, and the lede as the one doubt it removes.
|
|
10
|
+
- Use one `LinkCard` for `next-link`, with the next page's title and a caption that says it is next: 'Next: Task threads'.
|
|
11
|
+
- Put the block after the last section and before the `SiteFooter`.
|
|
12
|
+
|
|
13
|
+
## Don't
|
|
14
|
+
|
|
15
|
+
- Do not use both blocks on one page. A page ends one way.
|
|
16
|
+
- Do not add a new action that the header and the hero do not have.
|
|
17
|
+
- Do not close a reading page on a sign-up banner.
|
|
18
|
+
- Do not name the link 'Next'. Name the page.
|
|
19
|
+
|
|
20
|
+
## Option: Closing call to action
|
|
21
|
+
|
|
22
|
+
Use when: A marketing page closes on its main action.
|
|
23
|
+
|
|
24
|
+
Uses: `Button`, `Cluster`, `Heading`, `PageShell`, `Paragraph`, `Stack`, `Surface`
|
|
25
|
+
|
|
26
|
+
```tsx
|
|
27
|
+
'use client';
|
|
28
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
29
|
+
import Surface from 'oneslash-design-system/components/surface';
|
|
30
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
31
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
32
|
+
import Button from 'oneslash-design-system/components/button';
|
|
33
|
+
import { Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
34
|
+
|
|
35
|
+
export default function PageEndCtaBand() {
|
|
36
|
+
return (
|
|
37
|
+
<PageShell>
|
|
38
|
+
{/* The last block of the page: one statement, one line, and the same actions as the header and the hero. */}
|
|
39
|
+
<Surface padding="xlarge">
|
|
40
|
+
<Stack gap="xlarge">
|
|
41
|
+
<Stack gap="medium">
|
|
42
|
+
<Heading level={2} size="h4">Bring your team and its agent together</Heading>
|
|
43
|
+
<Paragraph tone="secondary" measure="lede">Start on Free with 3 members, and add people when you need them.</Paragraph>
|
|
44
|
+
</Stack>
|
|
45
|
+
<Cluster>
|
|
46
|
+
<Button size="large" type="primary" state="enabled" label="Sign Up" href="#sign-up" />
|
|
47
|
+
<Button size="large" type="secondary" state="enabled" label="See How It Works" href="#how-it-works" />
|
|
48
|
+
</Cluster>
|
|
49
|
+
</Stack>
|
|
50
|
+
</Surface>
|
|
51
|
+
</PageShell>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Option: Link to the next page
|
|
57
|
+
|
|
58
|
+
Use when: A reading page leads to the next thing to read.
|
|
59
|
+
|
|
60
|
+
Uses: `LinkCard`, `PageHeader`, `PageShell`, `Paragraph`, `Stack`
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
'use client';
|
|
64
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
65
|
+
import PageHeader from 'oneslash-design-system/components/pageHeader';
|
|
66
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
67
|
+
import LinkCard from 'oneslash-design-system/components/linkCard';
|
|
68
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
69
|
+
|
|
70
|
+
export default function PageEndNextLink() {
|
|
71
|
+
return (
|
|
72
|
+
<PageShell>
|
|
73
|
+
<Stack gap="giant">
|
|
74
|
+
<Stack gap="xxlarge">
|
|
75
|
+
<PageHeader level={1} title="How channels work" lede="A channel is a place for one subject. Everyone in it sees every message." />
|
|
76
|
+
<Paragraph tone="secondary">Make a channel for each team or project. Pin the messages people need to find again. Turn a message into a task when it needs an owner.</Paragraph>
|
|
77
|
+
</Stack>
|
|
78
|
+
{/* A reading page ends by pointing to the next page to read, and not to a sign-up. */}
|
|
79
|
+
<LinkCard href="#task-threads" title="Task threads" caption="Next: Task threads" />
|
|
80
|
+
</Stack>
|
|
81
|
+
</PageShell>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Native
|
|
87
|
+
|
|
88
|
+
On Apple a screen ends with its content. A flow moves on with a `NavigationLink` or a toolbar button. On Android use the same with a navigation bar.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PagedCardPager(): import("react").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import Pagination from '../../components/pagination';
|
|
5
|
+
import MenuItem from '../../components/menuItem';
|
|
6
|
+
import Line from '../../components/line';
|
|
7
|
+
import { formatCount } from '../../components/formatNumber';
|
|
8
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
9
|
+
// A real app reads these from the server.
|
|
10
|
+
var questions = [
|
|
11
|
+
{ id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
|
|
12
|
+
{ id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
|
|
13
|
+
{ id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
|
|
14
|
+
{ id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
|
|
15
|
+
{ id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
|
|
16
|
+
{ id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
|
|
17
|
+
{ id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
|
|
18
|
+
{ id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
|
|
19
|
+
];
|
|
20
|
+
var PER_PAGE = 4;
|
|
21
|
+
export default function PagedCardPager() {
|
|
22
|
+
var _a = useState(1), page = _a[0], setPage = _a[1];
|
|
23
|
+
var pageCount = Math.ceil(questions.length / PER_PAGE);
|
|
24
|
+
var rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
|
|
25
|
+
return (<Center width="page">
|
|
26
|
+
<Stack gap="medium">
|
|
27
|
+
<Line />
|
|
28
|
+
{/* The total is in the title, and the pager is in the title row, named for the card. */}
|
|
29
|
+
<Cluster justify="between">
|
|
30
|
+
<Heading level={2} size="h6">{"".concat(formatCount(questions.length), " ").concat(questions.length === 1 ? 'question' : 'questions', " waiting on you")}</Heading>
|
|
31
|
+
<Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage}/>
|
|
32
|
+
</Cluster>
|
|
33
|
+
<Stack gap="small">
|
|
34
|
+
{rows.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
|
|
35
|
+
// A real app lets the link go to the question's page. The example stays here.
|
|
36
|
+
event.preventDefault();
|
|
37
|
+
}}/>); })}
|
|
38
|
+
</Stack>
|
|
39
|
+
</Stack>
|
|
40
|
+
</Center>);
|
|
41
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PagedCardSeeAll(): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import Link from '../../components/link';
|
|
4
|
+
import MenuItem from '../../components/menuItem';
|
|
5
|
+
import Line from '../../components/line';
|
|
6
|
+
import { formatCount } from '../../components/formatNumber';
|
|
7
|
+
import { Center, Cluster, Stack } from '../../components/layout';
|
|
8
|
+
// A real app reads these from the server: the newest five, and how many there are in all.
|
|
9
|
+
var total = 142;
|
|
10
|
+
var questions = [
|
|
11
|
+
{ id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
|
|
12
|
+
{ id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
|
|
13
|
+
{ id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
|
|
14
|
+
{ id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
|
|
15
|
+
{ id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
|
|
16
|
+
];
|
|
17
|
+
export default function PagedCardSeeAll() {
|
|
18
|
+
return (<Center width="page">
|
|
19
|
+
<Stack gap="medium">
|
|
20
|
+
<Line />
|
|
21
|
+
<Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
|
|
22
|
+
<Stack gap="small">
|
|
23
|
+
{questions.map(function (q) { return (<MenuItem key={q.id} size="medium" label={q.text} secondLabel={q.when} href={"/questions/".concat(q.id)} onClick={function (event) {
|
|
24
|
+
// A real app lets the link go to the question's page. The example stays here.
|
|
25
|
+
event.preventDefault();
|
|
26
|
+
}}/>); })}
|
|
27
|
+
</Stack>
|
|
28
|
+
{/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
|
|
29
|
+
<Cluster>
|
|
30
|
+
<Link href="#" size="body2">See All Questions</Link>
|
|
31
|
+
</Cluster>
|
|
32
|
+
</Stack>
|
|
33
|
+
</Center>);
|
|
34
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# Short list on a dashboard
|
|
2
|
+
|
|
3
|
+
A dashboard section lists things that wait on the person, such as questions or comments, and the list may be longer than the section.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'.
|
|
8
|
+
- Say the total in the title, as a number and its unit: '8 questions waiting on you'.
|
|
9
|
+
- Make every row a link to the thing it names, with a second line for when it was asked.
|
|
10
|
+
- Put `Pagination variant="compact"` in the title row when the list pages, named for the card: 'Pages of questions waiting on you'.
|
|
11
|
+
- Keep the page length the same on every page. `Pagination` shows nothing when there is one page.
|
|
12
|
+
- Show five rows and a 'See All Questions' `Link` after them when the list does not page. The link goes to the full list, the case 'Data table page'.
|
|
13
|
+
- Show `EmptyBox size="small"` when the list is empty, such as 'No questions waiting on you', with a `secondText` that says what will appear.
|
|
14
|
+
- Show the card as a hairline, a title and rows. Do not box it.
|
|
15
|
+
|
|
16
|
+
## Don't
|
|
17
|
+
|
|
18
|
+
- Do not page a long list on the dashboard. Show five rows and a link.
|
|
19
|
+
- Do not leave the pager unnamed. Name it for the card, so a screen reader hears 'Pages of questions waiting on you'.
|
|
20
|
+
- Do not write the page as '1/3'. `Pagination` writes '1 of 3' in a card and 'Page 1 of 3' elsewhere.
|
|
21
|
+
- Do not make a row that is not a link, or a link with no name.
|
|
22
|
+
- Do not scroll a list inside the card.
|
|
23
|
+
|
|
24
|
+
## Option: Pager in the title row
|
|
25
|
+
|
|
26
|
+
Use when: The list is short and stays on the dashboard, a few rows a page.
|
|
27
|
+
|
|
28
|
+
Uses: `Center`, `Cluster`, `Heading`, `Line`, `MenuItem`, `Pagination`, `Stack`, `formatCount`
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
'use client';
|
|
32
|
+
import { useState } from 'react';
|
|
33
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
34
|
+
import Pagination from 'oneslash-design-system/components/pagination';
|
|
35
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
36
|
+
import Line from 'oneslash-design-system/components/line';
|
|
37
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
38
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
39
|
+
|
|
40
|
+
// A real app reads these from the server.
|
|
41
|
+
const questions = [
|
|
42
|
+
{ id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
|
|
43
|
+
{ id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
|
|
44
|
+
{ id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
|
|
45
|
+
{ id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
|
|
46
|
+
{ id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
|
|
47
|
+
{ id: 'q6', text: 'Can a guest see the activity log?', when: 'Asked 3 days ago' },
|
|
48
|
+
{ id: 'q7', text: 'Which time zone do the reports use?', when: 'Asked 4 days ago' },
|
|
49
|
+
{ id: 'q8', text: 'Does a deleted comment count as marked done?', when: 'Asked 5 days ago' },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const PER_PAGE = 4;
|
|
53
|
+
|
|
54
|
+
export default function PagedCardPager() {
|
|
55
|
+
const [page, setPage] = useState(1);
|
|
56
|
+
const pageCount = Math.ceil(questions.length / PER_PAGE);
|
|
57
|
+
const rows = questions.slice((page - 1) * PER_PAGE, page * PER_PAGE);
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<Center width="page">
|
|
61
|
+
<Stack gap="medium">
|
|
62
|
+
<Line />
|
|
63
|
+
{/* The total is in the title, and the pager is in the title row, named for the card. */}
|
|
64
|
+
<Cluster justify="between">
|
|
65
|
+
<Heading level={2} size="h6">{`${formatCount(questions.length)} ${questions.length === 1 ? 'question' : 'questions'} waiting on you`}</Heading>
|
|
66
|
+
<Pagination variant="compact" aria-label="Pages of questions waiting on you" page={page} pageCount={pageCount} onPageChange={setPage} />
|
|
67
|
+
</Cluster>
|
|
68
|
+
<Stack gap="small">
|
|
69
|
+
{rows.map((q) => (
|
|
70
|
+
<MenuItem
|
|
71
|
+
key={q.id}
|
|
72
|
+
size="medium"
|
|
73
|
+
label={q.text}
|
|
74
|
+
secondLabel={q.when}
|
|
75
|
+
href={`/questions/${q.id}`}
|
|
76
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
77
|
+
// A real app lets the link go to the question's page. The example stays here.
|
|
78
|
+
event.preventDefault();
|
|
79
|
+
}}
|
|
80
|
+
/>
|
|
81
|
+
))}
|
|
82
|
+
</Stack>
|
|
83
|
+
</Stack>
|
|
84
|
+
</Center>
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Option: Five rows and See All
|
|
90
|
+
|
|
91
|
+
Use when: The list is long, so the dashboard shows the newest five and a link to the full page.
|
|
92
|
+
|
|
93
|
+
Uses: `Center`, `Cluster`, `Heading`, `Line`, `Link`, `MenuItem`, `Stack`, `formatCount`
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
'use client';
|
|
97
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
98
|
+
import Link from 'oneslash-design-system/components/link';
|
|
99
|
+
import MenuItem from 'oneslash-design-system/components/menuItem';
|
|
100
|
+
import Line from 'oneslash-design-system/components/line';
|
|
101
|
+
import { formatCount } from 'oneslash-design-system/components/formatNumber';
|
|
102
|
+
import { Center, Cluster, Stack } from 'oneslash-design-system/components/layout';
|
|
103
|
+
|
|
104
|
+
// A real app reads these from the server: the newest five, and how many there are in all.
|
|
105
|
+
const total = 142;
|
|
106
|
+
const questions = [
|
|
107
|
+
{ id: 'q1', text: 'Which logo file should the launch page use?', when: 'Asked 2 hours ago' },
|
|
108
|
+
{ id: 'q2', text: 'Is the new pricing public before Friday?', when: 'Asked 4 times, 5 hours ago' },
|
|
109
|
+
{ id: 'q3', text: 'Who approves the final copy for the home page?', when: 'Asked yesterday' },
|
|
110
|
+
{ id: 'q4', text: 'Should the export include archived projects?', when: 'Asked yesterday' },
|
|
111
|
+
{ id: 'q5', text: 'What is the limit for a free workspace?', when: 'Asked 2 times, 2 days ago' },
|
|
112
|
+
];
|
|
113
|
+
|
|
114
|
+
export default function PagedCardSeeAll() {
|
|
115
|
+
return (
|
|
116
|
+
<Center width="page">
|
|
117
|
+
<Stack gap="medium">
|
|
118
|
+
<Line />
|
|
119
|
+
<Heading level={2} size="h6">{formatCount(total)} questions waiting on you</Heading>
|
|
120
|
+
<Stack gap="small">
|
|
121
|
+
{questions.map((q) => (
|
|
122
|
+
<MenuItem
|
|
123
|
+
key={q.id}
|
|
124
|
+
size="medium"
|
|
125
|
+
label={q.text}
|
|
126
|
+
secondLabel={q.when}
|
|
127
|
+
href={`/questions/${q.id}`}
|
|
128
|
+
onClick={(event: { preventDefault: () => void }) => {
|
|
129
|
+
// A real app lets the link go to the question's page. The example stays here.
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
}}
|
|
132
|
+
/>
|
|
133
|
+
))}
|
|
134
|
+
</Stack>
|
|
135
|
+
{/* A real app links to the full list at '/questions', with its search and sorting. Link has no click handler to keep the example here, so it uses '#'. */}
|
|
136
|
+
<Cluster>
|
|
137
|
+
<Link href="#" size="body2">See All Questions</Link>
|
|
138
|
+
</Cluster>
|
|
139
|
+
</Stack>
|
|
140
|
+
</Center>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
## Native
|
|
146
|
+
|
|
147
|
+
On Apple use a `Section` of a `List` with a `NavigationLink` for each row, and a `NavigationLink` named See All for the footer. On Android use a `LazyColumn` of clickable rows.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PasswordGateInline(): import("react").JSX.Element;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import PageHeader from '../../components/pageHeader';
|
|
5
|
+
import Figure from '../../components/figure';
|
|
6
|
+
import Image from '../../components/image';
|
|
7
|
+
import Surface from '../../components/surface';
|
|
8
|
+
import Heading from '../../components/heading';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import Link from '../../components/link';
|
|
11
|
+
import Form from '../../components/form';
|
|
12
|
+
import TextField from '../../components/textField';
|
|
13
|
+
import Button from '../../components/button';
|
|
14
|
+
import { Stack } from '../../components/layout';
|
|
15
|
+
// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
|
|
16
|
+
// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
|
|
17
|
+
// A stand-in for a screen. A real page passes its own picture.
|
|
18
|
+
var screen = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1280 720'%3E%3Crect width='1280' height='720' fill='%23eef2f6'/%3E%3Crect x='120' y='120' width='460' height='480' rx='24' fill='%23ffffff'/%3E%3Crect x='680' y='120' width='480' height='220' rx='24' fill='%23dfe7ef'/%3E%3Crect x='680' y='380' width='480' height='220' rx='24' fill='%232f6b4f'/%3E%3C/svg%3E";
|
|
19
|
+
var PASSPHRASE = 'acme-demo';
|
|
20
|
+
export default function PasswordGateInline() {
|
|
21
|
+
var _a = useState(''), password = _a[0], setPassword = _a[1];
|
|
22
|
+
var _b = useState(''), error = _b[0], setError = _b[1];
|
|
23
|
+
var _c = useState(false), checking = _c[0], setChecking = _c[1];
|
|
24
|
+
var _d = useState(false), unlocked = _d[0], setUnlocked = _d[1];
|
|
25
|
+
// A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
|
|
26
|
+
var _e = useState(0), attempt = _e[0], setAttempt = _e[1];
|
|
27
|
+
var timer = useRef();
|
|
28
|
+
var lockAgain = useRef(null);
|
|
29
|
+
// Stops the request if the example goes away before it ends.
|
|
30
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
31
|
+
// The field is gone once the work shows, so focus moves to the first control in it.
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
var _a;
|
|
34
|
+
if (unlocked)
|
|
35
|
+
(_a = lockAgain.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
36
|
+
}, [unlocked]);
|
|
37
|
+
function handleSubmit() {
|
|
38
|
+
if (checking)
|
|
39
|
+
return;
|
|
40
|
+
if (!password.trim()) {
|
|
41
|
+
setError('Enter the password.');
|
|
42
|
+
setAttempt(function (n) { return n + 1; });
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setError('');
|
|
46
|
+
setChecking(true);
|
|
47
|
+
// Stands in for the request to the server.
|
|
48
|
+
timer.current = setTimeout(function () {
|
|
49
|
+
setChecking(false);
|
|
50
|
+
if (password === PASSPHRASE) {
|
|
51
|
+
setUnlocked(true);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
setError('That password is not right.');
|
|
55
|
+
setAttempt(function (n) { return n + 1; });
|
|
56
|
+
}
|
|
57
|
+
}, 600);
|
|
58
|
+
}
|
|
59
|
+
var header = (<PageHeader level={1} title="Plan changes, a case study" lede="How we made a plan change clear before anyone pays." facts={[
|
|
60
|
+
{ label: 'Role', value: 'Lead designer' },
|
|
61
|
+
{ label: 'Team', value: '4 people' },
|
|
62
|
+
{ label: 'Year', value: '2026' },
|
|
63
|
+
]}/>);
|
|
64
|
+
return (<PageShell>
|
|
65
|
+
<Stack gap="giant">
|
|
66
|
+
{/* The summary and the facts stay readable. Only the screens are behind the gate. */}
|
|
67
|
+
<Stack gap="xlarge">
|
|
68
|
+
{header}
|
|
69
|
+
<Paragraph tone="secondary">People could not tell what a new plan would cost them. We showed the new price and the day it starts before the last step, and fewer people wrote to ask.</Paragraph>
|
|
70
|
+
</Stack>
|
|
71
|
+
{unlocked ? (<Stack gap="xlarge">
|
|
72
|
+
<Figure crop={16 / 9} caption="The plan change, before the person pays.">
|
|
73
|
+
<Image src={screen} alt="A plan change screen: the current plan beside the new plan, with the new price in green" width={1280} height={720}/>
|
|
74
|
+
</Figure>
|
|
75
|
+
<Stack align="start">
|
|
76
|
+
<Button ref={lockAgain} size="medium" type="secondary" state="enabled" label="Lock Again" onClickButton={function () { setUnlocked(false); setPassword(''); }}/>
|
|
77
|
+
</Stack>
|
|
78
|
+
</Stack>) : (<Surface padding="large">
|
|
79
|
+
<Stack gap="large">
|
|
80
|
+
<Heading level={2} size="h6">This case study needs a password</Heading>
|
|
81
|
+
<Paragraph>
|
|
82
|
+
The password comes by email. <Link href="#contact">Ask for the password</Link>.
|
|
83
|
+
</Paragraph>
|
|
84
|
+
<Form aria-label="Private work" onSubmit={handleSubmit}>
|
|
85
|
+
<TextField key={attempt} id="password-gate-inline-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={function (e) { setPassword(e.target.value); setError(''); }}/>
|
|
86
|
+
<Stack align="start">
|
|
87
|
+
<Button size="medium" type="primary" state="enabled" label="View Work" htmlType="submit" loading={checking}/>
|
|
88
|
+
</Stack>
|
|
89
|
+
</Form>
|
|
90
|
+
</Stack>
|
|
91
|
+
</Surface>)}
|
|
92
|
+
</Stack>
|
|
93
|
+
</PageShell>);
|
|
94
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PasswordGateModal(): import("react").JSX.Element;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import PageHeader from '../../components/pageHeader';
|
|
5
|
+
import Modal from '../../components/modal';
|
|
6
|
+
import Form from '../../components/form';
|
|
7
|
+
import TextField from '../../components/textField';
|
|
8
|
+
import Paragraph from '../../components/paragraph';
|
|
9
|
+
import Link from '../../components/link';
|
|
10
|
+
import Button from '../../components/button';
|
|
11
|
+
import { Stack } from '../../components/layout';
|
|
12
|
+
// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
|
|
13
|
+
// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
|
|
14
|
+
var PASSPHRASE = 'acme-demo';
|
|
15
|
+
export default function PasswordGateModal() {
|
|
16
|
+
var _a = useState(false), open = _a[0], setOpen = _a[1];
|
|
17
|
+
var _b = useState(false), unlocked = _b[0], setUnlocked = _b[1];
|
|
18
|
+
var _c = useState(''), password = _c[0], setPassword = _c[1];
|
|
19
|
+
var _d = useState(''), error = _d[0], setError = _d[1];
|
|
20
|
+
var _e = useState(false), checking = _e[0], setChecking = _e[1];
|
|
21
|
+
// A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
|
|
22
|
+
var _f = useState(0), attempt = _f[0], setAttempt = _f[1];
|
|
23
|
+
var timer = useRef();
|
|
24
|
+
// Stops the request if the example goes away before it ends.
|
|
25
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
26
|
+
// Escape, a click outside and Cancel all close it, except while the request runs.
|
|
27
|
+
function handleClose() {
|
|
28
|
+
if (checking)
|
|
29
|
+
return;
|
|
30
|
+
setOpen(false);
|
|
31
|
+
setPassword('');
|
|
32
|
+
setError('');
|
|
33
|
+
}
|
|
34
|
+
function handleSubmit() {
|
|
35
|
+
if (checking)
|
|
36
|
+
return;
|
|
37
|
+
if (!password.trim()) {
|
|
38
|
+
setError('Enter the password.');
|
|
39
|
+
setAttempt(function (n) { return n + 1; });
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
setError('');
|
|
43
|
+
setChecking(true);
|
|
44
|
+
// Stands in for the request to the server.
|
|
45
|
+
timer.current = setTimeout(function () {
|
|
46
|
+
setChecking(false);
|
|
47
|
+
if (password === PASSPHRASE) {
|
|
48
|
+
setUnlocked(true);
|
|
49
|
+
setOpen(false);
|
|
50
|
+
setPassword('');
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
setError('That password is not right.');
|
|
54
|
+
setAttempt(function (n) { return n + 1; });
|
|
55
|
+
}
|
|
56
|
+
}, 600);
|
|
57
|
+
}
|
|
58
|
+
return (<PageShell>
|
|
59
|
+
<Stack gap="xlarge">
|
|
60
|
+
<PageHeader level={1} title="Selected work" lede="Three case studies. The first is open. The others need a password."/>
|
|
61
|
+
<Stack gap="large" align="start">
|
|
62
|
+
<Link href="#how-we-write-errors">How we write error messages</Link>
|
|
63
|
+
{/* A link to private work asks for the password first. A real page keeps the link's address, so the work opens there after the check. The trigger stays, so focus has somewhere to go back to. */}
|
|
64
|
+
<Button size="medium" type="textOnly" state="enabled" label="Read the Plan Changes Case Study" onClickButton={function () { if (!unlocked)
|
|
65
|
+
setOpen(true); }}/>
|
|
66
|
+
{unlocked && <Paragraph>It is open for you now.</Paragraph>}
|
|
67
|
+
</Stack>
|
|
68
|
+
</Stack>
|
|
69
|
+
<Modal isOpen={open} size="small" initialFocus="body" title="View Work" onClose={handleClose} actions={<>
|
|
70
|
+
<Button size="small" type="tertiary" state={checking ? 'disabled' : 'enabled'} label="Cancel" onClickButton={handleClose}/>
|
|
71
|
+
<Button size="small" type="primary" state="enabled" label="View Work" loading={checking} onClickButton={handleSubmit}/>
|
|
72
|
+
</>}>
|
|
73
|
+
<Form aria-label="Private work" onSubmit={handleSubmit}>
|
|
74
|
+
<TextField key={attempt} id="password-gate-modal-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={function (e) { setPassword(e.target.value); setError(''); }}/>
|
|
75
|
+
<Paragraph tone="secondary" size="body2" measure="none">
|
|
76
|
+
This case study needs a password, and it comes by email. <Link href="#contact">Ask for the password</Link>.
|
|
77
|
+
</Paragraph>
|
|
78
|
+
</Form>
|
|
79
|
+
</Modal>
|
|
80
|
+
</PageShell>);
|
|
81
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function PasswordGatePage(): import("react").JSX.Element;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import PageHeader from '../../components/pageHeader';
|
|
5
|
+
import Surface from '../../components/surface';
|
|
6
|
+
import Heading from '../../components/heading';
|
|
7
|
+
import Paragraph from '../../components/paragraph';
|
|
8
|
+
import Link from '../../components/link';
|
|
9
|
+
import Form from '../../components/form';
|
|
10
|
+
import TextField from '../../components/textField';
|
|
11
|
+
import Button from '../../components/button';
|
|
12
|
+
import { Stack } from '../../components/layout';
|
|
13
|
+
// The example checks nothing real and sends nothing. It accepts one made-up passphrase, 'acme-demo', so you can see both outcomes.
|
|
14
|
+
// A real page asks its server. The server checks the password and sets a cookie, and it sends the private content only to a visitor with that cookie. The page never holds the secret.
|
|
15
|
+
var PASSPHRASE = 'acme-demo';
|
|
16
|
+
export default function PasswordGatePage() {
|
|
17
|
+
var _a = useState(''), password = _a[0], setPassword = _a[1];
|
|
18
|
+
var _b = useState(''), error = _b[0], setError = _b[1];
|
|
19
|
+
var _c = useState(false), checking = _c[0], setChecking = _c[1];
|
|
20
|
+
var _d = useState(false), unlocked = _d[0], setUnlocked = _d[1];
|
|
21
|
+
// A new key remounts the field with focus, so a wrong password leaves the cursor in the field, even after a click on the Button.
|
|
22
|
+
var _e = useState(0), attempt = _e[0], setAttempt = _e[1];
|
|
23
|
+
var timer = useRef();
|
|
24
|
+
var lockAgain = useRef(null);
|
|
25
|
+
// Stops the request if the example goes away before it ends.
|
|
26
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
27
|
+
// The field is gone once the work shows, so focus moves to the first control in it.
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
var _a;
|
|
30
|
+
if (unlocked)
|
|
31
|
+
(_a = lockAgain.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
32
|
+
}, [unlocked]);
|
|
33
|
+
function handleSubmit() {
|
|
34
|
+
if (checking)
|
|
35
|
+
return;
|
|
36
|
+
if (!password.trim()) {
|
|
37
|
+
setError('Enter the password.');
|
|
38
|
+
setAttempt(function (n) { return n + 1; });
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
setError('');
|
|
42
|
+
setChecking(true);
|
|
43
|
+
// Stands in for the request to the server.
|
|
44
|
+
timer.current = setTimeout(function () {
|
|
45
|
+
setChecking(false);
|
|
46
|
+
if (password === PASSPHRASE) {
|
|
47
|
+
setUnlocked(true);
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
setError('That password is not right.');
|
|
51
|
+
setAttempt(function (n) { return n + 1; });
|
|
52
|
+
}
|
|
53
|
+
}, 600);
|
|
54
|
+
}
|
|
55
|
+
if (unlocked) {
|
|
56
|
+
return (<PageShell>
|
|
57
|
+
<Stack gap="xlarge">
|
|
58
|
+
<PageHeader level={1} title="Plan changes, a case study" lede="How we made a plan change clear before anyone pays."/>
|
|
59
|
+
<Paragraph tone="secondary">The screens, the notes and the decisions for this case study are here.</Paragraph>
|
|
60
|
+
<Stack align="start">
|
|
61
|
+
<Button ref={lockAgain} size="medium" type="secondary" state="enabled" label="Lock Again" onClickButton={function () { setUnlocked(false); setPassword(''); }}/>
|
|
62
|
+
</Stack>
|
|
63
|
+
</Stack>
|
|
64
|
+
</PageShell>);
|
|
65
|
+
}
|
|
66
|
+
return (<PageShell>
|
|
67
|
+
<Surface padding="xlarge" minHeight="tall" align="center">
|
|
68
|
+
<Stack gap="large">
|
|
69
|
+
<Heading level={1} size="h5">This case study needs a password</Heading>
|
|
70
|
+
<Paragraph>
|
|
71
|
+
The password comes by email. <Link href="#contact">Ask for the password</Link>.
|
|
72
|
+
</Paragraph>
|
|
73
|
+
<Form aria-label="Private work" onSubmit={handleSubmit}>
|
|
74
|
+
<TextField key={attempt} id="password-gate-password" label="Password" type="password" autoComplete="current-password" autoFocus={attempt > 0} value={password} error={Boolean(error)} errorText={error} onChange={function (e) { setPassword(e.target.value); setError(''); }}/>
|
|
75
|
+
<Stack align="start">
|
|
76
|
+
<Button size="medium" type="primary" state="enabled" label="View Work" htmlType="submit" loading={checking}/>
|
|
77
|
+
</Stack>
|
|
78
|
+
</Form>
|
|
79
|
+
</Stack>
|
|
80
|
+
</Surface>
|
|
81
|
+
</PageShell>);
|
|
82
|
+
}
|