@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,77 @@
|
|
|
1
|
+
## RadioGroup
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A setting or answer with two to five options the person should see side by side: a visibility, a delivery method, a type.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
One of a few options, all visible, is a `RadioGroup`: the group has a name and each option its label.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Radio, RadioGroup } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<RadioGroup label="Shop type" defaultValue="vintage">
|
|
13
|
+
<Radio value="vintage" label="Vintage" />
|
|
14
|
+
<Radio value="books" label="Books" />
|
|
15
|
+
</RadioGroup>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### Do
|
|
19
|
+
- Give the `RadioGroup` a `label` that names the question, and a `Radio` per option with its own `label` and a `value`.
|
|
20
|
+
- Keep the choice with `defaultValue`, or control it with `value` and `onChange(value)`. `name` posts it in a form.
|
|
21
|
+
- A `hint` on a `Radio` is a muted line under its label, for the option that needs a sentence; a `hint` on the group is a line under the group's label. When every option needs one (a plan, a delivery speed), `variant="card"` makes each a bordered card, the label its title.
|
|
22
|
+
- An `error` on the group is a red line under the options and marks every circle red; it is the same wording rule as `Field`'s. The group draws its own label and error, so it is never put in a `Field`.
|
|
23
|
+
- `disabled` on the group disables every option; on a `Radio` it disables that one. Say why in the group's `hint`.
|
|
24
|
+
- `required` marks a choice the form cannot submit without; the group is `aria-required`.
|
|
25
|
+
- `size` (`sm`, `md` the default, `lg`) sets every circle and label, to match the `Input`s around it.
|
|
26
|
+
- More than five options, or a list that grows, is a `Select`. Several ticks are `Checkbox`es. Switching a view in place is a `SegmentedControl`.
|
|
27
|
+
|
|
28
|
+
### Don't
|
|
29
|
+
Checkboxes allow several ticks: they cannot say "one of these", and the screen reader hears no group.
|
|
30
|
+
```tsx
|
|
31
|
+
import { Checkbox, Stack } from "@slashsuite/ui-react";
|
|
32
|
+
|
|
33
|
+
<Stack gap="sm">
|
|
34
|
+
<Checkbox label="Vintage" defaultChecked />
|
|
35
|
+
<Checkbox label="Books" />
|
|
36
|
+
</Stack>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Accessibility
|
|
40
|
+
- The group is a `role="radiogroup"` named by its label; each `Radio` is a native `<input type="radio">` inside its `<label>`, so clicking the words chooses it.
|
|
41
|
+
- The group is one tab stop. The arrow keys move between the options and choose, wrapping at each end and skipping a disabled one.
|
|
42
|
+
- An `error` is announced politely, not as an alert, and the group is `aria-invalid`; a `hint` is the option's `aria-describedby`.
|
|
43
|
+
- The focus ring is drawn round the option that has focus, by the component.
|
|
44
|
+
|
|
45
|
+
### Props
|
|
46
|
+
### RadioGroup
|
|
47
|
+
A named group of radios, one chosen. The `label` names the group; `hint` is a muted line under the options that says more (the group's description); an `error` adds a red line with an alert icon under it, announced politely, and marks the group invalid. `required` puts a red asterisk after the label. Give it `value` and `onChange`, or `defaultValue` and let it keep the choice. `name` posts the choice in a form. The arrow keys move between the radios and choose, and the group is one tab stop. `size` sizes every radio in the group, the same scale as a `Checkbox`. `variant="card"` draws each radio as an option card: a bordered box, its label the title and its hint the description, the chosen one with an accent edge. While `loading` the labels are drawn and each circle is a bone.
|
|
48
|
+
- children: ReactNode (required). The `Radio`s.
|
|
49
|
+
- defaultValue: string. The `value` chosen to begin with, when the group keeps its own choice.
|
|
50
|
+
- disabled: boolean. Disables every radio.
|
|
51
|
+
- error: ReactNode. A red line under the hint, with an alert icon; marks the group invalid. Like `Field`'s `error`.
|
|
52
|
+
- hint: ReactNode. A muted line under the options that says more; it describes the group, and stays while `error` shows.
|
|
53
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
54
|
+
- label: ReactNode (required). The group's visible name, above the options.
|
|
55
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
56
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
57
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
58
|
+
- name: string. The form field the choice posts under.
|
|
59
|
+
- onChange: (value: string) => void. Called with the chosen radio's `value`.
|
|
60
|
+
- required: boolean. Marks the choice required: a red asterisk after the label, the group is `aria-required`, and a form will not submit with no option chosen.
|
|
61
|
+
- size: "sm" | "md" | "lg" (default md). The size of every radio in the group: `sm` is `text-xs` and a smaller circle, `lg` `text-base`
|
|
62
|
+
and a larger one.
|
|
63
|
+
- value: string. The `value` of the chosen radio.
|
|
64
|
+
- variant: "card" | "plain" (default plain). `plain` is a column of circles and their words. `card` makes each radio a bordered box the
|
|
65
|
+
width of the group, its label a title and its `hint` the description: for a few options that
|
|
66
|
+
each need a line of explaining (a plan, a delivery speed). The whole card is the click target.
|
|
67
|
+
|
|
68
|
+
### Radio
|
|
69
|
+
One option of a `RadioGroup`: a `label` and, under it, an optional `hint`. Click the label or the circle. While `loading` the circle is a bone.
|
|
70
|
+
- disabled: boolean. Disables this radio alone.
|
|
71
|
+
- hint: ReactNode. A muted line under the label that says more. It is the radio's `aria-describedby`.
|
|
72
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
73
|
+
- label: ReactNode (required). The text beside the circle.
|
|
74
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
75
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
76
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
77
|
+
- value: string (required). What the group's `value` becomes when this one is chosen.
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
## ScrollStrip
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A row of media or people that is longer than the page is wide: recent statuses, a team.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A row of media that runs past the page is a `ScrollStrip`: one line, a themed scrollbar, snapping.
|
|
9
|
+
```tsx
|
|
10
|
+
import { MediaTile, ScrollStrip } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<ScrollStrip label="Recent statuses">
|
|
13
|
+
{[...sampleScenes, ...sampleScenes].map((scene, index) => (
|
|
14
|
+
<MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
|
|
15
|
+
))}
|
|
16
|
+
</ScrollStrip>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- Put `MediaTile`s or `Avatar`s as the children and name the strip with `label`. They keep their own width and never shrink or wrap.
|
|
21
|
+
- `gap` is a `Cluster`'s: `xs`, `sm` (the default) or `md`; the `Size` type lists every default that is not `md`.
|
|
22
|
+
- It scrolls only when the items run past its width, with a themed scrollbar, and the items snap to the start edge.
|
|
23
|
+
|
|
24
|
+
### Don't
|
|
25
|
+
- Do not use it for a few items that fit: that is a `Cluster`. A grid that wraps is a `CardGrid`.
|
|
26
|
+
|
|
27
|
+
A `Cluster` wraps the tiles onto several lines, so the row takes over the page instead of staying in one line.
|
|
28
|
+
```tsx
|
|
29
|
+
import { Cluster, MediaTile } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Cluster>
|
|
32
|
+
{[...sampleScenes, ...sampleScenes].map((scene, index) => (
|
|
33
|
+
<MediaTile key={index} src={scene.src} alt={scene.alt} label="Anna" />
|
|
34
|
+
))}
|
|
35
|
+
</Cluster>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Accessibility
|
|
39
|
+
- A `role="group"` named by `label`. It takes keyboard focus (`tabindex="0"`) with a focus ring, so the arrow keys scroll it without a pointer.
|
|
40
|
+
- `id`, `data-*` and `aria-*` go on the strip.
|
|
41
|
+
|
|
42
|
+
### Props
|
|
43
|
+
### ScrollStrip
|
|
44
|
+
A single row of items that scrolls sideways when it runs past the width of its parent, with a themed scrollbar and the items snapping into place: a strip of `MediaTile`s or `Avatar`s. Items never shrink or wrap. The strip takes the keyboard focus, so the arrow keys scroll it without a pointer. A grid that wraps is a `CardGrid` or a `Cluster`.
|
|
45
|
+
- children: ReactNode (required). The items, one after another: `MediaTile`s, `Avatar`s. They keep their own width.
|
|
46
|
+
- gap: "sm" | "md" | "xs" (default sm). The space between items, as `Cluster`'s `gap`.
|
|
47
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
48
|
+
- label: string (required). Names the strip for a screen reader, e.g. "Recent statuses".
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
## SegmentedControl
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: A mode or a range chosen in place: daily or weekly, split or even.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Tabs (tabs.md): The choice switches the panel right under the row.
|
|
9
|
+
- Fieldset (fieldset.md): Several toggles can be on at once and narrow a list: pressed `Button`s in a `Fieldset`.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
A mode or a range chosen in place: the caller owns `value`, and `label` names the group.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [value, setValue] = useState("week");
|
|
19
|
+
return (
|
|
20
|
+
<SegmentedControl
|
|
21
|
+
label="Range"
|
|
22
|
+
items={[
|
|
23
|
+
{ value: "day", label: "Daily" },
|
|
24
|
+
{ value: "week", label: "Weekly" },
|
|
25
|
+
{ value: "month", label: "Monthly" },
|
|
26
|
+
]}
|
|
27
|
+
value={value}
|
|
28
|
+
onChange={setValue}
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Do
|
|
35
|
+
- Two to five short options. The caller owns `value` and `onChange`; `label` names the group.
|
|
36
|
+
- `size` is `sm`, `md` (default) or `lg`, the heights of a `Button`.
|
|
37
|
+
- `fill` when the group sits in a column (a form field): the options share its full width, so the border ends at the last option.
|
|
38
|
+
- An on/off setting is a `Checkbox` or a `Switch`; a long list is a `Select`.
|
|
39
|
+
- Switching the panel under a row of headings is `Tabs`.
|
|
40
|
+
- A `count` sits muted after the label.
|
|
41
|
+
- An option that cannot be chosen yet takes a `disabledReason` that says why; `disabled` on the group disables every option.
|
|
42
|
+
- Options that go to another page are links: `href` on each, drawn by the app's router link through `LinkProvider`. `value` marks the current page.
|
|
43
|
+
|
|
44
|
+
### Don't
|
|
45
|
+
An on/off setting is a `Checkbox`, not a two-option SegmentedControl.
|
|
46
|
+
```tsx
|
|
47
|
+
import { useState } from "react";
|
|
48
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
49
|
+
|
|
50
|
+
function Example() {
|
|
51
|
+
const [value, setValue] = useState("on");
|
|
52
|
+
return (
|
|
53
|
+
<SegmentedControl
|
|
54
|
+
label="Email me"
|
|
55
|
+
items={[
|
|
56
|
+
{ value: "on", label: "On" },
|
|
57
|
+
{ value: "off", label: "Off" },
|
|
58
|
+
]}
|
|
59
|
+
value={value}
|
|
60
|
+
onChange={setValue}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
A bare `disabled` option leaves the person guessing why it is greyed out.
|
|
67
|
+
```tsx
|
|
68
|
+
import { useState } from "react";
|
|
69
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
70
|
+
|
|
71
|
+
function Example() {
|
|
72
|
+
const [value, setValue] = useState("split");
|
|
73
|
+
return (
|
|
74
|
+
<SegmentedControl
|
|
75
|
+
label="Split"
|
|
76
|
+
items={[
|
|
77
|
+
{ value: "split", label: "Split" },
|
|
78
|
+
{ value: "even", label: "Even" },
|
|
79
|
+
{ value: "custom", label: "Custom", disabled: true },
|
|
80
|
+
]}
|
|
81
|
+
value={value}
|
|
82
|
+
onChange={setValue}
|
|
83
|
+
/>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Buttons that navigate from `onChange` are not links: they cannot be opened in a new tab or copied, and the current page is not marked as one.
|
|
89
|
+
```tsx
|
|
90
|
+
import { SegmentedControl } from "@slashsuite/ui-react";
|
|
91
|
+
|
|
92
|
+
<SegmentedControl
|
|
93
|
+
label="Journal"
|
|
94
|
+
value="daily"
|
|
95
|
+
items={[
|
|
96
|
+
{ value: "daily", label: "Daily" },
|
|
97
|
+
{ value: "weekly", label: "Weekly" },
|
|
98
|
+
]}
|
|
99
|
+
onChange={(value) => window.location.assign(`#${value}`)}
|
|
100
|
+
/>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Accessibility
|
|
104
|
+
- Buttons form a `radiogroup` named by `label`; each option is a `radio` with `aria-checked`.
|
|
105
|
+
- The group is one tab stop. The arrow keys (all four), Home and End move to the next enabled option and choose it.
|
|
106
|
+
- An option with `disabledReason` is `aria-disabled`: the arrow keys reach it and choose 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). A `disabled` option is skipped.
|
|
107
|
+
- Links form a `<nav>` named by `label`, and the current one has `aria-current="page"`.
|
|
108
|
+
- The focus ring comes from the component.
|
|
109
|
+
|
|
110
|
+
### Props
|
|
111
|
+
### SegmentedControl
|
|
112
|
+
A joined pill group where one option is filled: a mode or a range chosen in place. `items` are `{ value, label }` buttons (`value` and `onChange` are the caller's state; the arrow keys, Home and End move the choice) or links (`href`, an in-app one drawn by the app's router `<Link>` through `LinkProvider`; `value` marks the current one, which gets `aria-current`). An item may carry a `count`, and a button one `disabledReason` (it stays reachable by the arrows and its reason is a tooltip) or a bare `disabled`; `disabled` on the group disables every option. `label` names the group. `size` matches the height of a `Button` of the same size, and `{ base, md }` changes it at 48rem. `fill` stretches the options across the group's width; `wrap` lets them wrap into full rows of a box, always or (`"narrow"`) only while the group is under 32rem wide.
|
|
113
|
+
- disabled: boolean. Every option is disabled, e.g. until the page has hydrated.
|
|
114
|
+
- fill: boolean (default false). The group takes its parent's full width and the options grow to share it, so the border ends
|
|
115
|
+
at the last option. Still a pill.
|
|
116
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
117
|
+
- items: Segment[] | SwitchButton[] (required). The options in order: `{ value, label }` buttons, or links (`href`), the current link marked by its `selected` or by a `value` equal to the group's. Either may carry a `count`; a button may be `disabled`.
|
|
118
|
+
- label: string (required). The accessible name of the group.
|
|
119
|
+
- onChange: ((value: string) => void). Called with the option's `value` when one is chosen, by click or arrow key.
|
|
120
|
+
- size: Size | ResponsiveSize (default md). The control's height and text, on the scale of a `Button`. `{ base: "md", md: "lg" }` changes
|
|
121
|
+
size at the `md` breakpoint (48rem), in CSS.
|
|
122
|
+
|
|
123
|
+
Give it the same value as a responsive `Button` in the same row.
|
|
124
|
+
- value: string. The `value` of the current option; for links, an alternative to `selected` on the item.
|
|
125
|
+
- wrap: boolean | "narrow" (default false). The options wrap onto full rows of at most three (five are 3 then 2) in a box with rounded
|
|
126
|
+
corners and a line between options, instead of a pill. `"narrow"`: the box only while the group
|
|
127
|
+
itself is under 32rem wide (a container query, so it follows the column it sits in), and a
|
|
128
|
+
filled pill from 32rem up. Implies `fill`.
|
|
129
|
+
|
|
130
|
+
For five options that will not fit one row.
|
|
131
|
+
|
|
132
|
+
### Types
|
|
133
|
+
- Segment: `SwitchButton | SwitchLink`. One option of a SegmentedControl: a button with a `value`, or a link with an `href`; never both kinds in one group.
|
|
134
|
+
- SwitchButton: `{ label: ReactNode; count?: number; title?: string; value: string; disabled?: boolean; disabledReason?: string }`. An option that is a button: it calls `onChange(value)`.
|
|
135
|
+
- SwitchLink: `{ label: ReactNode; count?: number; title?: string; value?: string; selected?: boolean; external?: boolean; href: string }`. An option that is a link: `href`, drawn by the app's router link through `LinkProvider`. The router changes the page; `selected` on the item, or a `value` equal to the group's, marks the current one. `external` opens a new tab.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
## Select
|
|
2
|
+
|
|
3
|
+
Group: Forms
|
|
4
|
+
|
|
5
|
+
When to use: One choice from a list of about five or more: a category, a country, a rating.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Choosing one of several is a `Select` in a `Field`.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Field, Select } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Field label="Category" htmlFor="do-category">
|
|
13
|
+
<Select
|
|
14
|
+
id="do-category"
|
|
15
|
+
defaultValue="books"
|
|
16
|
+
items={[
|
|
17
|
+
{ value: "books", label: "Books" },
|
|
18
|
+
{ value: "clothes", label: "Clothes" },
|
|
19
|
+
{ value: "furniture", label: "Furniture" },
|
|
20
|
+
{ value: "records", label: "Records" },
|
|
21
|
+
{ value: "toys", label: "Toys" },
|
|
22
|
+
]}
|
|
23
|
+
/>
|
|
24
|
+
</Field>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Do
|
|
28
|
+
- Put a `Select` in a `Field` and give it its choices as `items` (`{ value, label, disabled? }`); set `defaultValue` or control it with `value` and `onChange`.
|
|
29
|
+
- A yes or no is a `Checkbox`.
|
|
30
|
+
- Two to five modes switched in place are a `SegmentedControl`.
|
|
31
|
+
- `size` and `width` are the same choices as on `Input`.
|
|
32
|
+
|
|
33
|
+
### Don't
|
|
34
|
+
A yes or no is not a choice from a list: it is a `Checkbox`.
|
|
35
|
+
```tsx
|
|
36
|
+
import { Field, Select } from "@slashsuite/ui-react";
|
|
37
|
+
|
|
38
|
+
<Field label="Open now" htmlFor="dont-open">
|
|
39
|
+
<Select
|
|
40
|
+
id="dont-open"
|
|
41
|
+
defaultValue="yes"
|
|
42
|
+
items={[
|
|
43
|
+
{ value: "yes", label: "Yes" },
|
|
44
|
+
{ value: "no", label: "No" },
|
|
45
|
+
]}
|
|
46
|
+
/>
|
|
47
|
+
</Field>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Accessibility
|
|
51
|
+
- A `Select` is a native `<select>`, so it keeps the browser's arrow, its keyboard handling and its mobile picker.
|
|
52
|
+
- In a `Field`, the `Field` around it gives it its label and its hint or error as `aria-describedby`, and an error marks it `aria-invalid` with a red edge.
|
|
53
|
+
- The focus ring comes from the component.
|
|
54
|
+
|
|
55
|
+
### Props
|
|
56
|
+
### Select
|
|
57
|
+
A native `<select>` styled like `Input`, keeping the browser's own arrow, over its `items`. Takes `size` and `width` too: inside a `Field` it fills the row, and on its own it is as wide as its longest choice. The `ref` reaches the `<select>`.
|
|
58
|
+
- disabled: boolean (native). Disables the select; say why in its `Field` hint.
|
|
59
|
+
- items: readonly SelectItem[] (required). The choices, in order.
|
|
60
|
+
- name: string (native). The key the value posts under in a form.
|
|
61
|
+
- ref: Ref<HTMLSelectElement>. The `<select>` itself, for focus control.
|
|
62
|
+
- size: Size | ResponsiveSize (default md). `sm` is compact, `text-sm` with less padding, for dense forms and table rows; `md` is `text-base`;
|
|
63
|
+
`lg` is `text-lg` with more padding, for a hero form. Under an `AppShell density="compact"` each
|
|
64
|
+
is one type step down, and on a touch screen a field is never under 16px.
|
|
65
|
+
`{ base: "md", md: "lg" }` changes size at the `md` breakpoint (48rem), in CSS, as a `Button`'s
|
|
66
|
+
does: give the field and the buttons in its row the same value, so the row stays aligned.
|
|
67
|
+
- width: "sm" | "md" | "lg" | "auto" | "xs" | "fill" | "full" (default full inside a `Field`, `auto` outside one). As an `Input`'s `width`.
|
|
68
|
+
|
|
69
|
+
### Types
|
|
70
|
+
- SelectItem: `{ value: string; label: string; disabled?: boolean }`. One choice of a `Select`.
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
## Show
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: Content that only fits a wide screen, and its narrow-screen form: a table from `sm`, a stack of cards below it.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A table that only fits a wide screen is in a `Show from`; its phone form, a stack of rows, is in a `Show below` at the same breakpoint.
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Card,
|
|
12
|
+
ListRow,
|
|
13
|
+
Show,
|
|
14
|
+
Stack,
|
|
15
|
+
Table,
|
|
16
|
+
TableBody,
|
|
17
|
+
TableCell,
|
|
18
|
+
TableHead,
|
|
19
|
+
TableHeaderCell,
|
|
20
|
+
TableRow,
|
|
21
|
+
} from "@slashsuite/ui-react";
|
|
22
|
+
|
|
23
|
+
<Stack>
|
|
24
|
+
<Show below="sm">
|
|
25
|
+
<Card flush>
|
|
26
|
+
<Stack as="ul" divided aria-label="Builds">
|
|
27
|
+
<li>
|
|
28
|
+
<ListRow secondary="main, 3 changed">Build 412</ListRow>
|
|
29
|
+
</li>
|
|
30
|
+
<li>
|
|
31
|
+
<ListRow secondary="main, no changes">Build 411</ListRow>
|
|
32
|
+
</li>
|
|
33
|
+
</Stack>
|
|
34
|
+
</Card>
|
|
35
|
+
</Show>
|
|
36
|
+
<Show from="sm">
|
|
37
|
+
<Table label="Builds">
|
|
38
|
+
<TableHead>
|
|
39
|
+
<TableRow>
|
|
40
|
+
<TableHeaderCell>Build</TableHeaderCell>
|
|
41
|
+
<TableHeaderCell>Branch</TableHeaderCell>
|
|
42
|
+
<TableHeaderCell numeric>Changed</TableHeaderCell>
|
|
43
|
+
</TableRow>
|
|
44
|
+
</TableHead>
|
|
45
|
+
<TableBody>
|
|
46
|
+
<TableRow>
|
|
47
|
+
<TableCell>Build 412</TableCell>
|
|
48
|
+
<TableCell mono>main</TableCell>
|
|
49
|
+
<TableCell numeric>3</TableCell>
|
|
50
|
+
</TableRow>
|
|
51
|
+
<TableRow>
|
|
52
|
+
<TableCell>Build 411</TableCell>
|
|
53
|
+
<TableCell mono>main</TableCell>
|
|
54
|
+
<TableCell numeric>0</TableCell>
|
|
55
|
+
</TableRow>
|
|
56
|
+
</TableBody>
|
|
57
|
+
</Table>
|
|
58
|
+
</Show>
|
|
59
|
+
</Stack>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Do
|
|
63
|
+
- Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a `Show below` at the same breakpoint: `<Show below="sm">{cards}</Show><Show from="sm">{table}</Show>`.
|
|
64
|
+
- Give exactly one of `from` or `below`, each `sm`, `md` or `lg`. There is no default: the reader sees the rule.
|
|
65
|
+
- `as="span"` inside phrasing content: a run in a `<p>`, a `Kbd` hint in a button row.
|
|
66
|
+
- The wrapper adds no box, so its children sit in the parent's row, grid or `Stack` and the parent's gap spaces them. To keep two items together, put a `Cluster` inside the `Show`.
|
|
67
|
+
- Hidden content stays mounted, so two `Show`s of one stateful panel mount it twice. A panel shown at every width that folds on a phone is a `SideColumn fold`, not two `Show`s.
|
|
68
|
+
|
|
69
|
+
### Don't
|
|
70
|
+
- Never write `hidden sm:block` or `sm:hidden` in an app: the breakpoint is a `Show`.
|
|
71
|
+
|
|
72
|
+
The same table at every width squashes on a phone and scrolls sideways; never hide it with a class of your own either.
|
|
73
|
+
```tsx
|
|
74
|
+
import {
|
|
75
|
+
Table,
|
|
76
|
+
TableBody,
|
|
77
|
+
TableCell,
|
|
78
|
+
TableHead,
|
|
79
|
+
TableHeaderCell,
|
|
80
|
+
TableRow,
|
|
81
|
+
} from "@slashsuite/ui-react";
|
|
82
|
+
|
|
83
|
+
<Table label="Builds">
|
|
84
|
+
<TableHead>
|
|
85
|
+
<TableRow>
|
|
86
|
+
<TableHeaderCell>Build</TableHeaderCell>
|
|
87
|
+
<TableHeaderCell>Branch</TableHeaderCell>
|
|
88
|
+
<TableHeaderCell numeric>Changed</TableHeaderCell>
|
|
89
|
+
</TableRow>
|
|
90
|
+
</TableHead>
|
|
91
|
+
<TableBody>
|
|
92
|
+
<TableRow>
|
|
93
|
+
<TableCell>Build 412</TableCell>
|
|
94
|
+
<TableCell mono>main</TableCell>
|
|
95
|
+
<TableCell numeric>3</TableCell>
|
|
96
|
+
</TableRow>
|
|
97
|
+
<TableRow>
|
|
98
|
+
<TableCell>Build 411</TableCell>
|
|
99
|
+
<TableCell mono>main</TableCell>
|
|
100
|
+
<TableCell numeric>0</TableCell>
|
|
101
|
+
</TableRow>
|
|
102
|
+
</TableBody>
|
|
103
|
+
</Table>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Accessibility
|
|
107
|
+
- Hidden is `display: none`: the content is out of the accessibility tree and the tab order, so a table hidden on a phone is not read out there.
|
|
108
|
+
- The reading order is the source order; `Show` moves nothing.
|
|
109
|
+
- It is CSS only, the same markup on the server and the client, so it works before the page hydrates and with no script.
|
|
110
|
+
|
|
111
|
+
### Props
|
|
112
|
+
### Show
|
|
113
|
+
Shows its children only from a width up (`from`) or only below it (`below`), by CSS alone: the same markup on the server and the client, with no script. Hidden is `display: none`, so the content is out of the accessibility tree and the tab order too. Shown, the wrapper adds no box, so the children sit in the parent's row, grid or Stack and take its gap. Content that only fits a wide screen is in a `Show from`; its narrow-screen form is in a `Show below` at the same breakpoint. Hidden content stays mounted, so two `Show`s of the same content mount it twice: a stateful panel shown at every width with a fold is a `SideColumn fold`. `as="span"` is for phrasing content (inside a `<p>` or a button row).
|
|
114
|
+
- as: "div" | "span" (default div). The element: `div`, or `span` inside phrasing content.
|
|
115
|
+
- below: "sm" | "md" | "lg". Shown below this width, gone from it up.
|
|
116
|
+
- from: "sm" | "md" | "lg". Shown from this width up, gone below it.
|
|
117
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
118
|
+
|
|
119
|
+
### Types
|
|
120
|
+
- Breakpoint: `"sm" | "md" | "lg"`. A width step: `sm` 640px, `md` 768px, `lg` 1024px.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## SideColumn
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: Any main area beside a side panel, such as a thread beside its assistant or a record beside its facts; a whole page with a header is `DetailLayout`, which is this split under a `PageHeader`.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A main area and a side column of a known width are a `SideColumn`: the aside is exactly as wide as `asideWidth`, whatever it holds.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Card, SideColumn, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<SideColumn
|
|
13
|
+
aside={
|
|
14
|
+
<Card title="Reply agent">
|
|
15
|
+
<Text>Ask for a draft, then edit it before it is sent.</Text>
|
|
16
|
+
</Card>
|
|
17
|
+
}
|
|
18
|
+
>
|
|
19
|
+
<Card title="Thread">
|
|
20
|
+
<Text>The main area takes everything the aside leaves.</Text>
|
|
21
|
+
</Card>
|
|
22
|
+
</SideColumn>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Do
|
|
26
|
+
- `children` are the main area and `aside` is the side column. From `lg` the aside is `asideWidth` wide on the right and the main area takes the room left; below `lg` the aside stacks under the main area.
|
|
27
|
+
- `side="start"` puts the aside on the left from `lg` and first in reading order, so below `lg` it stacks above the main area. Use it for a column the main area depends on, such as filters; `end`, the default, is for one that supports it.
|
|
28
|
+
- `asideWidth` is `xs` (12rem), `sm` (18rem), `md` (24rem, the default) or `third` (one third of the row, the main area two thirds). `xs`, `sm` and `md` are exact, whatever the aside holds; there is no other width.
|
|
29
|
+
- `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under the header and, when it is taller than the screen, scrolls itself.
|
|
30
|
+
- `asideLabel` names the aside's landmark. `fold` is for an aside that should not take a phone's screen: below `lg` it folds, closed, behind a disclosure named by `asideLabel` (so `fold` needs it), and from `lg` it is the same column, always shown, with no toggle. The aside stays mounted while folded, so state inside it is kept. Left out, the aside is always shown.
|
|
31
|
+
- It sets no page width, padding or header of its own: put it inside a layout, a `Card` or a panel. Space inside each column with a `Stack`.
|
|
32
|
+
- `DetailLayout`'s aside is a `SideColumn asideWidth="third"`, so a split inside a page that wants the thirds is `SideColumn asideWidth="third"`, never a `CardGrid`. A rail of links on the left is `SidebarLayout`. A `Stack` with `rowFrom` and a `ClusterGrow` sizes the side by its content, so it is not a fixed column.
|
|
33
|
+
|
|
34
|
+
### Don't
|
|
35
|
+
A `Stack` with `rowFrom` and a `ClusterGrow` sizes the side by its content: a long line makes it wide and takes the room from the main area.
|
|
36
|
+
```tsx
|
|
37
|
+
import { Card, ClusterGrow, Overline, Stack, Text } from "@slashsuite/ui-react";
|
|
38
|
+
|
|
39
|
+
<Stack rowFrom="lg">
|
|
40
|
+
<ClusterGrow>
|
|
41
|
+
<Card title="Thread">
|
|
42
|
+
<Text>The main area takes what is left.</Text>
|
|
43
|
+
</Card>
|
|
44
|
+
</ClusterGrow>
|
|
45
|
+
<Card>
|
|
46
|
+
<Overline>Reply agent</Overline>
|
|
47
|
+
<Text>
|
|
48
|
+
Whatever width the aside's text wants is the width it takes, so it changes with its words.
|
|
49
|
+
</Text>
|
|
50
|
+
</Card>
|
|
51
|
+
</Stack>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Accessibility
|
|
55
|
+
- The side column is an `<aside>`, a complementary landmark; the main area is a plain `div`. Give the aside a heading, or set `asideLabel`, which also names it, when it needs a name.
|
|
56
|
+
- In the DOM the main area comes first and the aside second (the aside first with `side="start"`), so that is the reading and tab order on every screen.
|
|
57
|
+
- A `sticky` aside that is taller than the screen and holds no link or field takes a tab stop of its own, named by `asideLabel`, so the keyboard can scroll it.
|
|
58
|
+
- With `fold` the aside is a native `<details>` disclosure below `lg`: its `<summary>` is the toggle, on the keyboard like any button. From `lg` the summary is gone and, once the page has loaded, the `<details>` is open for real, so the aside is in the accessibility tree.
|
|
59
|
+
|
|
60
|
+
### Props
|
|
61
|
+
### SideColumn
|
|
62
|
+
A main area beside a side column, in the Container the page already has: from `lg` the `aside` is `asideWidth` on the right and `children` take the room left; below `lg` the aside stacks under `children`. It sets no page width, padding or header of its own, so it sits inside a layout, a `Card` or a panel. `asideWidth` is `xs` (12rem), `sm` (18rem), `md` (24rem) or `third` (one third of the row, the main area two thirds: the split `DetailLayout` draws). A rail of links on the left is `SidebarLayout`. `side="start"` puts the aside on the left from `lg`, and first in reading order, so below `lg` it stacks above `children`. `asideLabel` names the `<aside>` landmark. `fold` is for an aside that should not take the phone's screen: below `lg` it folds, closed, behind a native disclosure named by `asideLabel`, and from `lg` it is the same column, always shown. The aside stays mounted while folded, so a conversation or a draft inside it is kept. `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under AppShell's header and, if it is taller than the room left, scrolls itself (a tab stop named by `asideLabel`) so its end stays reachable.
|
|
63
|
+
- aside: ReactNode (required). The side column: `asideWidth` wide on `side` from `lg`, stacked with `children` below it.
|
|
64
|
+
- asideLabel: string. Names the `<aside>` landmark, and the disclosure when `fold` is set. Left out, the aside is unnamed.
|
|
65
|
+
- asideWidth: "sm" | "md" | "xs" | "third" (default md). The aside's width from `lg`: `xs` 12rem, `sm` 18rem, `md` 24rem, or `third`, one third of the row.
|
|
66
|
+
- fold: boolean (default false). Folds the aside, closed, behind a disclosure named by `asideLabel` below `lg`.
|
|
67
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
68
|
+
- side: "end" | "start" (default end). The aside's side from `lg`: `end` (the right) or `start` (the left, and first in reading order).
|
|
69
|
+
- sticky: boolean (default false). From `lg`, keeps the aside in view under the header as the page scrolls; an aside taller than
|
|
70
|
+
the screen scrolls inside itself.
|
|
71
|
+
|
|
72
|
+
### Types
|
|
73
|
+
- SideColumnSide: `"end" | "start"`. Which side of the main area a `SideColumn`'s aside sits on from `lg`: `end` (the right) or `start` (the left).
|
|
74
|
+
- SideColumnWidth: `"sm" | "md" | "xs" | "third"`. How wide a `SideColumn`'s aside is from `lg`: `xs` 12rem, `sm` 18rem, `md` 24rem, or `third` a third of the row.
|