@slashsuite/ui-react 0.12.1 → 0.13.1
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/MIGRATING.md +386 -8
- package/README.md +89 -44
- package/agent-docs/components/app-shell.md +9 -6
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/badge.md +2 -1
- package/agent-docs/components/body-text.md +26 -15
- package/agent-docs/components/bottom-sheet.md +27 -17
- package/agent-docs/components/breadcrumbs.md +10 -6
- package/agent-docs/components/button.md +2 -2
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +4 -3
- package/agent-docs/components/card-grid.md +15 -7
- package/agent-docs/components/card.md +33 -18
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/chat-composer.md +4 -3
- package/agent-docs/components/checkbox.md +11 -5
- package/agent-docs/components/cluster.md +10 -8
- package/agent-docs/components/code-example.md +2 -2
- package/agent-docs/components/code.md +7 -5
- package/agent-docs/components/colour-scheme-toggle.md +12 -6
- package/agent-docs/components/colour-swatch.md +41 -0
- package/agent-docs/components/combobox.md +88 -0
- package/agent-docs/components/confirm-dialog.md +98 -0
- package/agent-docs/components/container.md +2 -1
- package/agent-docs/components/copy-button.md +7 -5
- package/agent-docs/components/copy-line.md +6 -5
- package/agent-docs/components/date-field.md +14 -11
- package/agent-docs/components/date-range-picker.md +16 -9
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/dialog.md +22 -68
- package/agent-docs/components/disclosure.md +4 -0
- package/agent-docs/components/docs-layout.md +10 -6
- package/agent-docs/components/drawer.md +13 -4
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +4 -1
- package/agent-docs/components/field-dialog.md +6 -5
- package/agent-docs/components/field.md +10 -7
- package/agent-docs/components/fieldset.md +4 -4
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +4 -1
- package/agent-docs/components/form-row.md +7 -7
- package/agent-docs/components/full-bleed-layout.md +0 -2
- package/agent-docs/components/headings.md +13 -7
- package/agent-docs/components/hero.md +11 -2
- package/agent-docs/components/icon-button.md +1 -3
- package/agent-docs/components/icon.md +6 -13
- package/agent-docs/components/image.md +24 -14
- package/agent-docs/components/input.md +8 -7
- package/agent-docs/components/key-value-list.md +4 -1
- package/agent-docs/components/lightbox.md +1 -1
- package/agent-docs/components/list-layout.md +5 -7
- package/agent-docs/components/list-row.md +37 -34
- package/agent-docs/components/loading.md +2 -2
- package/agent-docs/components/markdown.md +13 -13
- package/agent-docs/components/media-tile.md +8 -4
- package/agent-docs/components/menu.md +19 -12
- package/agent-docs/components/meta-list.md +2 -2
- package/agent-docs/components/morph.md +11 -5
- package/agent-docs/components/navigation-progress.md +2 -2
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +19 -8
- package/agent-docs/components/page-fade.md +2 -1
- package/agent-docs/components/pill.md +7 -6
- package/agent-docs/components/popover.md +63 -0
- package/agent-docs/components/price.md +49 -0
- package/agent-docs/components/product-tile.md +78 -0
- package/agent-docs/components/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +1 -1
- package/agent-docs/components/radio-group.md +9 -6
- package/agent-docs/components/scroll-strip.md +3 -3
- package/agent-docs/components/segmented-control.md +4 -2
- package/agent-docs/components/select.md +8 -3
- package/agent-docs/components/show.md +2 -2
- package/agent-docs/components/side-column.md +13 -9
- package/agent-docs/components/sidebar-layout.md +1 -1
- package/agent-docs/components/site-footer.md +4 -4
- package/agent-docs/components/site-search.md +21 -9
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +15 -10
- package/agent-docs/components/stack.md +3 -3
- package/agent-docs/components/stacked-bar.md +7 -4
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +13 -6
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/switch.md +4 -4
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +35 -24
- package/agent-docs/components/tabs.md +24 -26
- package/agent-docs/components/text-link.md +12 -7
- package/agent-docs/components/textarea.md +4 -2
- package/agent-docs/components/toast.md +19 -14
- package/agent-docs/components/video.md +7 -2
- package/agent-docs/llms.txt +22 -3
- package/dist/AppShell.d.ts +25 -9
- package/dist/AppShell.js +67 -33
- package/dist/AppShellMenu.d.ts +31 -18
- package/dist/AppShellMenu.js +72 -45
- package/dist/ArticleLayout.d.ts +36 -0
- package/dist/ArticleLayout.js +27 -0
- package/dist/Audio.d.ts +16 -0
- package/dist/Audio.js +11 -0
- package/dist/Badge.d.ts +2 -1
- package/dist/Badge.js +3 -2
- package/dist/BottomSheet.d.ts +17 -6
- package/dist/BottomSheet.js +62 -11
- package/dist/Breadcrumbs.d.ts +8 -6
- package/dist/Breadcrumbs.js +17 -7
- package/dist/Button.d.ts +4 -2
- package/dist/Button.js +9 -87
- package/dist/CallToAction.d.ts +25 -0
- package/dist/CallToAction.js +17 -0
- package/dist/Callout.d.ts +2 -2
- package/dist/Callout.js +2 -2
- package/dist/Card.d.ts +88 -31
- package/dist/Card.js +55 -92
- package/dist/CardBody.d.ts +2 -0
- package/dist/CardBody.js +33 -3
- package/dist/CardGrid.d.ts +32 -4
- package/dist/CardGrid.js +42 -8
- package/dist/CardParts.d.ts +7 -1
- package/dist/CardParts.js +7 -2
- package/dist/CartButton.d.ts +33 -0
- package/dist/CartButton.js +18 -0
- package/dist/ChatComposer.d.ts +10 -4
- package/dist/ChatComposer.js +35 -13
- package/dist/Checkbox.d.ts +21 -3
- package/dist/Checkbox.js +66 -20
- package/dist/Chevron.js +1 -1
- package/dist/Cluster.d.ts +28 -15
- package/dist/Cluster.js +21 -4
- package/dist/Code.d.ts +15 -3
- package/dist/Code.js +23 -3
- package/dist/CodeBlock.d.ts +4 -4
- package/dist/CodeBlock.js +2 -2
- package/dist/CodeBody.d.ts +1 -1
- package/dist/CodeBody.js +4 -10
- package/dist/CodeExample.d.ts +1 -1
- package/dist/CodeExample.js +3 -2
- package/dist/ColourSchemeToggle.d.ts +21 -5
- package/dist/ColourSchemeToggle.js +15 -9
- package/dist/ColourSwatch.d.ts +15 -0
- package/dist/ColourSwatch.js +14 -0
- package/dist/Combobox.d.ts +42 -0
- package/dist/Combobox.js +43 -0
- package/dist/ConfirmDialog.d.ts +40 -0
- package/dist/ConfirmDialog.js +36 -0
- package/dist/Container.d.ts +3 -3
- package/dist/Container.js +1 -1
- package/dist/CopyButton.d.ts +8 -2
- package/dist/CopyButton.js +38 -28
- package/dist/CopyLine.d.ts +4 -2
- package/dist/CopyLine.js +4 -4
- package/dist/DateCalendar.d.ts +2 -0
- package/dist/DateCalendar.js +11 -9
- package/dist/DateField.d.ts +52 -21
- package/dist/DateField.js +73 -37
- package/dist/DateFieldCalendar.d.ts +12 -8
- package/dist/DateFieldCalendar.js +37 -18
- package/dist/DateRangePicker.d.ts +23 -3
- package/dist/DateRangePicker.js +10 -8
- package/dist/DateTimeField.d.ts +31 -0
- package/dist/DateTimeField.js +19 -0
- package/dist/Dialog.d.ts +42 -6
- package/dist/Dialog.js +50 -12
- package/dist/Disclosure.js +9 -1
- package/dist/DocsLayout.d.ts +13 -5
- package/dist/DocsLayout.js +11 -9
- package/dist/Drawer.d.ts +22 -7
- package/dist/Drawer.js +89 -8
- package/dist/EmbedFrame.d.ts +36 -0
- package/dist/EmbedFrame.js +18 -0
- package/dist/Field.d.ts +41 -4
- package/dist/Field.js +61 -25
- package/dist/FieldDialog.d.ts +8 -3
- package/dist/FieldDialog.js +19 -9
- package/dist/Fieldset.d.ts +3 -3
- package/dist/Fieldset.js +7 -9
- package/dist/FileDrop.js +2 -1
- package/dist/FlowDiagram.d.ts +92 -0
- package/dist/FlowDiagram.js +100 -0
- package/dist/FormRow.d.ts +6 -4
- package/dist/FormRow.js +11 -9
- package/dist/Hero.d.ts +30 -7
- package/dist/Hero.js +23 -9
- package/dist/Icon.d.ts +1 -1
- package/dist/Icon.js +1 -1
- package/dist/IconButton.js +1 -1
- package/dist/Image.d.ts +33 -9
- package/dist/Image.js +61 -16
- package/dist/Input.d.ts +1 -1
- package/dist/Input.js +4 -4
- package/dist/InputShell.d.ts +7 -0
- package/dist/InputShell.js +18 -3
- package/dist/KeyValueList.d.ts +2 -2
- package/dist/Lightbox.js +5 -3
- package/dist/ListRow.d.ts +4 -5
- package/dist/ListRow.js +36 -26
- package/dist/Mark.d.ts +10 -0
- package/dist/Mark.js +9 -0
- package/dist/Markdown.d.ts +18 -4
- package/dist/Markdown.js +176 -37
- package/dist/MediaTile.d.ts +9 -3
- package/dist/MediaTile.js +8 -4
- package/dist/Menu.d.ts +19 -8
- package/dist/Menu.js +13 -11
- package/dist/MetaList.d.ts +4 -3
- package/dist/MetaList.js +12 -4
- package/dist/Morph.d.ts +15 -1
- package/dist/Morph.js +70 -22
- package/dist/NavigationProgress.d.ts +2 -2
- package/dist/NavigationProgress.js +7 -5
- package/dist/NumberField.d.ts +66 -0
- package/dist/NumberField.js +68 -0
- package/dist/OutlineRegion.d.ts +41 -10
- package/dist/OutlineRegion.js +31 -6
- package/dist/PageFade.d.ts +9 -5
- package/dist/PageFade.js +39 -8
- package/dist/PageLayouts.d.ts +15 -5
- package/dist/PageLayouts.js +3 -3
- package/dist/Pill.d.ts +9 -4
- package/dist/Pill.js +15 -6
- package/dist/Popover.d.ts +31 -0
- package/dist/Popover.js +43 -0
- package/dist/Price.d.ts +21 -0
- package/dist/Price.js +34 -0
- package/dist/ProductTile.d.ts +36 -0
- package/dist/ProductTile.js +31 -0
- package/dist/ProgressBar.js +4 -2
- package/dist/PromoBanner.d.ts +25 -0
- package/dist/PromoBanner.js +16 -0
- package/dist/RadioGroup.d.ts +18 -8
- package/dist/RadioGroup.js +42 -18
- package/dist/ScrollStrip.d.ts +1 -1
- package/dist/ScrollStrip.js +1 -1
- package/dist/SearchInput.d.ts +17 -2
- package/dist/SearchInput.js +72 -13
- package/dist/SegmentedField.d.ts +15 -0
- package/dist/SegmentedField.js +15 -0
- package/dist/Select.js +5 -4
- package/dist/Show.d.ts +1 -1
- package/dist/Show.js +1 -1
- package/dist/SideColumn.d.ts +42 -15
- package/dist/SideColumn.js +45 -19
- package/dist/SiteFooter.d.ts +3 -3
- package/dist/SiteFooter.js +4 -3
- package/dist/SiteSearch.d.ts +57 -27
- package/dist/SiteSearch.js +13 -93
- package/dist/Slider.d.ts +27 -0
- package/dist/Slider.js +58 -0
- package/dist/SortableList.d.ts +19 -35
- package/dist/SortableList.js +36 -88
- package/dist/Stack.d.ts +4 -4
- package/dist/StackedBar.d.ts +13 -4
- package/dist/StackedBar.js +12 -7
- package/dist/StateMachine.d.ts +65 -0
- package/dist/StateMachine.js +116 -0
- package/dist/StatusPages.d.ts +28 -10
- package/dist/StatusPages.js +10 -10
- package/dist/Stepper.d.ts +21 -0
- package/dist/Stepper.js +33 -0
- package/dist/Steps.js +4 -3
- package/dist/Switch.d.ts +3 -3
- package/dist/Switch.js +18 -14
- package/dist/Table.d.ts +32 -9
- package/dist/Table.js +50 -20
- package/dist/TableCells.d.ts +24 -21
- package/dist/TableCells.js +68 -27
- package/dist/TableEditCell.d.ts +1 -1
- package/dist/TableOfContents.d.ts +34 -0
- package/dist/TableOfContents.js +23 -0
- package/dist/Tabs.d.ts +31 -16
- package/dist/Tabs.js +97 -22
- package/dist/TextLink.d.ts +18 -5
- package/dist/TextLink.js +19 -6
- package/dist/Textarea.d.ts +12 -1
- package/dist/Textarea.js +15 -2
- package/dist/ToastRegion.d.ts +17 -9
- package/dist/ToastRegion.js +70 -13
- package/dist/Tooltip.d.ts +10 -2
- package/dist/Tooltip.js +32 -11
- package/dist/Video.d.ts +19 -4
- package/dist/Video.js +15 -5
- package/dist/cardContext.d.ts +7 -0
- package/dist/cardContext.js +14 -0
- package/dist/cardControl.d.ts +15 -0
- package/dist/cardControl.js +32 -0
- package/dist/cardForm.d.ts +39 -0
- package/dist/cardForm.js +81 -0
- package/dist/cardWait.js +2 -1
- package/dist/colourScheme.d.ts +12 -2
- package/dist/colourScheme.js +32 -6
- package/dist/control.d.ts +30 -8
- package/dist/control.js +74 -7
- package/dist/copyScript.d.ts +7 -8
- package/dist/copyScript.js +8 -9
- package/dist/core/button.d.ts +33 -0
- package/dist/core/button.js +89 -0
- package/dist/core/control.d.ts +15 -0
- package/dist/core/control.js +14 -0
- package/dist/core/fixtures/button.d.ts +26 -0
- package/dist/core/fixtures/button.js +52 -0
- package/dist/core/fixtures/types.d.ts +13 -0
- package/dist/core/fixtures/types.js +10 -0
- package/dist/core/focus.d.ts +7 -0
- package/dist/core/focus.js +7 -0
- package/dist/core/index.d.ts +12 -0
- package/dist/core/index.js +12 -0
- package/dist/core/parity.d.ts +22 -0
- package/dist/core/parity.js +53 -0
- package/dist/core/themeNative.d.ts +62 -0
- package/dist/core/themeNative.js +290 -0
- package/dist/cx.d.ts +17 -5
- package/dist/cx.js +18 -5
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +17 -3
- package/dist/density.js +30 -19
- package/dist/emptySlot.d.ts +1 -0
- package/dist/fieldAnnounce.d.ts +11 -0
- package/dist/fieldAnnounce.js +36 -0
- package/dist/fieldControl.d.ts +7 -2
- package/dist/fieldControl.js +6 -2
- package/dist/fieldWait.d.ts +3 -3
- package/dist/fieldWait.js +3 -4
- package/dist/flowLayout.d.ts +68 -0
- package/dist/flowLayout.js +105 -0
- package/dist/focus.d.ts +2 -0
- package/dist/focus.js +9 -0
- package/dist/fromXState.d.ts +73 -0
- package/dist/fromXState.js +110 -0
- package/dist/icons.d.ts +1 -1
- package/dist/icons.js +15 -0
- package/dist/index.d.ts +37 -11
- package/dist/index.js +24 -2
- package/dist/isoDate.d.ts +8 -1
- package/dist/isoDate.js +20 -1
- package/dist/labelWords.d.ts +16 -7
- package/dist/labelWords.js +14 -12
- package/dist/listRowProps.d.ts +17 -15
- package/dist/modal.d.ts +5 -0
- package/dist/modal.js +21 -1
- package/dist/navFold.js +6 -3
- package/dist/optionCard.d.ts +18 -0
- package/dist/optionCard.js +16 -0
- package/dist/scrollBody.d.ts +16 -0
- package/dist/scrollBody.js +15 -0
- package/dist/scrollEdges.d.ts +7 -0
- package/dist/scrollEdges.js +39 -5
- package/dist/scrollStop.d.ts +6 -2
- package/dist/scrollStop.js +24 -8
- package/dist/shownDate.d.ts +28 -10
- package/dist/shownDate.js +41 -22
- package/dist/siteSearchBody.d.ts +34 -0
- package/dist/siteSearchBody.js +117 -0
- package/dist/size.d.ts +7 -1
- package/dist/sortableDrop.d.ts +44 -0
- package/dist/sortableDrop.js +78 -0
- package/dist/sortableSlide.d.ts +9 -0
- package/dist/sortableSlide.js +70 -0
- package/dist/sortableTitle.d.ts +10 -0
- package/dist/sortableTitle.js +48 -0
- package/dist/stateMachineDots.d.ts +77 -0
- package/dist/stateMachineDots.js +188 -0
- package/dist/stickyColumn.d.ts +2 -2
- package/dist/stickyColumn.js +2 -2
- package/dist/switcher.d.ts +10 -5
- package/dist/switcher.js +7 -5
- package/dist/tableColumns.d.ts +17 -0
- package/dist/tableColumns.js +30 -2
- package/dist/tableEmpty.js +5 -5
- package/dist/tableRow.d.ts +26 -2
- package/dist/tableRow.js +23 -1
- package/dist/tableSort.d.ts +10 -5
- package/dist/tableSort.js +15 -4
- package/dist/target.d.ts +12 -0
- package/dist/target.js +12 -0
- package/dist/textBox.js +1 -1
- package/dist/truncated.d.ts +31 -0
- package/dist/truncated.js +51 -0
- package/dist/typography.d.ts +19 -11
- package/dist/typography.js +11 -13
- package/dist/useFlowLayout.d.ts +38 -0
- package/dist/useFlowLayout.js +122 -0
- package/package.json +5 -3
|
@@ -2,50 +2,50 @@
|
|
|
2
2
|
|
|
3
3
|
Group: Text
|
|
4
4
|
|
|
5
|
-
When to use: Text that arrives as markdown, such as an agent's summary, shown on a page.
|
|
5
|
+
When to use: Text that arrives as markdown, such as an agent's summary or a CMS article, shown on a page.
|
|
6
6
|
|
|
7
7
|
### The one right way
|
|
8
|
-
`Markdown` renders
|
|
8
|
+
`Markdown` renders headings, bullets and numbered lists, `**bold**`, links, pictures and tables, as React nodes and never as HTML.
|
|
9
9
|
```tsx
|
|
10
10
|
import { Markdown } from "@slashsuite/ui-react";
|
|
11
11
|
|
|
12
12
|
<Markdown
|
|
13
13
|
md={
|
|
14
14
|
"## What I did\n- **HC-142** shipped the EmptyState\n- Fixed the Pill label wrap\n\n" +
|
|
15
|
-
"### Next\
|
|
15
|
+
"### Next\n1. Review the Steps copy\n2. Read [the ticket](https://example.com)"
|
|
16
16
|
}
|
|
17
17
|
/>
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
### Do
|
|
21
|
-
- Pass the markdown as `md`. It renders `##` as a label heading, `###` as a subheading, lines starting `- ` or `* ` as bullets, `**bold
|
|
22
|
-
-
|
|
23
|
-
-
|
|
21
|
+
- Pass the markdown as `md`. It renders `##` as a label heading, `###` as a subheading, lines starting `- ` or `* ` as bullets, `1. ` as a numbered list, `**bold**`, `[words](href)` as a `TextLink`, a line that is only `` as an `Image`, a GFM table as a `Table`, and plain paragraphs.
|
|
22
|
+
- A table is named by the heading above it; one with no heading is named by `tableLabel` (Table), so pass it in an app in another language.
|
|
23
|
+
- Nothing else is supported: no `#` title, code span, quote or HTML. Those show as plain text.
|
|
24
|
+
- The text becomes React nodes and never HTML, so untrusted text cannot inject markup. A link whose address is not a web, mail or phone address or a path on the site (a `javascript:` one) keeps its words and loses the link; a picture whose address is not a web, site or data-image one shows the placeholder.
|
|
24
25
|
- Text you write yourself is not markdown: use `Text`, `BulletList` and the heading components.
|
|
25
26
|
|
|
26
27
|
### Don't
|
|
27
|
-
A `#` title, a
|
|
28
|
+
A `#` title, a code span, a quote or HTML is not supported: each shows as literal text.
|
|
28
29
|
```tsx
|
|
29
30
|
import { Markdown } from "@slashsuite/ui-react";
|
|
30
31
|
|
|
31
32
|
<Markdown
|
|
32
|
-
md={
|
|
33
|
-
"# What I did\n1. Shipped the EmptyState\n2. Fixed the Pill\n\n" +
|
|
34
|
-
"See [the ticket](https://example.com) and `bun install`."
|
|
35
|
-
}
|
|
33
|
+
md={"# What I did\n> Shipped the EmptyState\n\nRun `bun install`, then <b>restart</b>."}
|
|
36
34
|
/>
|
|
37
35
|
```
|
|
38
36
|
|
|
39
37
|
### Accessibility
|
|
40
|
-
- `##` renders an `h2` and `###` an `h3`, bullets render a `ul` with `li`s, bold a `strong` and a paragraph a `p`.
|
|
38
|
+
- `##` renders an `h2` and `###` an `h3`, bullets render a `ul` and numbers an `ol` with `li`s, bold a `strong` and a paragraph a `p`.
|
|
41
39
|
- The headings start at `h2`, so the page needs its own `h1` above.
|
|
40
|
+
- A link is underlined, since it sits in running text. A picture is named by its alt text, so write one.
|
|
42
41
|
- `aria-*` and `data-*` go on the root.
|
|
43
42
|
|
|
44
43
|
### Props
|
|
45
44
|
### Markdown
|
|
46
|
-
A small, safe Markdown renderer for
|
|
45
|
+
A small, safe Markdown renderer for notes and for rich text from a CMS: `## ` and `### ` headings, `- ` or `* ` bullets, `1. ` numbered lists, `**bold**`, `[links](href)`, a picture on a line of its own (``), GFM tables and paragraphs. Text is rendered as React nodes, never as HTML. A link is a `TextLink` (an in-app path goes through `LinkProvider`) and is kept only if its address is a web, mail or phone address or a path on this site; any other (`javascript:`) keeps its words and drops the link. A picture is an `Image` in its own shape, and a table a `Table` named by the heading above it, or `tableLabel`. While `loading` with no `md` yet it draws a paragraph of bones. A `## ` heading is one level below the heading that holds the Markdown (an `h2` on the page, an `h3` in a `Section`, an `h4` in a titled `Card` there) and a `### ` one below that, never past `h6`, so the notes keep the page's outline.
|
|
47
46
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
48
47
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
49
48
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
50
49
|
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
51
50
|
- md: string | undefined (required). The Markdown source; while `loading`, none yet is a paragraph of bones.
|
|
51
|
+
- tableLabel: string (default Table). The name a table takes when no heading comes before it, for an app in another language.
|
|
@@ -8,6 +8,7 @@ When to use: A photo or video in a grid or a strip, that opens full size when it
|
|
|
8
8
|
- Image (image.md): The picture is only shown, with no label, click or remove.
|
|
9
9
|
- Video (video.md): The video plays in the page: the player.
|
|
10
10
|
- Lightbox (lightbox.md): One photo or video opens over the page, at full size.
|
|
11
|
+
- ProductTile (product-tile.md): The tile is a thing for sale, with its name and price.
|
|
11
12
|
|
|
12
13
|
### The one right way
|
|
13
14
|
A thumbnail that opens a photo is a `MediaTile` with `onClick` that opens a `Lightbox`, which steps through the set.
|
|
@@ -52,7 +53,7 @@ function Example() {
|
|
|
52
53
|
### Do
|
|
53
54
|
- `src` and `alt` are the thumbnail, cropped to `aspect` (portrait `3:4` by default; `natural` shows the picture whole at its own proportions, as a chat does) at `width` (`md`, 160px, by default; `full` fills a grid cell).
|
|
54
55
|
- `label` is a short line on the picture's bottom edge, on the same near-black scrim as the `Lightbox`, in every theme: who posted it, or "Earlier". `caption` is muted text under the picture, such as when.
|
|
55
|
-
- `video` draws a play mark; say it is a video in `alt` too.
|
|
56
|
+
- `video` draws a play mark; say it is a video in `alt` too. `badge` is a short word in the top corner on the same scrim, such as "New" or a count, and is part of the tile's name.
|
|
56
57
|
- `onRemove` adds a round remove button on the picture's corner, named "Remove" and `alt`: a photo attached to a form, until it is sent. It is its own button beside the tile's, so the tile can still open a `Lightbox`.
|
|
57
58
|
- `onClick` makes the whole tile one button. Open a `Lightbox` from it, and keep the open item in your own state. Without `onClick` the tile is a plain block.
|
|
58
59
|
- With no `src`, the tile shows the `Image` placeholder, so a tile that is only a label ("Earlier") needs no picture.
|
|
@@ -74,10 +75,13 @@ A bare `<img>` in a button has no shape, frame or label, and no placeholder when
|
|
|
74
75
|
|
|
75
76
|
### Props
|
|
76
77
|
### MediaTile
|
|
77
|
-
A thumbnail tile: a picture in a fixed shape with an optional label on its bottom edge and a caption under it. With `onClick` the whole tile is one button, which is how a grid or a `ScrollStrip` of media opens each item in a `Lightbox`. The label sits on the same near-black media scrim as the Lightbox, in every theme. The thumbnail is cropped to fill its shape, or with `aspect="natural"` shown whole. With `href` the whole tile is one link instead. `onRemove` adds a remove button for a tile that can be taken back out. While `loading` with no `src` yet the picture is a bone of its shape.
|
|
78
|
+
A thumbnail tile: a picture in a fixed shape with an optional label on its bottom edge and a caption under it. With `onClick` the whole tile is one button, which is how a grid or a `ScrollStrip` of media opens each item in a `Lightbox`. The label sits on the same near-black media scrim as the Lightbox, in every theme. The thumbnail is cropped to fill its shape, or with `aspect="natural"` shown whole. With `href` the whole tile is one link instead. `onRemove` adds a remove button for a tile that can be taken back out. `badge` pins a short word to a top corner. While `loading` with no `src` yet the picture is a bone of its shape.
|
|
78
79
|
- alt: string (required). What the thumbnail shows; it is the tile's name, with `label`.
|
|
79
|
-
- aspect: "square" | "4:3" | "3:2" | "16:9" | "3:4" | "9:16" | "natural" (default 3:4). The shape of the thumbnail, as `Image`'s `aspect`; `natural` keeps the picture's own
|
|
80
|
+
- aspect: "square" | "4:3" | "3:2" | "16:10" | "16:9" | "3:4" | "9:16" | "natural" (default 3:4). The shape of the thumbnail, as `Image`'s `aspect`; `natural` keeps the picture's own
|
|
80
81
|
proportions (a chat image) and crops nothing.
|
|
82
|
+
- badge: string. A short word pinned to the picture's top-right corner on the media scrim: a count, "New" or a
|
|
83
|
+
size. Text only; it is part of the tile's name. With `onRemove` the button takes that corner,
|
|
84
|
+
so the badge sits top-left.
|
|
81
85
|
- caption: ReactNode. Muted text under the picture, e.g. when.
|
|
82
86
|
- external: boolean (default false). Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
83
87
|
- href: string. Makes the whole tile one link, named as the button form is; an in-app path goes through `LinkProvider`.
|
|
@@ -94,4 +98,4 @@ with `onClick` still opens its `Lightbox`.
|
|
|
94
98
|
- removeLabel: string (default Remove). The remove button's word, before `alt` in its name and alone as its tooltip.
|
|
95
99
|
- src: string. The thumbnail, a local path or a data URL. Left out, or if it fails to load, a placeholder shows.
|
|
96
100
|
- video: boolean (default false). Draws a play mark on the thumbnail: the tile opens a video, not a photo. Say so in `alt` too.
|
|
97
|
-
- width: "sm" | "md" | "lg" | "full" (default md). `sm` 96px, `md` 160px
|
|
101
|
+
- width: "sm" | "md" | "lg" | "xl" | "full" (default md). `sm` 96px, `md` 160px, `lg` 256px or `xl` 448px wide; `full` fills the parent (a tile in a grid).
|
|
@@ -4,6 +4,9 @@ Group: Actions
|
|
|
4
4
|
|
|
5
5
|
When to use: A row, card or header with more actions than fit: put the one main action in view and the rest in a Menu.
|
|
6
6
|
|
|
7
|
+
### Use instead
|
|
8
|
+
- Popover (popover.md): The button opens a few lines to read or a small form, not actions.
|
|
9
|
+
|
|
7
10
|
### The one right way
|
|
8
11
|
A row's secondary actions in one `Menu`, beside its one visible action.
|
|
9
12
|
```tsx
|
|
@@ -21,9 +24,9 @@ import { Button, Card, ListRow, Menu } from "@slashsuite/ui-react";
|
|
|
21
24
|
size="sm"
|
|
22
25
|
label="More actions"
|
|
23
26
|
items={[
|
|
24
|
-
{ label: "Favourite", icon: "plus",
|
|
25
|
-
{ label: "Settings", icon: "settings",
|
|
26
|
-
{ label: "Hide chat", tone: "danger",
|
|
27
|
+
{ label: "Favourite", icon: "plus", onClick: () => undefined },
|
|
28
|
+
{ label: "Settings", icon: "settings", onClick: () => undefined },
|
|
29
|
+
{ label: "Hide chat", tone: "danger", onClick: () => undefined },
|
|
27
30
|
]}
|
|
28
31
|
/>
|
|
29
32
|
</>
|
|
@@ -36,14 +39,15 @@ import { Button, Card, ListRow, Menu } from "@slashsuite/ui-react";
|
|
|
36
39
|
|
|
37
40
|
### Do
|
|
38
41
|
- Keep the one main action in view as a `Button` and put the rest in one `Menu` beside it; a row of several icon buttons is a `Menu`.
|
|
39
|
-
- `items` is data: each a `label` with `
|
|
42
|
+
- `items` is data: each a `label` with `onClick`, or a link with `href` (through the app's `LinkProvider`; `external` opens a new tab). `icon` adds a leading glyph from the `Icon` set. An item that cannot be chosen yet takes `disabledReason`: it dims and shows the reason under its label.
|
|
43
|
+
- `open` and `onOpenChange` hold the menu open from the app's own state, such as a keyboard shortcut.
|
|
40
44
|
- A destructive item is `tone="danger"` and goes last, so it is never the first thing the arrows reach.
|
|
41
45
|
- The default trigger is a ghost three-dot button named by `label`; `trigger="button"` is an outline button reading `label`, for a menu whose name is worth a word ("Export"). `size="sm"` inside a row or a card header.
|
|
42
|
-
- In a `ListRow
|
|
46
|
+
- In a `ListRow`, a row's `Menu` goes in its `actions`, shown on every row.
|
|
43
47
|
|
|
44
48
|
### Don't
|
|
45
49
|
- Never put the only action of a row in a `Menu`: one action is a `Button` or an `IconButton`.
|
|
46
|
-
-
|
|
50
|
+
- Never dim an item with no reason: a dimmed item says why with `disabledReason`.
|
|
47
51
|
|
|
48
52
|
Four ghost buttons in a row crowd it, and every one of them is a tab stop.
|
|
49
53
|
```tsx
|
|
@@ -74,9 +78,9 @@ import { Menu } from "@slashsuite/ui-react";
|
|
|
74
78
|
label="More actions"
|
|
75
79
|
defaultOpen
|
|
76
80
|
items={[
|
|
77
|
-
{ label: "Hide chat", tone: "danger",
|
|
78
|
-
{ label: "Favourite", icon: "plus",
|
|
79
|
-
{ label: "Settings", icon: "settings",
|
|
81
|
+
{ label: "Hide chat", tone: "danger", onClick: () => undefined },
|
|
82
|
+
{ label: "Favourite", icon: "plus", onClick: () => undefined },
|
|
83
|
+
{ label: "Settings", icon: "settings", onClick: () => undefined },
|
|
80
84
|
]}
|
|
81
85
|
/>
|
|
82
86
|
```
|
|
@@ -84,20 +88,23 @@ import { Menu } from "@slashsuite/ui-react";
|
|
|
84
88
|
### Accessibility
|
|
85
89
|
- The trigger is a button with `aria-haspopup` and `aria-expanded`, named by `label`; the menu takes the same name.
|
|
86
90
|
- Enter, Space or ArrowDown open it on the first item, ArrowUp on the last; the arrows, Home, End and a typed letter move; Enter chooses; Escape closes it, and focus goes back to the trigger.
|
|
87
|
-
- A link item is a real link with `role="menuitem"`;
|
|
91
|
+
- A link item is a real link with `role="menuitem"`; an item with `disabledReason` is skipped by the arrows, and its reason is its description.
|
|
88
92
|
- Inside a `Dialog` the menu opens in the dialog, so it is not inert, and Escape closes only the menu.
|
|
89
93
|
|
|
90
94
|
### Props
|
|
91
95
|
### Menu
|
|
92
|
-
A button that opens a short list of actions: the overflow menu at the end of a row, a card header or a page header. Keep the one main action in view beside it and put the rest here, the `danger` one last. `items` are data: each a `label` with `
|
|
96
|
+
A button that opens a short list of actions: the overflow menu at the end of a row, a card header or a page header. Keep the one main action in view beside it and put the rest here, the `danger` one last. `items` are data: each a `label` with `onClick`, or a link with `href` (`external` for a new tab), an optional leading `icon`, `tone="danger"` and `disabledReason`. `open` and `onOpenChange` hold it open from the app's own state. `trigger="icon"` (the default) is a ghost three-dot button named by `label`; `trigger="button"` is an outline button reading `label`. The menu opens below the trigger, aligned to its end, and flips when there is no room. The keyboard is the menu button pattern: Enter, Space or ArrowDown open it on the first item, ArrowUp on the last; the arrows, Home, End and a letter move; Enter chooses; Escape closes, and focus goes back to the trigger. `data-*` and `aria-*` land on the trigger.
|
|
93
97
|
- defaultOpen: boolean (default false). Opens on mount, for a story or a test that shows the open menu.
|
|
94
98
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
95
99
|
- items: readonly [MenuAction, ...MenuAction[]] (required). The actions, in order.
|
|
96
100
|
- label: string (required). The trigger's accessible name and the menu's. With `trigger="button"` it is the visible text.
|
|
101
|
+
- onOpenChange: ((open: boolean) => void). Runs with the new state when the trigger, Escape, a click outside or a choice opens or shuts it.
|
|
102
|
+
- open: boolean. Holds the menu open or shut from the app's own state (a keyboard shortcut that opens it). Pass
|
|
103
|
+
`onOpenChange` with it, or the trigger, Escape and a choice cannot change it.
|
|
97
104
|
- size: "sm" | "md" | "lg" (default md). The trigger's height, the same steps as `IconButton` and `Button`: `sm` inside a row or a card
|
|
98
105
|
header. The menu's own text does not change with it.
|
|
99
106
|
- trigger: "button" | "icon" (default icon). `icon` is a ghost square button holding three dots, the overflow menu; `button` is an outline
|
|
100
107
|
`Button` with `label` as its text and a chevron after it, for a menu whose name is worth a word.
|
|
101
108
|
|
|
102
109
|
### Types
|
|
103
|
-
- MenuAction: `{ label: string; icon?: IconName | undefined; tone?: IconButtonTone | undefined;
|
|
110
|
+
- MenuAction: `{ label: string; icon?: IconName | undefined; tone?: IconButtonTone | undefined; disabledReason?: string | undefined; } & ({ onClick: () => void; href?: undefined; external?: undefined; } | { onClick?: undefined; href: string; external?: boolean | undefined; })`. One entry of a `Menu`: an action that runs `onClick`, or a link to `href`. Never both.
|
|
@@ -51,13 +51,13 @@ import { Prose, TextLink } from "@slashsuite/ui-react";
|
|
|
51
51
|
|
|
52
52
|
### Accessibility
|
|
53
53
|
- A `MetaList` renders a `<ul>` with an `<li>` per item.
|
|
54
|
-
- The separators are `aria-hidden` and
|
|
54
|
+
- The separators are `aria-hidden` and lead each item; the one before whichever item starts a line falls in a margin the row clips, so no line starts or ends with one, at any width.
|
|
55
55
|
- Each link keeps its own focus ring; the row adds no extra tab stop.
|
|
56
56
|
- `aria-*` and `data-*` go on the list.
|
|
57
57
|
|
|
58
58
|
### Props
|
|
59
59
|
### MetaList
|
|
60
|
-
A wrapping row of facts or links in muted small text, joined by a `·`: branch · SHA · date, or a footer's Privacy · Terms · Email. An item is text, a `Code` or a `TextLink`. The separator is `aria-hidden` and
|
|
60
|
+
A wrapping row of facts or links in muted small text, joined by a `·`: branch · SHA · date, or a footer's Privacy · Terms · Email. An item is text, a `Code` or a `TextLink`. The separator is `aria-hidden` and leads every item in a slot of its own; the list starts one slot before its box, which clips it, so the separator of whichever item starts a line falls outside and no line starts or ends with one, at any width. `separator` swaps it for a `•` or none. An item never breaks inside itself: the row wraps between items. `mono` sets the whole row in the monospace face, for ids and paths. While `loading` with no items it draws three word-sized bones.
|
|
61
61
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
62
62
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
63
63
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
@@ -39,12 +39,12 @@ function Example() {
|
|
|
39
39
|
|
|
40
40
|
### Do
|
|
41
41
|
- Wrap the card in the grid and the element on the detail page, each with the same `name` and the record's id as `item`: `<Morph name="shop" item={shop.id}>`.
|
|
42
|
-
- The same `name` and `item` may appear only once on a page
|
|
42
|
+
- The same `name` and `item` may appear only once on a page; two and the browser skips the morph, so a list passes each record's own id. When one record shows twice (a featured card and the same card in the list), pass `active={false}` to the copy that should not morph; in development two active Morphs with one `name` and `item` log a console warning.
|
|
43
43
|
- Start the change inside a view transition: `startPageTransition(() => setOpen(id))` for a state change, or the router's own option (TanStack Router `defaultViewTransition: true` on `createRouter`, or `viewTransition` on a `Link`; React Router's `viewTransition`, Astro's `ClientRouter`). Without one nothing morphs.
|
|
44
44
|
- The destination's Morph must be in the page when the navigation lands: a route that shows a pending component first has nothing to morph into.
|
|
45
45
|
- Inside a `PageFade` the rest of the page cross-fades while the card morphs over it.
|
|
46
46
|
- Portal an overlay such as a dropdown to the body: the morphing element is a stacking context, so an overlay inside it cannot rise above a sticky header outside it.
|
|
47
|
-
- A Morph far below the fold carries no transition name until it scrolls near, so a long list costs only what is on screen.
|
|
47
|
+
- A card that is a list item takes `as="li"`, so a `Stack as="ul"` of Morphs stays a list of items. A Morph far below the fold carries no transition name until it scrolls near, so a long list costs only what is on screen.
|
|
48
48
|
- With TanStack Router, call `refreshMorphs()` after it restores scroll: `router.subscribe("onRendered", () => refreshMorphs())`, after `createRouter`. Its restore lands after the render, so without the call the card scrolled back on screen is not named and Back does not shrink into it.
|
|
49
49
|
|
|
50
50
|
### Don't
|
|
@@ -113,13 +113,19 @@ function Example() {
|
|
|
113
113
|
```
|
|
114
114
|
|
|
115
115
|
### Accessibility
|
|
116
|
-
- A Morph is a plain `<div>` with no role, so it changes nothing for assistive technology.
|
|
117
|
-
- Under `prefers-reduced-motion: reduce` the element swaps with no animation, and `startPageTransition` just runs the update.
|
|
116
|
+
- A Morph is a plain `<div>` (or `<li>` with `as="li"`) with no role of its own, so it changes nothing for assistive technology.
|
|
117
|
+
- Under `prefers-reduced-motion: reduce` the element swaps with no animation, and `startPageTransition` just runs the update. A router's own transition of the rest of the page is the router's: quiet it in the app's stylesheet, as the browser does not.
|
|
118
|
+
- Morph is for a page change in one document. A cross-document transition (`@view-transition { navigation: auto; }`) is an app stylesheet rule the library does not ship.
|
|
118
119
|
- Where the browser has no View Transitions it is a plain `<div>` and the content swaps.
|
|
119
120
|
|
|
120
121
|
### Props
|
|
121
122
|
### Morph
|
|
122
|
-
An element that grows into its counterpart on the next page, and shrinks back on Back, through the View Transitions API. Wrap the card in the list and the element on the detail page, each with the same `name` and the record's id as `item`: the browser morphs one into the other over 450 ms. The same `name` and `item` may appear only once on a page; two on one page and the browser skips the morph, so a list passes each record's own id. The morph runs only when the change is wrapped in a view transition: `startPageTransition`, or a router's own option (TanStack Router `defaultViewTransition: true` on `createRouter`, or `viewTransition` on a `Link`; React Router's `viewTransition`, Astro's `ClientRouter`). Otherwise, or where the browser has no View Transitions, it renders and behaves as a plain `<div>`. Inside a `PageFade` the page fades while this element morphs. While it is named (near the screen) the div is a stacking context, so a dropdown inside it cannot rise above a sticky header outside it: portal overlays to the body. Under `prefers-reduced-motion: reduce` it swaps with no animation; a router's own transition of the rest of the page is the router's to quiet. A Morph more than a screen above or below the viewport carries no transition name until it scrolls near, so a long list costs only what is on screen.
|
|
123
|
+
An element that grows into its counterpart on the next page, and shrinks back on Back, through the View Transitions API. Wrap the card in the list and the element on the detail page, each with the same `name` and the record's id as `item`: the browser morphs one into the other over 450 ms. The same `name` and `item` may appear only once on a page; two on one page and the browser skips the morph, so a list passes each record's own id. The morph runs only when the change is wrapped in a view transition: `startPageTransition`, or a router's own option (TanStack Router `defaultViewTransition: true` on `createRouter`, or `viewTransition` on a `Link`; React Router's `viewTransition`, Astro's `ClientRouter`). Otherwise, or where the browser has no View Transitions, it renders and behaves as a plain `<div>`. Inside a `PageFade` the page fades while this element morphs. While it is named (near the screen) the div is a stacking context, so a dropdown inside it cannot rise above a sticky header outside it: portal overlays to the body. Under `prefers-reduced-motion: reduce` it swaps with no animation; a router's own transition of the rest of the page is the router's to quiet. A Morph more than a screen above or below the viewport carries no transition name until it scrolls near, so a long list costs only what is on screen. In a list, `as="li"` makes it the list's item. When one record shows twice on a page, pass `active={false}` to the copy that should not morph; in development two active Morphs with the same `name` and `item` log a console warning.
|
|
124
|
+
- active: boolean (default true). Whether it carries its transition name; `true` by default. Pass `false` to every copy but one
|
|
125
|
+
when the same record shows twice on a page (a featured card and the same card in the list), so
|
|
126
|
+
only the one that should grow into the detail is named.
|
|
127
|
+
- as: "div" | "li" (default div). The element it renders: `"div"` (the default), or `"li"` for a card that is an item of a list,
|
|
128
|
+
so the list stays a `ul` of `li`.
|
|
123
129
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
124
130
|
- item: string | number (required). Which one, usually the record's id. Any text or number; unique on the page for one `name`.
|
|
125
131
|
- name: string (required). What the element is, shared by the card and its detail: `"shop"`, `"product"`. Any text.
|
|
@@ -45,12 +45,12 @@ import { ProgressBar, Stack, Text } from "@slashsuite/ui-react";
|
|
|
45
45
|
|
|
46
46
|
### Accessibility
|
|
47
47
|
- While shown it is `role="progressbar"` named by `label` ("Loading page" by default) and has no `aria-valuenow`, so it reads as an indeterminate progress bar. When hidden it is not in the page.
|
|
48
|
-
- Under `prefers-reduced-motion: reduce`
|
|
48
|
+
- Under `prefers-reduced-motion: reduce` the segment slides slowly and evenly rather than stopping: a still, full-width bar would read as finished.
|
|
49
49
|
- It takes no pointer events, so it never covers a control in the header.
|
|
50
50
|
|
|
51
51
|
### Props
|
|
52
52
|
### NavigationProgress
|
|
53
|
-
A thin indeterminate bar along the top edge of the viewport, in the accent tone, for a route change that is under way and has no known length. Pass `loading` from the router's pending state and render it once per app, beside the page frame. It draws exactly what `loading` says: the bar while it is true and nothing while it is false. The stylesheet holds it invisible for the first 150ms, so a fast navigation shows nothing. It is fixed to the viewport and overlays the top of the header, so nothing on the page moves. Under `prefers-reduced-motion: reduce`
|
|
53
|
+
A thin indeterminate bar along the top edge of the viewport, in the accent tone, for a route change that is under way and has no known length. Pass `loading` from the router's pending state and render it once per app, beside the page frame. It draws exactly what `loading` says: the bar while it is true and nothing while it is false. The stylesheet holds it invisible for the first 150ms, so a fast navigation shows nothing. It is fixed to the viewport and overlays the top of the header, so nothing on the page moves. Under `prefers-reduced-motion: reduce` the segment slides slowly and evenly instead: a still, full bar would read as finished.
|
|
54
54
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
55
55
|
- label: string (default Loading page). The bar's accessible name.
|
|
56
56
|
- loading: boolean (required). True while a navigation is pending, e.g. from the router's state.
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
## NumberField
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A quantity, a count or an amount the person sets exactly: items in a cart, guests, a price.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A count the person sets is a `NumberField`: type it, or step it with the buttons.
|
|
9
|
+
```tsx
|
|
10
|
+
import { NumberField } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<NumberField label="Quantity" defaultValue={1} minValue={1} maxValue={99} width="sm" />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Do
|
|
16
|
+
- Give it a `label`; it draws its own label, `hint` and `error`, so it is never put in a `Field`.
|
|
17
|
+
- Set `minValue` and `maxValue`: the buttons stop there, and a typed number outside them is clamped when the field is left.
|
|
18
|
+
- `step` is how far a button or an arrow key moves it; a typed number snaps to it.
|
|
19
|
+
- `formatOptions` writes it as a currency (`{ style: "currency", currency: "EUR" }`), a percent or with fixed decimals, in the app's locale; `name` posts the plain number.
|
|
20
|
+
- Keep it with `defaultValue`, or control it with `value` and `onChange(number)`.
|
|
21
|
+
- `size` and `width` are the same choices as on `Input`. Name the buttons in another language with `decrementLabel` and `incrementLabel`.
|
|
22
|
+
- A level set by eye is a `Slider`. A choice from a few fixed numbers is a `Select` or a `RadioGroup`.
|
|
23
|
+
|
|
24
|
+
### Don't
|
|
25
|
+
- Do not use a `Select` of numbers for a count: it caps the count and makes the person scroll.
|
|
26
|
+
|
|
27
|
+
A `Select` of numbers caps the count at its last option and makes the person scroll for it.
|
|
28
|
+
```tsx
|
|
29
|
+
import { Select } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Select
|
|
32
|
+
aria-label="Quantity"
|
|
33
|
+
defaultValue="1"
|
|
34
|
+
items={Array.from({ length: 10 }, (_, i) => ({
|
|
35
|
+
value: String(i + 1),
|
|
36
|
+
label: String(i + 1),
|
|
37
|
+
}))}
|
|
38
|
+
/>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
### Accessibility
|
|
42
|
+
- React Aria's number field: the input is a `textbox` with the label as its name, and the arrow keys, Page Up and Page Down step it.
|
|
43
|
+
- The minus and plus buttons are named after the label ("Decrease Quantity") and kept out of the tab order, since the keys do the same.
|
|
44
|
+
- A `hint` and an `error` are the field's description; an `error` marks it `aria-invalid` and is announced politely.
|
|
45
|
+
|
|
46
|
+
### Props
|
|
47
|
+
### NumberField
|
|
48
|
+
A number with a minus and a plus button either side of it, for a quantity, a count or an amount: React Aria's `NumberField`. The person types the number or steps it by `step` with the buttons, the arrow keys, Page Up and Page Down; `minValue` and `maxValue` stop the buttons and clamp a typed number when the field is left. `formatOptions` writes it as a currency, a percent or with fixed decimals in the app's locale, and the person types in that format. `label`, `hint`, `error`, `required` and `disabled` are a `DateField`'s; `size` and `width` an `Input`'s. While `loading` the label is drawn and the field is a bone of its height.
|
|
49
|
+
- decrementLabel: string (default Decrease). The name of the minus button, for an app in another language.
|
|
50
|
+
- defaultValue: number. The number it starts with, uncontrolled.
|
|
51
|
+
- disabled: boolean. Disables the field and its buttons.
|
|
52
|
+
- error: ReactNode. Marks the field invalid and shows this in red under the hint, announced politely.
|
|
53
|
+
- formatOptions: NumberFormatOptions. How the number is written, in the locale of the app's `I18nProvider` or else the browser's:
|
|
54
|
+
`{ style: "currency", currency: "EUR" }`, `{ style: "percent" }`, `{ maximumFractionDigits: 2 }`.
|
|
55
|
+
The person types in the same format.
|
|
56
|
+
- hint: ReactNode. A muted line under the field that says more; it stays while an error shows under it.
|
|
57
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
58
|
+
- incrementLabel: string (default Increase). The name of the plus button, for an app in another language.
|
|
59
|
+
- label: ReactNode. The field's visible label, above it. Without one, name the field with `aria-label`.
|
|
60
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
61
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
62
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
63
|
+
- maxValue: number. The largest number allowed: the plus button stops there, and a larger typed one is lowered to it.
|
|
64
|
+
- minValue: number. The smallest number allowed: the minus button stops there, and a smaller typed one is raised to it.
|
|
65
|
+
- name: string. Posts the number in a form under this key, as plain digits whatever the format.
|
|
66
|
+
- onChange: ((value: number) => void). Called with the new number when it is committed (a step, or leaving the field); `NaN` when it is cleared.
|
|
67
|
+
- required: boolean. Marks the number required: the field is `aria-required`, and an empty one is invalid.
|
|
68
|
+
- size: Size | ResponsiveSize (default md). `sm` is compact, `text-sm` with less padding, for dense forms and table rows; `md` is `text-base`;
|
|
69
|
+
`lg` is `text-lg` with more padding, for a hero form. Under an `AppShell density="compact"` each
|
|
70
|
+
is one type step down, and on a touch screen a field is never under 16px.
|
|
71
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as a `Button`'s
|
|
72
|
+
does: give the field and the buttons in its row the same value, so the row stays aligned.
|
|
73
|
+
- step: number (default 1). How far one press of a button or an arrow key moves the number; a typed number snaps to it.
|
|
74
|
+
- value: number. The number shown, controlled, with `onChange`. `NaN` is an empty field.
|
|
75
|
+
- width: "sm" | "md" | "lg" | "auto" | "xs" | "fill" | "full". `full` (default) fills the parent; `fill` grows to fill the room left in a row beside other items (it can shrink to nothing, so buttons stay on the line); `xs`, `sm`, `md`, `lg` are fixed; `auto` adds no width class, so the control is as wide as the browser makes it.
|
|
@@ -23,11 +23,13 @@ import { OutlineRegion, RegionFrame } from "@slashsuite/ui-react";
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
### Do
|
|
26
|
-
- Put the picture in a `RegionFrame` (`src`, `alt`, and
|
|
26
|
+
- Put the picture in a `RegionFrame` (`src`, `alt`, and `onLoad`, `id`, `data-*` or `aria-*`) and the `OutlineRegion`s inside it; each region places itself over the picture.
|
|
27
27
|
- `rect` is the area and `within` the picture's full size, both in the picture's own pixels (its natural size), so the box stays on its area at any width.
|
|
28
|
-
- Size the frame as an `Image`: `width` (`full`, or `sm`, `md`, `lg`) and `aspect` (`natural`, its own proportions, or a shape that letterboxes the picture, never cropping it and never scaling it up). The regions stay on the picture, not the box. A shape also holds the frame's height before the picture loads.
|
|
28
|
+
- Size the frame as an `Image`: `width` (`full`, or `sm`, `md`, `lg`, `xl`) and `aspect` (`natural`, its own proportions, or a shape that letterboxes the picture, never cropping it and never scaling it up). The regions stay on the picture, not the box. A shape also holds the frame's height before the picture loads.
|
|
29
29
|
- `label` is a short tag in the top-left corner that says what the area is or where it came from. `hatched` stripes the inside, for an area that is left out.
|
|
30
|
-
-
|
|
30
|
+
- `tone` says what the area is: `accent` (the default), `positive`, `warn` or `danger`. There is no `neutral` or `info`: their edges are too pale to stand out on a picture.
|
|
31
|
+
- `dashed` draws the edge dashed, for an area that is proposed or approximate. `active` draws a thicker edge on the one region the app has picked, such as the one hovered in a list beside the picture; the region has no hover state of its own.
|
|
32
|
+
- The outline takes its colour from the theme; do not draw a box of your own with a raw colour.
|
|
31
33
|
|
|
32
34
|
### Don't
|
|
33
35
|
An unlabelled box leaves the reader to guess what it marks and where it came from.
|
|
@@ -45,19 +47,28 @@ import { OutlineRegion, RegionFrame } from "@slashsuite/ui-react";
|
|
|
45
47
|
|
|
46
48
|
### Props
|
|
47
49
|
### RegionFrame
|
|
48
|
-
A picture with a hairline edge, and `children` laid over it: the `OutlineRegion`s that mark its areas.
|
|
50
|
+
A picture with a hairline edge, and `children` laid over it: the `OutlineRegion`s that mark its areas. `onLoad`, `id`, `data-*` and `aria-*` go to the `<img>`, so the app can read the picture's own size for `within`. While `loading` with no `src` yet it is a bone of the frame's shape (4:3 for a `natural` one), as an `Image` is. It sizes as `Image` does. `width` is `full` (the parent's width) or 96, 160 or 256px. `aspect` `natural` keeps the picture's own proportions; any other shape letterboxes it (contain, never a crop) on the inset surface, centred and never scaled up, and the regions are laid over the picture itself, not the box, so each stays on its spot. A letterboxed picture needs its own size: a screenshot has one; an SVG needs `width` and `height` on its root, not only a `viewBox`.
|
|
49
51
|
- alt: string (required). What the picture shows; `""` for one that only decorates.
|
|
50
|
-
- aspect: "square" | "4:3" | "3:2" | "16:9" | "3:4" | "9:16" | "natural" (default natural). The box's shape: `natural` is the picture's own; any other letterboxes the picture inside it.
|
|
52
|
+
- aspect: "square" | "4:3" | "3:2" | "16:10" | "16:9" | "3:4" | "9:16" | "natural" (default natural). The box's shape: `natural` is the picture's own; any other letterboxes the picture inside it.
|
|
51
53
|
- children: ReactNode. The `OutlineRegion`s over the picture.
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
55
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
56
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
57
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
58
|
+
- src: string. The picture; left out while it is not known yet, with `loading`.
|
|
59
|
+
- width: "sm" | "md" | "lg" | "xl" | "full" (default full). How wide the frame is: `full` fills its parent; `sm`, `md` and `lg` are 96, 160 and 256px, capped at the parent's width.
|
|
54
60
|
|
|
55
61
|
### OutlineRegion
|
|
56
|
-
An accent outline over one area of a picture, such as a screenshot's ignored or flagged region. `rect` is in the picture's own units and `within` is the picture's full size in the same units; the box is placed in percent of them, so it sits right at any scale. Put it in a `RegionFrame`, over the picture. `label` is a small tag in its top-left corner; `hatched` stripes the inside, for an area that is left out. It takes no pointer events, so it never blocks the picture or a layer drawn over it.
|
|
62
|
+
An accent outline over one area of a picture, such as a screenshot's ignored or flagged region. `rect` is in the picture's own units and `within` is the picture's full size in the same units; the box is placed in percent of them, so it sits right at any scale. Put it in a `RegionFrame`, over the picture. `label` is a small tag in its top-left corner; `hatched` stripes the inside, for an area that is left out. It takes no pointer events, so it never blocks the picture or a layer drawn over it. `tone` colours it by what the area is (`positive`, `warn`, `danger`; `accent` by default), `dashed` draws the edge dashed, for an area that is proposed or approximate, and `active` draws a thicker edge, for the one region the app has picked (the one hovered in a list beside the picture, say). The app sets `active`; the region has no hover state of its own.
|
|
63
|
+
- active: boolean (default false). Draws a thicker edge, for the region the app has picked. The app sets it; there is no hover state.
|
|
64
|
+
- dashed: boolean (default false). Draws the edge dashed, for an area that is proposed or approximate.
|
|
57
65
|
- hatched: boolean (default false). Stripes the inside, for an area left out (ignored, masked).
|
|
66
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
58
67
|
- label: ReactNode. A short tag in the top-left corner: where the area came from, or what it is.
|
|
59
68
|
- rect: RegionRect (required). The area, in the picture's own units.
|
|
69
|
+
- tone: "positive" | "warn" | "danger" | "accent" (default accent). The colour: `accent`, `positive`, `warn` or `danger`.
|
|
60
70
|
- within: { width: number; height: number; } (required). The picture's full size, in the same units as `rect`.
|
|
61
71
|
|
|
62
72
|
### Types
|
|
73
|
+
- OutlineRegionTone: `"positive" | "warn" | "danger" | "accent"`. An `OutlineRegion`'s colour: `accent` (the default), or the shared `Tone`s that have a strong edge, `positive`, `warn` and `danger`. `neutral` and `info` are left out: their edges are pale lines that would not stand out on a picture.
|
|
63
74
|
- RegionRect: `{ x: number; y: number; width: number; height: number }`. A box in a picture's own units (an image's pixels): its top-left corner and its size.
|
|
@@ -103,12 +103,13 @@ function Example() {
|
|
|
103
103
|
|
|
104
104
|
### Accessibility
|
|
105
105
|
- A PageFade is a plain `<div>` with no role, so it changes nothing for assistive technology.
|
|
106
|
+
- After `startPageTransition` swaps the page, focus moves to the new view (the PageFade with no `name`), so a screen reader starts reading the new page and Tab goes on from there. A tab or a segmented control that switched the view in place keeps its focus.
|
|
106
107
|
- Under `prefers-reduced-motion: reduce` the content swaps with no fade, and `startPageTransition` just runs the update.
|
|
107
108
|
- Where the browser has no View Transitions it is a plain `<div>` and the content swaps.
|
|
108
109
|
|
|
109
110
|
### Props
|
|
110
111
|
### PageFade
|
|
111
|
-
The page's content area, cross-faded by the View Transitions API when the route changes. Wrap what changes between pages, once per page. With no `name` the fade is the browser's own cross-fade of the whole viewport; the frame around the content (header, footer) stays still because it is the same on both pages. A `name` names this box so it fades apart from the page, for a second region; a named region is captured at its full height, so name only a region no taller than the screen, and give each named one on a page its own `name`. The fade runs only when the navigation is wrapped in a view transition: `startPageTransition`, or a router's own option (TanStack Router `viewTransition`, React Router's `viewTransition` prop, Astro's `ClientRouter`). Otherwise, or where the browser has no View Transitions, it renders and behaves as a plain `<div>`. A named PageFade is a stacking context, so a dropdown inside it cannot rise above a sticky header outside it: portal overlays to the body. The default one is not. Under `prefers-reduced-motion: reduce` the content swaps with no fade; a named one quiets only its own box, and a router's own transition of the rest of the page is the router's to quiet.
|
|
112
|
+
The page's content area, cross-faded by the View Transitions API when the route changes. Wrap what changes between pages, once per page. With no `name` the fade is the browser's own cross-fade of the whole viewport; the frame around the content (header, footer) stays still because it is the same on both pages. A `name` names this box so it fades apart from the page, for a second region; a named region is captured at its full height, so name only a region no taller than the screen, and give each named one on a page its own `name`. The fade runs only when the navigation is wrapped in a view transition: `startPageTransition`, or a router's own option (TanStack Router `viewTransition`, React Router's `viewTransition` prop, Astro's `ClientRouter`). Otherwise, or where the browser has no View Transitions, it renders and behaves as a plain `<div>`. A named PageFade is a stacking context, so a dropdown inside it cannot rise above a sticky header outside it: portal overlays to the body. The default one is not. Under `prefers-reduced-motion: reduce` the content swaps with no fade; a named one quiets only its own box, and a router's own transition of the rest of the page is the router's to quiet. It is where `startPageTransition` puts the focus after the change: it takes focus from script, never from Tab, and draws no ring for it.
|
|
112
113
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
113
114
|
- name: string. A view-transition name for this box, a CSS identifier (letters, digits, `-`, `_`), for a region no taller than the screen that fades apart from the page.
|
|
114
115
|
|
|
@@ -30,11 +30,11 @@ import { Cluster, Pill } from "@slashsuite/ui-react";
|
|
|
30
30
|
- Choose `tone` by meaning: `positive` for done or good, `warn` for waiting or at risk, `danger` for failed, `neutral` (the default) for a draft or no state, `info` for a note; `accent` for a kind or category that is none of those.
|
|
31
31
|
- `size` is `sm`, `md` (default) or `lg`; with none, a Pill takes the size of the `Card`, `ListRow` or `Table` it sits in.
|
|
32
32
|
- `dot` adds a leading dot in the Pill's colour; `round` swaps the rounded-square corners for a full pill shape. Use one look across a view.
|
|
33
|
+
- A Pill's text never wraps onto a second line: keep it to a word or two, and let the row the Pills sit in wrap them.
|
|
33
34
|
- `name` makes a two-tone `name: value` pill (`<Pill name="Weight">72 kg</Pill>`): the name keeps the tone's tint and the children sit on the surface beside it. Keep the name to a word or two.
|
|
34
|
-
- `onRemove` adds an x button after the text, for a chip the reader can drop (an attachment, a filter); `
|
|
35
|
+
- `onRemove` adds an x button after the text, for a chip the reader can drop (an attachment, a filter); it is named `Remove` and the pill's text (`Remove invoice.pdf`) when that text is a string, and `removeLabel` replaces the whole name, for another wording or language. On a link or button Pill the x is a separate button beside it, never nested inside.
|
|
35
36
|
- A Pill that goes somewhere takes `href` (`external` for a new tab; an in-app one goes through your router's `Link` on `LinkProvider`); one that does something takes `onClick`.
|
|
36
|
-
- A Pill beside a card's title is the Card's `status`, not a hand-built row.
|
|
37
|
-
- A message to read is a `Callout`, and an action is a `Button`.
|
|
37
|
+
- A Pill beside a card's title is the Card's `status`, not a hand-built row. A message to read is a `Callout`, and an action is a `Button`.
|
|
38
38
|
|
|
39
39
|
### Don't
|
|
40
40
|
- Never make a row of clickable `Pill`s a filter: a filter is pressed `Button`s in a `Fieldset`.
|
|
@@ -68,14 +68,14 @@ import { Pill, TextLink } from "@slashsuite/ui-react";
|
|
|
68
68
|
```
|
|
69
69
|
|
|
70
70
|
### Accessibility
|
|
71
|
-
- A two-tone Pill reads "Weight: 72 kg" to a screen reader (a visually hidden colon follows the label). The x of `onRemove` is a `<button type="button">` with `removeLabel
|
|
71
|
+
- A two-tone Pill reads "Weight: 72 kg" to a screen reader (a visually hidden colon follows the label). The x of `onRemove` is a `<button type="button">` with its name (`removeLabel`, or "Remove" and the pill's text) as its `aria-label` and its tooltip, with the icon `aria-hidden`.
|
|
72
72
|
- A plain Pill is a `<span>`; the dot is `aria-hidden`. The tone is colour only, so the text must say the status itself.
|
|
73
73
|
- With `href` it is a link and with `onClick` a `<button type="button">`; both dim on hover and show the focus ring.
|
|
74
74
|
- `external` adds `target="_blank"` and `rel="noreferrer"`.
|
|
75
75
|
|
|
76
76
|
### Props
|
|
77
77
|
### Pill
|
|
78
|
-
A small tinted label whose `tone` says what it means; `dot` adds a leading dot in the pill's own text colour, `round` swaps the rounded-md corners for a full pill shape, and `size` steps the text (with none, it takes its container's). `name` makes it two-tone, `name: value`: the name keeps the tone's tint and the children, the value, sit on the surface beside it. `href` makes it a link (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`; `external` opens a new tab) and `onClick` makes it a button, each with a hover dim and the focus ring. `onRemove` adds an x button after the text (named by `removeLabel`), a separate button beside a link or button pill rather than nested in it. `title` is its tooltip and description; a plain pill with one takes a tab stop. While `loading` with no text yet it is a bone of its size.
|
|
78
|
+
A small tinted label whose `tone` says what it means; `dot` adds a leading dot in the pill's own text colour, `round` swaps the rounded-md corners for a full pill shape, and `size` steps the text (with none, it takes its container's). `name` makes it two-tone, `name: value`: the name keeps the tone's tint and the children, the value, sit on the surface beside it. `href` makes it a link (the app's router link through `LinkProvider` for an in-app path, else a plain `<a>`; `external` opens a new tab) and `onClick` makes it a button, each with a hover dim and the focus ring. `onRemove` adds an x button after the text (named by `removeLabel`, by default `Remove` and the pill's text), a separate button beside a link or button pill rather than nested in it. `title` is its tooltip and description; a plain pill with one takes a tab stop. While `loading` with no text yet it is a bone of its size. Its text never wraps: a pill is one unit, so keep it to a word or two.
|
|
79
79
|
- children: ReactNode. The pill's text; while `loading`, none yet draws the pill as a bone of its size.
|
|
80
80
|
- dot: boolean. A leading dot in the pill's own text colour.
|
|
81
81
|
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
@@ -89,7 +89,8 @@ tone's tint and the value sits on a plain surface beside it, in a hairline borde
|
|
|
89
89
|
name to a word or two (`Weight`, `Sleep`).
|
|
90
90
|
- onClick: MouseEventHandler<HTMLButtonElement>. A Pill that is a button: runs `onClick`. Defaults to `type="button"`.
|
|
91
91
|
- onRemove: (() => void). Adds a small x button after the text that calls this: for a chip the reader can drop (an attachment, a filter). It sits beside a link or button pill, never inside it.
|
|
92
|
-
- removeLabel: string. The x button's accessible name and tooltip: `Remove invoice.pdf`.
|
|
92
|
+
- removeLabel: string (default Remove). The x button's whole accessible name and tooltip: `Remove invoice.pdf`. Left out, it is
|
|
93
|
+
`Remove` followed by the pill's text when that text is a string or a number, else `Remove`.
|
|
93
94
|
- round: boolean. A full pill shape in place of the rounded-md corners.
|
|
94
95
|
- size: "sm" | "md" | "lg" (default the container's, else md). `sm` is smaller text, for a dense row; `lg` larger, beside a heading. Left out, a Pill takes
|
|
95
96
|
the size of the `Card`, `ListRow` or `Table` it sits in, else `md`.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
## Popover
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: A detail, a short explanation or a filter or two that belongs to one control and is not worth a page or a modal.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Menu (menu.md): The panel would be a list of actions.
|
|
9
|
+
- Disclosure (disclosure.md): The detail can open in the page and push what is below it down.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
A detail beside the thing it explains: the panel holds a few facts and closes on a click away.
|
|
13
|
+
```tsx
|
|
14
|
+
import { KeyValue, KeyValueList, Popover } from "@slashsuite/ui-react";
|
|
15
|
+
|
|
16
|
+
<Popover label="Build details" icon="more">
|
|
17
|
+
<KeyValueList>
|
|
18
|
+
<KeyValue label="Commit">982a166</KeyValue>
|
|
19
|
+
<KeyValue label="Shots">412</KeyValue>
|
|
20
|
+
<KeyValue label="Took">3 min 12 s</KeyValue>
|
|
21
|
+
</KeyValueList>
|
|
22
|
+
</Popover>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Do
|
|
26
|
+
- `label` names the trigger and the panel. Without `icon` the trigger is an outline button reading `label`; with `icon` it is a ghost square button, and `label` is its tooltip.
|
|
27
|
+
- Keep the panel small: a few lines, a short list of facts, a filter or two. It is never wider than 22rem or the screen.
|
|
28
|
+
- A list of actions is a `Menu`, which the arrow keys move through. A question to answer first is a `Dialog`.
|
|
29
|
+
|
|
30
|
+
### Don't
|
|
31
|
+
- Do not put the only way to do something in a Popover: a reader who never opens it never finds it.
|
|
32
|
+
- Do not use one for a list of actions: a `Menu` is the one way.
|
|
33
|
+
|
|
34
|
+
A list of actions in a Popover: the arrow keys do not move through them and nothing says they are a menu.
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button, Popover } from "@slashsuite/ui-react";
|
|
37
|
+
|
|
38
|
+
<Popover label="Actions">
|
|
39
|
+
<Button variant="ghost">Rename</Button>
|
|
40
|
+
<Button variant="ghost">Duplicate</Button>
|
|
41
|
+
<Button variant="ghost" tone="danger">
|
|
42
|
+
Delete
|
|
43
|
+
</Button>
|
|
44
|
+
</Popover>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Accessibility
|
|
48
|
+
- It is the browser's own popover: a click outside it, Esc or the trigger closes it, and Esc puts the focus back on the trigger.
|
|
49
|
+
- It is not modal: the page stays usable, and Tab moves from the trigger into the panel and on.
|
|
50
|
+
- The trigger says whether it is open (`aria-expanded`), and the panel is a `dialog` named by `label`.
|
|
51
|
+
- Where the browser positions by anchor, the panel sits under the trigger and flips above when there is no room; elsewhere it shows in the middle of the screen.
|
|
52
|
+
|
|
53
|
+
### Props
|
|
54
|
+
### Popover
|
|
55
|
+
A button that opens a small panel of content beside it: a detail, a short list, a filter. It is the browser's own popover, rendered in place: a click outside it, Esc or the trigger closes it, and the focus goes back to the trigger. It is not modal: the page stays usable, and Tab moves from the trigger into the panel and on. A list of actions is a `Menu`; a question to answer first is a `Dialog`. `data-*` and `aria-*` land on the trigger.
|
|
56
|
+
- children: ReactNode (required). What the panel holds: a few lines, a short list, a filter or two.
|
|
57
|
+
- defaultOpen: boolean (default false). Opens on mount, for a story or a test that shows the open panel.
|
|
58
|
+
- icon: "page" | "grid" | "search" | "alert" | "table" | "type" | "diff" | "baseline" | "review" | "ci" | "self-host" | "privacy" | "capture" | "branch" | "theme" | "speed" | "chevron-right" | "chevron-down" | "close" | "external-link" | "settings" | "bell" | "check" | "plus" | "minus" | "more" | "window" | "card" | "pointer" | "field" | "compass" | "briefcase" | "cart" | "pause" | "play". Makes the trigger a ghost square button holding this glyph, named by `label` (shown as its
|
|
59
|
+
tooltip). Without it the trigger is an outline `Button` reading `label`, with a chevron.
|
|
60
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
61
|
+
- label: string (required). The trigger's accessible name and the panel's. Without `icon` it is the trigger's visible text.
|
|
62
|
+
- size: "sm" | "md" | "lg" (default md). The trigger's height, the same steps as `IconButton` and `Button`: `sm` inside a row or a card
|
|
63
|
+
header. The panel does not change with it.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
## Price
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: Showing what something costs: on a product tile, a product's page or a cart line.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- ProductTile (product-tile.md): The price is one thing for sale in a shop's grid.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
A sale is the price with the old one as `was`: struck through on the page, "R52, was R65" out loud.
|
|
12
|
+
```tsx
|
|
13
|
+
import { Price } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Price value="R52" was="R65" />
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- `value` is the price already formatted for the reader ("R52", "€12.50"): the app owns the currency and the locale, and `Price` formats nothing.
|
|
21
|
+
- `was` is the price before a sale. It follows `value` struck through and a step smaller, and a screen reader hears "R52, was R65".
|
|
22
|
+
- `size` is `sm` for a dense row, `md` (the default) for a tile and `lg` for a product's own page.
|
|
23
|
+
- Figures are tabular, so a column of prices lines up.
|
|
24
|
+
|
|
25
|
+
### Don't
|
|
26
|
+
- Do not strike a price through by hand: the strike is silent, so the old price reads as a second price.
|
|
27
|
+
|
|
28
|
+
A strike drawn by hand is silent: a screen reader hears two prices and cannot tell which one is paid.
|
|
29
|
+
```tsx
|
|
30
|
+
<span>
|
|
31
|
+
R52 <s>R65</s>
|
|
32
|
+
</span>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Accessibility
|
|
36
|
+
- The old price carries a screen-reader-only ", was ", since a strike says nothing out loud.
|
|
37
|
+
- While `loading` with no `value` yet it is a bone of its size and `aria-busy`.
|
|
38
|
+
- `id`, `data-*` and `aria-*` go on the price.
|
|
39
|
+
|
|
40
|
+
### Props
|
|
41
|
+
### Price
|
|
42
|
+
A price as the page already formatted it ("R52"), in tabular figures so a column of prices lines up. With `was` the old price follows it struck through, and a screen reader hears "R52, was R65", since a strike says nothing out loud. It formats nothing: the app owns the currency and the locale. While `loading` with no `value` yet it is a bone of its size.
|
|
43
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
44
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
45
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
46
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
47
|
+
- size: "sm" | "md" | "lg" (default md). `sm` for a dense row, `md` for a tile, `lg` for a product's own page.
|
|
48
|
+
- value: string | undefined (required). The price, formatted for the reader ("R52", "€12.50"). While `loading`, none yet is a bone.
|
|
49
|
+
- was: string. The price before a sale, struck through after `value`.
|