@slashsuite/ui-react 0.12.0 → 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 +101 -44
- package/agent-docs/components/app-shell.md +139 -0
- package/agent-docs/components/article-layout.md +140 -0
- package/agent-docs/components/audio.md +42 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +62 -0
- package/agent-docs/components/body-text.md +169 -0
- package/agent-docs/components/bottom-sheet.md +105 -0
- package/agent-docs/components/breadcrumbs.md +66 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/call-to-action.md +59 -0
- package/agent-docs/components/callout.md +87 -0
- package/agent-docs/components/card-grid.md +116 -0
- package/agent-docs/components/card.md +128 -0
- package/agent-docs/components/cart-button.md +63 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +49 -0
- package/agent-docs/components/chat-message.md +61 -0
- package/agent-docs/components/chat-thread.md +49 -0
- package/agent-docs/components/checkbox.md +81 -0
- package/agent-docs/components/cluster.md +108 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +72 -0
- package/agent-docs/components/colour-scheme-toggle.md +98 -0
- 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 +51 -0
- package/agent-docs/components/copy-button.md +63 -0
- package/agent-docs/components/copy-line.md +55 -0
- package/agent-docs/components/date-field.md +106 -0
- package/agent-docs/components/date-range-picker.md +108 -0
- package/agent-docs/components/date-time-field.md +73 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +132 -0
- package/agent-docs/components/disclosure.md +70 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +164 -0
- package/agent-docs/components/drawer.md +137 -0
- package/agent-docs/components/embed-frame.md +48 -0
- package/agent-docs/components/empty-state.md +70 -0
- package/agent-docs/components/field-dialog.md +98 -0
- package/agent-docs/components/field.md +71 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/flow-diagram.md +87 -0
- package/agent-docs/components/form-layout.md +144 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +114 -0
- package/agent-docs/components/headings.md +107 -0
- package/agent-docs/components/hero.md +68 -0
- package/agent-docs/components/icon-button.md +90 -0
- package/agent-docs/components/icon.md +59 -0
- package/agent-docs/components/image.md +74 -0
- package/agent-docs/components/input.md +84 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +84 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +152 -0
- package/agent-docs/components/list-row.md +119 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +101 -0
- package/agent-docs/components/menu.md +110 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +134 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/number-field.md +75 -0
- package/agent-docs/components/outline-region.md +74 -0
- package/agent-docs/components/page-fade.md +117 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +105 -0
- 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/progress-bar.md +66 -0
- package/agent-docs/components/promo-banner.md +46 -0
- package/agent-docs/components/prose-layout.md +87 -0
- package/agent-docs/components/prose.md +41 -0
- package/agent-docs/components/radio-group.md +77 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +135 -0
- package/agent-docs/components/select.md +70 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +74 -0
- package/agent-docs/components/sidebar-layout.md +134 -0
- package/agent-docs/components/site-footer.md +63 -0
- package/agent-docs/components/site-search.md +79 -0
- package/agent-docs/components/slider.md +59 -0
- package/agent-docs/components/sortable-list.md +112 -0
- package/agent-docs/components/split-bar.md +54 -0
- package/agent-docs/components/stack.md +197 -0
- package/agent-docs/components/stacked-bar.md +91 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/state-machine.md +95 -0
- package/agent-docs/components/status-pages.md +112 -0
- package/agent-docs/components/stepper.md +54 -0
- package/agent-docs/components/steps.md +74 -0
- package/agent-docs/components/sticky-bar.md +51 -0
- package/agent-docs/components/switch.md +79 -0
- package/agent-docs/components/table-of-contents.md +78 -0
- package/agent-docs/components/table.md +384 -0
- package/agent-docs/components/tabs.md +178 -0
- package/agent-docs/components/text-link.md +110 -0
- package/agent-docs/components/textarea.md +53 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +91 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +49 -0
- package/agent-docs/llms.txt +174 -0
- 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 +7 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
## Callout
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: A message the reader should see in the page, without being made to answer it.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Card (card.md): A block of content has a status: a `Card` with `tone`.
|
|
9
|
+
- EmptyState (empty-state.md): There is nothing here yet, and the message offers the first step.
|
|
10
|
+
- Status pages (status-pages.md): The whole route cannot show: not found, failed, offline, down or not allowed.
|
|
11
|
+
|
|
12
|
+
### The one right way
|
|
13
|
+
The tone matches how much the message matters: `warn` for a thing to check before going on.
|
|
14
|
+
```tsx
|
|
15
|
+
import { Callout, Stack } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
<Stack gap="sm">
|
|
18
|
+
<Callout tone="info">The import runs overnight.</Callout>
|
|
19
|
+
<Callout tone="warn" title="3 uncategorised.">
|
|
20
|
+
Sort them before the month closes.
|
|
21
|
+
</Callout>
|
|
22
|
+
</Stack>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Do
|
|
26
|
+
- Pick the `tone` by how much the message matters: `neutral` (the default) for a note, `info` for something worth knowing, `positive` for a result, `warn` for a thing to check before going on, `danger` for a failure or something that cannot be undone. Keep `danger` for the real failure.
|
|
27
|
+
- Add a `title` for a short bold lead-in; the body carries the detail.
|
|
28
|
+
- Put the one action in `actions`, at the end of the row: a `Button size="sm"` or a `TextLink stretch`, which makes the whole callout the click target.
|
|
29
|
+
- `banner` is the flat strip at the top of a `Card flush`; do not use it anywhere else. In a page's column (a `FullBleedLayout`, padded or not) the notice is a plain Callout, first in the column's `Stack`.
|
|
30
|
+
- A section that failed to load is a `Callout tone="danger"` with a `title` that says what failed and one `Button` in `actions` that tries again. A whole page that failed is an `ErrorPage`.
|
|
31
|
+
- A block of content that has a status is a `Card` with `tone`; a Callout is the message.
|
|
32
|
+
- A short confirmation that should not move the page ("Saved", "Copied") is a `Toast`. A message that must be answered before the reader goes on is a `Dialog`; a field's own error is the `error` of its `Field`; a submit's failure in a `Dialog` or `FormLayout` is its `error`.
|
|
33
|
+
- `align="center"` centres the title and body, for a success that stands alone; with `actions` only the text is centred. `start` is the default.
|
|
34
|
+
|
|
35
|
+
### Don't
|
|
36
|
+
`danger` on a plain note cries wolf: when everything is red, a real failure no longer stands out.
|
|
37
|
+
```tsx
|
|
38
|
+
import { Callout, Stack } from "@slashsuite/ui-react";
|
|
39
|
+
|
|
40
|
+
<Stack gap="sm">
|
|
41
|
+
<Callout tone="danger">The import runs overnight.</Callout>
|
|
42
|
+
<Callout tone="danger" title="3 uncategorised.">
|
|
43
|
+
Sort them before the month closes.
|
|
44
|
+
</Callout>
|
|
45
|
+
</Stack>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
A button inside the body drops under the text and leaves the row without its action.
|
|
49
|
+
```tsx
|
|
50
|
+
import { Button, Callout } from "@slashsuite/ui-react";
|
|
51
|
+
|
|
52
|
+
<Callout tone="warn" title="Import failed.">
|
|
53
|
+
The last file did not finish. <Button size="sm">Retry</Button>
|
|
54
|
+
</Callout>
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
A whole error page inside one section takes over the screen for a part that failed.
|
|
58
|
+
```tsx
|
|
59
|
+
import { ErrorPage, Section } from "@slashsuite/ui-react";
|
|
60
|
+
|
|
61
|
+
<Section title="Recent builds">
|
|
62
|
+
<ErrorPage />
|
|
63
|
+
</Section>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Accessibility
|
|
67
|
+
- `danger` is `role="alert"` and `warn` is `role="status"`, so a screen reader announces them when they appear; the other tones have no role. The tone is also colour and text, so say what happened in the words.
|
|
68
|
+
- A `title` is a bold paragraph, not a heading, so it adds nothing to the heading outline.
|
|
69
|
+
- Buttons and links in `actions` keep their own focus ring and keyboard behaviour.
|
|
70
|
+
- Below `sm` the actions share a full-width row under the text, so a phone's thumb finds them; from `sm` they sit at the end of the row.
|
|
71
|
+
|
|
72
|
+
### Props
|
|
73
|
+
### Callout
|
|
74
|
+
A tinted notice box, with an optional bold title above its body. Its text is text-sm (text-base/7 inside a `Prose`, boxed or `banner`). `actions` puts a button or link at the end of the row, or under the text at full width below `sm`; `banner` makes it a flat strip (bottom border only, no radius) for the top of a `Card flush` and nowhere else: a padded card or a padded `FullBleedLayout` column would inset it. `align="center"` centres the text. In a page's column the notice is a plain Callout, first in the column's `Stack`. With `actions` the box is `relative`, so a `TextLink stretch` there makes the whole callout its click target, like a link in a table row. `icon` sets one of the library's icons at the start of the box, in the tone's ink. `danger` is `role="alert"` and `warn` is `role="status"`, so a screen reader announces them when they appear; the other tones have no role.
|
|
75
|
+
- actions: ReactNode. A button or link at the end of the row, beside the title and body; on a phone, under them at full width.
|
|
76
|
+
- align: "center" | "start" (default start). `center` centres the title and body, for a success that stands alone. With
|
|
77
|
+
`actions` only the text is centred.
|
|
78
|
+
- banner: boolean (default false). A flat strip: `border-b` only and no radius, for the top of a `Card flush` only.
|
|
79
|
+
- 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, at the start of the box beside the text.
|
|
80
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
81
|
+
- title: ReactNode. A bold line above the body.
|
|
82
|
+
- tone: "neutral" | "info" | "positive" | "warn" | "danger" (default neutral). What the notice means: `neutral` a plain note, `info` something worth knowing, `positive` a
|
|
83
|
+
result, `warn` a thing to check before going on, `danger` a failure or something that cannot
|
|
84
|
+
be undone.
|
|
85
|
+
|
|
86
|
+
### Types
|
|
87
|
+
- Tone: `"neutral" | "info" | "positive" | "warn" | "danger"`. The one tone vocabulary of the library: what a thing means, not what colour it is. `neutral` (no meaning, the role's own ink or surface) is every component's default, `info` is a note, `positive` a success, `warn` a caution and `danger` an error or a destructive act. A component extends it outward only where it has a real use, and says so beside its own type: the text roles add `muted` (a quieter line) and `accent` (the theme's accent ink), `Pill` and the charts add `accent` for a category that is none of the five meanings. No component renames a tone (`negative`, `default`, `slate` and the colour names are gone), and no scale skips `neutral`.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
## CardGrid
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: Several cards or `StatTile`s of the same weight that should sit side by side on a wide screen.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Tiles go in a `CardGrid`: one column on a phone, two from `sm`, `columns` from `lg`.
|
|
9
|
+
```tsx
|
|
10
|
+
import { CardGrid, StatTile } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<CardGrid columns={3}>
|
|
13
|
+
<StatTile label="Open" value="12" />
|
|
14
|
+
<StatTile label="Won" value="8" tone="positive" />
|
|
15
|
+
<StatTile label="Lost" value="3" tone="danger" />
|
|
16
|
+
</CardGrid>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Full page
|
|
20
|
+
A whole dashboard page: the shell with its brand and nav, then a `PageHeader` and a `CardGrid` of tiles.
|
|
21
|
+
```tsx
|
|
22
|
+
import {
|
|
23
|
+
AppShell,
|
|
24
|
+
CardGrid,
|
|
25
|
+
Tabs,
|
|
26
|
+
PageHeader,
|
|
27
|
+
Stack,
|
|
28
|
+
StatTile,
|
|
29
|
+
} from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<AppShell
|
|
32
|
+
brand={<a href="#">Hack Cove</a>}
|
|
33
|
+
nav={
|
|
34
|
+
<Tabs
|
|
35
|
+
label="Main"
|
|
36
|
+
items={[
|
|
37
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
38
|
+
{ label: "Clients", href: "#clients" },
|
|
39
|
+
]}
|
|
40
|
+
/>
|
|
41
|
+
}
|
|
42
|
+
>
|
|
43
|
+
<Stack gap="xl">
|
|
44
|
+
<PageHeader title="Business" description="This month at a glance." />
|
|
45
|
+
<CardGrid columns={3}>
|
|
46
|
+
<StatTile label="Open" value="12" />
|
|
47
|
+
<StatTile label="Won" value="8" tone="positive" />
|
|
48
|
+
<StatTile label="Lost" value="3" tone="danger" />
|
|
49
|
+
</CardGrid>
|
|
50
|
+
</Stack>
|
|
51
|
+
</AppShell>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Do
|
|
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`).
|
|
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.
|
|
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
|
+
- `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
|
+
- `empty` is an `EmptyState`, drawn in place of the grid when it has no children.
|
|
63
|
+
|
|
64
|
+
### Don't
|
|
65
|
+
A `Stack` is one column, so the tiles never sit side by side and the page runs long. Use a `CardGrid`.
|
|
66
|
+
```tsx
|
|
67
|
+
import { Stack, StatTile } from "@slashsuite/ui-react";
|
|
68
|
+
|
|
69
|
+
<Stack>
|
|
70
|
+
<StatTile label="Open" value="12" />
|
|
71
|
+
<StatTile label="Won" value="8" tone="positive" />
|
|
72
|
+
<StatTile label="Lost" value="3" tone="danger" />
|
|
73
|
+
</Stack>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
A fixed `columns={4}` for a count that varies leaves the row part empty when there are three. When the count varies, use `columns="auto"`.
|
|
77
|
+
```tsx
|
|
78
|
+
import { Card, CardGrid, Text } from "@slashsuite/ui-react";
|
|
79
|
+
|
|
80
|
+
<CardGrid columns={4} align="start">
|
|
81
|
+
<Card title="Dashboard">
|
|
82
|
+
<Text>Quotes and renewals this week.</Text>
|
|
83
|
+
</Card>
|
|
84
|
+
<Card title="Billing">
|
|
85
|
+
<Text>Invoices and payments.</Text>
|
|
86
|
+
</Card>
|
|
87
|
+
<Card title="Members">
|
|
88
|
+
<Text>Who can sign in.</Text>
|
|
89
|
+
</Card>
|
|
90
|
+
</CardGrid>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
### Accessibility
|
|
94
|
+
- The grid is a plain `div` with no role: the cards keep their own order and semantics. With `as="ul"` it is a list, and each child is a list item.
|
|
95
|
+
- The order is the DOM order, so the tab order follows the reading order.
|
|
96
|
+
|
|
97
|
+
### Props
|
|
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; `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.
|
|
103
|
+
- as: "div" | "ul" (default div). `ul` makes the grid a list: each child is wrapped in an `<li>`. Default `div`.
|
|
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.
|
|
105
|
+
- empty: ReactNode. Drawn in place of the grid when there are no children: an `EmptyState`.
|
|
106
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
107
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
108
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
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.
|
|
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`.
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
## Card
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A titled block of related content: a record, a status, a list, an empty state.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Callout (callout.md): The status is a message of a line or two, with at most one action.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
`status` puts a Pill directly beside the title; `actions` stays at the far end.
|
|
12
|
+
```tsx
|
|
13
|
+
import { Card, Pill, Text } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Card title="PixelSlash" status={<Pill tone="warn">Coming soon</Pill>}>
|
|
16
|
+
<Text tone="muted">Visual review for every pull request.</Text>
|
|
17
|
+
</Card>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- Name the Card with `title`; add a `count` or a `status` and they sit beside the title.
|
|
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
|
+
- `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`, 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.
|
|
28
|
+
|
|
29
|
+
### Don't
|
|
30
|
+
A hand-built title row drifts from every other Card's: use `title` and `status`.
|
|
31
|
+
```tsx
|
|
32
|
+
import { Card, Pill, SubsectionHeading, Text } from "@slashsuite/ui-react";
|
|
33
|
+
|
|
34
|
+
<Card>
|
|
35
|
+
<SubsectionHeading>PixelSlash</SubsectionHeading>
|
|
36
|
+
<Pill tone="warn">Coming soon</Pill>
|
|
37
|
+
<Text tone="muted">Visual review for every pull request.</Text>
|
|
38
|
+
</Card>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Cards with nothing between them butt together. Space them with `Stack` or `CardGrid`.
|
|
42
|
+
```tsx
|
|
43
|
+
import { Card, Text } from "@slashsuite/ui-react";
|
|
44
|
+
|
|
45
|
+
<>
|
|
46
|
+
<Card title="Open" count={3}>
|
|
47
|
+
<Text tone="muted">Three things to do.</Text>
|
|
48
|
+
</Card>
|
|
49
|
+
<Card title="Done" count={12}>
|
|
50
|
+
<Text tone="muted">Twelve things finished.</Text>
|
|
51
|
+
</Card>
|
|
52
|
+
</>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Accessibility
|
|
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.
|
|
61
|
+
- `attention` is colour only: say why in the card's title or text.
|
|
62
|
+
- The `icon` is decorative and `aria-hidden`: the title says what the card is.
|
|
63
|
+
|
|
64
|
+
### Props
|
|
65
|
+
### Card
|
|
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.
|
|
67
|
+
- actions: ReactNode. Buttons or links at the end of the header: in the strip with `bar`, else beside the title.
|
|
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
|
|
69
|
+
a look (a run that differed). It keeps the card's fill. Name why in the card too (a `Pill` in
|
|
70
|
+
`badge`, or the body); the border alone says nothing to a screen reader.
|
|
71
|
+
|
|
72
|
+
Add `tone="warn"` for the warn surface too.
|
|
73
|
+
- badge: ReactNode. A `Pill` (or any small node) pinned in the top corner at the end edge, over the content and
|
|
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.
|
|
77
|
+
|
|
78
|
+
Use it for a category (`Pill tone="info"`) or a flag on the thing itself.
|
|
79
|
+
- bar: boolean. Put the title, count and actions in a tinted strip above the body, edge to edge.
|
|
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.
|
|
83
|
+
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
84
|
+
- fill: boolean. Take the parent's full height: the title or bar stays put and the body scrolls. The parent sets
|
|
85
|
+
the height.
|
|
86
|
+
|
|
87
|
+
For a panel in a fixed-height layout, such as a sheet over a map. Put links or controls in the
|
|
88
|
+
body, so a keyboard can reach and scroll it.
|
|
89
|
+
- flush: boolean. No padding and `overflow-hidden`: the body (a table, a list) fills the card.
|
|
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`.
|
|
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
|
|
97
|
+
mark of a feature card. Ignored with `bar` and `flush`.
|
|
98
|
+
|
|
99
|
+
Pick it by the idea it stands for.
|
|
100
|
+
- inset: ReactNode. A band across the card, edge to edge inside its padding, under the title and above the
|
|
101
|
+
children: a `ProgressBar` or a strip of colour that runs the card's full width.
|
|
102
|
+
|
|
103
|
+
A bordered sub-card inside a card is a nested `Card tone="neutral"`, not a hand-built box.
|
|
104
|
+
- level: 2 | 3 | 4 | 5 | 6 (default one below the heading that holds the card: 2 on the page, 3 in a `Section`). The title's heading level, 2 to 6. It does not change how the title looks.
|
|
105
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
106
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
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`).
|
|
114
|
+
- size: "sm" | "md" | "lg" (default md). `sm` is dense padding on the body, heading and bar, and makes a `Button`, `IconButton` or `Pill`
|
|
115
|
+
inside with no `size` of its own `sm` too; `lg` is one step roomier than `md`.
|
|
116
|
+
|
|
117
|
+
`sm` suits a dense dashboard, `lg` a card that stands alone.
|
|
118
|
+
- status: ReactNode. A `Pill` (or any node) directly beside the title and count, not at the far end like `actions`. Needs a `title`.
|
|
119
|
+
- title: string. The card's heading (a small uppercase label unless `titleStyle` says otherwise). It names the card, which is then an `article`.
|
|
120
|
+
- titleStyle: "name" | "overline" (default overline). How the `title` is set. `overline` is the small uppercase label of a panel; `name` is the same
|
|
121
|
+
heading in sentence case and the primary ink, for a card whose title is a name (a shop, a listing,
|
|
122
|
+
an event). Count, status, actions, `bar` and `size` work the same with both.
|
|
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.
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
## CenteredLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: Sign-in, a landing page, or a not-found or error page.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Sign-in, landing, not-found and error pages are one narrow card, centred.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Button, CenteredLayout, Field, Input } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<CenteredLayout title="Sign in" description="Use your Hack Cove account.">
|
|
13
|
+
<Field label="Email" htmlFor="do-page-email">
|
|
14
|
+
<Input id="do-page-email" type="email" placeholder="you@example.com" />
|
|
15
|
+
</Field>
|
|
16
|
+
<Button>Continue</Button>
|
|
17
|
+
</CenteredLayout>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Full page
|
|
21
|
+
A whole sign-in page: the shell with its brand and nav, then one narrow card, centred.
|
|
22
|
+
```tsx
|
|
23
|
+
import {
|
|
24
|
+
AppShell,
|
|
25
|
+
Button,
|
|
26
|
+
CenteredLayout,
|
|
27
|
+
Field,
|
|
28
|
+
Input,
|
|
29
|
+
Tabs,
|
|
30
|
+
} from "@slashsuite/ui-react";
|
|
31
|
+
|
|
32
|
+
<AppShell
|
|
33
|
+
brand={<a href="#">Hack Cove</a>}
|
|
34
|
+
nav={
|
|
35
|
+
<Tabs
|
|
36
|
+
label="Main"
|
|
37
|
+
items={[
|
|
38
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
39
|
+
{ label: "Clients", href: "#clients" },
|
|
40
|
+
]}
|
|
41
|
+
/>
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
<CenteredLayout title="Sign in" description="Use your Hack Cove account.">
|
|
45
|
+
<Field label="Email" htmlFor="full-page-email">
|
|
46
|
+
<Input id="full-page-email" type="email" placeholder="you@example.com" />
|
|
47
|
+
</Field>
|
|
48
|
+
<Button>Continue</Button>
|
|
49
|
+
</CenteredLayout>
|
|
50
|
+
</AppShell>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Do
|
|
54
|
+
- Give it a `title` and a `description`; the `children` are the card's content: a `Field` or two and a `Button`.
|
|
55
|
+
- It is the one layout that does not share the start edge: it is centred, at a fixed offset from the top.
|
|
56
|
+
- A form inside the app is `FormLayout`, not this.
|
|
57
|
+
- The ready-made status pages (not found, forbidden, offline, error, maintenance) are already built on it.
|
|
58
|
+
- `mark` is drawn first in the card, above the title: a large status numeral, as the status pages draw. It is not a heading.
|
|
59
|
+
|
|
60
|
+
### Don't
|
|
61
|
+
`FormLayout` is for a form inside the app: its wide column hangs off the left edge, which is wrong for a sign-in. Use `CenteredLayout`.
|
|
62
|
+
```tsx
|
|
63
|
+
import { Button, Field, FormLayout, Input } from "@slashsuite/ui-react";
|
|
64
|
+
|
|
65
|
+
<FormLayout
|
|
66
|
+
title="Sign in"
|
|
67
|
+
description="Use your Hack Cove account."
|
|
68
|
+
actions={<Button type="submit">Continue</Button>}
|
|
69
|
+
>
|
|
70
|
+
<Field label="Email" htmlFor="dont-page-email">
|
|
71
|
+
<Input id="dont-page-email" type="email" placeholder="you@example.com" />
|
|
72
|
+
</Field>
|
|
73
|
+
</FormLayout>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Accessibility
|
|
77
|
+
- The title is the page's `h1`.
|
|
78
|
+
- The card is a plain `div`, not a landmark; the shell's `main` holds it.
|
|
79
|
+
- Give each control a `Field`, so every input has a label.
|
|
80
|
+
|
|
81
|
+
### Props
|
|
82
|
+
### CenteredLayout
|
|
83
|
+
A narrow card (`max-w-md`) centred in the Container at a fixed offset from the top, for sign-in, landing, not-found and error pages. The one layout that does not share the start edge. While `loading` it owns the wait and passes it to everything inside, the header too.
|
|
84
|
+
- description: ReactNode. A muted line under the title.
|
|
85
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
86
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
87
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
88
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
89
|
+
- mark: ReactNode. Drawn first in the card, above the title, e.g. a large status numeral. Not a heading.
|
|
90
|
+
- title: ReactNode (required). The card's `h1`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
## ChatComposer
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: The foot of a chat, under the `ChatThread`.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
While a reply arrives, `busy` keeps the box open and offers Stop.
|
|
9
|
+
```tsx
|
|
10
|
+
import { ChatComposer } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<ChatComposer label="Message" busy onSend={() => undefined} onStop={() => undefined} />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Do
|
|
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. 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
|
+
- `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
|
+
- `disabled` is for a chat that cannot take a message at all; it disables the box and the button.
|
|
20
|
+
- `sendLabel` and `stopLabel` are the button's words, Send and Stop by default.
|
|
21
|
+
|
|
22
|
+
### Don't
|
|
23
|
+
`disabled` during a reply takes the box away from a reader mid-thought, with no way to stop the reply.
|
|
24
|
+
```tsx
|
|
25
|
+
import { ChatComposer } from "@slashsuite/ui-react";
|
|
26
|
+
|
|
27
|
+
<ChatComposer label="Message" disabled onSend={() => undefined} />
|
|
28
|
+
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Accessibility
|
|
32
|
+
- `label` is the box's name, in a visually hidden `<label>`.
|
|
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, to type the next message or the missing one.
|
|
35
|
+
|
|
36
|
+
### Props
|
|
37
|
+
### ChatComposer
|
|
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
|
+
- 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
|
+
stays a disabled Send and no Stop is drawn.
|
|
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.
|
|
43
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
44
|
+
- label: string (required). The box's name for assistive tech; it is not drawn.
|
|
45
|
+
- onSend: (text: string) => void (required). Called with the trimmed text.
|
|
46
|
+
- onStop: (() => void). Called when the reader presses Stop.
|
|
47
|
+
- placeholder: string. The hint inside the empty box.
|
|
48
|
+
- sendLabel: string (default Send). The button's word, for sending.
|
|
49
|
+
- stopLabel: string (default Stop). The button's word, while `busy`.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## ChatMessage
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A message from a person or an assistant inside a `ChatThread`.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A reply still arriving says so with `streaming`: the caret, and `aria-busy` for a screen reader.
|
|
9
|
+
```tsx
|
|
10
|
+
import { ChatMessage } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<ChatMessage role="assistant" author="Helper" streaming>
|
|
13
|
+
Start by sweating the leeks in
|
|
14
|
+
</ChatMessage>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
### Do
|
|
18
|
+
- `role` picks the side: `user` on the right, `assistant` on the left.
|
|
19
|
+
- `author` is required and is for a screen reader. To show a sender and a time, pass them, already formatted, as `meta`, the small line above the bubble.
|
|
20
|
+
- The children are the body and it does not call `Markdown` for you: pass plain text, which keeps its line breaks, or a `Markdown` or an `Image`.
|
|
21
|
+
- `actions` is a row under the bubble on the message's own side: copy, retry, a row of reaction `Pill`s. It is always in view, never only on hover.
|
|
22
|
+
- `streaming` marks a reply still arriving, with a caret after the body. With no children it draws the bubble with the caret alone: the pending state.
|
|
23
|
+
|
|
24
|
+
### Don't
|
|
25
|
+
Dots typed into the body say nothing to a screen reader, and are read out as text when it is done.
|
|
26
|
+
```tsx
|
|
27
|
+
import { ChatMessage } from "@slashsuite/ui-react";
|
|
28
|
+
|
|
29
|
+
<ChatMessage role="assistant" author="Helper">
|
|
30
|
+
Start by sweating the leeks in...
|
|
31
|
+
</ChatMessage>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
A button in the body reads as part of what was said, and is copied with it.
|
|
35
|
+
```tsx
|
|
36
|
+
import { Button, ChatMessage, Text } from "@slashsuite/ui-react";
|
|
37
|
+
|
|
38
|
+
<ChatMessage role="assistant" author="Helper">
|
|
39
|
+
<Text>The pantry did not answer.</Text>
|
|
40
|
+
<Button size="sm" variant="ghost">
|
|
41
|
+
Retry
|
|
42
|
+
</Button>
|
|
43
|
+
</ChatMessage>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Accessibility
|
|
47
|
+
- It is an `<article>`. `author` comes first in the DOM, visually hidden, because alignment tells a screen reader nothing.
|
|
48
|
+
- `streaming` sets `aria-busy`. The caret is `aria-hidden`, and it pulses only for a reader who has not asked for reduced motion.
|
|
49
|
+
- A message is not announced as it arrives: that is the `ChatThread`'s `announce`.
|
|
50
|
+
|
|
51
|
+
### Props
|
|
52
|
+
### ChatMessage
|
|
53
|
+
One message in a chat: a bubble on the sender's side, with an optional line above it and a row of actions under it. `children` is the body as the caller wants it (plain text, which keeps its line breaks, a `Markdown`, an `Image`). `streaming` marks a reply still arriving; with no children it draws the caret alone, the pending state.
|
|
54
|
+
- actions: ReactNode. A row under the bubble on the message's own side: copy, retry, a row of reaction `Pill`s.
|
|
55
|
+
- author: string (required). Who sent it, read first by a screen reader and drawn nowhere: alignment alone tells a screen reader nothing. Show a sender with `meta`.
|
|
56
|
+
- children: ReactNode. The body. It may be empty while `streaming`.
|
|
57
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
58
|
+
- meta: ReactNode. A small line above the bubble: a sender and a time, already formatted.
|
|
59
|
+
- role: "user" | "assistant" (required). Whose side it sits on: `user` on the right on the inset fill, `assistant` on the left on the surface.
|
|
60
|
+
- streaming: boolean (default false). The reply is still arriving: sets `aria-busy` and draws a caret after the body, which pulses
|
|
61
|
+
unless the reader asks for reduced motion.
|