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,176 @@
|
|
|
1
|
+
# Site search
|
|
2
|
+
|
|
3
|
+
A site has many pages, and a person wants to reach one by its name or by a word in it, from any page.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Put a 'Search' `Button` with `decoIcon="Search"` in the `SiteHeader`, in `phoneAction`, so it stays in the bar at every width. Give it `aria-haspopup="dialog"` and `aria-keyshortcuts="Meta+K Control+K"`.
|
|
8
|
+
- Put Search before 'Sign Up' in `phoneAction` on a site with a main action, as an `IconButton` named 'Search', so both fit on a phone.
|
|
9
|
+
- Open the same dialog with Cmd+K, or Ctrl+K on Windows, using `useHotkey('k', …)`. The shortcut does nothing while a person types in a field. Say it on the page in words, as the case 'Quick switcher' does.
|
|
10
|
+
- Use `SearchDialog`. Keep the query and the results in your page and pass them in with `status`. Focus stays in the field; the arrow keys move the highlight, Enter follows the highlighted link and Escape closes it.
|
|
11
|
+
- Group the results under names such as 'Components' and 'Cases', and give each a `secondLabel` that says where it is and an `excerpt` of the text around the match. The words typed are marked in the title and the excerpt, as written, so 'c++ (beta)' is not read as a pattern.
|
|
12
|
+
- Set `status` to 'loading' when you ask and 'done' when the answer comes. After 300 ms the dialog says 'Searching' once and keeps the old results, marked `aria-busy`. A search that is faster than that shows no flash.
|
|
13
|
+
- Number each request and drop a reply for an older query. Keep timers in a ref and clear them on unmount.
|
|
14
|
+
- Show `recent` places before anything is typed, at most six, newest first.
|
|
15
|
+
- Let the dialog say what was searched when nothing matches, with 'Clear Search' that puts focus back in the field, as the case 'Empty search' says. Set `status` to 'error' when the request fails: it says 'Search is not working right now.' with 'Try Again'; pass `onRetry`.
|
|
16
|
+
- Use the case 'Quick switcher' instead inside an app, with workspaces, channels and people.
|
|
17
|
+
|
|
18
|
+
## Don't
|
|
19
|
+
|
|
20
|
+
- Do not put the Search Button in `actions`. On a phone it moves into the menu, which closes when it is chosen, so the dialog has no Button to give focus back to.
|
|
21
|
+
- Do not search on every key with no wait for the answer. Drop an answer that is out of date instead.
|
|
22
|
+
- Do not build the dialog, the list and the keys by hand. `SearchDialog` does the roles, the focus and the status.
|
|
23
|
+
- Do not write the match as a pattern. A person may type brackets or a plus sign.
|
|
24
|
+
- Do not show a spinner in place of the results. Keep the old results on screen while the new ones load.
|
|
25
|
+
- Do not close the dialog when 'Clear Search' is pressed. A person who cleared the words wants to search again.
|
|
26
|
+
|
|
27
|
+
## Example: Search in a dialog
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `Heading`, `PageShell`, `Paragraph`, `SearchDialog`, `SiteHeader`, `Stack`, `useHotkey`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import { useEffect, useRef, useState } from 'react';
|
|
34
|
+
import SiteHeader from 'oneslash-design-system/components/siteHeader';
|
|
35
|
+
import SearchDialog, { type SearchGroup, type SearchResult } from 'oneslash-design-system/components/searchDialog';
|
|
36
|
+
import useHotkey from 'oneslash-design-system/components/useHotkey';
|
|
37
|
+
import Button from 'oneslash-design-system/components/button';
|
|
38
|
+
import PageShell from 'oneslash-design-system/components/pageShell';
|
|
39
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
40
|
+
import Paragraph from 'oneslash-design-system/components/paragraph';
|
|
41
|
+
import { Stack } from 'oneslash-design-system/components/layout';
|
|
42
|
+
|
|
43
|
+
type Entry = SearchResult & { group: 'Components' | 'Cases'; text: string };
|
|
44
|
+
|
|
45
|
+
// A real site asks its server, which has every page. These are the pages of a made-up docs site.
|
|
46
|
+
const entries: Entry[] = [
|
|
47
|
+
{ id: 'button', group: 'Components', title: 'Button', secondLabel: 'Components', href: '#button', iconName: 'MousePointerClick', text: 'The control that starts an action, in four sizes.' },
|
|
48
|
+
{ id: 'tag', group: 'Components', title: 'Tag', secondLabel: 'Components', href: '#tag', iconName: 'Tag', text: 'A short label for a state, such as Paid or Draft.' },
|
|
49
|
+
{ id: 'tabs', group: 'Components', title: 'Tabs', secondLabel: 'Components', href: '#tabs', iconName: 'PanelTop', text: 'Switch between views of one thing on one page.' },
|
|
50
|
+
{ id: 'table', group: 'Components', title: 'Table', secondLabel: 'Components', href: '#table', iconName: 'Table', text: 'Rows and columns that scroll inside their own region.' },
|
|
51
|
+
{ id: 'accordion', group: 'Components', title: 'Accordion', secondLabel: 'Components', href: '#accordion', iconName: 'ChevronsUpDown', text: 'Headings that open a panel under them.' },
|
|
52
|
+
{ id: 'faq', group: 'Cases', title: 'FAQ', secondLabel: 'Cases', href: '#faq', iconName: 'CircleHelp', text: 'Answer the questions a visitor asks before signing up.' },
|
|
53
|
+
{ id: 'pricing', group: 'Cases', title: 'Pricing section', secondLabel: 'Cases', href: '#pricing', iconName: 'CreditCard', text: 'Show the plans side by side with one price each.' },
|
|
54
|
+
{ id: 'login', group: 'Cases', title: 'Login page', secondLabel: 'Cases', href: '#login', iconName: 'LogIn', text: 'Let a person log in with an email or a provider.' },
|
|
55
|
+
{ id: 'tabbed', group: 'Cases', title: 'Tabbed panels', secondLabel: 'Cases', href: '#tabbed', iconName: 'PanelTop', text: 'Four views of one thing, and a visitor reads one.' },
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
const SEARCH_MS = 300;
|
|
59
|
+
|
|
60
|
+
// A stand-in for the request. A real site calls its server here and may fail.
|
|
61
|
+
function searchPages(query: string, keep: (t: ReturnType<typeof setTimeout>) => void): Promise<SearchGroup[]> {
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
keep(setTimeout(() => {
|
|
64
|
+
const words = query.toLowerCase().split(/\s+/).filter(Boolean);
|
|
65
|
+
const found = entries.filter((e) => words.every((w) => `${e.title} ${e.text}`.toLowerCase().includes(w)));
|
|
66
|
+
const groups = (['Components', 'Cases'] as const)
|
|
67
|
+
.map((label) => ({ label, items: found.filter((e) => e.group === label).map(({ group, text, ...item }) => ({ ...item, excerpt: text })) }))
|
|
68
|
+
.filter((g) => g.items.length > 0);
|
|
69
|
+
resolve(groups);
|
|
70
|
+
}, SEARCH_MS));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Visited pages, most recent first. A real site keeps them for the person.
|
|
75
|
+
const recent: SearchResult[] = entries.slice(0, 3).map(({ group, text, ...item }) => item);
|
|
76
|
+
|
|
77
|
+
export default function SiteSearchDialog() {
|
|
78
|
+
const [open, setOpen] = useState(false);
|
|
79
|
+
const [query, setQuery] = useState('');
|
|
80
|
+
const [groups, setGroups] = useState<SearchGroup[]>([]);
|
|
81
|
+
const [status, setStatus] = useState<'idle' | 'loading' | 'done' | 'error'>('idle');
|
|
82
|
+
// Each request has a number; only the newest one may answer.
|
|
83
|
+
const latest = useRef(0);
|
|
84
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
85
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
86
|
+
|
|
87
|
+
function run(next: string) {
|
|
88
|
+
const id = ++latest.current;
|
|
89
|
+
if (next.trim() === '') {
|
|
90
|
+
setStatus('idle');
|
|
91
|
+
setGroups([]);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
setStatus('loading');
|
|
95
|
+
// An older request's timer is cleared, so only one is ever pending and unmount clears it
|
|
96
|
+
searchPages(next, (t) => {
|
|
97
|
+
clearTimeout(timer.current);
|
|
98
|
+
timer.current = t;
|
|
99
|
+
})
|
|
100
|
+
.then((found) => {
|
|
101
|
+
// A reply for an older query is dropped
|
|
102
|
+
if (id !== latest.current) return;
|
|
103
|
+
setGroups(found);
|
|
104
|
+
setStatus('done');
|
|
105
|
+
})
|
|
106
|
+
.catch(() => {
|
|
107
|
+
if (id !== latest.current) return;
|
|
108
|
+
setStatus('error');
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function change(next: string) {
|
|
113
|
+
setQuery(next);
|
|
114
|
+
run(next);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function show() {
|
|
118
|
+
setQuery('');
|
|
119
|
+
run('');
|
|
120
|
+
setOpen(true);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Cmd+K, or Ctrl+K on Windows, from anywhere on the page except a text field
|
|
124
|
+
useHotkey('k', () => {
|
|
125
|
+
if (!open) show();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<>
|
|
130
|
+
{/* The Search Button is the main action of the bar, so it stays beside the brand at every width. */}
|
|
131
|
+
<SiteHeader
|
|
132
|
+
brand={{ href: '#top', name: 'Acme' }}
|
|
133
|
+
links={[
|
|
134
|
+
{ label: 'Guides', href: '#guides' },
|
|
135
|
+
{ label: 'Components', href: '#components', current: true },
|
|
136
|
+
{ label: 'Cases', href: '#cases' },
|
|
137
|
+
]}
|
|
138
|
+
phoneAction={
|
|
139
|
+
<Button
|
|
140
|
+
size="medium"
|
|
141
|
+
type="secondary"
|
|
142
|
+
state="enabled"
|
|
143
|
+
label="Search"
|
|
144
|
+
decoIcon="Search"
|
|
145
|
+
aria-haspopup="dialog"
|
|
146
|
+
aria-keyshortcuts="Meta+K Control+K"
|
|
147
|
+
onClickButton={show}
|
|
148
|
+
/>
|
|
149
|
+
}
|
|
150
|
+
mainId="site-search-main"
|
|
151
|
+
/>
|
|
152
|
+
<PageShell id="site-search-main" tabIndex={-1}>
|
|
153
|
+
<Stack gap="large">
|
|
154
|
+
<Heading level={1} size="h5">Components</Heading>
|
|
155
|
+
<Paragraph tone="secondary" measure="none">Press Cmd+K, or Ctrl+K on Windows, to search every page.</Paragraph>
|
|
156
|
+
</Stack>
|
|
157
|
+
</PageShell>
|
|
158
|
+
<SearchDialog
|
|
159
|
+
isOpen={open}
|
|
160
|
+
onClose={() => setOpen(false)}
|
|
161
|
+
query={query}
|
|
162
|
+
onQueryChange={change}
|
|
163
|
+
groups={groups}
|
|
164
|
+
status={status}
|
|
165
|
+
onRetry={() => run(query)}
|
|
166
|
+
recent={recent}
|
|
167
|
+
placeholder="Search components and cases"
|
|
168
|
+
/>
|
|
169
|
+
</>
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Native
|
|
175
|
+
|
|
176
|
+
On Apple use `searchable` on a `NavigationStack`, with `searchSuggestions` for recent places and `searchScopes` for the groups. On Android use a `SearchBar` with a `DockedSearchBar` or a full-screen search view.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function StatRowFeatured(): import("react").JSX.Element;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import StatTile from '../../components/statTile';
|
|
4
|
+
import { Center, Grid, Stack } from '../../components/layout';
|
|
5
|
+
export default function StatRowFeatured() {
|
|
6
|
+
return (<Center width="page">
|
|
7
|
+
<Stack gap="large">
|
|
8
|
+
<Heading level={2} size="h6">This month</Heading>
|
|
9
|
+
{/* The number that matters most is one step larger and has the row to itself. */}
|
|
10
|
+
<StatTile label="Responses" value={48210} previous={41980} period="month" size="large"/>
|
|
11
|
+
<Grid compact columns={2}>
|
|
12
|
+
<StatTile label="Estimated cost" value={96.4} format="money" previous={88.2} period="month"/>
|
|
13
|
+
<StatTile label="Data stored" value={1288490188} format="bytes" previous={1073741824} period="month"/>
|
|
14
|
+
</Grid>
|
|
15
|
+
</Stack>
|
|
16
|
+
</Center>);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function StatRowTiles(): import("react").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import Heading from '../../components/heading';
|
|
4
|
+
import StatTile from '../../components/statTile';
|
|
5
|
+
import Button from '../../components/button';
|
|
6
|
+
import { Center, Cluster, Grid, Stack } from '../../components/layout';
|
|
7
|
+
export default function StatRowTiles() {
|
|
8
|
+
var _a = useState(false), loading = _a[0], setLoading = _a[1];
|
|
9
|
+
var timer = useRef();
|
|
10
|
+
// Stops the request if the example goes away before it ends.
|
|
11
|
+
useEffect(function () { return function () { return clearTimeout(timer.current); }; }, []);
|
|
12
|
+
function reload() {
|
|
13
|
+
if (loading)
|
|
14
|
+
return;
|
|
15
|
+
setLoading(true);
|
|
16
|
+
// Stands in for the request to the server.
|
|
17
|
+
timer.current = setTimeout(function () { return setLoading(false); }, 1200);
|
|
18
|
+
}
|
|
19
|
+
return (<Center width="page">
|
|
20
|
+
<Stack gap="large">
|
|
21
|
+
<Cluster justify="between">
|
|
22
|
+
<Heading level={2} size="h6">This week</Heading>
|
|
23
|
+
<Button size="small" type="tertiary" state="enabled" label="Reload" decoIcon="RefreshCw" onClickButton={reload}/>
|
|
24
|
+
</Cluster>
|
|
25
|
+
{/* Four tiles at most. Two across on a phone, four from md up. Each counts one thing over the same range. */}
|
|
26
|
+
<Grid compact columns={4}>
|
|
27
|
+
<StatTile label="New comments" value={1240} previous={1106} loading={loading}/>
|
|
28
|
+
<StatTile label="Marked done" value={312} previous={280} loading={loading}/>
|
|
29
|
+
<StatTile label="People engaged" value={18} previous={18} loading={loading}/>
|
|
30
|
+
<StatTile label="Average reply time" value={8640000} format="duration" previous={9200000} loading={loading}/>
|
|
31
|
+
</Grid>
|
|
32
|
+
</Stack>
|
|
33
|
+
</Center>);
|
|
34
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# Stat row
|
|
2
|
+
|
|
3
|
+
A page opens with the few numbers that say how things are going, counted over one range.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Follow the rule 'A number shows its unit and never shows 0 for unknown'. Use `StatTile`, which does.
|
|
8
|
+
- Put the tiles in `<Grid compact columns={4}>`: two across on a phone, up to four from md up.
|
|
9
|
+
- Use four tiles at most. A fifth number goes in a table.
|
|
10
|
+
- Make each tile count one thing, with its unit in the label or the `unit` prop: 'New comments', 'Responses'.
|
|
11
|
+
- Count every tile over the same range, and say the range in the heading above the row: 'This week'.
|
|
12
|
+
- Pass `previous` and `period` to get the change line, such as 'Up 12% from last week'. Leave `previous` out when there is nothing to compare with.
|
|
13
|
+
- Pass `loading` while the numbers load, so a `Skeleton` holds each place. Pass `value={null}` when there is no data: the tile says 'No data yet'.
|
|
14
|
+
- Pass `format` for money, a percent, a size or a time, such as `format="money"`. Do not format a number by hand.
|
|
15
|
+
- Give the one number that matters most `size="large"` and a row of its own, with the others under it.
|
|
16
|
+
|
|
17
|
+
## Don't
|
|
18
|
+
|
|
19
|
+
- Do not show 0 while a number loads or when it is missing.
|
|
20
|
+
- Do not color a change green or red. More is not good or bad by itself.
|
|
21
|
+
- Do not put more than four tiles in a row, or two things in one tile.
|
|
22
|
+
- Do not draw a chart or a sparkline in a tile. A trend is the change line.
|
|
23
|
+
- Do not box each tile in a card. The row sits on the page.
|
|
24
|
+
|
|
25
|
+
## Option: Tiles of equal weight
|
|
26
|
+
|
|
27
|
+
Use when: Two to four numbers matter about the same, over one range.
|
|
28
|
+
|
|
29
|
+
Uses: `Button`, `Center`, `Cluster`, `Grid`, `Heading`, `Stack`, `StatTile`
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
'use client';
|
|
33
|
+
import { useEffect, useRef, useState } from 'react';
|
|
34
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
35
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
36
|
+
import Button from 'oneslash-design-system/components/button';
|
|
37
|
+
import { Center, Cluster, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
38
|
+
|
|
39
|
+
export default function StatRowTiles() {
|
|
40
|
+
const [loading, setLoading] = useState(false);
|
|
41
|
+
const timer = useRef<ReturnType<typeof setTimeout>>();
|
|
42
|
+
|
|
43
|
+
// Stops the request if the example goes away before it ends.
|
|
44
|
+
useEffect(() => () => clearTimeout(timer.current), []);
|
|
45
|
+
|
|
46
|
+
function reload() {
|
|
47
|
+
if (loading) return;
|
|
48
|
+
setLoading(true);
|
|
49
|
+
// Stands in for the request to the server.
|
|
50
|
+
timer.current = setTimeout(() => setLoading(false), 1200);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Center width="page">
|
|
55
|
+
<Stack gap="large">
|
|
56
|
+
<Cluster justify="between">
|
|
57
|
+
<Heading level={2} size="h6">This week</Heading>
|
|
58
|
+
<Button size="small" type="tertiary" state="enabled" label="Reload" decoIcon="RefreshCw" onClickButton={reload} />
|
|
59
|
+
</Cluster>
|
|
60
|
+
{/* Four tiles at most. Two across on a phone, four from md up. Each counts one thing over the same range. */}
|
|
61
|
+
<Grid compact columns={4}>
|
|
62
|
+
<StatTile label="New comments" value={1240} previous={1106} loading={loading} />
|
|
63
|
+
<StatTile label="Marked done" value={312} previous={280} loading={loading} />
|
|
64
|
+
<StatTile label="People engaged" value={18} previous={18} loading={loading} />
|
|
65
|
+
<StatTile label="Average reply time" value={8_640_000} format="duration" previous={9_200_000} loading={loading} />
|
|
66
|
+
</Grid>
|
|
67
|
+
</Stack>
|
|
68
|
+
</Center>
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Option: One number first
|
|
74
|
+
|
|
75
|
+
Use when: One number matters most, with two others under it.
|
|
76
|
+
|
|
77
|
+
Uses: `Center`, `Grid`, `Heading`, `Stack`, `StatTile`
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
'use client';
|
|
81
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
82
|
+
import StatTile from 'oneslash-design-system/components/statTile';
|
|
83
|
+
import { Center, Grid, Stack } from 'oneslash-design-system/components/layout';
|
|
84
|
+
|
|
85
|
+
export default function StatRowFeatured() {
|
|
86
|
+
return (
|
|
87
|
+
<Center width="page">
|
|
88
|
+
<Stack gap="large">
|
|
89
|
+
<Heading level={2} size="h6">This month</Heading>
|
|
90
|
+
{/* The number that matters most is one step larger and has the row to itself. */}
|
|
91
|
+
<StatTile label="Responses" value={48210} previous={41980} period="month" size="large" />
|
|
92
|
+
<Grid compact columns={2}>
|
|
93
|
+
<StatTile label="Estimated cost" value={96.4} format="money" previous={88.2} period="month" />
|
|
94
|
+
<StatTile label="Data stored" value={1_288_490_188} format="bytes" previous={1_073_741_824} period="month" />
|
|
95
|
+
</Grid>
|
|
96
|
+
</Stack>
|
|
97
|
+
</Center>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Native
|
|
103
|
+
|
|
104
|
+
On Apple use a `LabeledContent` or a `Grid` of `VStack`s with the number in `.title2` and `monospacedDigit()`. On Android use a `Row` of `Column`s with `headlineMedium` text.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function StatusLabelDot(): import("react").JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import Tag from '../../components/tag';
|
|
4
|
+
import TableContainer from '../../components/tableContainer';
|
|
5
|
+
import TableHeader from '../../components/tableHeader';
|
|
6
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
7
|
+
import TableRow from '../../components/tableRow';
|
|
8
|
+
import TableCell from '../../components/tableCell';
|
|
9
|
+
import { Center, Stack } from '../../components/layout';
|
|
10
|
+
// A real app reads these from the server.
|
|
11
|
+
var workspaces = [
|
|
12
|
+
{ id: 'acme', name: 'Acme', plan: 'Pro', status: 'Past due', color: 'error' },
|
|
13
|
+
{ id: 'acme-labs', name: 'Acme Labs', plan: 'Pro', status: 'Canceling', color: 'warning' },
|
|
14
|
+
{ id: 'acme-studio', name: 'Acme Studio', plan: 'Pro', status: 'Active', color: undefined },
|
|
15
|
+
];
|
|
16
|
+
export default function StatusLabelDot() {
|
|
17
|
+
return (<Center width="page">
|
|
18
|
+
<Stack gap="large">
|
|
19
|
+
<Heading level={2} size="h5">Workspaces</Heading>
|
|
20
|
+
<TableContainer aria-label="Workspaces" minWidth="480px">
|
|
21
|
+
<TableHeader>
|
|
22
|
+
<TableRow>
|
|
23
|
+
<TableHeaderCell>Workspace</TableHeaderCell>
|
|
24
|
+
<TableHeaderCell width="100px">Plan</TableHeaderCell>
|
|
25
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
26
|
+
</TableRow>
|
|
27
|
+
</TableHeader>
|
|
28
|
+
{workspaces.map(function (w) { return (<TableRow key={w.id}>
|
|
29
|
+
<TableCell>{w.name}</TableCell>
|
|
30
|
+
<TableCell width="100px">{w.plan}</TableCell>
|
|
31
|
+
<TableCell width="160px">
|
|
32
|
+
{/* The word is always there. Only a state that needs action gets a color: 'Active' keeps the grey dot. */}
|
|
33
|
+
<Tag variant="dot" size="small" color={w.color} label={w.status}/>
|
|
34
|
+
</TableCell>
|
|
35
|
+
</TableRow>); })}
|
|
36
|
+
</TableContainer>
|
|
37
|
+
</Stack>
|
|
38
|
+
</Center>);
|
|
39
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function StatusLabelText(): import("react").JSX.Element;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import Heading from '../../components/heading';
|
|
3
|
+
import Tag from '../../components/tag';
|
|
4
|
+
import TableContainer from '../../components/tableContainer';
|
|
5
|
+
import TableHeader from '../../components/tableHeader';
|
|
6
|
+
import TableHeaderCell from '../../components/tableHeaderCell';
|
|
7
|
+
import TableRow from '../../components/tableRow';
|
|
8
|
+
import TableCell from '../../components/tableCell';
|
|
9
|
+
import { formatMoney } from '../../components/formatNumber';
|
|
10
|
+
import { Center, Stack } from '../../components/layout';
|
|
11
|
+
// A real app reads these from the server.
|
|
12
|
+
var payments = [
|
|
13
|
+
{ id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
|
|
14
|
+
{ id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
|
|
15
|
+
{ id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
|
|
16
|
+
{ id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
|
|
17
|
+
];
|
|
18
|
+
export default function StatusLabelText() {
|
|
19
|
+
return (<Center width="page">
|
|
20
|
+
<Stack gap="large">
|
|
21
|
+
<Heading level={2} size="h5">Payments</Heading>
|
|
22
|
+
<TableContainer aria-label="Payments" minWidth="480px">
|
|
23
|
+
<TableHeader>
|
|
24
|
+
<TableRow>
|
|
25
|
+
<TableHeaderCell>Date</TableHeaderCell>
|
|
26
|
+
<TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
|
|
27
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
28
|
+
</TableRow>
|
|
29
|
+
</TableHeader>
|
|
30
|
+
{payments.map(function (p) { return (<TableRow key={p.id}>
|
|
31
|
+
<TableCell>{p.date}</TableCell>
|
|
32
|
+
<TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
|
|
33
|
+
<TableCell width="160px">
|
|
34
|
+
{p.status === 'Upcoming' ? (
|
|
35
|
+
// The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
|
|
36
|
+
<Tag variant="dot" size="small" color="info" label={p.status}/>) : (
|
|
37
|
+
// A settled record is a word with no dot and no color.
|
|
38
|
+
<Tag variant="textOnly" size="small" label={p.status}/>)}
|
|
39
|
+
</TableCell>
|
|
40
|
+
</TableRow>); })}
|
|
41
|
+
</TableContainer>
|
|
42
|
+
</Stack>
|
|
43
|
+
</Center>);
|
|
44
|
+
}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# Status in a row
|
|
2
|
+
|
|
3
|
+
A row in a table or a list says what state its thing is in, such as an invoice, a plan or a connection. ODS has no separate Badge part, because `Tag` does a Badge's job.
|
|
4
|
+
|
|
5
|
+
## Do
|
|
6
|
+
|
|
7
|
+
- Use `Tag` for a state in a row, with `size="small"`. ODS has no Badge part: a second part for the same job would mark the same states two ways.
|
|
8
|
+
- Show the word every time. The dot alone means nothing to a screen reader or to a person who cannot tell the colors apart.
|
|
9
|
+
- Use `variant="dot"` for a state that changes and may need the person: 'Past due', 'Canceling', 'Connected'.
|
|
10
|
+
- Give the dot a color only when the state needs action: `color="error"` for 'Past due', `color="warning"` for 'Canceling'. One exception: `color="info"` for a charge that has not happened yet, 'Upcoming', so it does not read as paid. A usual state, such as 'Connected', keeps the grey dot.
|
|
11
|
+
- Use `variant="textOnly"` with no color for a settled record: 'Paid', 'Refunded'.
|
|
12
|
+
- Write one word or two, in sentence case: 'Past due', 'Needs reconnecting'.
|
|
13
|
+
- Put the Tag in a 'Status' column, or at the end of the row's text. It is not clickable.
|
|
14
|
+
|
|
15
|
+
## Don't
|
|
16
|
+
|
|
17
|
+
- Do not show a dot with no word, or a color with no word.
|
|
18
|
+
- Do not color a settled state. A green 'Paid' on every row hides the one red 'Past due'.
|
|
19
|
+
- Do not write the word in Title Case ('Past Due') or as a sentence ('Your payment is late').
|
|
20
|
+
- Do not fill the Tag with `variant="contained"` for a status in a row. A filled Tag is a label the person picks.
|
|
21
|
+
- Do not make the Tag a button. A status that opens something is a row action, in the More menu.
|
|
22
|
+
- Do not draw the dot by hand.
|
|
23
|
+
|
|
24
|
+
## Option: A dot and a word
|
|
25
|
+
|
|
26
|
+
Use when: The state changes and may need the person: Past due, Canceling, Connected.
|
|
27
|
+
|
|
28
|
+
Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`
|
|
29
|
+
|
|
30
|
+
```tsx
|
|
31
|
+
'use client';
|
|
32
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
33
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
34
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
35
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
36
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
37
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
38
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
39
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
40
|
+
|
|
41
|
+
type Color = 'error' | 'warning' | undefined;
|
|
42
|
+
|
|
43
|
+
// A real app reads these from the server.
|
|
44
|
+
const workspaces: { id: string; name: string; plan: string; status: string; color: Color }[] = [
|
|
45
|
+
{ id: 'acme', name: 'Acme', plan: 'Pro', status: 'Past due', color: 'error' },
|
|
46
|
+
{ id: 'acme-labs', name: 'Acme Labs', plan: 'Pro', status: 'Canceling', color: 'warning' },
|
|
47
|
+
{ id: 'acme-studio', name: 'Acme Studio', plan: 'Pro', status: 'Active', color: undefined },
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default function StatusLabelDot() {
|
|
51
|
+
return (
|
|
52
|
+
<Center width="page">
|
|
53
|
+
<Stack gap="large">
|
|
54
|
+
<Heading level={2} size="h5">Workspaces</Heading>
|
|
55
|
+
<TableContainer aria-label="Workspaces" minWidth="480px">
|
|
56
|
+
<TableHeader>
|
|
57
|
+
<TableRow>
|
|
58
|
+
<TableHeaderCell>Workspace</TableHeaderCell>
|
|
59
|
+
<TableHeaderCell width="100px">Plan</TableHeaderCell>
|
|
60
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
61
|
+
</TableRow>
|
|
62
|
+
</TableHeader>
|
|
63
|
+
{workspaces.map((w) => (
|
|
64
|
+
<TableRow key={w.id}>
|
|
65
|
+
<TableCell>{w.name}</TableCell>
|
|
66
|
+
<TableCell width="100px">{w.plan}</TableCell>
|
|
67
|
+
<TableCell width="160px">
|
|
68
|
+
{/* The word is always there. Only a state that needs action gets a color: 'Active' keeps the grey dot. */}
|
|
69
|
+
<Tag variant="dot" size="small" color={w.color} label={w.status} />
|
|
70
|
+
</TableCell>
|
|
71
|
+
</TableRow>
|
|
72
|
+
))}
|
|
73
|
+
</TableContainer>
|
|
74
|
+
</Stack>
|
|
75
|
+
</Center>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Option: A word alone
|
|
81
|
+
|
|
82
|
+
Use when: The record is settled and nothing is left to do: Paid, Refunded.
|
|
83
|
+
|
|
84
|
+
Uses: `Center`, `Heading`, `Stack`, `TableCell`, `TableContainer`, `TableHeader`, `TableHeaderCell`, `TableRow`, `Tag`, `formatMoney`
|
|
85
|
+
|
|
86
|
+
```tsx
|
|
87
|
+
'use client';
|
|
88
|
+
import Heading from 'oneslash-design-system/components/heading';
|
|
89
|
+
import Tag from 'oneslash-design-system/components/tag';
|
|
90
|
+
import TableContainer from 'oneslash-design-system/components/tableContainer';
|
|
91
|
+
import TableHeader from 'oneslash-design-system/components/tableHeader';
|
|
92
|
+
import TableHeaderCell from 'oneslash-design-system/components/tableHeaderCell';
|
|
93
|
+
import TableRow from 'oneslash-design-system/components/tableRow';
|
|
94
|
+
import TableCell from 'oneslash-design-system/components/tableCell';
|
|
95
|
+
import { formatMoney } from 'oneslash-design-system/components/formatNumber';
|
|
96
|
+
import { Center, Stack } from 'oneslash-design-system/components/layout';
|
|
97
|
+
|
|
98
|
+
// A real app reads these from the server.
|
|
99
|
+
const payments = [
|
|
100
|
+
{ id: 'p0', date: 'Dec 1, 2026', amount: 24, status: 'Upcoming' },
|
|
101
|
+
{ id: 'p1', date: 'Nov 1, 2026', amount: 24, status: 'Paid' },
|
|
102
|
+
{ id: 'p2', date: 'Oct 1, 2026', amount: 24, status: 'Paid' },
|
|
103
|
+
{ id: 'p3', date: 'Sep 1, 2026', amount: 24, status: 'Refunded' },
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export default function StatusLabelText() {
|
|
107
|
+
return (
|
|
108
|
+
<Center width="page">
|
|
109
|
+
<Stack gap="large">
|
|
110
|
+
<Heading level={2} size="h5">Payments</Heading>
|
|
111
|
+
<TableContainer aria-label="Payments" minWidth="480px">
|
|
112
|
+
<TableHeader>
|
|
113
|
+
<TableRow>
|
|
114
|
+
<TableHeaderCell>Date</TableHeaderCell>
|
|
115
|
+
<TableHeaderCell width="120px" align="right">Amount</TableHeaderCell>
|
|
116
|
+
<TableHeaderCell width="160px">Status</TableHeaderCell>
|
|
117
|
+
</TableRow>
|
|
118
|
+
</TableHeader>
|
|
119
|
+
{payments.map((p) => (
|
|
120
|
+
<TableRow key={p.id}>
|
|
121
|
+
<TableCell>{p.date}</TableCell>
|
|
122
|
+
<TableCell width="120px" align="right">{formatMoney(p.amount)}</TableCell>
|
|
123
|
+
<TableCell width="160px">
|
|
124
|
+
{p.status === 'Upcoming' ? (
|
|
125
|
+
// The one exception: a charge that has not happened yet is an info dot, so it does not read as paid.
|
|
126
|
+
<Tag variant="dot" size="small" color="info" label={p.status} />
|
|
127
|
+
) : (
|
|
128
|
+
// A settled record is a word with no dot and no color.
|
|
129
|
+
<Tag variant="textOnly" size="small" label={p.status} />
|
|
130
|
+
)}
|
|
131
|
+
</TableCell>
|
|
132
|
+
</TableRow>
|
|
133
|
+
))}
|
|
134
|
+
</TableContainer>
|
|
135
|
+
</Stack>
|
|
136
|
+
</Center>
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Native
|
|
142
|
+
|
|
143
|
+
On Apple use a `Label` with a small filled circle as its image and the word, colored with a semantic style only when the state needs action. On Android use a leading dot and the word in a `Text`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function TabbedPanelsTabs(): import("react").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import PageShell from '../../components/pageShell';
|
|
4
|
+
import SectionIntro from '../../components/sectionIntro';
|
|
5
|
+
import TabsContainer from '../../components/tabsContainer';
|
|
6
|
+
import Tab from '../../components/tab';
|
|
7
|
+
import TabPanel from '../../components/tabPanel';
|
|
8
|
+
import Heading from '../../components/heading';
|
|
9
|
+
import Paragraph from '../../components/paragraph';
|
|
10
|
+
import List from '../../components/list';
|
|
11
|
+
import { PageSection, Stack } from '../../components/layout';
|
|
12
|
+
// Four views of one thing, and a visitor reads one. The first is the one most visitors need.
|
|
13
|
+
var views = [
|
|
14
|
+
{ id: 'channels', label: 'Channels', title: 'One place for each subject', line: 'A channel holds the talk about one team or project.', points: ['Everyone in a channel sees every message.', 'Pin the messages people need again.', 'Turn a message into a task when it needs an owner.'] },
|
|
15
|
+
{ id: 'tasks', label: 'Tasks', title: 'A task and its talk together', line: 'A task keeps its owner, its status and its talk together.', points: ['Give a task one owner and one due date.', 'Reply in the task, not in the channel.', 'Close the task when the work is done.'] },
|
|
16
|
+
{ id: 'notes', label: 'Notes', title: 'Notes the whole team can search', line: 'Write a decision once and find it later.', points: ['Link a note to the task it came from.', 'Search every note from one box.', 'Export a note to PDF on Pro and Business.'] },
|
|
17
|
+
{ id: 'agent', label: 'Agent', title: 'Answers with their sources', line: 'Ask the agent a question in any channel or task.', points: ['It says which notes and messages it used.', 'It never reads a channel you are not in.', 'Each reply counts as one AI agent response.'] },
|
|
18
|
+
];
|
|
19
|
+
export default function TabbedPanelsTabs() {
|
|
20
|
+
var _a = useState('channels'), selected = _a[0], setSelected = _a[1];
|
|
21
|
+
return (<PageShell>
|
|
22
|
+
<PageSection gap="xxlarge">
|
|
23
|
+
<SectionIntro id="how-it-works" name="How it works" statement="Four parts, each for one kind of work."/>
|
|
24
|
+
<Stack gap="xlarge">
|
|
25
|
+
{/* Title Case, one short word each. The tablist is named by the section's heading, and each Tab controls its panel. */}
|
|
26
|
+
<TabsContainer aria-labelledby="how-it-works">
|
|
27
|
+
{views.map(function (v) { return (<Tab key={v.id} id={"tabbed-panels-tab-".concat(v.id)} controls={"tabbed-panels-panel-".concat(v.id)} size="small" label={v.label} isSelected={v.id === selected} onClickTab={function () { return setSelected(v.id); }}/>); })}
|
|
28
|
+
</TabsContainer>
|
|
29
|
+
{/* Every panel is in the page. Only the selected one shows. */}
|
|
30
|
+
{views.map(function (v) { return (<TabPanel key={v.id} id={"tabbed-panels-panel-".concat(v.id)} labelledBy={"tabbed-panels-tab-".concat(v.id)} selected={v.id === selected}>
|
|
31
|
+
<Stack gap="medium">
|
|
32
|
+
<Heading level={3} size="h5">{v.title}</Heading>
|
|
33
|
+
<Paragraph tone="secondary" measure="none">{v.line}</Paragraph>
|
|
34
|
+
<List items={v.points} marker="dot"/>
|
|
35
|
+
</Stack>
|
|
36
|
+
</TabPanel>); })}
|
|
37
|
+
</Stack>
|
|
38
|
+
</PageSection>
|
|
39
|
+
</PageShell>);
|
|
40
|
+
}
|