@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,147 @@
|
|
|
1
|
+
## DetailLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: One quote, build or member, with its content in the main column and its facts in the aside.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
The record's content is the main column; the facts about it go in `aside`.
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
Card,
|
|
13
|
+
DetailLayout,
|
|
14
|
+
KeyValue,
|
|
15
|
+
KeyValueList,
|
|
16
|
+
Text,
|
|
17
|
+
} from "@slashsuite/ui-react";
|
|
18
|
+
|
|
19
|
+
<DetailLayout
|
|
20
|
+
title="Quote Q-1042"
|
|
21
|
+
description="Naledi Mokoena"
|
|
22
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
23
|
+
aside={
|
|
24
|
+
<Card title="Details">
|
|
25
|
+
<KeyValueList>
|
|
26
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
27
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
28
|
+
</KeyValueList>
|
|
29
|
+
</Card>
|
|
30
|
+
}
|
|
31
|
+
>
|
|
32
|
+
<Card title="Cover">
|
|
33
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
34
|
+
</Card>
|
|
35
|
+
</DetailLayout>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Full page
|
|
39
|
+
A whole record page: the shell with its brand and nav, then the layout with the record in `children` and its facts in `aside`.
|
|
40
|
+
```tsx
|
|
41
|
+
import {
|
|
42
|
+
AppShell,
|
|
43
|
+
Button,
|
|
44
|
+
Card,
|
|
45
|
+
DetailLayout,
|
|
46
|
+
KeyValue,
|
|
47
|
+
KeyValueList,
|
|
48
|
+
Tabs,
|
|
49
|
+
Text,
|
|
50
|
+
} from "@slashsuite/ui-react";
|
|
51
|
+
|
|
52
|
+
<AppShell
|
|
53
|
+
brand={<a href="#">Hack Cove</a>}
|
|
54
|
+
nav={
|
|
55
|
+
<Tabs
|
|
56
|
+
label="Main"
|
|
57
|
+
items={[
|
|
58
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
59
|
+
{ label: "Clients", href: "#clients" },
|
|
60
|
+
]}
|
|
61
|
+
/>
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<DetailLayout
|
|
65
|
+
title="Quote Q-1042"
|
|
66
|
+
description="Naledi Mokoena"
|
|
67
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
68
|
+
aside={
|
|
69
|
+
<Card title="Details">
|
|
70
|
+
<KeyValueList>
|
|
71
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
72
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
73
|
+
</KeyValueList>
|
|
74
|
+
</Card>
|
|
75
|
+
}
|
|
76
|
+
>
|
|
77
|
+
<Card title="Cover">
|
|
78
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
79
|
+
</Card>
|
|
80
|
+
<Card title="Notes">
|
|
81
|
+
<Text>The client asked to be debited on the 25th.</Text>
|
|
82
|
+
</Card>
|
|
83
|
+
</DetailLayout>
|
|
84
|
+
</AppShell>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Do
|
|
88
|
+
- The record's content is the `children`, in the main two thirds; they are spaced as a `Stack`, so give each block its own `Card`.
|
|
89
|
+
- The facts about the record go in `aside`, in the third beside it: a `Card` with a `KeyValueList`, a status, the people on it.
|
|
90
|
+
- Both columns are required: with nothing for the aside, use `ListLayout`.
|
|
91
|
+
- From `lg` the aside sits beside the content; below it, it stacks under the content.
|
|
92
|
+
- `sticky` keeps the aside in view from `lg` as a long page scrolls: it sticks under the shell's header, and an aside taller than the room left scrolls inside itself, so its end stays reachable. Leave it off when the aside is ordinary cards that may be taller than the screen; below `lg` it stacks either way.
|
|
93
|
+
- `asideLabel` names the aside's landmark. Set it when the page has another complementary landmark (a `SidebarLayout` rail, a `FullBleedLayout` panel), so a screen reader can tell them apart. It only names the aside; `DetailLayout` never folds it.
|
|
94
|
+
- The header props are the same as `ListLayout`: `breadcrumbs`, `title`, `description`, `actions`, `tabs`.
|
|
95
|
+
|
|
96
|
+
### Don't
|
|
97
|
+
`ListLayout` has no aside, so the facts become one more block under the content. Use `DetailLayout` for a record.
|
|
98
|
+
```tsx
|
|
99
|
+
import {
|
|
100
|
+
Button,
|
|
101
|
+
Card,
|
|
102
|
+
KeyValue,
|
|
103
|
+
KeyValueList,
|
|
104
|
+
ListLayout,
|
|
105
|
+
Text,
|
|
106
|
+
} from "@slashsuite/ui-react";
|
|
107
|
+
|
|
108
|
+
<ListLayout
|
|
109
|
+
title="Quote Q-1042"
|
|
110
|
+
description="Naledi Mokoena"
|
|
111
|
+
actions={<Button variant="outline">Edit</Button>}
|
|
112
|
+
>
|
|
113
|
+
<Card title="Cover">
|
|
114
|
+
<Text>Life cover of R 1 500 000, to age 65.</Text>
|
|
115
|
+
</Card>
|
|
116
|
+
<Card title="Details">
|
|
117
|
+
<KeyValueList>
|
|
118
|
+
<KeyValue label="Status">Sent</KeyValue>
|
|
119
|
+
<KeyValue label="Premium">R 1 240 / mo</KeyValue>
|
|
120
|
+
</KeyValueList>
|
|
121
|
+
</Card>
|
|
122
|
+
</ListLayout>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Accessibility
|
|
126
|
+
- The title is the page's `h1`.
|
|
127
|
+
- The aside is an `<aside>`, a complementary landmark; the main column is a plain `div`.
|
|
128
|
+
- In the DOM the content comes first and the aside second, so that is the reading and tab order on every screen.
|
|
129
|
+
- With `sticky` a scrolling aside is still in the tab order, and a focus ring on a control in it is not cut off at its edge. An aside that scrolls and holds no link, field or button (plain text) takes one tab stop, named by `asideLabel`, so the keyboard can scroll it; an aside with a control in it takes none.
|
|
130
|
+
|
|
131
|
+
### Props
|
|
132
|
+
### DetailLayout
|
|
133
|
+
A detail page: header, then `children` (two thirds from `lg`) beside `aside` (one third), which stacks below on a smaller screen: a `SideColumn asideWidth="third"` under a `PageHeader`. `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 so its end stays reachable. While `loading` it owns the wait and passes it to everything inside, the header too.
|
|
134
|
+
- actions: ReactNode. Right of the title on `sm` and up, below it on a phone.
|
|
135
|
+
- aside: ReactNode (required). The side column: one third from `lg`, below `children` on a smaller screen.
|
|
136
|
+
- asideLabel: string. Names the aside's landmark (`aria-label`), so a page with another complementary landmark can tell them apart. It does not fold the aside. Left out, the aside is unnamed.
|
|
137
|
+
- breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
|
|
138
|
+
- description: ReactNode. The lede under the title: a `Lead`, so it outranks the body text after it.
|
|
139
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
140
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
141
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
142
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
143
|
+
- sticky: boolean (default false). From `lg`, keeps the aside in view under the header as the page scrolls; an aside taller than
|
|
144
|
+
the screen scrolls inside itself. Off by default, since an aside of ordinary cards may be
|
|
145
|
+
taller than the screen. Below `lg` the aside stacks as ever.
|
|
146
|
+
- tabs: ReactNode. A `Tabs` (or similar) under the title.
|
|
147
|
+
- title: ReactNode (required). The page's `h1`.
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
## Dialog
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: A short form or a message the reader must deal with before they go on.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Drawer (drawer.md): A record or a long form is worked on beside the page.
|
|
9
|
+
- ConfirmDialog (confirm-dialog.md): One yes-or-no question before an action.
|
|
10
|
+
- FieldDialog (field-dialog.md): Only one text value is asked for.
|
|
11
|
+
- BottomSheet (bottom-sheet.md): Content sits over a map or a canvas that must stay usable: not modal.
|
|
12
|
+
- Lightbox (lightbox.md): One photo or video is shown at full size.
|
|
13
|
+
|
|
14
|
+
### The one right way
|
|
15
|
+
A result that needs no answer is a `Callout` in the page, where it does not take the page away.
|
|
16
|
+
```tsx
|
|
17
|
+
import { Button, Callout, Stack } from "@slashsuite/ui-react";
|
|
18
|
+
|
|
19
|
+
<Stack gap="sm">
|
|
20
|
+
<Button variant="outline">Save</Button>
|
|
21
|
+
<Callout tone="positive">Your review is saved.</Callout>
|
|
22
|
+
</Stack>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Do
|
|
26
|
+
- Render it only while it is open: `{open && <Dialog … onClose={() => setOpen(false)} />}`. It opens itself on mount.
|
|
27
|
+
- A `title` that names the action, a `description` with the consequence, and the actions in `footer`: Cancel as `variant="ghost"` first, then the one action, `tone="danger"` when it destroys something.
|
|
28
|
+
- A form is the Dialog's own `onSubmit`: the body, the error and the footer are one form, so the footer's `Button type="submit"` and Enter in a field submit it, with no form id and no `form` attribute. The footer is Cancel (`variant="ghost"`), then the one submit button. With `onSubmit`, put no `<form method="dialog">` in the footer: it would nest a form.
|
|
29
|
+
- An error about one field is that `Field`'s `error`. An error about the whole submit (the server refused it, a conflict, no connection) is the Dialog's `error`: an alert between the body and the footer, beside the button that was pressed however tall the body is.
|
|
30
|
+
- A tall body scrolls inside the dialog, which is never taller than the screen: the title, the description and the footer stay on screen, so the actions are always in reach. A scroll that reaches the end of the body stops there and never moves the page behind. There is nothing to set.
|
|
31
|
+
- Every Dialog has a close button in its top corner, named "Close" (set `closeLabel` to the reader's language). A notice or a list to read needs no footer: the close button is the way out.
|
|
32
|
+
- A yes-or-no question before an action is a `ConfirmDialog`. One text field is a `FieldDialog`. A record or a long form is a `Drawer`. A message that needs no answer is a `Callout` in the page, or a `Toast` when it should not move the page.
|
|
33
|
+
- It fades and slides in, and out again on close, but a `<dialog>` only animates out while it is still in the DOM. So `onClose` is called once the exit has finished: put `setOpen(false)` there and nowhere else. Esc, the backdrop and a `<form method="dialog">` close it that way already. Your own Cancel or action button closes it by calling `.close()` on its `<dialog>`, which a click handler finds with `event.currentTarget.closest("dialog")`. A button that calls `setOpen(false)` itself unmounts the dialog at once, and it vanishes with no exit animation. After async work (a save), keep the `<dialog>` from the event before the `await` (`const dialog = event.currentTarget.closest("dialog")`) and call `dialog?.close()` when it resolves.
|
|
34
|
+
|
|
35
|
+
### Don't
|
|
36
|
+
A modal for a message makes the reader dismiss it before they can carry on.
|
|
37
|
+
```tsx
|
|
38
|
+
import { useState } from "react";
|
|
39
|
+
import { Button, Dialog } from "@slashsuite/ui-react";
|
|
40
|
+
|
|
41
|
+
function Example() {
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
return (
|
|
44
|
+
<>
|
|
45
|
+
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
46
|
+
Save
|
|
47
|
+
</Button>
|
|
48
|
+
{open && (
|
|
49
|
+
<Dialog
|
|
50
|
+
title="Saved"
|
|
51
|
+
description="Your review is saved."
|
|
52
|
+
onClose={() => setOpen(false)}
|
|
53
|
+
footer={<Button onClick={() => setOpen(false)}>OK</Button>}
|
|
54
|
+
/>
|
|
55
|
+
)}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
A form id in the body, a `form` attribute on the button, and a hand-made error line under the fields, away from the button that was pressed.
|
|
62
|
+
```tsx
|
|
63
|
+
import { useState } from "react";
|
|
64
|
+
import { Button, Dialog, Field, Input, Stack, Text } from "@slashsuite/ui-react";
|
|
65
|
+
|
|
66
|
+
function Example() {
|
|
67
|
+
const [open, setOpen] = useState(false);
|
|
68
|
+
return (
|
|
69
|
+
<>
|
|
70
|
+
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
71
|
+
New flag
|
|
72
|
+
</Button>
|
|
73
|
+
{open && (
|
|
74
|
+
<Dialog
|
|
75
|
+
title="New flag"
|
|
76
|
+
onClose={() => setOpen(false)}
|
|
77
|
+
footer={
|
|
78
|
+
<Button type="submit" form="new-flag-form">
|
|
79
|
+
Create
|
|
80
|
+
</Button>
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
<form id="new-flag-form" onSubmit={(event) => event.preventDefault()}>
|
|
84
|
+
<Stack>
|
|
85
|
+
<Field label="Key">
|
|
86
|
+
<Input defaultValue="new-checkout" />
|
|
87
|
+
</Field>
|
|
88
|
+
<Text tone="danger">Could not create the flag: the key is taken.</Text>
|
|
89
|
+
</Stack>
|
|
90
|
+
</form>
|
|
91
|
+
</Dialog>
|
|
92
|
+
)}
|
|
93
|
+
</>
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Accessibility
|
|
99
|
+
- A Dialog is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
|
|
100
|
+
- The fade and slide are switched off under `prefers-reduced-motion: reduce`, and then it closes at once.
|
|
101
|
+
- It is named by its `title`, an `h2`, through `aria-labelledby`.
|
|
102
|
+
- A click on the backdrop closes it, and so do the close button and a submit of a `<form method="dialog">`; every close calls `onClose`.
|
|
103
|
+
- The close button comes last in the keyboard order, after the footer, so opening still focuses the first field or the first footer button.
|
|
104
|
+
- The browser focuses the first focusable element in it when it opens; put `autoFocus` on the button that should have focus first.
|
|
105
|
+
- A tall body that holds nothing focusable, such as plain text, takes a tab stop so the arrow keys can scroll it. A tall form keeps its first focus on its first field.
|
|
106
|
+
- Once a form's `onSubmit` settles (a returned promise resolves or rejects), the focus moves to the first field marked invalid (`aria-invalid="true"`), so a failed submit puts the reader on what to fix.
|
|
107
|
+
|
|
108
|
+
### Props
|
|
109
|
+
### Dialog
|
|
110
|
+
A modal on the browser's own `<dialog>`: it is opened with `showModal()` on mount, so render it only while it is open. The page behind goes inert, Esc closes it and focus stays inside; a click on the backdrop (the `<dialog>` element itself, not its contents) closes it too, and so does the close button in its top corner, which every dialog has. The close button comes last in the keyboard order, so the open focuses the first field, not it. A windowed dialog is never taller than the screen: a tall body scrolls and the title and footer stay on screen, and a scroll inside it never carries on to the page behind.
|
|
111
|
+
- closeLabel: string (default Close). The name of the close button in the top corner, for an app in another language.
|
|
112
|
+
- description: ReactNode. A muted line under the title.
|
|
113
|
+
- error: ReactNode. What went wrong with the whole submit (the server refused it, no connection): a danger
|
|
114
|
+
`Callout`, announced as an alert, between the body and the footer, so it stays beside the
|
|
115
|
+
buttons however tall the body is. An error about one field is that `Field`'s `error`.
|
|
116
|
+
- footer: ReactNode. Actions under the body, right-aligned: Cancel (`variant="ghost"`), then the one main action.
|
|
117
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
118
|
+
- onClose: () => void (required). Called when the dialog closes: its close button, Esc, a click on the backdrop, or a
|
|
119
|
+
`<form method="dialog">` submit.
|
|
120
|
+
- onSubmit: ((event: FormEvent<HTMLFormElement>) => void | Promise<unknown>). Makes the dialog a form: one `<form noValidate>` holds the body, the `error` and the footer,
|
|
121
|
+
so a `Button type="submit"` in the footer or Enter in a field submits it, with no `form`
|
|
122
|
+
attribute or id. The default is prevented before this runs, and a rejection is yours to
|
|
123
|
+
catch and show as `error`. Once the submit settles, the focus moves to the first field marked
|
|
124
|
+
invalid (`aria-invalid="true"`), if any. Put no `<form method="dialog">` in the footer of a form dialog:
|
|
125
|
+
it would nest a form.
|
|
126
|
+
- title: ReactNode (required). The dialog's accessible name, shown as its heading.
|
|
127
|
+
- width: "sm" | "md" | "lg" | "full" (default md). The panel's width: `sm` (320px) is a list, `md` (440px) holds a form, `lg` (640px) a wider
|
|
128
|
+
form or a table. `full` fills the whole screen, for media or a player: the body takes the
|
|
129
|
+
height between the header and the footer and scrolls if it is taller. It has no backdrop to
|
|
130
|
+
click: its close button and Esc close it.
|
|
131
|
+
|
|
132
|
+
A single photo or video is a `Lightbox`.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
## Disclosure
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: Detail the person may not need on first sight: a history, an FAQ answer, the fine print.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Popover (popover.md): The detail floats beside its button and leaves the page as it is.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
Detail the person may not need, behind a summary that says what it is, is a `Disclosure`.
|
|
12
|
+
```tsx
|
|
13
|
+
import { Disclosure, Stack, Text } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Stack gap="xs">
|
|
16
|
+
<Text>Order 1042 was posted on Monday.</Text>
|
|
17
|
+
<Disclosure summary="Tracking history">
|
|
18
|
+
<Text>Posted Monday · Sorted Tuesday · Out for delivery Wednesday.</Text>
|
|
19
|
+
</Disclosure>
|
|
20
|
+
</Stack>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Do
|
|
24
|
+
- Give it a `summary` that says what is inside; the `children` are the body. It starts closed; `defaultOpen` starts it open.
|
|
25
|
+
- It keeps its own state. Several in a column are independent of each other.
|
|
26
|
+
- `bordered` draws it as a panel for a section that opens in place on a page of cards: a bordered box, the summary a full-width row that fills on hover, the body padded under a hairline.
|
|
27
|
+
- A collapsible section header in a list of rows is a `ListRow` with `expanded`, where the caller owns the state.
|
|
28
|
+
- It replaces `<details>` and `<summary>`.
|
|
29
|
+
|
|
30
|
+
### Don't
|
|
31
|
+
- Do not hide what the person must read to carry on, such as an error or the one thing the page is for.
|
|
32
|
+
|
|
33
|
+
A hand-built `<details>` and `<summary>` has none of the library's look or focus ring. `Disclosure` replaces it.
|
|
34
|
+
```tsx
|
|
35
|
+
import { Stack, Text } from "@slashsuite/ui-react";
|
|
36
|
+
|
|
37
|
+
<Stack gap="xs">
|
|
38
|
+
<Text>Order 1042 was posted on Monday.</Text>
|
|
39
|
+
<details>
|
|
40
|
+
<summary>Tracking history</summary>
|
|
41
|
+
<Text>Posted Monday · Sorted Tuesday · Out for delivery Wednesday.</Text>
|
|
42
|
+
</details>
|
|
43
|
+
</Stack>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
What the person must read to carry on, such as an error, is not hidden behind a summary: show it.
|
|
47
|
+
```tsx
|
|
48
|
+
import { Callout, Disclosure } from "@slashsuite/ui-react";
|
|
49
|
+
|
|
50
|
+
<Disclosure summary="Details">
|
|
51
|
+
<Callout tone="danger">Your payment was declined. Your order is not placed.</Callout>
|
|
52
|
+
</Disclosure>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Accessibility
|
|
56
|
+
- The summary is a real `<button>` with `aria-expanded` and `aria-controls`; Enter and Space toggle it.
|
|
57
|
+
- The body is a `role="group"` named by the summary, and hidden from assistive tech while closed.
|
|
58
|
+
- The chevron is decorative. The focus ring comes from the component.
|
|
59
|
+
- The body slides open and shut and the chevron turns; under `prefers-reduced-motion: reduce` it opens and closes at once. Find in page still finds text in a closed body and opens it.
|
|
60
|
+
|
|
61
|
+
### Props
|
|
62
|
+
### Disclosure
|
|
63
|
+
A summary line with a chevron over a body that opens and closes under it. The summary is a button with `aria-expanded`, and Enter and Space toggle it; the body is hidden while closed. It starts closed and keeps its own state; `defaultOpen` starts it open. To drive it from the app, pass `open` with `onOpenChange`. `bordered` draws it as a panel: a bordered box with the summary as a roomy row across the top (the hover fill of a `ListRow`) and the body padded under a hairline, for a section that opens in place in a page of cards. Plain, it is a line of text with the body indented under it.
|
|
64
|
+
- bordered: boolean (default false). Draws it as a bordered panel: the summary a full-width row, the body padded under a hairline.
|
|
65
|
+
- children: ReactNode (required). The body, shown while open.
|
|
66
|
+
- defaultOpen: boolean (default false). Starts with the body showing.
|
|
67
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
68
|
+
- onOpenChange: ((open: boolean) => void). Called with the new state when the summary is pressed.
|
|
69
|
+
- open: boolean. Whether the body shows, for an app that holds the state; pass `onOpenChange` with it.
|
|
70
|
+
- summary: ReactNode (required). The always-visible line: the button that toggles the body.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
## Divider
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: One line between a heading and its content, or above a footer.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A `Divider` is one hairline between two parts of a page, here the content and its footer. The space around it is the `Stack`'s.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Caption, Divider, Stack, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Stack gap="lg">
|
|
13
|
+
<Text>The last paragraph of a page.</Text>
|
|
14
|
+
<Divider />
|
|
15
|
+
<Caption>Hack Cove (Pty) Ltd</Caption>
|
|
16
|
+
</Stack>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- Use it between two parts of a page that are not bordered, such as the content and its footer.
|
|
21
|
+
- The space around it is the layout's: put it in a `Stack`, never add margin.
|
|
22
|
+
- For a rule under a section title, `SectionHeading` and `Section` have `rule`. For a line between two `Section`s, put a `Divider` between them in their `Stack`.
|
|
23
|
+
- Rows with a line between each and no gap (a list of `ListRow`s) are a `Stack divided`, not a `Divider` after every row.
|
|
24
|
+
|
|
25
|
+
### Don't
|
|
26
|
+
- Do not draw it between bordered blocks such as `Card`: their borders and the `gap` already separate them.
|
|
27
|
+
|
|
28
|
+
A `Divider` and a footer placed by hand inside a `Card`: the card's own `footer` draws that strip, its line and its spacing.
|
|
29
|
+
```tsx
|
|
30
|
+
import { Caption, Card, Divider, Stack, Text } from "@slashsuite/ui-react";
|
|
31
|
+
|
|
32
|
+
<Card title="Quote 12">
|
|
33
|
+
<Stack gap="lg">
|
|
34
|
+
<Text>Two lines, R 1 200.</Text>
|
|
35
|
+
<Divider />
|
|
36
|
+
<Caption>Total R 1 200</Caption>
|
|
37
|
+
</Stack>
|
|
38
|
+
</Card>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
A `Divider` between two Cards is a second line on top of their borders and the gap.
|
|
42
|
+
```tsx
|
|
43
|
+
import { Card, Divider, Stack, Text } from "@slashsuite/ui-react";
|
|
44
|
+
|
|
45
|
+
<Stack>
|
|
46
|
+
<Card title="Build 412">
|
|
47
|
+
<Text>3 changed</Text>
|
|
48
|
+
</Card>
|
|
49
|
+
<Divider />
|
|
50
|
+
<Card title="Build 411">
|
|
51
|
+
<Text>No changes</Text>
|
|
52
|
+
</Card>
|
|
53
|
+
</Stack>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Accessibility
|
|
57
|
+
- It is an `<hr>`, which assistive tech announces as a separator. Use it only where the content really changes.
|
|
58
|
+
|
|
59
|
+
### Props
|
|
60
|
+
### Divider
|
|
61
|
+
A hairline rule in the theme's line colour: between a heading and its content, or above a footer. Space around it is the layout's.
|
|
62
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
## DocsLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: Every page of a docs site: a nav of grouped pages, an article with its own headings, and previous and next in reading order.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
A docs page is one `DocsLayout`: the nav, the title, `contents` and the neighbours are props, and the layout draws the list and the links.
|
|
9
|
+
```tsx
|
|
10
|
+
import { DocsLayout, Section, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<DocsLayout
|
|
13
|
+
nav={[{ title: "Guides", items: [{ label: "Install", href: "#install", selected: true }] }]}
|
|
14
|
+
asideLabel="Docs"
|
|
15
|
+
title="Install"
|
|
16
|
+
contents={[
|
|
17
|
+
{ id: "do-setup", label: "Setup", level: 2 },
|
|
18
|
+
{ id: "do-run", label: "Run", level: 2 },
|
|
19
|
+
]}
|
|
20
|
+
next={{ label: "First build", href: "#first-build" }}
|
|
21
|
+
>
|
|
22
|
+
<Section id="do-setup" title="Setup">
|
|
23
|
+
<Text>Add the package.</Text>
|
|
24
|
+
</Section>
|
|
25
|
+
<Section id="do-run" title="Run">
|
|
26
|
+
<Text>Capture the stories.</Text>
|
|
27
|
+
</Section>
|
|
28
|
+
</DocsLayout>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Full page
|
|
32
|
+
A whole docs page in the shell: nav, breadcrumbs, a `Prose` article whose h2 and h3 ids match `contents`, the second heading `current`, and previous and next.
|
|
33
|
+
```tsx
|
|
34
|
+
import { Breadcrumbs, DocsLayout, Prose, Section, Text } from "@slashsuite/ui-react";
|
|
35
|
+
|
|
36
|
+
<DemoShell>
|
|
37
|
+
<DocsLayout
|
|
38
|
+
nav={[
|
|
39
|
+
{ items: [{ label: "All docs", href: "#docs" }] },
|
|
40
|
+
{
|
|
41
|
+
title: "Get started",
|
|
42
|
+
items: [
|
|
43
|
+
{ label: "Install", href: "#install", selected: true },
|
|
44
|
+
{ label: "First build", href: "#first-build" },
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
title: "Guides",
|
|
49
|
+
items: [
|
|
50
|
+
{ label: "Baselines", href: "#baselines" },
|
|
51
|
+
{ label: "Ignore areas", href: "#ignore" },
|
|
52
|
+
{ label: "CI", href: "#ci" },
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
]}
|
|
56
|
+
asideLabel="Docs"
|
|
57
|
+
breadcrumbs={<Breadcrumbs items={[{ label: "Docs", href: "#docs" }, "Install"]} />}
|
|
58
|
+
title="Install"
|
|
59
|
+
description="Add the CLI to a project and run its first capture."
|
|
60
|
+
contents={[
|
|
61
|
+
{ id: "requirements", label: "Requirements", level: 2 },
|
|
62
|
+
{ id: "package", label: "The package", level: 2 },
|
|
63
|
+
{ id: "token", label: "A token", level: 3 },
|
|
64
|
+
{ id: "check", label: "Check it works", level: 2 },
|
|
65
|
+
]}
|
|
66
|
+
current="package"
|
|
67
|
+
previous={{ label: "All docs", href: "#docs" }}
|
|
68
|
+
next={{ label: "First build", href: "#first-build" }}
|
|
69
|
+
>
|
|
70
|
+
<Prose>
|
|
71
|
+
<Section id="requirements" title="Requirements">
|
|
72
|
+
<Text>Bun 1.3 or Node 24, and a Storybook that builds.</Text>
|
|
73
|
+
</Section>
|
|
74
|
+
<Section id="package" title="The package">
|
|
75
|
+
<Text>Add the CLI as a dev dependency of the project that owns the stories.</Text>
|
|
76
|
+
<Section id="token" title="A token">
|
|
77
|
+
<Text>Create a token on the server and keep it in the CI secrets.</Text>
|
|
78
|
+
</Section>
|
|
79
|
+
</Section>
|
|
80
|
+
<Section id="check" title="Check it works">
|
|
81
|
+
<Text>Run a capture; the report lists every story it shot.</Text>
|
|
82
|
+
</Section>
|
|
83
|
+
</Prose>
|
|
84
|
+
</DocsLayout>
|
|
85
|
+
</DemoShell>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Do
|
|
89
|
+
- Give `nav` the docs pages in reading order, in groups: each group's `title` over its links, a group with no title at the top. `asideLabel` names the rail and the disclosure it folds behind below `md`.
|
|
90
|
+
- Give `contents` the page's own headings (`id`, `label`, `level` 2 or 3) in order; the layout draws the On this page list, a closed disclosure above the article below `xl` and a sticky column right of it from `xl`. With fewer than two there is no list.
|
|
91
|
+
- `current` is the id of the heading being read, a value the page passes; a site that follows the reader computes it. Left out, no entry is marked.
|
|
92
|
+
- Give `previous` and `next` the pages either side in reading order; they are links, not cards, so they add no heading to the outline.
|
|
93
|
+
- Wrap the article in a `Prose`; its `Section` headings start at `h2` under the layout's `h1`.
|
|
94
|
+
|
|
95
|
+
### Don't
|
|
96
|
+
- Do not hand-build a contents list or a pager beside a `SidebarLayout`: that is `DocsLayout`.
|
|
97
|
+
- Never put a scroll spy in the page to mark the list; pass `current`.
|
|
98
|
+
|
|
99
|
+
A `SidebarLayout` with a hand-built contents list and pager: two copies of the rules every docs site must then keep in step. Use `DocsLayout`.
|
|
100
|
+
```tsx
|
|
101
|
+
import {
|
|
102
|
+
Overline,
|
|
103
|
+
Section,
|
|
104
|
+
SidebarLayout,
|
|
105
|
+
Stack,
|
|
106
|
+
Tabs,
|
|
107
|
+
Text,
|
|
108
|
+
TextLink,
|
|
109
|
+
} from "@slashsuite/ui-react";
|
|
110
|
+
|
|
111
|
+
<SidebarLayout
|
|
112
|
+
aside={
|
|
113
|
+
<Tabs
|
|
114
|
+
orientation="vertical"
|
|
115
|
+
label="Guides"
|
|
116
|
+
items={[{ label: "Install", href: "#install", selected: true }]}
|
|
117
|
+
/>
|
|
118
|
+
}
|
|
119
|
+
>
|
|
120
|
+
<Stack gap="md">
|
|
121
|
+
<nav aria-label="Contents">
|
|
122
|
+
<Overline>Contents</Overline>
|
|
123
|
+
<TextLink href="#dont-setup">Setup</TextLink> <TextLink href="#dont-run">Run</TextLink>
|
|
124
|
+
</nav>
|
|
125
|
+
<Section id="dont-setup" title="Setup">
|
|
126
|
+
<Text>Add the package.</Text>
|
|
127
|
+
</Section>
|
|
128
|
+
<TextLink href="#first-build">Next: First build</TextLink>
|
|
129
|
+
</Stack>
|
|
130
|
+
</SidebarLayout>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Accessibility
|
|
134
|
+
- The rail is an `<aside>` named `asideLabel`; each group is a `<nav>` named by its title (the top group by `asideLabel`), and the current page has `aria-current="page"`.
|
|
135
|
+
- The title is the page's one `h1`.
|
|
136
|
+
- The On this page list is one `<nav>` named `contentsLabel` at every width, so there is one copy of each link; the entry for `current` has `aria-current="location"`.
|
|
137
|
+
- Previous and next are one `<nav>` named from `previousLabel` and `nextLabel`; each link's name is its visible text, the word then the page ("Previous Install").
|
|
138
|
+
|
|
139
|
+
### Props
|
|
140
|
+
### DocsLayout
|
|
141
|
+
A docs page: a `SidebarLayout` whose rail is the docs `nav` (each group's title over its links, folded behind a disclosure named `asideLabel` below `md`), and a canvas of the page's title, an "On this page" list of its `contents`, the article and the previous and next links. The contents list is rendered once: from `xl` a 12rem column right of the article that sticks under the header, below `xl` a closed disclosure above the article. `current` marks the heading being read; it is a value the page passes (a site that follows the reader computes it), with no scroll spy inside. The previous and next links are links, not cards, so they add no heading to the page's outline. While `loading` the canvas waits, as in `SidebarLayout`: an empty title is a bone and what the article holds draws its own bones; the nav, the contents list and the previous and next links are navigation, drawn as themselves. The layout owns the wait.
|
|
142
|
+
- asideLabel: string (required). Names the rail's landmark, and the disclosure it folds behind below `md` ("Docs", "All
|
|
143
|
+
components"), as `SidebarLayout`'s `asideLabel` does.
|
|
144
|
+
- breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
|
|
145
|
+
- children: ReactNode (required). The article. Wrap long text in a `Prose`.
|
|
146
|
+
- contents: DocsHeading[] (default []). The page's own headings, in order. With fewer than two there is no "On this page" list.
|
|
147
|
+
- contentsLabel: string (default On this page). The contents list's name and its label.
|
|
148
|
+
- current: string. The id of the heading being read: its entry is marked (`aria-current="location"`). A value the page passes, never tracked inside.
|
|
149
|
+
- description: ReactNode. The line under the title (a `Lead`).
|
|
150
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
151
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
152
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
153
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
154
|
+
- nav: DocsNavGroup[] (required). The docs nav, in reading order: each group's title over a vertical pill list of its pages.
|
|
155
|
+
- next: DocsNeighbour. The page after this one in reading order.
|
|
156
|
+
- nextLabel: string (default Next). The word over the next page's label.
|
|
157
|
+
- previous: DocsNeighbour. The page before this one in reading order.
|
|
158
|
+
- previousLabel: string (default Previous). The word over the previous page's label.
|
|
159
|
+
- title: ReactNode (required). The page's title, its `h1`.
|
|
160
|
+
|
|
161
|
+
### Types
|
|
162
|
+
- DocsHeading: `{ id: string; label: string; level: 2 | 3 }`. One entry of "On this page": a heading's id, its text and its level.
|
|
163
|
+
- DocsNavGroup: `{ title?: string; items: Tab[] }`. One group of the docs nav: a title over its links (`Tab`s with an `href`). A group with no title is the nav's top.
|
|
164
|
+
- DocsNeighbour: `{ label: string; href: string }`. The page before or after this one in reading order.
|