@slashsuite/ui-react 0.12.1 → 0.13.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/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 +1 -0
- package/dist/Button.js +4 -3
- 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 +113 -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/cx.d.ts +22 -3
- package/dist/cx.js +22 -3
- package/dist/dateLocale.d.ts +17 -0
- package/dist/dateLocale.js +30 -0
- package/dist/density.d.ts +15 -1
- package/dist/density.js +27 -8
- 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/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 +45 -0
- package/dist/stateMachineDots.js +162 -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 +27 -0
- package/dist/useFlowLayout.js +119 -0
- package/package.json +3 -2
|
@@ -52,12 +52,12 @@ import {
|
|
|
52
52
|
```
|
|
53
53
|
|
|
54
54
|
### Do
|
|
55
|
-
- Use `columns` 2, 3 or 4 when you know how many
|
|
56
|
-
- Use `columns="auto"` when the count varies: it fits as many per row as the width allows, none narrower than `minWidth` (`md`, the default, or `sm`).
|
|
55
|
+
- Use `columns` 2, 3 or 4 when you know how many: one column on a phone, two from `sm` and `columns` from `lg`. Use `columns="auto"` when the count varies: as many per row as fit, none narrower than `minWidth` (`md`, the default, or `sm`).
|
|
57
56
|
- Every tile in a `CardGrid` is one width. A main card beside a narrower one is a `SideColumn` (`asideWidth="third"` for two thirds and one third), not a grid.
|
|
58
|
-
- `align="start"` keeps each
|
|
59
|
-
- `
|
|
60
|
-
-
|
|
57
|
+
- By default every card stretches to the tallest in its row; `align="start"` keeps each its own height, and `align="regions"` lines up each card's title, body and footer across the row, so a long title does not push its body below its neighbours' (one `Card` per cell).
|
|
58
|
+
- `minColumns={2}` keeps two tiles to a row on a phone, for small tiles such as `StatTile`s.
|
|
59
|
+
- `CardGridRow` holds one child across the whole row, such as a wide card above the tiles; in an `as="ul"` grid it is its own list item.
|
|
60
|
+
- `CardGrid` goes inside a page layout and sets no page width of its own. A single column of blocks is a `Stack`, not a one-column `CardGrid`.
|
|
61
61
|
- `as="ul"` makes the grid a list and wraps each child in a list item, for a set of like tiles a screen reader should count. The look is the same.
|
|
62
62
|
- `empty` is an `EmptyState`, drawn in place of the grid when it has no children.
|
|
63
63
|
|
|
@@ -96,8 +96,10 @@ import { Card, CardGrid, Text } from "@slashsuite/ui-react";
|
|
|
96
96
|
|
|
97
97
|
### Props
|
|
98
98
|
### CardGrid
|
|
99
|
-
A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`. A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"` for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide: `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height instead of stretching it to the tallest in its row. `as="ul"` makes it a list of cards for a screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched. With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with none it draws one card of bones per column (three for `auto`), never `empty`.
|
|
100
|
-
- align: "start" | "stretch" (default stretch). `start` keeps each card its own height; the default stretches every card to the tallest in its
|
|
99
|
+
A responsive grid of tiles of one width: one column on a phone, two from `sm`, `columns` from `lg`. A main area beside a narrower one is not a grid of tiles: it is `SideColumn` (`asideWidth="third"` for two thirds and one). `columns="auto"` instead fits as many per row as the width allows, each at least `minWidth` wide: `md` (17rem, the default) or `sm` (12rem). `align="start"` keeps each card its own height instead of stretching it to the tallest in its row; `align="regions"` lines up each card's header, body and footer across the row (CSS subgrid). `minColumns={2}` keeps two tiles to a row on a phone. Every cell has `min-w-0`, so a truncating name inside a card cuts instead of widening its column. A `CardGridRow` spans every column. `as="ul"` makes it a list of cards for a screen reader: the grid is a `<ul>` and each child is wrapped in an `<li>`, still stretched. With no children it draws `empty` (an `EmptyState`) in place of the grid. While `loading` with none it draws one card of bones per column (three for `auto`), never `empty`.
|
|
100
|
+
- align: "start" | "stretch" | "regions" (default stretch). `start` keeps each card its own height; the default stretches every card to the tallest in its
|
|
101
|
+
row. `regions` stretches them too and lines up each card's header, body and footer with its
|
|
102
|
+
neighbours' across the row, so titles of different lengths do not push the bodies out of line.
|
|
101
103
|
- as: "div" | "ul" (default div). `ul` makes the grid a list: each child is wrapped in an `<li>`. Default `div`.
|
|
102
104
|
- columns: "auto" | 2 | 3 | 4 (default 3). Cards per row from `lg` (one on a phone, two from `sm`), or `auto` for as many as fit.
|
|
103
105
|
- empty: ReactNode. Drawn in place of the grid when there are no children: an `EmptyState`.
|
|
@@ -105,4 +107,10 @@ A responsive grid of tiles of one width: one column on a phone, two from `sm`, `
|
|
|
105
107
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
106
108
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
107
109
|
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
110
|
+
- minColumns: 2 | 1 (default 1). The fewest cards in a row: `2` keeps two small tiles side by side on a phone (products in a
|
|
111
|
+
shop), where the default is one.
|
|
108
112
|
- minWidth: "sm" | "md" (default md). With `columns="auto"`, the narrowest a card gets: `md` 17rem or `sm` 12rem.
|
|
113
|
+
|
|
114
|
+
### CardGridRow
|
|
115
|
+
One item that spans every column of a `CardGrid`: a heading over a group of cards, or one wide card in the run (an announcement among products). In `as="ul"` its `<li>` spans the row. It takes no `align="regions"` rows: what it holds keeps its own layout.
|
|
116
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
@@ -21,11 +21,10 @@ import { Card, Pill, Text } from "@slashsuite/ui-react";
|
|
|
21
21
|
- Name the Card with `title`; add a `count` or a `status` and they sit beside the title.
|
|
22
22
|
- `titleStyle="name"` sets the title in sentence case and the primary ink, for a card that is a thing with a name (a shop, a listing, an event). The default `overline` is the small uppercase label of a panel (Status, Activity). Count, status, actions and `bar` work with both.
|
|
23
23
|
- `actions` sit at the far end of the header; use `bar` to put the header in a tinted strip.
|
|
24
|
-
- Space several Cards with a `Stack` or a `CardGrid
|
|
25
|
-
- `flush` is for a table that runs edge to edge, and it needs a `bar` for its title.
|
|
26
|
-
- A Card with `href` is one link
|
|
27
|
-
- `
|
|
28
|
-
- An empty state is an `EmptyState`, inside the card or on its own, where it draws its own dashed frame.
|
|
24
|
+
- Space several Cards with a `Stack` or a `CardGrid`, never with nothing between. An empty state is an `EmptyState`, inside the card or on its own, where it draws its own dashed frame.
|
|
25
|
+
- `flush` is for a table that runs edge to edge, and it needs a `bar` for its title. `width="sm"` caps a card at a narrow width, for one card on its own in a wide column such as a sign-in form.
|
|
26
|
+
- A Card with `href` is one link and one with `onPress` one button, for a card the user picks (pass `aria-pressed` when it stays picked). A `TextLink` or `Button` inside sits above it and is clickable on its own. `more` adds a Read more line at the foot of a link card; `moreLabel` sets its words.
|
|
27
|
+
- `hue` paints a set of peer cards, one hue each, such as one card per product; it is not a status (that is `tone`), and the title still names each card. `dashed` draws a dashed edge for a card that stands for something not real yet, such as a plan beside a measured result; with `bar` the strip is dashed too.
|
|
29
28
|
|
|
30
29
|
### Don't
|
|
31
30
|
A hand-built title row drifts from every other Card's: use `title` and `status`.
|
|
@@ -54,31 +53,33 @@ import { Card, Text } from "@slashsuite/ui-react";
|
|
|
54
53
|
```
|
|
55
54
|
|
|
56
55
|
### Accessibility
|
|
57
|
-
- A
|
|
58
|
-
- `id`, `data-*` and `aria-*` go on the root element. On a link card too: the link inside it keeps only its own `aria-label`, `aria-labelledby` and `aria-current
|
|
59
|
-
-
|
|
56
|
+
- A panel Card (no `href` or `onPress`) with a `title` or an `aria-label` is an `<article>`, named by its title (`aria-labelledby` points at the heading) or by that label; any other is a `<div>`. Your own `aria-label` or `aria-labelledby` wins. The title is an `h2` on the page and an `h3` in a `Section`; `level` sets it by hand.
|
|
57
|
+
- `id`, `data-*` and `aria-*` go on the root element. On a link card too: the link inside it keeps only its own `aria-label`, `aria-labelledby` and `aria-current`. It is named by the card's title, or by the card's text when it has none.
|
|
58
|
+
- A card with `onPress` is one `<button>` named the same way; `aria-pressed` goes on that button.
|
|
59
|
+
- The `more` line is `aria-hidden`: the link is already named by the title.
|
|
60
|
+
- The `badge` is read after the content, and on a titled link card it is not part of the link's name, which is the title.
|
|
60
61
|
- `attention` is colour only: say why in the card's title or text.
|
|
61
62
|
- The `icon` is decorative and `aria-hidden`: the title says what the card is.
|
|
62
63
|
|
|
63
64
|
### Props
|
|
64
65
|
### Card
|
|
65
|
-
A bordered panel with an optional title, count and status. A titled card is
|
|
66
|
+
A bordered panel with an optional title, count and status. A titled card is an `article` named by its title, one with only an `aria-label` an `article` too, and any other a `div`. Two opt-in forms for data views: `flush` drops the padding and clips the corners, for a table that runs edge to edge; `bar` puts the title, count and `actions` in a tinted strip across the top, over the body. A flush card has no padding for a `title`, so give it a `bar`. An empty state is an `EmptyState`, which draws its own dashed frame. Inside a card a `Stack` is `xs` apart, and the title's heading level is one below the heading that holds the card. `size="sm"` is the dense padding and `size="lg"` the roomy one, the same on a `ListRow` and a `FileDrop`. `tone` is the Callout's set, for a data panel that carries a status (a soft fill and border, no shadow); a message is still a `Callout`, and `bar` has no tone. `hue` paints one of a set of peer cards in its own hue, the theme's; it is not a status, and `tone`, `bar` and `dashed` win over it. `dashed` draws a dashed edge for a card that stands for something not real yet, and with `bar` the strip's edge is dashed too. `width="sm"` caps the card at 24rem. A titled panel is named by its title: the root gets `aria-labelledby` pointing at the heading, unless the caller passes its own `aria-label` or `aria-labelledby`, which wins. Other props (`id`, `data-*`, `aria-*`) go on the root. The root is `relative`, so a `TextLink stretch` inside it covers the card. A card with an `id` is an anchor target: `#id` scrolls it clear of the sticky header (and a `subnav`) and outlines it in the accent colour while it is the target. `icon` is one of the library's icons at feature size in the accent colour, above the title: the mark of a feature card. It sits in the padded body, so `bar` and `flush` have none. `footer` is a tinted strip across the bottom, under a hairline, for the card's own actions or a total; in a `CardGrid` it stays at the foot of a card that is stretched to the row's height. It suits a panel, not a card that is a link. `fill` makes a panel take its parent's full height (the parent sets it): the title or bar and the `inset` band stay put and the body scrolls, with room inside it for a focus ring at its edge. Not on a link card. `href` makes the whole card one link: a hover border and the focus ring, with the link stretched over the card, so it takes no `actions` or `footer`. `onPress` makes it one button the same way. A `TextLink`, `Button` or `Checkbox` in the body sits above the link and is clickable on its own. An in-app `href` is drawn by the app's router link through `LinkProvider`. `external` opens it in a new tab, and `more` draws a "Read more" line at its foot. On a link or button card `id`, `data-*` and the describing `aria-*` (`aria-describedby`, `aria-details`, …) go on the card root; the control's own `aria-label`, `aria-labelledby`, `aria-current` and `aria-pressed` stay on it. The link or button is named by the card's title; an untitled one by the card's text, through the root's id, which is generated when the caller gives none. In a `CardGrid align="regions"` the card's header, body and footer line up with its neighbours' across the row. While `loading` a card with no children draws three lines of text bones, a `flush` one three `ListRow` bones; what it has (its title, its children) draws as usual.
|
|
66
67
|
- actions: ReactNode. Buttons or links at the end of the header: in the strip with `bar`, else beside the title.
|
|
67
|
-
- as: "article". `article` for a card that stands alone as a piece of content (a post, a listing). Left out, a
|
|
68
|
-
titled card is a `section` named by its title, one with only an `aria-label` a `section` named
|
|
69
|
-
by that, and any other a `div`. Not on a card that is a link.
|
|
70
68
|
- attention: boolean. The warn tone's strong border in place of the card's own, for the one card in a set that needs
|
|
71
69
|
a look (a run that differed). It keeps the card's fill. Name why in the card too (a `Pill` in
|
|
72
70
|
`badge`, or the body); the border alone says nothing to a screen reader.
|
|
73
71
|
|
|
74
72
|
Add `tone="warn"` for the warn surface too.
|
|
75
73
|
- badge: ReactNode. A `Pill` (or any small node) pinned in the top corner at the end edge, over the content and
|
|
76
|
-
inside the radius, with no change to the layout. On a
|
|
77
|
-
|
|
74
|
+
inside the radius, with no change to the layout. On a titled link card the link is named by the
|
|
75
|
+
title alone; an untitled one is named by its whole content, badge included. A link or button in
|
|
76
|
+
it is clickable on its own.
|
|
78
77
|
|
|
79
78
|
Use it for a category (`Pill tone="info"`) or a flag on the thing itself.
|
|
80
79
|
- bar: boolean. Put the title, count and actions in a tinted strip above the body, edge to edge.
|
|
81
80
|
- count: number. A small number beside the title (how many rows the card holds). Needs a `title`.
|
|
81
|
+
- dashed: boolean. A dashed edge, for a card that stands for something not real yet: a plan, a draft, an imagined
|
|
82
|
+
result beside a real one. With `bar` the strip's lower edge is dashed too.
|
|
82
83
|
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
83
84
|
- fill: boolean. Take the parent's full height: the title or bar stays put and the body scrolls. The parent sets
|
|
84
85
|
the height.
|
|
@@ -87,9 +88,12 @@ For a panel in a fixed-height layout, such as a sheet over a map. Put links or c
|
|
|
87
88
|
body, so a keyboard can reach and scroll it.
|
|
88
89
|
- flush: boolean. No padding and `overflow-hidden`: the body (a table, a list) fills the card.
|
|
89
90
|
- footer: ReactNode. A tinted strip across the bottom of the card, under a hairline, for the card's own actions or a total. It stays at the foot when the card is stretched in a `CardGrid`.
|
|
90
|
-
- href: string. Makes the whole card one link to this URL, with no `actions
|
|
91
|
-
|
|
92
|
-
-
|
|
91
|
+
- href: string. Makes the whole card one link to this URL, with no `actions` or `footer`; an in-app path goes
|
|
92
|
+
through the app's `LinkProvider`. The link is named by the card's title.
|
|
93
|
+
- hue: "orange" | "violet" | "sky" | "green" | "yellow" | "blue". One hue of a set of peer cards, such as one card per product: a soft fill and edge the theme
|
|
94
|
+
paints. It is not a status (that is `tone`), and the title still names the card. Ignored with
|
|
95
|
+
`bar` and `dashed`.
|
|
96
|
+
- 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". One of the library's icons, drawn at feature size in the accent colour above the title: the
|
|
93
97
|
mark of a feature card. Ignored with `bar` and `flush`.
|
|
94
98
|
|
|
95
99
|
Pick it by the idea it stands for.
|
|
@@ -101,13 +105,24 @@ A bordered sub-card inside a card is a nested `Card tone="neutral"`, not a hand-
|
|
|
101
105
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
102
106
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
103
107
|
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
108
|
+
- more: boolean. A "Read more" line with an arrow at the foot of the card, in the accent colour: the cue that the
|
|
109
|
+
card goes somewhere, for a post or an article. Draw it on every card of a set or on none.
|
|
110
|
+
- moreLabel: string (default "Read more"). The words of the `more` line.
|
|
111
|
+
- onPress: (() => void). Makes the whole card one button that runs this, stretched over the card like a link card's link
|
|
112
|
+
and named by its title: a card the user picks (a store, a plan). With no `actions`, `footer` or
|
|
113
|
+
`href`. A picked card says so with `aria-pressed` and its own words (a `Pill` in `badge`).
|
|
104
114
|
- size: "sm" | "md" | "lg" (default md). `sm` is dense padding on the body, heading and bar, and makes a `Button`, `IconButton` or `Pill`
|
|
105
115
|
inside with no `size` of its own `sm` too; `lg` is one step roomier than `md`.
|
|
106
116
|
|
|
107
117
|
`sm` suits a dense dashboard, `lg` a card that stands alone.
|
|
108
118
|
- status: ReactNode. A `Pill` (or any node) directly beside the title and count, not at the far end like `actions`. Needs a `title`.
|
|
109
|
-
- title: string. The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then
|
|
119
|
+
- title: string. The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then an `article`.
|
|
110
120
|
- titleStyle: "name" | "overline" (default overline). How the `title` is set. `overline` is the small uppercase label of a panel; `name` is the same
|
|
111
121
|
heading in sentence case and the primary ink, for a card whose title is a name (a shop, a listing,
|
|
112
122
|
an event). Count, status, actions, `bar` and `size` work the same with both.
|
|
113
123
|
- tone: "neutral" | "info" | "positive" | "warn" | "danger". A soft fill and border in the Callout's tones, for a data panel with a status. Ignored with `bar`.
|
|
124
|
+
- width: "sm". `sm` caps the card at 24rem, for a card that stands alone in a wide column (a sign-in panel, a
|
|
125
|
+
plan). Left out, the card takes the width it is given.
|
|
126
|
+
|
|
127
|
+
### Types
|
|
128
|
+
- CardHue: `"orange" | "violet" | "sky" | "green" | "yellow" | "blue"`. The peer hues a set of cards can take, one each: green is the palette's emerald and yellow its amber.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
## CartButton
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A shop's header, to open the cart from any page.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
The cart opens in a `Drawer`, and the button carries the drawer's state in `aria-expanded`.
|
|
9
|
+
```tsx
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { CartButton, Drawer, Text } from "@slashsuite/ui-react";
|
|
12
|
+
|
|
13
|
+
function Example() {
|
|
14
|
+
const [open, setOpen] = useState(false);
|
|
15
|
+
return (
|
|
16
|
+
<>
|
|
17
|
+
<CartButton
|
|
18
|
+
count={2}
|
|
19
|
+
total="R800"
|
|
20
|
+
onClick={() => setOpen(true)}
|
|
21
|
+
aria-expanded={open}
|
|
22
|
+
aria-controls="cart"
|
|
23
|
+
/>
|
|
24
|
+
{open && (
|
|
25
|
+
<Drawer id="cart" title="Your cart" onClose={() => setOpen(false)}>
|
|
26
|
+
<Text>Two prints, R800.</Text>
|
|
27
|
+
</Drawer>
|
|
28
|
+
)}
|
|
29
|
+
</>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Do
|
|
35
|
+
- `count` is how many things are in the cart; `0` is shown, so the header does not shift as things go in.
|
|
36
|
+
- `total` is what they come to, formatted by the app ("R480"). Left out, only the count shows.
|
|
37
|
+
- `onClick` opens the cart in a `Drawer`; pass `aria-expanded` and `aria-controls` with the drawer's state. `href` makes it a link to the cart's page instead.
|
|
38
|
+
- `label` (default "Cart") and `itemsLabel` (default "1 item" or "n items") are its words, for an app in another language.
|
|
39
|
+
|
|
40
|
+
### Don't
|
|
41
|
+
- Do not draw a cart icon with a bare number: a screen reader hears a number with nothing to say what it counts.
|
|
42
|
+
|
|
43
|
+
An icon with a bare number says "2" to a screen reader: two of what, and where?
|
|
44
|
+
```tsx
|
|
45
|
+
<button type="button">
|
|
46
|
+
<span aria-hidden="true">🛒</span> 2
|
|
47
|
+
</button>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Accessibility
|
|
51
|
+
- Named by its label, the count in words and the total: "Cart, 2 items, R480". The chip and the total are drawn for the eye and hidden from a screen reader, which hears the words.
|
|
52
|
+
- `id`, `data-*` and `aria-*` go on the button or the link.
|
|
53
|
+
|
|
54
|
+
### Props
|
|
55
|
+
### CartButton
|
|
56
|
+
The header's cart: the bag icon, how many things are in it and, with `total`, what they come to. It is one ghost button that opens the cart (a `Drawer`), so pass `aria-expanded` and `aria-controls` with the drawer's state; with `href` it is a link to the cart page instead. A screen reader hears it as "Cart, 2 items, R480": the label, the count in words and the total. The count is drawn whatever it is, `0` included, so the header does not shift as things go in.
|
|
57
|
+
- count: number (required). How many things are in the cart; `0` is shown.
|
|
58
|
+
- href: string. The cart's own page, in place of a drawer; an in-app path goes through `LinkProvider`.
|
|
59
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
60
|
+
- itemsLabel: ((count: number) => string) (default (count: number): string => (count === 1 ? "1 item" : `${count} items`)). The count in words, for a screen reader, in an app's own language.
|
|
61
|
+
- label: string (default Cart). The button's name before the count.
|
|
62
|
+
- onClick: MouseEventHandler<HTMLButtonElement>. Opens the cart; pass `aria-expanded` and `aria-controls` for the drawer it opens.
|
|
63
|
+
- total: string. What they come to, formatted by the app ("R480"). Left out, only the count shows.
|
|
@@ -14,7 +14,7 @@ import { ChatComposer } from "@slashsuite/ui-react";
|
|
|
14
14
|
|
|
15
15
|
### Do
|
|
16
16
|
- Give it a `label` and `onSend`. It keeps its own text and calls `onSend` with it trimmed, then clears the box.
|
|
17
|
-
- Enter sends and Shift+Enter is a newline.
|
|
17
|
+
- Enter sends and Shift+Enter is a newline. Send stays enabled on an empty box: empty or whitespace-only text sends nothing and shows `emptyReason` ("Write a message first.") under the box, announced politely, until the next keystroke. The box grows with its text from 2 rows to 8.
|
|
18
18
|
- `busy` is a reply on its way: the button is Stop and calls `onStop`, Enter does not send, and the reader can go on typing. With no `onStop`, Send stays disabled and no Stop is drawn.
|
|
19
19
|
- `disabled` is for a chat that cannot take a message at all; it disables the box and the button.
|
|
20
20
|
- `sendLabel` and `stopLabel` are the button's words, Send and Stop by default.
|
|
@@ -31,14 +31,15 @@ import { ChatComposer } from "@slashsuite/ui-react";
|
|
|
31
31
|
### Accessibility
|
|
32
32
|
- `label` is the box's name, in a visually hidden `<label>`.
|
|
33
33
|
- Enter during an IME composition commits the text and does not send.
|
|
34
|
-
- After Send is pressed the focus goes back to the box,
|
|
34
|
+
- After Send is pressed the focus goes back to the box, to type the next message or the missing one.
|
|
35
35
|
|
|
36
36
|
### Props
|
|
37
37
|
### ChatComposer
|
|
38
|
-
The box a message is typed into, with its button beside it. It keeps its own text. Enter sends the trimmed text and clears the box; Shift+Enter is a newline
|
|
38
|
+
The box a message is typed into, with its button beside it. It keeps its own text, and the box grows with it from 2 rows to 8. Enter sends the trimmed text and clears the box; Shift+Enter is a newline. Send stays enabled on an empty box: sending empty or whitespace-only text sends nothing and shows `emptyReason` under the box until the next keystroke. While `busy` a reply is on its way: the button is Stop, Enter does not send, and typing carries on with the text kept for the next send.
|
|
39
39
|
- busy: boolean (default false). A reply is on its way: the button is Stop and Enter does not send. With no `onStop`, the button
|
|
40
40
|
stays a disabled Send and no Stop is drawn.
|
|
41
41
|
- disabled: boolean (default false). Disables the box and the button. For a chat that cannot take a message at all, not for a reply in flight: that is `busy`.
|
|
42
|
+
- emptyReason: string (default Write a message first.). Shown under the box when Send is pressed on an empty box.
|
|
42
43
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
43
44
|
- label: string (required). The box's name for assistive tech; it is not drawn.
|
|
44
45
|
- onSend: (text: string) => void (required). Called with the trimmed text.
|
|
@@ -10,16 +10,16 @@ A yes or no is a `Checkbox` with its `label`: the whole label is the click targe
|
|
|
10
10
|
import { Checkbox } from "@slashsuite/ui-react";
|
|
11
11
|
|
|
12
12
|
<Checkbox label="Email me when a shop I follow posts" defaultChecked />
|
|
13
|
-
|
|
14
13
|
```
|
|
15
14
|
|
|
16
15
|
### Do
|
|
17
16
|
- Give a `Checkbox` a `label`; the whole label is the click target.
|
|
18
17
|
- In a table cell leave the `label` out, use `size="sm"` and name the box with `aria-label`. `size="lg"` matches a large `Input`.
|
|
19
|
-
- A `hint` is a muted line under the label for an option that needs a sentence, and an `error`
|
|
18
|
+
- A `hint` is a muted line under the label for an option that needs a sentence, and an `error` goes under it in red. The box always sits on the label's first line.
|
|
20
19
|
- A setting that takes effect the moment it is flipped, usually by saving it, is a `Switch`. A `Checkbox` is ticked and then submitted with the form.
|
|
21
20
|
- Choosing one of several is a `RadioGroup`, a `Select` or a `SegmentedControl`, not a row of checkboxes.
|
|
22
21
|
- Several checkboxes for one question go in a `Fieldset`.
|
|
22
|
+
- `variant="card"` is an option card, the label its title and the `hint` its description, for a few options that each need a sentence; give every box in the `Fieldset` the same variant.
|
|
23
23
|
- Say why the box cannot change with `disabledReason`.
|
|
24
24
|
|
|
25
25
|
### Don't
|
|
@@ -54,18 +54,21 @@ import { Checkbox } from "@slashsuite/ui-react";
|
|
|
54
54
|
### Accessibility
|
|
55
55
|
- A native `<input type="checkbox">` inside a `<label>`, so clicking the text toggles it and the label is its name.
|
|
56
56
|
- A bare box has no name of its own: `aria-label` is required.
|
|
57
|
-
- A `hint`
|
|
57
|
+
- A `hint` and an `error` are the box's `aria-describedby`, added to any you pass; an `error` is announced politely, not as an alert, and marks the box `aria-invalid`. `indeterminate` draws a dash for a group partly ticked and is read out as "mixed".
|
|
58
58
|
- `disabledReason` sets `aria-disabled` and keeps the box in the tab order; a click and Space do nothing, and the reason shows as a tooltip on hover, keyboard focus and a tap, read out as its description (the native `title` without CSS anchor positioning).
|
|
59
59
|
- The focus ring comes from the component.
|
|
60
60
|
|
|
61
61
|
### Props
|
|
62
62
|
### Checkbox
|
|
63
|
-
A checkbox with its label. It is a real `<input type="checkbox">`, drawn by the library (an empty outlined box, then a filled accent one with a check mark) so it reads the same in every theme and browser. Every prop but the label goes on the input, and `ref` reaches it. `size="sm"` is `text-xs` and a smaller box, for a dense row; `size="lg"` is `text-base` and a larger box. Leave `label` out for a bare box in a table cell, and name it with `aria-label`. The box sits on the label's first line, so a label that wraps reads from the box. `hint` is a muted line under the label that says more, like a `Field`'s; `error`
|
|
63
|
+
A checkbox with its label. It is a real `<input type="checkbox">`, drawn by the library (an empty outlined box, then a filled accent one with a check mark) so it reads the same in every theme and browser. Every prop but the label goes on the input, and `ref` reaches it. `size="sm"` is `text-xs` and a smaller box, for a dense row; `size="lg"` is `text-base` and a larger box. Leave `label` out for a bare box in a table cell, and name it with `aria-label`. The box sits on the label's first line, so a label that wraps reads from the box. `hint` is a muted line under the label that says more, like a `Field`'s; `error` adds a red line under it, with an alert icon, and makes the box `aria-invalid` and red-edged. The note is the box's `aria-describedby`. `onChange` gets the new checked state; take `checked` with it, or `defaultChecked` alone. `indeterminate` draws a dash for a select-all box over a partly chosen list. `variant="card"` draws it as an option card: a bordered box with the label as its title and the hint under it. Under a finger the hit area grows to 44px. While `loading` the label is drawn and the box is a bone of its size.
|
|
64
64
|
- disabledReason: string. Why the box cannot be changed: it dims and is blocked (`aria-disabled`; a click and Space
|
|
65
65
|
change nothing) while it stays in the tab order, and the reason is its tooltip on hover,
|
|
66
66
|
keyboard focus and a tap, read out as its description.
|
|
67
|
-
- error: ReactNode.
|
|
67
|
+
- error: ReactNode. A red line under the hint, with an alert icon, announced politely; makes the box `aria-invalid`.
|
|
68
68
|
- hint: ReactNode. A muted line under the label that says more. It is the box's `aria-describedby`.
|
|
69
|
+
- indeterminate: boolean (default false). Mixed: some of what the box stands for is chosen and some is not, as a select-all box over a
|
|
70
|
+
partly chosen list. It draws a dash and is read as "mixed"; a click checks it. The caller owns
|
|
71
|
+
it: work it out from the list on every render.
|
|
69
72
|
- label: ReactNode. The text beside the box. Leave it out for a bare box (a table cell) and name it with `aria-label`.
|
|
70
73
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
71
74
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
@@ -73,3 +76,6 @@ Left out, the part takes the nearest loading layout's or part's; `false` opts it
|
|
|
73
76
|
- onChange: ((checked: boolean) => void). Called with the new checked state when the person ticks or clears the box.
|
|
74
77
|
- ref: Ref<HTMLInputElement>. The `<input>`, for focus control.
|
|
75
78
|
- size: "sm" | "md" | "lg" (default md). The label's text size and the box with it.
|
|
79
|
+
- variant: "card" | "plain" (default plain). `plain` is the box and its words. `card` puts them in a bordered box the width of its parent,
|
|
80
|
+
the label a title and the `hint` its description: for a few options that each need a line of
|
|
81
|
+
explaining. The whole card is the click target, and a ticked one takes an accent edge.
|
|
@@ -19,13 +19,13 @@ import { Button, Cluster, ClusterGrow, Input } from "@slashsuite/ui-react";
|
|
|
19
19
|
|
|
20
20
|
### Do
|
|
21
21
|
- `gap` is `xs`, `sm` (default) or `md`, the first steps of the `Stack` scale: the items of a row sit closer than the blocks of a column. The `Size` type lists every default that is not `md`.
|
|
22
|
-
- `align` is the cross axis: `center` (default), `baseline` for mixed text sizes, `start` or `end`. `justify` is the main axis: `start` (default), `between` for the two ends, `end`.
|
|
22
|
+
- `align` is the cross axis: `center` (default), `baseline` for mixed text sizes, `start` or `end`. `justify` is the main axis: `start` (default), `center`, `between` for the two ends, `end`.
|
|
23
23
|
- The items flow onto more lines when the row runs out of room; `wrap={false}` keeps them on one line.
|
|
24
24
|
- Wrap the one item that should fill the row in `ClusterGrow`; it can shrink to nothing, so a long value truncates and the others stay.
|
|
25
25
|
- An empty `ClusterGrow` is a spacer: what follows it goes to the end.
|
|
26
26
|
- A row of buttons is a `ButtonGroup`, which wraps on a phone and can pin an item to the end. Use `Cluster` for every other row.
|
|
27
27
|
- `justify="between"` is for two items; with more, the middle one floats, so use a spacer.
|
|
28
|
-
- `as="ul"` or `as="ol"` makes a wrapping row of like things (tags, chips) a list
|
|
28
|
+
- `as="ul"` or `as="ol"` makes a wrapping row of like things (tags, chips) a list, and `as="nav"` a row of links (a footer's) in a `<nav>` named by its required `aria-label`. Pass the items themselves: the Cluster puts each in its own `<li>`, and a `ClusterGrow` does not belong in a list.
|
|
29
29
|
|
|
30
30
|
### Don't
|
|
31
31
|
Without `ClusterGrow` the input keeps a fixed width and the rest of the row sits empty. Wrap the input in `ClusterGrow` instead.
|
|
@@ -78,20 +78,22 @@ import { Cluster, Pill } from "@slashsuite/ui-react";
|
|
|
78
78
|
### Accessibility
|
|
79
79
|
- A `Cluster` is a `div` (or a `span` with `as="span"`) and adds no role; the reading and tab order is the source order of its children.
|
|
80
80
|
- A `ul` or `ol` Cluster is a list a screen reader counts; give it an `aria-label` when more than one list is on the page.
|
|
81
|
+
- A `nav` Cluster is a navigation landmark named by its `aria-label`, holding a list of its links.
|
|
81
82
|
- `ClusterGrow` is a `div` too: put the labelled control inside it, with its own `aria-label` or `Field`.
|
|
82
83
|
|
|
83
84
|
### Props
|
|
84
85
|
### Cluster
|
|
85
|
-
A horizontal row of items a fixed `gap` apart (`sm` by default): the row counterpart of `Stack`. `align` is the cross axis (`center` default, `baseline` for mixed text sizes, `start`, `end`) and `justify` the main one (`start` default, `between` to push the first and last items to the two ends, `end`). The items flow onto further lines when the row runs out of room; `wrap={false}` keeps them on one line. Put one `ClusterGrow` around the item that takes the room left over, an input beside its buttons, say. An empty `ClusterGrow` is a spacer that pushes what follows it to the end. `ButtonGroup` is the row for buttons; use `Cluster` for any other row. `as="span"` is for a row inside phrasing content, such as a `PageHeader` description (a `<p>`): its items must be phrasing content too, so no `ClusterGrow`. `as="ul"` or `as="ol"` is a wrapping list with no markers (tags, chips)
|
|
86
|
+
A horizontal row of items a fixed `gap` apart (`sm` by default): the row counterpart of `Stack`. `align` is the cross axis (`center` default, `baseline` for mixed text sizes, `start`, `end`) and `justify` the main one (`start` default, `between` to push the first and last items to the two ends, `end`). The items flow onto further lines when the row runs out of room; `wrap={false}` keeps them on one line. Put one `ClusterGrow` around the item that takes the room left over, an input beside its buttons, say. An empty `ClusterGrow` is a spacer that pushes what follows it to the end. `ButtonGroup` is the row for buttons; use `Cluster` for any other row. `as="span"` is for a row inside phrasing content, such as a `PageHeader` description (a `<p>`): its items must be phrasing content too, so no `ClusterGrow`. `as="ul"` or `as="ol"` is a wrapping list with no markers (tags, chips), as in `CardGrid`: the Cluster wraps each child in its own `<li>`, so the caller writes the items (`Pill`s) and never an `<li>`. `as="nav"` is a row of links (a footer's or a section's): a `<nav>` named by its required `aria-label`, holding a list with each link in its own `<li>`.
|
|
86
87
|
- align: "center" | "baseline" | "end" | "start" (default center). The cross axis: `center`, `baseline` (for mixed text sizes), `start` or `end`.
|
|
87
|
-
- as: "div" | "ol" | "span" | "ul" (default div). The element: `div`, `span` for a row inside a `<p>` or other phrasing content,
|
|
88
|
-
for a list (no markers; each child
|
|
88
|
+
- as: "nav" | "div" | "ol" | "span" | "ul" (default div). The element: `div`, `span` for a row inside a `<p>` or other phrasing content, `ul` or `ol`
|
|
89
|
+
for a list (no markers; the Cluster wraps each child in an `<li>`), or `nav` for a row of
|
|
90
|
+
links (a `<nav>` named by `aria-label`, around such a list).
|
|
89
91
|
|
|
90
92
|
In a `span` the items must be phrasing content, so no `ClusterGrow`.
|
|
91
93
|
- gap: "sm" | "md" | "xs" (default sm). The space between items: the first steps of the gap scale. Its default is one of those the
|
|
92
94
|
`Size` type lists as not `md`.
|
|
93
95
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
94
|
-
- justify: "end" | "start" | "between" (default start). The main axis: `start`, `between` (the first and last items at the two ends) or `end`.
|
|
96
|
+
- justify: "center" | "end" | "start" | "between" (default start). The main axis: `start`, `center`, `between` (the first and last items at the two ends) or `end`.
|
|
95
97
|
- wrap: boolean (default true). Let the items flow onto further lines when the row runs out of room. `false` keeps them on one line.
|
|
96
98
|
|
|
97
99
|
### ClusterGrow
|
|
@@ -100,7 +102,7 @@ The one child of a `Cluster` (or of a `Stack` with `rowFrom`) that grows to the
|
|
|
100
102
|
- minWidth: "sm" | "md". The narrowest it gets: `sm` 12rem or `md` 17rem. In a `Cluster` with `wrap` it wraps under the other items below this width. Left out, it shrinks to nothing.
|
|
101
103
|
|
|
102
104
|
### Types
|
|
103
|
-
- ClusterAlign: `"
|
|
105
|
+
- ClusterAlign: `"end" | "start" | "center" | "baseline"`. Where a `Cluster`'s items sit across the row: `center`, `baseline` for mixed text sizes, `start` or `end`.
|
|
104
106
|
- ClusterGap: `"sm" | "md" | "xs"`. The first three steps of `Stack`'s scale: `xs` between items in a line, `sm` inside a group, `md` between blocks.
|
|
105
107
|
- ClusterGrowMinWidth: `"sm" | "md"`. The narrowest a `ClusterGrow` gets before the row wraps: `sm` or `md`.
|
|
106
|
-
- ClusterJustify: `"start" | "
|
|
108
|
+
- ClusterJustify: `"end" | "start" | "center" | "between"`. Where a `Cluster`'s items sit along the row: `start`, `center`, `end`, or `between` to spread them to both ends.
|
|
@@ -18,7 +18,7 @@ import { Button, CodeExample } from "@slashsuite/ui-react";
|
|
|
18
18
|
- Put the rendered part in `children` and its source in `code`, a string with the newlines kept.
|
|
19
19
|
- `caption` is one note on the example, the last band of the frame.
|
|
20
20
|
- Side by side in a grid, each frame is its own height, so do not pad the previews to match.
|
|
21
|
-
- A wide preview or a long line of code scrolls inside the frame under a
|
|
21
|
+
- A wide preview or a long line of code scrolls inside the frame under a themed scrollbar; it does not widen the page.
|
|
22
22
|
- `copy` adds a button beside the code that copies the code, not the preview. It needs client JS; on a page rendered to static HTML, inline `copyScript` once (see CopyButton).
|
|
23
23
|
- Inside a `Prose` the preview stays on the app scale, so the part looks as it does on an app screen; the caption is outside it.
|
|
24
24
|
- Only for documentation. A command to copy is a `CopyLine`, and code alone is a `CodeBlock`.
|
|
@@ -40,7 +40,7 @@ import { Button, CodeBlock, Stack } from "@slashsuite/ui-react";
|
|
|
40
40
|
|
|
41
41
|
### Props
|
|
42
42
|
### CodeExample
|
|
43
|
-
One framed example: the rendered `children` on top and the `code` that makes them attached underneath, in a single bordered box with one divider between. With `copy`, a copy button beside the code copies it exactly as given (client JS; off by default). An optional `caption` is the frame's last band. The code is React, so it is coloured as TSX. The preview is its own height, never padded to match a neighbour, down to a shared minimum so two frames side by side start alike. A wide preview or a long line of code scrolls inside the frame, under a
|
|
43
|
+
One framed example: the rendered `children` on top and the `code` that makes them attached underneath, in a single bordered box with one divider between. With `copy`, a copy button beside the code copies it exactly as given (client JS; off by default). An optional `caption` is the frame's last band. The code is React, so it is coloured as TSX. The preview is its own height, never padded to match a neighbour, down to a shared minimum so two frames side by side start alike. A wide preview or a long line of code scrolls inside the frame, under a themed scrollbar, instead of widening the page or wrapping. Inside a `Prose` the preview stays on the app scale, so a demo looks as the component does anywhere else; the caption is outside it.
|
|
44
44
|
- caption: ReactNode. One note on the example, under the code.
|
|
45
45
|
- code: string (required). The source shown under the preview, newlines kept.
|
|
46
46
|
- copy: boolean (default false). A copy button beside the code. On a page rendered to static HTML without hydration, inline
|
|
@@ -19,13 +19,13 @@ import { Code, Text } from "@slashsuite/ui-react";
|
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
### Do
|
|
22
|
-
- Use `Code` for one short run inside a sentence. It takes the text colour and size around it, and keeps no line breaks.
|
|
22
|
+
- Use `Code` for one short run inside a sentence. It takes the text colour and size around it, and keeps no line breaks. A long value (a hash, a path) takes `lines={1}`, cut with an ellipsis and showing its whole text in a tooltip while it is cut, or `breakWords`, which breaks it at the edge of its box.
|
|
23
23
|
- Use `CodeBlock` for several lines. Give the text as `children`, or as `lines` with one entry per line.
|
|
24
24
|
- `label` names the language or file (`bash`, `css`) in a caption above the code; `language` says what to colour, from `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` and `yaml`.
|
|
25
25
|
- A shell session is `console`: a line starting with `$ ` is a command, coloured as bash, and every other line is output. With `copy`, only the commands are copied, without the `$ `.
|
|
26
26
|
- A line a reader copies is a `CopyLine`, not a one-line `CodeBlock`. A rendered part shown with its code is a `CodeExample`.
|
|
27
27
|
- Without a `language` the code is one colour (`text`), which suits an error or a log.
|
|
28
|
-
- A long line wraps, so a command is never cut off and still copies as one line. `overflow="scroll"` keeps lines whole and scrolls them sideways under a
|
|
28
|
+
- A long line wraps, so a command is never cut off and still copies as one line. `overflow="scroll"` keeps lines whole and scrolls them sideways under a scrollbar in the theme's colour, for code whose layout matters.
|
|
29
29
|
- `copy` adds a copy button beside the code. It needs client JS; on a page rendered to static HTML, inline `copyScript` once (see CopyButton).
|
|
30
30
|
|
|
31
31
|
### Don't
|
|
@@ -43,7 +43,6 @@ One short line a reader copies is a `CopyLine`, the smaller box. A one-line `Cod
|
|
|
43
43
|
import { CodeBlock } from "@slashsuite/ui-react";
|
|
44
44
|
|
|
45
45
|
<CodeBlock language="bash">bun add @slashsuite/ui-react</CodeBlock>
|
|
46
|
-
|
|
47
46
|
```
|
|
48
47
|
|
|
49
48
|
### Accessibility
|
|
@@ -53,13 +52,16 @@ import { CodeBlock } from "@slashsuite/ui-react";
|
|
|
53
52
|
|
|
54
53
|
### Props
|
|
55
54
|
### Code
|
|
56
|
-
Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face).
|
|
55
|
+
Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line, cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken value at the edge of its box, as `Text` does.
|
|
56
|
+
- breakWords: boolean (default false). Breaks a long unbroken value (a URL, a hash) at the edge of its box.
|
|
57
57
|
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
58
|
+
- lines: 1. `1` keeps it on one line, cut with an ellipsis; while it is cut, its whole text shows in a tooltip.
|
|
58
59
|
|
|
59
60
|
### CodeBlock
|
|
60
|
-
A block of code: mono, in a bordered inset box. No client JS unless `copy` adds a copy button beside the code, which copies it exactly as given. `language` colours it: `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`. `console` is a shell session: a line starting with `$ ` is a command (coloured as bash, its `$ ` dimmed and not selectable) and any other line is output; with `copy` only the commands are copied, without the `$ `. `label` names the language or file (`bash`, `css`) in a caption above the code. `text` (the default) leaves the code in one colour, for a block that is not a language. Give the text as `children` or as `lines`. Long lines wrap, so nothing is cut off and a command stays one copyable line; `overflow="scroll"` keeps lines whole and scrolls them sideways under a
|
|
61
|
+
A block of code: mono, in a bordered inset box. No client JS unless `copy` adds a copy button beside the code, which copies it exactly as given. `language` colours it: `tsx`, `ts`, `js`, `json`, `bash`, `console`, `css`, `html` or `yaml`. `console` is a shell session: a line starting with `$ ` is a command (coloured as bash, its `$ ` dimmed and not selectable) and any other line is output; with `copy` only the commands are copied, without the `$ `. `label` names the language or file (`bash`, `css`) in a caption above the code. `text` (the default) leaves the code in one colour, for a block that is not a language. Give the text as `children` or as `lines`. Long lines wrap, so nothing is cut off and a command stays one copyable line; `overflow="scroll"` keeps lines whole and scrolls them sideways under a themed scrollbar, for code whose layout matters. With `overflow="scroll"`, a strip wider than its box is a tab stop named by `label`, else "Code". Every other figure prop goes on the root `<figure>`. For one short line to copy, `CopyLine` is the smaller box.
|
|
61
62
|
- copy: boolean (default false). A copy button beside the code, which copies it exactly as given (a `console` block copies only
|
|
62
63
|
its commands). On a page rendered to static HTML without hydration, inline `copyScript` and it works there too.
|
|
64
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
63
65
|
- label: string. A caption above the code naming its language or file (`bash`, `theme.css`).
|
|
64
66
|
- language: "text" | "html" | "tsx" | "ts" | "js" | "json" | "bash" | "console" | "css" | "yaml" (default text). What the code is written in; `text` (the default) colours nothing.
|
|
65
67
|
- lines: string[]. The code as one array entry per line, in place of `children`.
|
|
@@ -15,10 +15,11 @@ import { ColourSchemeToggle } from "@slashsuite/ui-react";
|
|
|
15
15
|
|
|
16
16
|
### Do
|
|
17
17
|
- Use one `ColourSchemeToggle` per site. It switches `<html>` between light and dark and remembers the choice in `localStorage`.
|
|
18
|
+
- It follows the system until a click picks the other scheme; a click back to the system's scheme forgets the choice, so the page follows the system again. It also takes a choice made in another tab, and the system switching while nothing is stored.
|
|
18
19
|
- `size` is `sm`, `md` (default) or `lg`, the same squares as `IconButton`.
|
|
19
20
|
- Put `colourSchemeScript` inline in `<head>`, so the stored or system scheme is on `<html>` before first paint and neither scheme flashes the other. It knows only the `dark` class.
|
|
20
21
|
- A light theme with a class of its own passes `schemes`, as in `schemes={{ light: "my-light", dark: "dark" }}`; render the same class on `<html>` on the server with `schemeClass`, and leave the head script out.
|
|
21
|
-
- An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, sets `store={false}` and persists from `onChange
|
|
22
|
+
- An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, sets `store={false}` and persists from `onChange`, clearing the cookie when its `followsSystem` is true. It then leaves the head script out.
|
|
22
23
|
|
|
23
24
|
### Don't
|
|
24
25
|
- Do not build a switch from your own buttons; the functions below are what the toggle itself calls.
|
|
@@ -46,15 +47,19 @@ import { ColourSchemeToggle } from "@slashsuite/ui-react";
|
|
|
46
47
|
```
|
|
47
48
|
|
|
48
49
|
### Accessibility
|
|
49
|
-
- It is a button named `Switch to dark theme` or `Switch to light theme`, so the name says the action, and the icon is `aria-hidden`. The name follows the class on `<html>` through CSS before hydration, with no script; only the tooltip waits for the client.
|
|
50
|
+
- It is a button named `Switch to dark theme` or `Switch to light theme` (`darkLabel` and `lightLabel`, for an app in another language), so the name says the action, and the icon is `aria-hidden`. The name follows the class on `<html>` through CSS before hydration, with no script; only the tooltip waits for the client.
|
|
50
51
|
- The icon shown is the scheme you would switch to: the moon on a light page, the sun on a dark one. It follows the class on `<html>` through CSS, so it is right on the first frame.
|
|
51
52
|
- `applyColourScheme` also sets `color-scheme` on `<html>`, so native controls and scrollbars follow.
|
|
52
53
|
|
|
53
54
|
### Props
|
|
54
55
|
### ColourSchemeToggle
|
|
55
|
-
A sun/moon button that switches `<html>` between light and dark and remembers the choice. It shows the scheme you would switch to. Pair it with `colourSchemeScript` in `<head>`, unless you pass `schemes` or `defaultValue`: the script knows only the `dark` class and the stored choice, so an app that sets the scheme itself leaves it out. An app whose light scheme has a class of its own passes `schemes` (`{ light: "my-light", dark: "dark" }`); the toggle swaps those classes, and `schemeClass` gives the same one for the server to render on `<html>`. An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, so the server markup, the hydrating client and the `<html>` class agree; persist a change from `onChange`. The icon and the button's accessible name follow the class on `<html>` through CSS (the name is two visually hidden "Switch to …" spans, one hidden by `display:none`), so even without `defaultValue` a dark page shows the sun and is named "Switch to light theme" from the first frame, with no script. Only the tooltip catches up once the client has hydrated. `store={false}` skips `localStorage`, for an app that keeps the choice in a server cookie and writes it from `onChange`. Every other button prop (`id`, `data-*`, `aria-*`) goes on the button.
|
|
56
|
+
A sun/moon button that switches `<html>` between light and dark and remembers the choice. It shows the scheme you would switch to. A click that lands on the system's own scheme forgets the stored choice, so the page follows the system again; a click away from it stores the choice. With `store` on, the page also follows a choice made in another tab and, while nothing is stored, the system switching. Pair it with `colourSchemeScript` in `<head>`, unless you pass `schemes` or `defaultValue`: the script knows only the `dark` class and the stored choice, so an app that sets the scheme itself leaves it out. An app whose light scheme has a class of its own passes `schemes` (`{ light: "my-light", dark: "dark" }`); the toggle swaps those classes, and `schemeClass` gives the same one for the server to render on `<html>`. An app that knows the scheme on the server (from a cookie) passes it as `defaultValue`, so the server markup, the hydrating client and the `<html>` class agree; persist a change from `onChange`. The icon and the button's accessible name follow the class on `<html>` through CSS (the name is two visually hidden "Switch to …" spans, one hidden by `display:none`), so even without `defaultValue` a dark page shows the sun and is named `lightLabel` ("Switch to light theme") from the first frame, with no script. Only the tooltip catches up once the client has hydrated. `store={false}` skips `localStorage`, for an app that keeps the choice in a server cookie and writes it from `onChange`. Every other button prop (`id`, `data-*`, `aria-*`) goes on the button.
|
|
57
|
+
- darkLabel: string (default Switch to dark theme). The button's accessible name and tooltip on a light page, where it switches to dark.
|
|
56
58
|
- defaultValue: (ColourScheme & (string | number | readonly string[])) (default light). The scheme the server rendered. What the server and the hydrating client show; the real state follows right after.
|
|
57
|
-
-
|
|
59
|
+
- lightLabel: string (default Switch to light theme). The button's accessible name and tooltip on a dark page, where it switches to light.
|
|
60
|
+
- onChange: (scheme: ColourScheme, followsSystem: boolean) => void. Called with the new scheme after a click, for an app that persists the choice itself (a cookie).
|
|
61
|
+
`followsSystem` is true when the new scheme is the system's: forget the choice (clear the cookie)
|
|
62
|
+
rather than store it, so the page follows the system again.
|
|
58
63
|
- schemes: ColourSchemeClasses (default { light: "", dark: "dark" }). The class each scheme puts on `<html>`.
|
|
59
64
|
- size: "sm" | "md" | "lg" (default md). The button's height, as an `IconButton`'s.
|
|
60
65
|
- store: boolean (default true). Remember the choice in `localStorage`. `false` leaves persisting to `onChange`.
|
|
@@ -76,7 +81,7 @@ button.addEventListener("click", () => {
|
|
|
76
81
|
```tsx
|
|
77
82
|
<html className={schemeClass(scheme, { light: "my-light", dark: "dark" })}>
|
|
78
83
|
```
|
|
79
|
-
- colourSchemeScript: `colourSchemeScript: string`. A string of JavaScript to inline in `<head>` before first paint: applies the stored scheme, else the system one.
|
|
84
|
+
- colourSchemeScript: `colourSchemeScript: string`. A string of JavaScript to inline in `<head>` before first paint: applies the stored scheme, else the system one, then follows another tab's choice and the system switching while nothing is stored.
|
|
80
85
|
```tsx
|
|
81
86
|
<head>
|
|
82
87
|
<script dangerouslySetInnerHTML={{ __html: colourSchemeScript }} />
|
|
@@ -86,7 +91,8 @@ button.addEventListener("click", () => {
|
|
|
86
91
|
```tsx
|
|
87
92
|
const scheme = readColourScheme(); // the stored choice, else the system's, else light
|
|
88
93
|
```
|
|
89
|
-
- storeColourScheme: `storeColourScheme(scheme: ColourScheme): void`. Remembers a scheme in `localStorage` for the next visit; a storage error is swallowed.
|
|
94
|
+
- storeColourScheme: `storeColourScheme(scheme: ColourScheme | "system"): void`. Remembers a scheme in `localStorage` for the next visit, or with `system` forgets it so the page follows the system again; a storage error is swallowed.
|
|
90
95
|
```tsx
|
|
91
96
|
storeColourScheme(next); // read back on the next visit
|
|
97
|
+
storeColourScheme("system"); // follow the system again
|
|
92
98
|
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
## ColourSwatch
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: Showing a colour as data: one read off a page, a screenshot, a brand or a theme.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Image (image.md): What is shown is a picture, not one colour.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
Each colour as a swatch with its name and its hex value in text, so it reads without seeing the square.
|
|
12
|
+
```tsx
|
|
13
|
+
import { ColourSwatch, Stack } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Stack gap="sm">
|
|
16
|
+
<ColourSwatch value="#1e293b" label="Background" />
|
|
17
|
+
<ColourSwatch value="#38bdf8" label="Accent" />
|
|
18
|
+
</Stack>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Do
|
|
22
|
+
- `value` is the colour as `#rrggbb`. Anything else draws an empty swatch and leaves the value out, so a bad value never paints the page.
|
|
23
|
+
- `label` says what the colour is, as "Background" or "Accent". The hex value follows it in mono, lower case.
|
|
24
|
+
- A list of colours is a `Stack` of swatches, or swatches in the cells of a `Table`.
|
|
25
|
+
|
|
26
|
+
### Don't
|
|
27
|
+
A painted square alone says nothing to a screen reader, nor to anyone who cannot tell the colours apart.
|
|
28
|
+
```tsx
|
|
29
|
+
<span style={{ display: "inline-block", width: 16, height: 16, backgroundColor: "#1e293b" }} />
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Accessibility
|
|
33
|
+
- The square is decorative and hidden from a screen reader; the label and the hex value say the colour in text.
|
|
34
|
+
- A hairline edges the square, so a colour close to the page's own still shows.
|
|
35
|
+
|
|
36
|
+
### Props
|
|
37
|
+
### ColourSwatch
|
|
38
|
+
A small square in a measured colour, with its `label` and its hex `value` beside it in mono: a colour read off a page, a screenshot or a theme. The colour is the data on show, not a look, so it is painted from `value`; anything but a `#rrggbb` value draws an empty swatch and no value. A hairline edges the square, so a colour close to the page still shows. The square is decorative: the label and the value say the colour.
|
|
39
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
40
|
+
- label: string (required). What the colour is, as "Background" or "Accent", shown before the value.
|
|
41
|
+
- value: string (required). The colour, as `#rrggbb`. Anything else draws an empty swatch and leaves the value out.
|