@slashsuite/ui-react 0.11.3 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -1
- package/agent-docs/components/app-shell.md +136 -0
- package/agent-docs/components/avatar-stack.md +64 -0
- package/agent-docs/components/avatar.md +76 -0
- package/agent-docs/components/badge.md +61 -0
- package/agent-docs/components/body-text.md +158 -0
- package/agent-docs/components/bottom-sheet.md +95 -0
- package/agent-docs/components/breadcrumbs.md +62 -0
- package/agent-docs/components/bullet-list.md +54 -0
- package/agent-docs/components/button.md +135 -0
- package/agent-docs/components/callout.md +86 -0
- package/agent-docs/components/card-grid.md +108 -0
- package/agent-docs/components/card.md +113 -0
- package/agent-docs/components/centered-layout.md +90 -0
- package/agent-docs/components/chat-composer.md +48 -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 +75 -0
- package/agent-docs/components/cluster.md +106 -0
- package/agent-docs/components/code-example.md +48 -0
- package/agent-docs/components/code.md +70 -0
- package/agent-docs/components/colour-scheme-toggle.md +92 -0
- package/agent-docs/components/container.md +50 -0
- package/agent-docs/components/copy-button.md +61 -0
- package/agent-docs/components/copy-line.md +54 -0
- package/agent-docs/components/date-field.md +103 -0
- package/agent-docs/components/date-range-picker.md +101 -0
- package/agent-docs/components/detail-layout.md +147 -0
- package/agent-docs/components/dialog.md +178 -0
- package/agent-docs/components/disclosure.md +66 -0
- package/agent-docs/components/divider.md +62 -0
- package/agent-docs/components/docs-layout.md +160 -0
- package/agent-docs/components/drawer.md +128 -0
- package/agent-docs/components/empty-state.md +67 -0
- package/agent-docs/components/field-dialog.md +97 -0
- package/agent-docs/components/field.md +68 -0
- package/agent-docs/components/fieldset.md +82 -0
- package/agent-docs/components/file-drop.md +52 -0
- package/agent-docs/components/form-layout.md +141 -0
- package/agent-docs/components/form-row.md +93 -0
- package/agent-docs/components/full-bleed-layout.md +116 -0
- package/agent-docs/components/headings.md +101 -0
- package/agent-docs/components/hero.md +59 -0
- package/agent-docs/components/icon-button.md +92 -0
- package/agent-docs/components/icon.md +66 -0
- package/agent-docs/components/image.md +64 -0
- package/agent-docs/components/input.md +83 -0
- package/agent-docs/components/kbd.md +38 -0
- package/agent-docs/components/key-value-list.md +81 -0
- package/agent-docs/components/lightbox.md +97 -0
- package/agent-docs/components/list-layout.md +154 -0
- package/agent-docs/components/list-row.md +116 -0
- package/agent-docs/components/loading.md +69 -0
- package/agent-docs/components/markdown.md +51 -0
- package/agent-docs/components/media-tile.md +97 -0
- package/agent-docs/components/menu.md +103 -0
- package/agent-docs/components/meta-list.md +69 -0
- package/agent-docs/components/morph.md +128 -0
- package/agent-docs/components/navigation-progress.md +56 -0
- package/agent-docs/components/outline-region.md +63 -0
- package/agent-docs/components/page-fade.md +116 -0
- package/agent-docs/components/page-header.md +93 -0
- package/agent-docs/components/pagination.md +64 -0
- package/agent-docs/components/pill.md +104 -0
- package/agent-docs/components/progress-bar.md +66 -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 +74 -0
- package/agent-docs/components/scroll-strip.md +48 -0
- package/agent-docs/components/segmented-control.md +133 -0
- package/agent-docs/components/select.md +65 -0
- package/agent-docs/components/show.md +120 -0
- package/agent-docs/components/side-column.md +70 -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 +67 -0
- package/agent-docs/components/sortable-list.md +107 -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 +88 -0
- package/agent-docs/components/stat-tile.md +69 -0
- package/agent-docs/components/status-pages.md +105 -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.md +373 -0
- package/agent-docs/components/tabs.md +180 -0
- package/agent-docs/components/text-link.md +105 -0
- package/agent-docs/components/textarea.md +51 -0
- package/agent-docs/components/timeline.md +79 -0
- package/agent-docs/components/toast.md +86 -0
- package/agent-docs/components/trend-chart.md +61 -0
- package/agent-docs/components/video.md +44 -0
- package/agent-docs/llms.txt +155 -0
- package/package.json +6 -3
- package/skills/uislash/SKILL.md +20 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
## Lightbox
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: Showing a photo or a video at full size, and stepping through a set of them.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- MediaTile (media-tile.md): The pictures are shown in the page, as tiles to open.
|
|
9
|
+
- Dialog (dialog.md): A question or a form, not a picture.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
A photo or a video opens in a Lightbox: full screen, on its own dark scrim, with steps between items.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { Button, Lightbox } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [at, setAt] = useState<number | null>(null);
|
|
19
|
+
const photo = at === null ? undefined : sampleScenes[at];
|
|
20
|
+
return (
|
|
21
|
+
<>
|
|
22
|
+
<Button variant="outline" onClick={() => setAt(0)}>
|
|
23
|
+
View photos
|
|
24
|
+
</Button>
|
|
25
|
+
{at !== null && photo && (
|
|
26
|
+
<Lightbox
|
|
27
|
+
label={photo.alt}
|
|
28
|
+
title="Anna"
|
|
29
|
+
caption={photo.caption}
|
|
30
|
+
onClose={() => setAt(null)}
|
|
31
|
+
onPrevious={at > 0 ? () => setAt(at - 1) : undefined}
|
|
32
|
+
onNext={at < sampleScenes.length - 1 ? () => setAt(at + 1) : undefined}
|
|
33
|
+
>
|
|
34
|
+
<img src={photo.src} alt={photo.alt} />
|
|
35
|
+
</Lightbox>
|
|
36
|
+
)}
|
|
37
|
+
</>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Do
|
|
43
|
+
- Render it only while it is open: `{open && <Lightbox … onClose={() => setOpen(false)} />}`. It opens itself on mount.
|
|
44
|
+
- Pass one `<img>` or `<video>` as its children, with no classes: the Lightbox scales it down to fit the screen and keeps its shape.
|
|
45
|
+
- `label` names it for a screen reader. `title` and `meta` are lines above the media (who posted it, and when); `caption` is the text under it.
|
|
46
|
+
- To step through a set, pass `onPrevious` and `onNext`: each shows its button and binds its arrow key. Leave `onPrevious` out on the first item and `onNext` on the last.
|
|
47
|
+
- The scrim is near-black with light text in every theme, light themes included, so a photo reads as it would in any viewer.
|
|
48
|
+
- It fades out on close while it is still in the DOM, so `onClose` is called once the fade has finished: put `setOpen(false)` there and nowhere else. Esc, the scrim and the close button close it that way already.
|
|
49
|
+
|
|
50
|
+
### Don't
|
|
51
|
+
- Do not draw your own scrim for media; a question about a photo is a `Dialog`.
|
|
52
|
+
|
|
53
|
+
A Dialog is for a question: its panel boxes a photo in at a form's width, on the theme's light surface.
|
|
54
|
+
```tsx
|
|
55
|
+
import { useState } from "react";
|
|
56
|
+
import { Button, Dialog } from "@slashsuite/ui-react";
|
|
57
|
+
|
|
58
|
+
function Example() {
|
|
59
|
+
const [open, setOpen] = useState(false);
|
|
60
|
+
const photo = sampleScenes[0];
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
<Button variant="outline" onClick={() => setOpen(true)}>
|
|
64
|
+
View photo
|
|
65
|
+
</Button>
|
|
66
|
+
{open && photo && (
|
|
67
|
+
<Dialog title="Anna" onClose={() => setOpen(false)}>
|
|
68
|
+
<img src={photo.src} alt={photo.alt} />
|
|
69
|
+
</Dialog>
|
|
70
|
+
)}
|
|
71
|
+
</>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Accessibility
|
|
77
|
+
- A Lightbox is the browser's own `<dialog>` opened with `showModal()`: the page behind goes inert, focus stays inside it and Esc closes it.
|
|
78
|
+
- It is named by `label` through `aria-label`; give the `<img>` its own `alt`.
|
|
79
|
+
- The close, previous and next buttons are named Close, Previous and Next (`closeLabel`, `previousLabel` and `nextLabel` for another language), and keep a light focus ring that shows on the dark scrim in every theme.
|
|
80
|
+
- A click on the scrim around the media closes it; a click on the media or its text does not.
|
|
81
|
+
- Closing, or unmounting it, hands focus back to the element that opened it. The fade is switched off under `prefers-reduced-motion: reduce`.
|
|
82
|
+
|
|
83
|
+
### Props
|
|
84
|
+
### Lightbox
|
|
85
|
+
A full-screen photo or video viewer 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 scrim around the media and its text closes it too. The scrim stays near-black with light text in every theme. `onPrevious` and `onNext` add step buttons and the arrow keys.
|
|
86
|
+
- caption: ReactNode. Muted text on the scrim under the media.
|
|
87
|
+
- children: ReactNode (required). The media: one `<img>` or `<video>`, scaled down to fit the screen.
|
|
88
|
+
- closeLabel: string (default Close). The close button's name, for an app in another language.
|
|
89
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
90
|
+
- label: string (required). The viewer's accessible name, e.g. "Photo from Anna".
|
|
91
|
+
- meta: ReactNode. A muted line under the title, e.g. when.
|
|
92
|
+
- nextLabel: string (default Next). The next button's name.
|
|
93
|
+
- onClose: () => void (required). Called when the viewer closes: Esc, a click on the scrim or the close button.
|
|
94
|
+
- onNext: (() => void). Shows a next button and binds ArrowRight. Leave it out at the last item.
|
|
95
|
+
- onPrevious: (() => void). Shows a previous button and binds ArrowLeft. Leave it out at the first item.
|
|
96
|
+
- previousLabel: string (default Previous). The previous button's name.
|
|
97
|
+
- title: ReactNode. A line on the scrim above the media, e.g. who posted it.
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
## ListLayout
|
|
2
|
+
|
|
3
|
+
Group: Page layouts
|
|
4
|
+
|
|
5
|
+
When to use: An index of quotes, builds, members or any other collection; a single record is `DetailLayout`.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
`filters` sit under the header, then the rows: one `Card` per item.
|
|
9
|
+
```tsx
|
|
10
|
+
import {
|
|
11
|
+
Button,
|
|
12
|
+
ButtonGroup,
|
|
13
|
+
Card,
|
|
14
|
+
Fieldset,
|
|
15
|
+
ListLayout,
|
|
16
|
+
Pill,
|
|
17
|
+
Text,
|
|
18
|
+
} from "@slashsuite/ui-react";
|
|
19
|
+
|
|
20
|
+
<ListLayout
|
|
21
|
+
title="Quotes"
|
|
22
|
+
description="Every quote you have sent."
|
|
23
|
+
actions={<Button>New quote</Button>}
|
|
24
|
+
filters={
|
|
25
|
+
<Fieldset label="Status">
|
|
26
|
+
<ButtonGroup>
|
|
27
|
+
<Button variant="outline" size="sm" pressed>
|
|
28
|
+
All
|
|
29
|
+
</Button>
|
|
30
|
+
<Button variant="outline" size="sm" pressed={false}>
|
|
31
|
+
Sent
|
|
32
|
+
</Button>
|
|
33
|
+
</ButtonGroup>
|
|
34
|
+
</Fieldset>
|
|
35
|
+
}
|
|
36
|
+
>
|
|
37
|
+
<Card as="article" title="Naledi Mokoena" status={<Pill tone="positive">Accepted</Pill>}>
|
|
38
|
+
<Text>Q-1042 · R 1 240 / mo</Text>
|
|
39
|
+
</Card>
|
|
40
|
+
<Card as="article" title="Pieter van Wyk" status={<Pill tone="neutral">Sent</Pill>}>
|
|
41
|
+
<Text>Q-1041 · R 860 / mo</Text>
|
|
42
|
+
</Card>
|
|
43
|
+
</ListLayout>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Full page
|
|
47
|
+
A whole list page: the shell with its brand and nav, then the layout with its filters and rows.
|
|
48
|
+
```tsx
|
|
49
|
+
import {
|
|
50
|
+
AppShell,
|
|
51
|
+
Button,
|
|
52
|
+
ButtonGroup,
|
|
53
|
+
Card,
|
|
54
|
+
Fieldset,
|
|
55
|
+
ListLayout,
|
|
56
|
+
Tabs,
|
|
57
|
+
Text,
|
|
58
|
+
} from "@slashsuite/ui-react";
|
|
59
|
+
|
|
60
|
+
<AppShell
|
|
61
|
+
brand={<a href="#">Hack Cove</a>}
|
|
62
|
+
nav={
|
|
63
|
+
<Tabs
|
|
64
|
+
label="Main"
|
|
65
|
+
items={[
|
|
66
|
+
{ label: "Quotes", href: "#quotes", selected: true },
|
|
67
|
+
{ label: "Clients", href: "#clients" },
|
|
68
|
+
]}
|
|
69
|
+
/>
|
|
70
|
+
}
|
|
71
|
+
>
|
|
72
|
+
<ListLayout
|
|
73
|
+
title="Quotes"
|
|
74
|
+
description="Every quote you have sent."
|
|
75
|
+
actions={<Button>New quote</Button>}
|
|
76
|
+
filters={
|
|
77
|
+
<Fieldset label="Status">
|
|
78
|
+
<ButtonGroup>
|
|
79
|
+
<Button variant="outline" size="sm" pressed>
|
|
80
|
+
All
|
|
81
|
+
</Button>
|
|
82
|
+
<Button variant="outline" size="sm" pressed={false}>
|
|
83
|
+
Sent
|
|
84
|
+
</Button>
|
|
85
|
+
<Button variant="outline" size="sm" pressed={false}>
|
|
86
|
+
Accepted
|
|
87
|
+
</Button>
|
|
88
|
+
</ButtonGroup>
|
|
89
|
+
</Fieldset>
|
|
90
|
+
}
|
|
91
|
+
>
|
|
92
|
+
<Card as="article">
|
|
93
|
+
<Text strong>Naledi Mokoena</Text>
|
|
94
|
+
<Text>Q-1042 · R 1 240 / mo</Text>
|
|
95
|
+
</Card>
|
|
96
|
+
<Card as="article">
|
|
97
|
+
<Text strong>Pieter van Wyk</Text>
|
|
98
|
+
<Text>Q-1041 · R 860 / mo</Text>
|
|
99
|
+
</Card>
|
|
100
|
+
</ListLayout>
|
|
101
|
+
</AppShell>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Do
|
|
105
|
+
- Put the page's title, `description` and primary `actions` in the header props; `breadcrumbs` and `tabs` go there too.
|
|
106
|
+
- `filters` sit between the header and the list: a `Fieldset` of pressed-toggle `Button`s in a `ButtonGroup`.
|
|
107
|
+
- The items are the `children`, one `Card` per item, or a `Table`; the layout spaces them.
|
|
108
|
+
- Give `empty` an `EmptyState` that says what is missing and what to do next: it shows when there are no children, and with no `empty` an empty list is a blank page.
|
|
109
|
+
|
|
110
|
+
### Don't
|
|
111
|
+
- Do not build the header and the list by hand with `PageHeader` and `Stack`: the layout is the one right header, filters and list.
|
|
112
|
+
|
|
113
|
+
A one-off header and stack drifts from every other list page; `ListLayout` is the one header, filters and list.
|
|
114
|
+
```tsx
|
|
115
|
+
import { Card, PageHeader, Stack, Text } from "@slashsuite/ui-react";
|
|
116
|
+
|
|
117
|
+
<Stack>
|
|
118
|
+
<PageHeader title="Quotes" description="Every quote you have sent." />
|
|
119
|
+
<Card as="article" title="Naledi Mokoena">
|
|
120
|
+
<Text>Q-1042 · R 1 240 / mo</Text>
|
|
121
|
+
</Card>
|
|
122
|
+
</Stack>
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
A muted line as `empty` says nothing is here and offers no way forward: a dead end.
|
|
126
|
+
```tsx
|
|
127
|
+
import { ListLayout, Text } from "@slashsuite/ui-react";
|
|
128
|
+
|
|
129
|
+
<ListLayout
|
|
130
|
+
title="Quotes"
|
|
131
|
+
description="Every quote you have sent."
|
|
132
|
+
empty={<Text tone="muted">No quotes yet.</Text>}
|
|
133
|
+
/>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Accessibility
|
|
137
|
+
- The title is the page's `h1`.
|
|
138
|
+
- `filters` and `children` render as given, so each filter group keeps its own `fieldset` and legend.
|
|
139
|
+
- `data-*` and `aria-*` go on the list's wrapper.
|
|
140
|
+
|
|
141
|
+
### Props
|
|
142
|
+
### ListLayout
|
|
143
|
+
A list page: header, an optional `filters` slot, then the list, or `empty` when there are no children. While `loading` it owns the wait and passes it to everything inside, the header too. With no children yet it draws a card of row bones, never `empty`.
|
|
144
|
+
- actions: ReactNode. Right of the title on `sm` and up, below it on a phone.
|
|
145
|
+
- breadcrumbs: ReactNode. A `Breadcrumbs` above the title.
|
|
146
|
+
- description: ReactNode. The lede under the title: a `Lead`, so it outranks the body text after it.
|
|
147
|
+
- empty: ReactNode. Shown in place of `children` when there are none (no rows, an empty array, `null`): an `EmptyState`.
|
|
148
|
+
- filters: ReactNode. A row between the header and the list, e.g. a `Fieldset` of chips or an `Input type="search"`.
|
|
149
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
150
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
151
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
152
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
153
|
+
- tabs: ReactNode. A `Tabs` (or similar) under the title.
|
|
154
|
+
- title: ReactNode (required). The page's `h1`.
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
## ListRow
|
|
2
|
+
|
|
3
|
+
Group: Data
|
|
4
|
+
|
|
5
|
+
When to use: A short list where each row opens something, toggles a section or holds its own buttons.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Table (table.md): The records are read and compared across columns.
|
|
9
|
+
- KeyValueList (key-value-list.md): One record's fields, each label beside its value.
|
|
10
|
+
- MetaList (meta-list.md): A few facts inline on one line, not rows to open.
|
|
11
|
+
|
|
12
|
+
### The one right way
|
|
13
|
+
Rows sit in a `Card flush`, and `divided` draws the line between them on every row after the first.
|
|
14
|
+
```tsx
|
|
15
|
+
import { Card, ListRow } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
<Card flush>
|
|
18
|
+
<ListRow trailing="R 9 500">Rent</ListRow>
|
|
19
|
+
<ListRow divided trailing="R 1 850">
|
|
20
|
+
Transport
|
|
21
|
+
</ListRow>
|
|
22
|
+
<ListRow divided href="#bills" trailing="3">
|
|
23
|
+
Bills
|
|
24
|
+
</ListRow>
|
|
25
|
+
</Card>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Do
|
|
29
|
+
- Put the rows in a `Card flush` and set `divided` on every row after the first. `trailing` is a value, a count or a `Pill`; `leading` is an `Avatar` or an icon.
|
|
30
|
+
- A row with `onClick` is a button; with `href` it is a link. `external` opens a link in a new tab.
|
|
31
|
+
- `expanded` makes the row the header of a collapsible section: you own the state and the section, and pass `aria-controls` to name it.
|
|
32
|
+
- `selected` marks the one row whose detail is open; set it on a single row of a list. `focused` marks the row the keyboard cursor is on in a list you move through yourself: an inset accent ring, apart from `selected`'s fill.
|
|
33
|
+
- A button row (`onClick`) or a link row (`href`) can hold its own link or button in `trailing`: it sits above the row's button or link and takes its own click, with no class from you, so a row that selects can still carry a "View" link to its page. A row with no `href` and no `onClick` has no action of its own: its buttons go in `actions`, after `trailing`. `revealOnHover` shows them only on hover or focus, so a long list is not a wall of buttons.
|
|
34
|
+
- A row's own link or button goes in `trailing`, never in the label. `size="sm"` is the dense padding for a list that must fit more rows, `size="lg"` the roomy one for a short list of big targets; `md` is the default.
|
|
35
|
+
- A compact bordered list for read-only data, such as the lines of a split, is a `Card flush` around rows with no action at `size="sm"`, `divided` after the first, with the amount in `trailing`. There is no separate part: a row with no action has no hover fill and no click target.
|
|
36
|
+
- Records with several columns to compare are a `Table`, not rows.
|
|
37
|
+
|
|
38
|
+
### Don't
|
|
39
|
+
- Do not add your own indent or a wrapper around the row.
|
|
40
|
+
|
|
41
|
+
Rows in a Card that is not `flush` sit inside its padding, so the hover fill stops short of the edges and the lines do not run across.
|
|
42
|
+
```tsx
|
|
43
|
+
import { Card, ListRow } from "@slashsuite/ui-react";
|
|
44
|
+
|
|
45
|
+
<Card>
|
|
46
|
+
<ListRow trailing="R 9 500">Rent</ListRow>
|
|
47
|
+
<ListRow divided trailing="R 1 850">
|
|
48
|
+
Transport
|
|
49
|
+
</ListRow>
|
|
50
|
+
</Card>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
A row that silently ignores its click leaves the person tapping it again.
|
|
54
|
+
```tsx
|
|
55
|
+
import { Card, ListRow } from "@slashsuite/ui-react";
|
|
56
|
+
|
|
57
|
+
<Card flush>
|
|
58
|
+
<ListRow onClick={() => undefined} trailing="R 1 850">
|
|
59
|
+
Rent
|
|
60
|
+
</ListRow>
|
|
61
|
+
<ListRow divided onClick={() => undefined} trailing="R 640">
|
|
62
|
+
Water
|
|
63
|
+
</ListRow>
|
|
64
|
+
</Card>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Accessibility
|
|
68
|
+
- A button row is a `<div>` with a native `<button type="button">` stretched over it, named by the label alone; a link row is a `<div>` with a real link stretched over it, named by the whole row; a row with no `href` and no `onClick` is a plain `<div>` with no click target.
|
|
69
|
+
- `selected` sets `aria-current="true"` on the row.
|
|
70
|
+
- `expanded` sets `aria-expanded` and draws a chevron, which is hidden from assistive tech.
|
|
71
|
+
- A button or link row has a focus ring from the component; a button row's `disabled` fades the row and disables its button, so a tap on the row itself does nothing; a link or button in `trailing` still works.
|
|
72
|
+
- A button row with `disabledReason` fades and its button is `aria-disabled`, still in the tab order; a click, Enter and Space do nothing, and the reason shows as a tooltip on hover, keyboard focus and a tap, read out as its description (the native `title` without CSS anchor positioning).
|
|
73
|
+
- `revealOnHover` actions appear when the row is hovered or has focus inside it, so a keyboard user can reach them, and they are always shown on a touch screen.
|
|
74
|
+
|
|
75
|
+
### Props
|
|
76
|
+
### ListRow
|
|
77
|
+
A full-width row that runs `onClick` (or, with `href`, opens a link) with a hover fill, a left-aligned label and `trailing` content at the far end. The row is a `<div>` with its `<button>` or link stretched over it, so a tap anywhere on the row runs it; a `TextLink`, `Button` or `Checkbox` in the row (in `trailing`, say a "View" link on a row that selects) sits above it and is clickable on its own. A button row's button is named by the label alone. With `expanded` it is the header of a collapsible section: `aria-expanded` and a chevron. Rows sit in a `Card flush`; `divided` draws the line between them, on each row after the first. `secondary` is a second, muted line under the label. `leading` is content before the label (`leadingWidth="thumbnail"` gives it a fixed picture width), `selected` marks the row in view, `focused` the one the keyboard cursor is on and `highlighted` fills the row a list follows (`onPointerEnter`, `onPointerLeave` and `onFocus` reach every form; on a button or linked row the pointer handlers go on the row itself). The label is a `<div>`, so it can hold block content (a name over a path). A row with no `href` and no `onClick` is a plain `<div>` with no action of its own, for one that holds its own buttons: `actions` follow `trailing`, and `revealOnHover` shows them only on hover or focus. Such a row also takes a `panel`, content under the row that starts where the label does (a conversation that opens under its chat); `divided` draws the line above the whole row, panel included, so a list of them is `divided={index > 0}` on each. Inside a row a `Stack` is `xs` apart, and a `sm` row makes the buttons in it `sm`. While `loading` an empty label is a bone, and what the row holds waits with it.
|
|
78
|
+
- actions: ReactNode. Buttons for this row, after `trailing`: `Button size="sm"`, `IconButton`.
|
|
79
|
+
- disabledReason: string. Why the row cannot be pressed: it fades, `aria-disabled` and focusable, the reason its tooltip.
|
|
80
|
+
- divided: boolean. A hairline above the row: set it on every row after the first.
|
|
81
|
+
- expanded: boolean. Makes the row a collapsible header: sets `aria-expanded` and shows a chevron that turns down
|
|
82
|
+
when open. The caller owns the state and the section; pass `aria-controls` to name it.
|
|
83
|
+
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
84
|
+
- focused: boolean. Marks the row the keyboard cursor is on, for a list moved with the arrow keys or `j`/`k` while
|
|
85
|
+
focus stays on the list: the focus ring, drawn inside the row. It says nothing to a screen
|
|
86
|
+
reader (move real focus for that) and combines with `selected`.
|
|
87
|
+
- highlighted: boolean. Marks the row a list follows with the pointer and the keyboard alike (set it from
|
|
88
|
+
`onPointerEnter` and `onFocus`): a fill one step deeper than hover, so it shows on a white card
|
|
89
|
+
and on a tinted panel alike. On a static row it shows the fill without `revealOnHover`, and
|
|
90
|
+
shows `actions` that `revealOnHover` hides. `selected` wins.
|
|
91
|
+
|
|
92
|
+
Clear it from `onPointerLeave`.
|
|
93
|
+
- href: string. Makes the row a link to this URL; an in-app path goes through the app's `LinkProvider`.
|
|
94
|
+
- leading: ReactNode. Content before the label: an Avatar, a thumbnail, an icon.
|
|
95
|
+
- leadingWidth: "thumbnail". A fixed width for `leading`, for a thumbnail (an `<img>` fills it), so the labels of rows with
|
|
96
|
+
and without a picture still line up. Without it `leading` is as wide as its content.
|
|
97
|
+
|
|
98
|
+
For a row that shows a screenshot.
|
|
99
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
100
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
101
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
102
|
+
- onClick: MouseEventHandler<HTMLButtonElement> | MouseEventHandler<HTMLAnchorElement>. What the row does when pressed: it makes the row a button.
|
|
103
|
+
- onPointerEnter: PointerEventHandler<HTMLDivElement>. On the row, not its link or button, so a link or button in the row does not count as entering it.
|
|
104
|
+
- onPointerLeave: PointerEventHandler<HTMLDivElement>. On the row, not its link or button, so a link or button in the row does not count as leaving it.
|
|
105
|
+
- panel: ReactNode. Content under the row, lined up with the label rather than the row's edge (past `leading`): the
|
|
106
|
+
panel of a row that opens in place, such as a conversation under its chat. It sits inside the
|
|
107
|
+
row, so `divided`, the fill and `revealOnHover` cover it too. Only a row that is neither a
|
|
108
|
+
button nor a link takes it.
|
|
109
|
+
- revealOnHover: boolean. Hides `actions` until the row is hovered or something in it has focus, so a long list is not a
|
|
110
|
+
wall of buttons. A touch screen has no hover, so they are always shown there.
|
|
111
|
+
- secondary: ReactNode. A second, muted line under the label (a date, a note), like `TableCell`'s `secondary`.
|
|
112
|
+
- selected: boolean. Marks the row in view, the one whose detail is open: an accent fill and `aria-current="true"`.
|
|
113
|
+
Set it on one row of a list.
|
|
114
|
+
- size: "sm" | "md" | "lg" (default md). `sm` is dense padding, `lg` one step roomier than `md`. A `Button`, `IconButton` or `Pill` in a
|
|
115
|
+
`sm` row with no `size` of its own is `sm` too.
|
|
116
|
+
- trailing: ReactNode. Content at the far end of the row: a value, a count, a Pill.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
## Loading
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: Data that is on its way: give the layout or the part `loading` and keep the tree it draws with data.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Give the part `loading` and the same tree it draws with data: the captions it knows stay, and a bone stands where each figure will land. A button lands the data here; an app passes its query's pending flag.
|
|
9
|
+
```tsx
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { Button, Card, KeyValue, KeyValueList, Stack } from "@slashsuite/ui-react";
|
|
12
|
+
|
|
13
|
+
function Example() {
|
|
14
|
+
const [vat, setVat] = useState<string | undefined>(undefined);
|
|
15
|
+
return (
|
|
16
|
+
<Stack gap="md">
|
|
17
|
+
<Button variant="outline" onClick={() => setVat(vat === undefined ? "R 2 400" : undefined)}>
|
|
18
|
+
{vat === undefined ? "Land the data" : "Wait again"}
|
|
19
|
+
</Button>
|
|
20
|
+
<Card>
|
|
21
|
+
<KeyValueList loading={vat === undefined} loadingLabel="Loading the quote">
|
|
22
|
+
<KeyValue label="Customer">{vat && "Cove Hardware"}</KeyValue>
|
|
23
|
+
<KeyValue label="Lines">{vat && "R 16 000"}</KeyValue>
|
|
24
|
+
<KeyValue label="VAT">{vat}</KeyValue>
|
|
25
|
+
</KeyValueList>
|
|
26
|
+
</Card>
|
|
27
|
+
</Stack>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Do
|
|
33
|
+
- Set `loading` on the page layout, or on the one part that waits, and render the same tree you render with data: `<StatTile loading={q.isPending} label="Revenue" value={q.data?.revenue} />`. There is no separate skeleton component to keep in step.
|
|
34
|
+
- One rule for every part: what it has is drawn, and an empty slot (`null`, `undefined`, `false`, an empty string or array) is a bone of that slot's shape. A caption you know stays; the figure you are fetching is a bone. A part whose value is a number (`Badge`, the bars and charts) is all bone while loading, since 0 is a value.
|
|
35
|
+
- A part with nothing in it draws a fixed set of bones of its children's shape: a `ListLayout` with no records a `Card` of three row bones, a `CardGrid` one `Card` of bones per column (three for `auto`), a `Table` whose `TableBody` has no rows five rows with one bone per column, a `Card` three lines of text and a `flush` `Card` three `ListRow` bones, a `Timeline` three items, a `KeyValueList` three rows, a `MetaList` three items, an `AvatarStack` three avatars, a `Legend` three entries, a paragraph three lines and a heading one. There is no count to set.
|
|
36
|
+
- A part's own `loading` wins; left out, it takes the nearest loading layout's or part's, so one `loading` on a layout reaches everything inside. `loading={false}` opts a part out inside a loading page.
|
|
37
|
+
- Loading beats empty: while `loading`, an empty slot is a bone, never the `empty` state.
|
|
38
|
+
- Three words, three meanings: `loading` is data not here yet (a skeleton); `busy` is an action in flight on a control (`Button`, `Switch`, `ChatComposer`); `streaming` is content arriving piece by piece (`ChatMessage`). `NavigationProgress loading` is the bar for a page change, not a skeleton.
|
|
39
|
+
- Take `loading`. Page layouts, each the owner of its page's wait, passing it to everything inside, the header too: `PageHeader`, `ListLayout`, `DetailLayout`, `FormLayout`, `ProseLayout`, `SidebarLayout` (its canvas; the rail is navigation), `FullBleedLayout`, `CenteredLayout` and `CardGrid`. Text: `Text`, `Lead`, `Caption`, `Overline`, `Display`, `PageHeading`, `SectionHeading`, `SubsectionHeading` and `Markdown`. Data and content: `StatTile`, `KeyValueList`, `KeyValue`, `Badge`, `Pill`, `MetaList`, `Card`, `Table` and `TableCell` (`TableHead`, `TableBody`, `TableRow`, `TableFoot`, `TableGroupRow` and `TableHeaderCell` wait with their table), `ListRow`, `Timeline`, `TimelineItem`, `Avatar`, `AvatarStack`, `Image`, `MediaTile`, `ProgressBar`, `SplitBar`, `StackedBar`, `Legend` and `TrendChart`. Forms: `Field` and `FormRowField` draw their label and a bone the height of their control (read from the density around them, so a `sm` card's is `sm`), and `Checkbox`, `Switch`, `RadioGroup` with `Radio`, and `DateField` draw their labels with the box, track, circles or field as bones.
|
|
40
|
+
- Draw as themselves, by design. Actions and navigation are known before the data: `Button`, `ButtonGroup`, `IconButton`, `CopyButton`, `CopyLine`, `ColourSchemeToggle`, `Menu`, `Tabs`, `SegmentedControl`, `Breadcrumbs`, `Pagination`, `TextLink`, `SiteSearch` and `TableExpandCell`; an action that needs the data says why it waits with `disabledReason`. Bare controls hold the caller's own state, and a fetched value waits in its `Field` or `FormRowField`: `Input`, `Select`, `Textarea`, `FileDrop`, `DateRangePicker`, `Fieldset`, `InlineEdit` and `TableEditCell`. Frames and primitives have no data of their own, and what they hold draws its own bones: `AppShell`, `AppShellBrand`, `Container`, `Stack`, `Section`, `Cluster`, `ClusterGrow`, `SideColumn`, `StickyBar`, `Show`, `ScrollStrip`, `FormGrid`, `FormRow`, `Divider`, `Icon`, `Kbd`, `Code`, `Prose`, `BulletList`, `BulletItem`, `Steps`, `Step`, `Hero`, `SiteFooter`, `Callout`, `EmptyState`, `Disclosure` and `LinkProvider`. Overlays open on an action and their contents draw bones: `Dialog`, `Drawer`, `BottomSheet`, `Lightbox`, `FieldDialog` and `ToastRegion`. Static copy and authored code: `ErrorPage`, `NotFound`, `Forbidden`, `Offline`, `Maintenance`, `CodeBlock` and `CodeExample`. In flight on their own terms: `ChatThread`, `ChatMessage` (`streaming`), `ChatComposer` (`busy`), `NavigationProgress`, `PageFade`, `Morph` and `Video` (the browser's poster). `RegionFrame` and `OutlineRegion` pass `loading` to their `<img>` as the native attribute. `SortableList`, `SortableItem` and `SortableSection` need their items to reorder; `ListRow` bones stand in. `DocsLayout` has no loading page yet.
|
|
41
|
+
|
|
42
|
+
### Don't
|
|
43
|
+
- Do not build a grey box by hand or write a "Loading..." `Text`: it drops the captions the reader could already see, and the page jumps when the data lands.
|
|
44
|
+
- Do not hold a skeleton on screen for a minimum time or behind a delay: the part draws what `loading` says, the moment it says it.
|
|
45
|
+
|
|
46
|
+
A "Loading..." line drops every caption the reader could already see, and the page jumps when the rows arrive.
|
|
47
|
+
```tsx
|
|
48
|
+
import { Card, Text } from "@slashsuite/ui-react";
|
|
49
|
+
|
|
50
|
+
<Card>
|
|
51
|
+
<Text tone="muted">Loading...</Text>
|
|
52
|
+
</Card>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
A page swapped for a "Loading..." line loses its header and actions, and jumps when the data lands.
|
|
56
|
+
```tsx
|
|
57
|
+
import { Text } from "@slashsuite/ui-react";
|
|
58
|
+
|
|
59
|
+
<Text tone="muted">Loading quotes...</Text>
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Accessibility
|
|
64
|
+
- The part whose own `loading` is set is the owner: its root has `aria-busy="true"` and holds one visually hidden text, `loadingLabel` ("Loading" by default). Parts that inherit draw bones only, so one wait is one busy region and one announcement.
|
|
65
|
+
- Every bone is `aria-hidden`. A part keeps its role and accessible name while it loads: a heading is still its heading, a `Table` still its table named by its caption.
|
|
66
|
+
- Bones pulse only when the reader allows motion: under `prefers-reduced-motion: reduce` they are still.
|
|
67
|
+
|
|
68
|
+
### Props
|
|
69
|
+
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## Markdown
|
|
2
|
+
|
|
3
|
+
Group: Text
|
|
4
|
+
|
|
5
|
+
When to use: Text that arrives as markdown, such as an agent's summary, shown on a page.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
`Markdown` renders `##` and `###` headings, `-` bullets, `**bold**` and plain paragraphs, as text nodes and never as HTML.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Markdown } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Markdown
|
|
13
|
+
md={
|
|
14
|
+
"## What I did\n- **HC-142** shipped the EmptyState\n- Fixed the Pill label wrap\n\n" +
|
|
15
|
+
"### Next\nReview the Steps copy."
|
|
16
|
+
}
|
|
17
|
+
/>
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Do
|
|
21
|
+
- Pass the markdown as `md`. It renders `##` as a label heading, `###` as a subheading, lines starting `- ` or `* ` as bullets, `**bold**` and plain paragraphs.
|
|
22
|
+
- Nothing else is supported: no `#` title, numbered list, link, code span, table or HTML. Those show as plain text.
|
|
23
|
+
- The text becomes React nodes and never HTML, so untrusted text cannot inject markup.
|
|
24
|
+
- Text you write yourself is not markdown: use `Text`, `BulletList` and the heading components.
|
|
25
|
+
|
|
26
|
+
### Don't
|
|
27
|
+
A `#` title, a numbered list, a link or a code span is not supported: each shows as literal text.
|
|
28
|
+
```tsx
|
|
29
|
+
import { Markdown } from "@slashsuite/ui-react";
|
|
30
|
+
|
|
31
|
+
<Markdown
|
|
32
|
+
md={
|
|
33
|
+
"# What I did\n1. Shipped the EmptyState\n2. Fixed the Pill\n\n" +
|
|
34
|
+
"See [the ticket](https://example.com) and `bun install`."
|
|
35
|
+
}
|
|
36
|
+
/>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Accessibility
|
|
40
|
+
- `##` renders an `h2` and `###` an `h3`, bullets render a `ul` with `li`s, bold a `strong` and a paragraph a `p`.
|
|
41
|
+
- The headings start at `h2`, so the page needs its own `h1` above.
|
|
42
|
+
- `aria-*` and `data-*` go on the root.
|
|
43
|
+
|
|
44
|
+
### Props
|
|
45
|
+
### Markdown
|
|
46
|
+
A small, safe Markdown renderer for short notes: `## ` and `### ` headings, `- ` or `* ` bullets, `**bold**` and paragraphs. Text is rendered as React nodes, never as HTML. While `loading` with no `md` yet it draws a paragraph of bones.
|
|
47
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
48
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
49
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
50
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
51
|
+
- md: string | undefined (required). The Markdown source; while `loading`, none yet is a paragraph of bones.
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
## MediaTile
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A photo or video in a grid or a strip, that opens full size when it is picked: a status, a gallery, an attachment.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Image (image.md): The picture is only shown, with no label, click or remove.
|
|
9
|
+
- Video (video.md): The video plays in the page: the player.
|
|
10
|
+
- Lightbox (lightbox.md): One photo or video opens over the page, at full size.
|
|
11
|
+
|
|
12
|
+
### The one right way
|
|
13
|
+
A thumbnail that opens a photo is a `MediaTile` with `onClick` that opens a `Lightbox`, which steps through the set.
|
|
14
|
+
```tsx
|
|
15
|
+
import { useState } from "react";
|
|
16
|
+
import { Cluster, Lightbox, MediaTile } from "@slashsuite/ui-react";
|
|
17
|
+
|
|
18
|
+
function Example() {
|
|
19
|
+
const [at, setAt] = useState<number | null>(null);
|
|
20
|
+
const photo = at === null ? undefined : sampleScenes[at];
|
|
21
|
+
return (
|
|
22
|
+
<>
|
|
23
|
+
<Cluster>
|
|
24
|
+
{sampleScenes.map((scene, index) => (
|
|
25
|
+
<MediaTile
|
|
26
|
+
key={scene.src}
|
|
27
|
+
src={scene.src}
|
|
28
|
+
alt={scene.alt}
|
|
29
|
+
label="Anna"
|
|
30
|
+
caption={`09:1${index}`}
|
|
31
|
+
onClick={() => setAt(index)}
|
|
32
|
+
/>
|
|
33
|
+
))}
|
|
34
|
+
</Cluster>
|
|
35
|
+
{at !== null && photo && (
|
|
36
|
+
<Lightbox
|
|
37
|
+
label={photo.alt}
|
|
38
|
+
title="Anna"
|
|
39
|
+
caption={photo.caption}
|
|
40
|
+
onClose={() => setAt(null)}
|
|
41
|
+
onPrevious={at > 0 ? () => setAt(at - 1) : undefined}
|
|
42
|
+
onNext={at < sampleScenes.length - 1 ? () => setAt(at + 1) : undefined}
|
|
43
|
+
>
|
|
44
|
+
<img src={photo.src} alt={photo.alt} />
|
|
45
|
+
</Lightbox>
|
|
46
|
+
)}
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Do
|
|
53
|
+
- `src` and `alt` are the thumbnail, cropped to `aspect` (portrait `3:4` by default; `natural` shows the picture whole at its own proportions, as a chat does) at `width` (`md`, 160px, by default; `full` fills a grid cell).
|
|
54
|
+
- `label` is a short line on the picture's bottom edge, on the same near-black scrim as the `Lightbox`, in every theme: who posted it, or "Earlier". `caption` is muted text under the picture, such as when.
|
|
55
|
+
- `video` draws a play mark; say it is a video in `alt` too.
|
|
56
|
+
- `onRemove` adds a round remove button on the picture's corner, named "Remove" and `alt`: a photo attached to a form, until it is sent. It is its own button beside the tile's, so the tile can still open a `Lightbox`.
|
|
57
|
+
- `onClick` makes the whole tile one button. Open a `Lightbox` from it, and keep the open item in your own state. Without `onClick` the tile is a plain block.
|
|
58
|
+
- With no `src`, the tile shows the `Image` placeholder, so a tile that is only a label ("Earlier") needs no picture.
|
|
59
|
+
- A row of tiles that runs past the page is a `ScrollStrip`; a wrapping grid is a `CardGrid`.
|
|
60
|
+
- A picture that is only shown, with no label, click or remove, is an `Image`.
|
|
61
|
+
|
|
62
|
+
### Don't
|
|
63
|
+
A bare `<img>` in a button has no shape, frame or label, and no placeholder when it fails to load.
|
|
64
|
+
```tsx
|
|
65
|
+
<button type="button">
|
|
66
|
+
<img src={sampleScenes[0]?.src} alt={sampleScenes[0]?.alt} width={120} />
|
|
67
|
+
</button>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Accessibility
|
|
71
|
+
- A tile with `onClick` is a real `<button type="button">` named by `alt` and `label`, with the focus ring from the component; Enter and Space open it.
|
|
72
|
+
- The play mark is decorative and hidden from a screen reader.
|
|
73
|
+
- `id`, `data-*` and `aria-*` go on the tile.
|
|
74
|
+
|
|
75
|
+
### Props
|
|
76
|
+
### MediaTile
|
|
77
|
+
A thumbnail tile: a picture in a fixed shape with an optional label on its bottom edge and a caption under it. With `onClick` the whole tile is one button, which is how a grid or a `ScrollStrip` of media opens each item in a `Lightbox`. The label sits on the same near-black media scrim as the Lightbox, in every theme. The thumbnail is cropped to fill its shape, or with `aspect="natural"` shown whole. With `href` the whole tile is one link instead. `onRemove` adds a remove button for a tile that can be taken back out. While `loading` with no `src` yet the picture is a bone of its shape.
|
|
78
|
+
- alt: string (required). What the thumbnail shows; it is the tile's name, with `label`.
|
|
79
|
+
- aspect: "square" | "4:3" | "3:2" | "16:9" | "3:4" | "9:16" | "natural" (default 3:4). The shape of the thumbnail, as `Image`'s `aspect`; `natural` keeps the picture's own
|
|
80
|
+
proportions (a chat image) and crops nothing.
|
|
81
|
+
- caption: ReactNode. Muted text under the picture, e.g. when.
|
|
82
|
+
- external: boolean (default false). Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
83
|
+
- href: string. Makes the whole tile one link, named as the button form is; an in-app path goes through `LinkProvider`.
|
|
84
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
85
|
+
- label: ReactNode. A short line on the bottom edge of the picture, on the media scrim: who posted it, or "Earlier".
|
|
86
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
87
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
88
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
89
|
+
- onClick: MouseEventHandler<HTMLButtonElement>. Makes the whole tile one button; open a `Lightbox` from it. Without it (or `href`) the
|
|
90
|
+
tile is a plain, non-interactive block.
|
|
91
|
+
- onRemove: (() => void). Adds a round remove button on the picture's top-right corner, named `removeLabel` and `alt`: a
|
|
92
|
+
photo attached to a form, until it is sent. It is its own button, beside the tile's, so a tile
|
|
93
|
+
with `onClick` still opens its `Lightbox`.
|
|
94
|
+
- removeLabel: string (default Remove). The remove button's word, before `alt` in its name and alone as its tooltip.
|
|
95
|
+
- src: string. The thumbnail, a local path or a data URL. Left out, or if it fails to load, a placeholder shows.
|
|
96
|
+
- video: boolean (default false). Draws a play mark on the thumbnail: the tile opens a video, not a photo. Say so in `alt` too.
|
|
97
|
+
- width: "sm" | "md" | "lg" | "full" (default md). `sm` 96px, `md` 160px or `lg` 256px wide; `full` fills the parent (a tile in a grid).
|