@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
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
> **Agents:** the docs for this version ship in this package as Markdown. Read `agent-docs/llms.txt` (the index) first, then only the `agent-docs/components/<slug>.md` pages your task needs.
|
|
2
|
+
|
|
1
3
|
# @slashsuite/ui-react
|
|
2
4
|
|
|
3
5
|
UISlash React components, written against Tailwind v4 utilities. They carry no theme: pair them
|
|
@@ -5,7 +7,8 @@ with a theme from `@slashsuite/themes`, such as `@slashsuite/themes/catppuccin-m
|
|
|
5
7
|
class on `<html>` (`.dark` for Mocha). With no theme they render in Tailwind's own default colours,
|
|
6
8
|
a plain light look; it works, but it is not a look UISlash designs or checks.
|
|
7
9
|
|
|
8
|
-
Status: `0.x`, published to npm. License: MIT.
|
|
10
|
+
Status: `0.x`, published to npm. License: MIT. This package was `@hackcove/ui-react` up to 0.11.2; that name is deprecated,
|
|
11
|
+
and `MIGRATING.md` has the switch.
|
|
9
12
|
|
|
10
13
|
## Install
|
|
11
14
|
|
|
@@ -27,6 +30,16 @@ in the stylesheet that imports Tailwind (the path is relative to that file):
|
|
|
27
30
|
@source "../node_modules/@slashsuite/ui-react/dist";
|
|
28
31
|
```
|
|
29
32
|
|
|
33
|
+
## Agent skill
|
|
34
|
+
|
|
35
|
+
The package ships a skill, `skills/uislash/SKILL.md`, that tells a coding agent (Claude Code, or any agent that reads `.claude/skills`) to build with the docs that ship in the package, `agent-docs/`, and to typecheck when it is done. Copy it into your app once, from the app's root:
|
|
36
|
+
|
|
37
|
+
```sh
|
|
38
|
+
mkdir -p .claude/skills && cp -r node_modules/@slashsuite/ui-react/skills/uislash .claude/skills/
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Copy it again after an upgrade, so it matches the installed docs.
|
|
42
|
+
|
|
30
43
|
## Use
|
|
31
44
|
|
|
32
45
|
```tsx
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
## AppShell
|
|
2
|
+
|
|
3
|
+
Group: Layout
|
|
4
|
+
|
|
5
|
+
When to use: Every page of an app sits in one `AppShell`; it is the only place the page canvas, the font and the header live.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
`AppShellBrand` makes the logo and the label one link, so the whole brand is the way home; `collapse` leaves only the logo below `sm`.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Avatar, AppShellBrand } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<AppShellBrand href="#" logo={<Avatar name="Quotes" size="sm" />} label="Quotes" collapse />
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
### Do
|
|
16
|
+
- Fill the slots and write no wrapper: `brand`, `nav` (`Tabs` of links), `controls` (a picker, a `ColourSchemeToggle`), then an optional `subnav` row and `footer`.
|
|
17
|
+
- `brand` is an `AppShellBrand`: logo and label in one link. `collapse` leaves only the logo below `sm`. `logoSize` is `sm` (20px), `md` (24px, the default, an `Avatar size="sm"`) or `lg` (32px); an `<img>` or `<svg>` logo fills it.
|
|
18
|
+
- A header control that only matters on a wide screen, such as the viewer's name, goes in a `Show from="sm"` (or `md`, `lg`) in `controls`; put a `Cluster` inside it to keep an avatar and a name together.
|
|
19
|
+
- Header, main and footer each sit in a `Container`, so a page never sets its own width or padding.
|
|
20
|
+
- `controls` stay in the row at every width, so keep them few (a theme toggle, the viewer's avatar). Pickers and actions that do not fit a phone row go in `menuControls`: from `md` they sit in the row after `controls`, and below `md` they are at the top of the Menu.
|
|
21
|
+
- `nav` and `subnav` fold into one Menu button below `md`, and the `nav` also from `md` whenever it does not fit the row, so a nav of any length stays reachable with no sideways scroll; `menuLabel` renames the button (`Menu` by default), for a translated app.
|
|
22
|
+
- Put `appShellRootClassFor(scheme)` on the app's own `<html>`. `AppShell` never touches `<html>`.
|
|
23
|
+
- A theme sets the canvas colour and the font, and the shell turns on font smoothing (`antialiased`); the app writes no page background, font or smoothing rule.
|
|
24
|
+
|
|
25
|
+
### Don't
|
|
26
|
+
- Do not add a `Container` inside the shell.
|
|
27
|
+
|
|
28
|
+
A logo and a name as two separate links are two targets, and the logo link has no name. Put both in `AppShellBrand`.
|
|
29
|
+
```tsx
|
|
30
|
+
import { Avatar, Cluster, TextLink } from "@slashsuite/ui-react";
|
|
31
|
+
|
|
32
|
+
<Cluster gap="xs">
|
|
33
|
+
<a href="#">
|
|
34
|
+
<Avatar name="Quotes" size="sm" />
|
|
35
|
+
</a>
|
|
36
|
+
<TextLink href="#">Quotes</TextLink>
|
|
37
|
+
</Cluster>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
A link written by hand round the logo and the label, navigating in its own click handler, is a wrapper per link with no brand focus ring. Set the router once on `LinkProvider` and give `AppShellBrand` its `href`.
|
|
41
|
+
```tsx
|
|
42
|
+
import { Avatar, Cluster, Text } from "@slashsuite/ui-react";
|
|
43
|
+
|
|
44
|
+
<a
|
|
45
|
+
href="#/"
|
|
46
|
+
onClick={(event) => {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
history.pushState(null, "", "#/");
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
<Cluster gap="xs">
|
|
52
|
+
<Avatar name="Quotes" size="sm" />
|
|
53
|
+
<Text as="span">Quotes</Text>
|
|
54
|
+
</Cluster>
|
|
55
|
+
</a>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Shown at every width, the name pushes the nav and the toggle off a phone's header row.
|
|
59
|
+
```tsx
|
|
60
|
+
import { Avatar, Cluster, Text } from "@slashsuite/ui-react";
|
|
61
|
+
|
|
62
|
+
<Cluster gap="xs">
|
|
63
|
+
<Avatar name="Ada Lovelace" size="sm" />
|
|
64
|
+
<Text>Ada Lovelace</Text>
|
|
65
|
+
</Cluster>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
A hand-written `scroll-margin` guesses the header's height and goes stale when a subnav or the notch changes it. Leave the offset to the shell.
|
|
69
|
+
```tsx
|
|
70
|
+
import { Stack, Text, TextLink } from "@slashsuite/ui-react";
|
|
71
|
+
|
|
72
|
+
<Stack gap="sm">
|
|
73
|
+
<TextLink href="#plans">See pricing</TextLink>
|
|
74
|
+
<section id="plans" style={{ scrollMarginTop: 80 }}>
|
|
75
|
+
<Text strong>Pricing</Text>
|
|
76
|
+
<Text>Pay for what you review.</Text>
|
|
77
|
+
</section>
|
|
78
|
+
</Stack>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Accessibility
|
|
82
|
+
- The header is a `<header>` (the banner landmark), main is `<main>` and the footer is `<footer>`.
|
|
83
|
+
- `AppShellBrand` is one link named by its `label`; the logo is `aria-hidden`. With `collapse` the label is visually hidden below `sm` and still names the link.
|
|
84
|
+
- On a phone `nav` and `subnav` sit behind one Menu button, a native disclosure: it opens with no JavaScript, from the keyboard (Enter or Space) and for a screen reader, Escape closes it and returns to the button, and following a link closes it. The panel is not in the header's flow, so the header is the same height on every page.
|
|
85
|
+
- `menuControls` render once, in the Menu below `md` and in the row from `md`, so a field keeps its value and its label names one control. A crowded `controls` clips beside the Menu button, never over it, so the nav stays reachable.
|
|
86
|
+
- From `md` a `nav` too wide for the header row folds into the Menu instead of scrolling, and comes back when the screen is wide enough. A `subnav` row that is wider than the screen scrolls sideways and never wraps; a link that takes focus scrolls into view, and the side with more to reach fades out.
|
|
87
|
+
- Give `nav` and `subnav` `Tabs` of links, so each is a labelled `<nav>`.
|
|
88
|
+
|
|
89
|
+
### Props
|
|
90
|
+
### AppShell
|
|
91
|
+
The page frame: it paints the page canvas and sets the type face, ink and font smoothing (`antialiased`), so an app writes no page-background or font rule of its own (a theme remaps the canvas and the font stacks). A sticky one-row header, an optional second `subnav` row, the main area and an optional footer. Header, main and footer each sit in a `Container`, so pages never set their own width or padding. `bleed` drops main's Container (the header keeps its own), for a layout that needs the whole width (`FullBleedLayout`). Main is a flex column. `SidebarLayout` needs no `bleed`: its rail and canvas share the header's Container. The header row is laid out by its slots, left to right: `brand`, `nav`, then `header` (anything the slots do not cover), then `controls`, pushed to the end. An app writes no wrapper or styling for any of them: an item that only fits a wide screen goes in a `Show from`. A bar that sticks under the header as the page scrolls is a `StickyBar`. On a phone (below `md`) the header is one 56px row at every page: `brand`, `header`, `controls` and a "Menu" button (`menuLabel`), and `nav` and `subnav` move into that menu, so every link is reachable and nothing scrolls sideways. The menu is a native `<details>`, so it works with the keyboard, with a screen reader and on a page that never hydrates. From `md` the header is the row, and the `subnav` row, as they are, except that a `nav` too wide for the row folds into the Menu and comes back when the screen is wide enough (measured, with script; a `subnav` never folds, it scrolls sideways with a fade). The edges need nothing from the app: with `viewport-fit=cover` every Container clears the safe-area insets at the sides, the header the top one and the shell the bottom one; and an element with an `id` anywhere inside lands below the sticky header when a link or focus scrolls to it. `controls` stay in the row at every width, so keep them few (a theme toggle, the viewer's avatar); on a phone a crowded `controls` clips, and the Menu button is never the part cut off. Pickers and actions that do not fit a phone row go in `menuControls`: rendered once, they sit in the row after `controls` from `md`, and below `md` at the top of the Menu, above `nav` and `subnav`.
|
|
92
|
+
- bleed: boolean (default false). Main without a Container, for a full-bleed layout.
|
|
93
|
+
|
|
94
|
+
For a layout that needs the whole width, such as `FullBleedLayout`; `SidebarLayout` needs no
|
|
95
|
+
`bleed`.
|
|
96
|
+
- brand: ReactNode. The brand: a logo and a name, in the header's brand type, with the gap between them. `AppShellBrand` makes both one link.
|
|
97
|
+
- controls: ReactNode. The end of the row: a picker, a theme toggle. Gap-2, vertically centred; no child shrinks, and a full-width control (a `Select` at its default) sizes to its content.
|
|
98
|
+
- density: "compact". The app's type step, set once here and nowhere else: `compact` sets text, headings and controls
|
|
99
|
+
one step down everywhere inside, for an app's dense chrome. Left out, text is 16px, as a site's.
|
|
100
|
+
- footer: ReactNode. The page footer: small muted text in a `Container`, under a hairline. Hidden in print with `printChrome={false}`.
|
|
101
|
+
- header: ReactNode. The escape hatch: a free node in the header row, after `brand` and `nav`.
|
|
102
|
+
|
|
103
|
+
Only for a node no other slot covers: prefer `brand`, `nav` and `controls`.
|
|
104
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
105
|
+
- menuControls: ReactNode. Pickers and actions that do not fit a phone row, such as a project `Select` and a Sign out
|
|
106
|
+
`Button`. From `md` they sit in the row after `controls`; below `md` they are at the top of the
|
|
107
|
+
Menu, above `nav` and `subnav`. Rendered once, so a field keeps its state and ids stay unique.
|
|
108
|
+
`controls` stay in the row at every width, so keep those few.
|
|
109
|
+
- menuLabel: string (default Menu). The phone menu button's name, for an app in another language. Only drawn below `md`, and only
|
|
110
|
+
when `nav`, `subnav` or `menuControls` is given.
|
|
111
|
+
- nav: ReactNode. The main navigation, e.g. a `Tabs` of links (it is already a `<nav>`). Below `md` it is in the menu.
|
|
112
|
+
- printChrome: boolean (default true). Whether a print shows the header and footer. `false` prints only the page: the header and
|
|
113
|
+
footer are hidden, and main's Container drops its padding (the page margin is then `@page`'s).
|
|
114
|
+
|
|
115
|
+
The screen is unchanged.
|
|
116
|
+
- subnav: ReactNode. A second fixed-height row under the header from `md`, e.g. a `Tabs` of links. Below `md` it is in the menu with `nav`.
|
|
117
|
+
|
|
118
|
+
### AppShellBrand
|
|
119
|
+
The `brand` slot as one link: a logo and a label inside the same `<a>`, so the whole brand is the way home. The label names the link; the logo is decoration and hidden from assistive tech. `collapse` shows only the logo below `sm`, the label staying in the accessible name. An in-app `href` is drawn by the app's router link through `LinkProvider`.
|
|
120
|
+
- collapse: boolean (default false). Below `sm` only the logo shows; the label is visually hidden and still names the link. Needs a `logo`.
|
|
121
|
+
- href: string (required). Where the brand links, usually the app's home (`/`).
|
|
122
|
+
|
|
123
|
+
With a router it goes through the app's `LinkProvider`, like every link.
|
|
124
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
125
|
+
- label: ReactNode (required). The name beside the logo. It is the link's accessible name.
|
|
126
|
+
- logo: ReactNode. The mark before the label, e.g. an `Avatar` or an `<img>`.
|
|
127
|
+
- logoSize: "sm" | "md" | "lg" (default md). The logo slot's box: sm 20px, md 24px (the default, an `Avatar size="sm"`), lg 32px. An `<img>` or `<svg>` logo fills it.
|
|
128
|
+
|
|
129
|
+
### Types
|
|
130
|
+
- AppShellDensity: `"compact"`. The type step an app sets once on its `AppShell`: `compact` is one step down for the whole app.
|
|
131
|
+
|
|
132
|
+
### Functions
|
|
133
|
+
- appShellRootClassFor: `appShellRootClassFor(scheme: ColourScheme, schemes?: ColourSchemeClasses): string`. Everything the app's `<html>` takes from the scheme the server knows: that scheme's class and the class that always reserves the scrollbar, so centred content does not shift between a short page and a long one.
|
|
134
|
+
```tsx
|
|
135
|
+
<html className={appShellRootClassFor(scheme, schemes)}>
|
|
136
|
+
```
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
## AvatarStack
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: Who is in something (a team, the reviewers, the people on a page) where one row says it.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
With many people, `max` keeps the row short and the "+N" says how many more there are.
|
|
9
|
+
```tsx
|
|
10
|
+
import { AvatarStack } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<AvatarStack
|
|
13
|
+
items={[
|
|
14
|
+
{ name: "Ada Lovelace" },
|
|
15
|
+
{ name: "Grace Hopper" },
|
|
16
|
+
{ name: "Linus Torvalds" },
|
|
17
|
+
{ name: "Margaret Hamilton" },
|
|
18
|
+
{ name: "Dennis Ritchie" },
|
|
19
|
+
{ name: "Ken Thompson" },
|
|
20
|
+
]}
|
|
21
|
+
max={4}
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Do
|
|
26
|
+
- Pass `items`, each with the full `name` and an optional local `src`, as for `Avatar`.
|
|
27
|
+
- Each avatar overlaps the one before it, in a ring in the page colour that keeps them apart. Draw no ring or overlap of your own.
|
|
28
|
+
- `max` shows the first `max` and a "+N" chip of the same size and shape for the rest; leave it off to show everyone.
|
|
29
|
+
- `size` and `shape` are `Avatar`'s and apply to every avatar and the chip: `square` for a stack of orgs or teams.
|
|
30
|
+
|
|
31
|
+
### Don't
|
|
32
|
+
Avatars side by side are a row of separate marks: they take the width of the whole team and read as a list, not a group.
|
|
33
|
+
```tsx
|
|
34
|
+
import { Avatar, Cluster } from "@slashsuite/ui-react";
|
|
35
|
+
|
|
36
|
+
<Cluster gap="xs">
|
|
37
|
+
<Avatar name="Ada Lovelace" />
|
|
38
|
+
<Avatar name="Grace Hopper" />
|
|
39
|
+
<Avatar name="Linus Torvalds" />
|
|
40
|
+
<Avatar name="Margaret Hamilton" />
|
|
41
|
+
<Avatar name="Dennis Ritchie" />
|
|
42
|
+
<Avatar name="Ken Thompson" />
|
|
43
|
+
</Cluster>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Accessibility
|
|
47
|
+
- The stack is one `role="img"` named by the people in it ("Ada Lovelace, Grace Hopper and 3 more"); the avatars inside are hidden from a screen reader.
|
|
48
|
+
- The +N chip is hidden from a screen reader (the name already counts the rest) and its `title` lists who it stands for.
|
|
49
|
+
- `aria-*` and `data-*` props go on the root element.
|
|
50
|
+
|
|
51
|
+
### Props
|
|
52
|
+
### AvatarStack
|
|
53
|
+
Members as a row of overlapping avatars, each in a ring in the page colour that separates it from the next. With `max`, the first `max` show and a "+N" chip of the same size and shape stands for the rest. The row is one image to assistive tech, named by the people in it. While `loading` with no `items` yet it draws three avatar bones.
|
|
54
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
55
|
+
- items: readonly AvatarStackPerson[] (required). Who is in the stack, in order. Give each person's full name, as for `Avatar`.
|
|
56
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
57
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
58
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
59
|
+
- max: number. How many avatars show before a "+N" chip takes the rest. Without it every person shows.
|
|
60
|
+
- shape: "round" | "square" (default round). `square` for a stack of orgs or teams, as `Avatar`'s `shape`.
|
|
61
|
+
- size: "sm" | "md" | "lg" | "xs" | "xl" | "2xl" | "3xl" (default md). The size of every avatar and of the chip, as `Avatar`'s `size`.
|
|
62
|
+
|
|
63
|
+
### Types
|
|
64
|
+
- AvatarStackPerson: `{ name: string; src?: string }`. One member of an `AvatarStack`: the same `name` and optional local `src` an `Avatar` takes.
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
## Avatar
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: Marking who did something or who owns something, next to their name.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Image (image.md): The picture is not a person: a photo, a screenshot or an illustration.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
Give the person's full name every time: the same name gets the same colour and initials in every list and header.
|
|
12
|
+
```tsx
|
|
13
|
+
import { Avatar, Cluster } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<Cluster>
|
|
16
|
+
<Avatar name="Ada Lovelace" />
|
|
17
|
+
<Avatar name="Ada Lovelace" size="lg" />
|
|
18
|
+
<Avatar name="Grace Hopper" />
|
|
19
|
+
</Cluster>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Do
|
|
23
|
+
- Pass the person's full `name`, the same string everywhere: the colour and the initials are worked out from it, so one person looks the same in every list and header.
|
|
24
|
+
- `size` is `xs` (16px, for an inline mention in a line of text), `sm`, `md` (default), `lg`, `xl`, `2xl` (64px) or `3xl` (96px); use `sm` or `md` in a row and a larger one at the head of a profile.
|
|
25
|
+
- `src` is the person's photo, as a path your app serves. It replaces the initials, and the Avatar never loads an image from another server on its own, so use your own local image. If the photo fails to load, the initials show instead.
|
|
26
|
+
- `shape="square"` is for an org, a team or a project, not a person: rounded corners that scale with the size. Round (the default) is a person.
|
|
27
|
+
- `onClick` makes the whole Avatar one button, for a profile or an account menu: it is named by `name`, keeps its shape and takes the focus ring. Without it the Avatar is a mark, and a click handler on it would be one no keyboard can reach.
|
|
28
|
+
- Several people as one group is an `AvatarStack`, not a row of Avatars.
|
|
29
|
+
- Put the person's name beside the Avatar as text; the Avatar is a mark, not a label.
|
|
30
|
+
|
|
31
|
+
### Don't
|
|
32
|
+
The colour comes from the name, so "Ada" in one place and "A. Lovelace" in another read as two different people.
|
|
33
|
+
```tsx
|
|
34
|
+
import { Avatar, Cluster } from "@slashsuite/ui-react";
|
|
35
|
+
|
|
36
|
+
<Cluster>
|
|
37
|
+
<Avatar name="Ada" />
|
|
38
|
+
<Avatar name="A. Lovelace" />
|
|
39
|
+
</Cluster>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
An initials Avatar on its own is `aria-hidden`: it names no one to a screen reader. Put the name beside it.
|
|
43
|
+
```tsx
|
|
44
|
+
import { Avatar } from "@slashsuite/ui-react";
|
|
45
|
+
|
|
46
|
+
<Avatar name="Ada Lovelace" />
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Accessibility
|
|
51
|
+
- Initials are drawn in a `<span>` with `aria-hidden="true"` and a `title` of the name, so a screen reader skips them: the name has to be on the page as text.
|
|
52
|
+
- With `src` the Avatar is an `<img>` whose `alt` and `title` are the name.
|
|
53
|
+
- With `onClick` the Avatar is a `<button type="button">` whose `aria-label` is the name, so the initials need no text beside them to name the button. `onError` still reports a photo that fails to load while the page is live, and the initials take its place; a photo that already failed before the page hydrated shows the initials too, without calling `onError`.
|
|
54
|
+
- `aria-*` and `data-*` props go on the root element.
|
|
55
|
+
|
|
56
|
+
### Props
|
|
57
|
+
### Avatar
|
|
58
|
+
A person as a round badge of initials, or as their photo when `src` is given; `shape="square"` marks an org or a team instead. It never loads a remote image on its own: that is a request to another server for decoration, and it makes a screenshot depend on the network. `src` is the app's own local path. With `onClick` the whole Avatar is one button, with `href` one link. A row of overlapping avatars is an `AvatarStack`. While `loading` with an empty `name` it is a bone of its size and shape.
|
|
59
|
+
- external: boolean. Opens in a new tab: adds `target="_blank"` and `rel="noreferrer"`.
|
|
60
|
+
- href: string. Makes the Avatar one link, named by `name`; an in-app path goes through `LinkProvider`.
|
|
61
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
62
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
63
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
64
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
65
|
+
- name: string (required). Whose avatar: its initials, its colour (a hash of the name) and its title or `alt`.
|
|
66
|
+
- onClick: MouseEventHandler<HTMLButtonElement>. Makes the Avatar one button, named by `name`: a person who opens their profile or a menu.
|
|
67
|
+
Without it (or `href`) the Avatar is a plain mark.
|
|
68
|
+
- shape: "round" | "square" (default round). `round` for a person; `square` (rounded corners) for an org or a team, so the two never read
|
|
69
|
+
as each other.
|
|
70
|
+
- size: "sm" | "md" | "lg" | "xs" | "xl" | "2xl" | "3xl" (default md). `xs` 16px, `sm` 24px, `md` 32px, `lg` 40px, `xl` 56px, `2xl` 64px or `3xl` 96px.
|
|
71
|
+
- src: string. The person's photo, a local path. It replaces the initials and is announced as `name`. If it
|
|
72
|
+
fails to load, the initials show instead.
|
|
73
|
+
|
|
74
|
+
### Types
|
|
75
|
+
- AvatarShape: `"round" | "square"`. `round` for a person, `square` (rounded corners that grow with the size) for an org or a team.
|
|
76
|
+
- AvatarSize: `"sm" | "md" | "lg" | "xs" | "xl" | "2xl" | "3xl"`. An Avatar's size: `xs` 16px, `sm` 24px, `md` 32px, `lg` 40px, `xl` 56px, `2xl` 64px, `3xl` 96px.
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
## Badge
|
|
2
|
+
|
|
3
|
+
Group: Content
|
|
4
|
+
|
|
5
|
+
When to use: A count of unread or pending things that sits on an icon button.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Pill (pill.md): The label is words, such as a status.
|
|
9
|
+
|
|
10
|
+
### The one right way
|
|
11
|
+
`count` on an `IconButton` pins the count to the corner and adds it to the button's name ("Alerts, 3").
|
|
12
|
+
```tsx
|
|
13
|
+
import { IconButton } from "@slashsuite/ui-react";
|
|
14
|
+
|
|
15
|
+
<IconButton label="Alerts" count={3} icon="bell" />
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Do
|
|
20
|
+
- On an icon, give the `IconButton` a `count`; it pins the Badge to the corner and puts the count in the button's name.
|
|
21
|
+
- A `count` above 99 reads `99+`.
|
|
22
|
+
- Show a Badge only when there is something to count: a `count` of 0 still draws a `0`, so leave it out instead.
|
|
23
|
+
- A tinted label with words in it is a `Pill`, not a Badge.
|
|
24
|
+
|
|
25
|
+
### Don't
|
|
26
|
+
A Pill beside the button is not pinned to it and a screen reader never hears it as part of the button. Use `count`.
|
|
27
|
+
```tsx
|
|
28
|
+
import { Cluster, IconButton, Pill } from "@slashsuite/ui-react";
|
|
29
|
+
|
|
30
|
+
<Cluster>
|
|
31
|
+
<IconButton label="Alerts" icon="bell" />
|
|
32
|
+
<Pill tone="danger" round>
|
|
33
|
+
3
|
|
34
|
+
</Pill>
|
|
35
|
+
</Cluster>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
A count is not a `Pill`: a Pill is a status label, and it prints `120` where a Badge caps at `99+`.
|
|
39
|
+
```tsx
|
|
40
|
+
import { Cluster, Pill } from "@slashsuite/ui-react";
|
|
41
|
+
|
|
42
|
+
<Cluster>
|
|
43
|
+
<Pill>7</Pill>
|
|
44
|
+
<Pill>120</Pill>
|
|
45
|
+
</Cluster>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Accessibility
|
|
49
|
+
- A Badge is a `<span>` with the number as its text.
|
|
50
|
+
- Inside an `IconButton`, the Badge is `aria-hidden` and the count is part of the button's `aria-label` and `title` ("Alerts, 3"), so it is announced once.
|
|
51
|
+
- `corner` pins the Badge to its nearest positioned parent; `IconButton` already provides one.
|
|
52
|
+
|
|
53
|
+
### Props
|
|
54
|
+
### Badge
|
|
55
|
+
A small red count, 10px, for sitting on an icon. An icon with a count is an `IconButton` with its `count`, which pins the Badge to its corner and puts the count in the button's name. A count above 99 reads `99+`. While `loading` it is a bone of its size: a count is a number, so 0 is a value and not a gap.
|
|
56
|
+
- corner: boolean (default false). Pin it to the top corner at the end edge of its `relative` parent, over the icon.
|
|
57
|
+
- count: number (required). The number shown; above 99 it reads `99+`.
|
|
58
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
59
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
60
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
61
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
## Body text
|
|
2
|
+
|
|
3
|
+
Group: Text
|
|
4
|
+
|
|
5
|
+
When to use: Every run of text that is not a heading: a paragraph, a supporting line, a note, a label, the line in an empty Card.
|
|
6
|
+
|
|
7
|
+
### The one right way
|
|
8
|
+
Body copy is `Text`, with `Text strong` for emphasis inside it and `Caption` for the fine print.
|
|
9
|
+
```tsx
|
|
10
|
+
import { Caption, Stack, Text } from "@slashsuite/ui-react";
|
|
11
|
+
|
|
12
|
+
<Stack gap="xs">
|
|
13
|
+
<Text>
|
|
14
|
+
Invoice{" "}
|
|
15
|
+
<Text as="span" strong>
|
|
16
|
+
INV-204
|
|
17
|
+
</Text>{" "}
|
|
18
|
+
is due on Friday.
|
|
19
|
+
</Text>
|
|
20
|
+
<Caption>Sent 2 minutes ago</Caption>
|
|
21
|
+
</Stack>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Do
|
|
25
|
+
- Set a paragraph in `Text`, a `<p>`. Inside a row, a cell or a sentence it is `Text as="span"`. A block of it stops at a readable line length.
|
|
26
|
+
- Emphasise a run with `Text strong` inside the `Text`: font-medium in the primary ink. Use `Caption` for fine print and metadata, `Caption as="span"` inside a row.
|
|
27
|
+
- Put a `Text` under a heading and `Lead` under a `Display`. `Overline` is the small all-caps label above a group, not a title.
|
|
28
|
+
- A Card, a table or a list with nothing in it yet takes an `EmptyState` in its `empty` slot, which draws it as one muted line there; a muted `Text` is not an empty state.
|
|
29
|
+
- `tone` is the one ink prop: `neutral`, the default, the role's own ink; `muted` and `accent` for the hierarchy of the text; and `positive`, `warn`, `danger` or `info` for what a run means. The words still say it, so colour is never the only signal.
|
|
30
|
+
- `numeric` sets tabular figures so a column of amounts lines up and `mono` the monospace face for an id or a path. `lines` (1 to 4) on `Text` or `Caption` shows at most that many lines and ends in an ellipsis: `lines={1}` cuts a run where its box ends, `lines={3}` clamps a long description. A "Show all" is your own state: `lines={open ? undefined : 3}` beside a `Button`.
|
|
31
|
+
- `align` sets a run at `start`, `center` or `end` of its block, for a table header or a right-hand column. `minWidth="amount"` on `Text` fixes a width and right-aligns a money figure in it, so a column of amounts lines up.
|
|
32
|
+
- `italic` on `Text` or `Caption` sets a muted hint or a caption in italic. `breakWords` breaks a long unbroken string, such as a URL or a token, at the edge of its box.
|
|
33
|
+
|
|
34
|
+
### Don't
|
|
35
|
+
- Never write a bare `<p>`, `<span>`, `<strong>` or `<small>`: they carry none of the theme's type scale or colour.
|
|
36
|
+
|
|
37
|
+
Plain HTML text elements carry no size, weight or colour of the theme. Every run of text is a typography part.
|
|
38
|
+
```tsx
|
|
39
|
+
import { Stack } from "@slashsuite/ui-react";
|
|
40
|
+
|
|
41
|
+
<Stack gap="xs">
|
|
42
|
+
<p>
|
|
43
|
+
Invoice <strong>INV-204</strong> is due on Friday.
|
|
44
|
+
</p>
|
|
45
|
+
<small>Sent 2 minutes ago</small>
|
|
46
|
+
</Stack>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
`muted` and `accent` are the hierarchy of text, not its meaning: an error in the accent ink reads as a link, and in muted grey as nothing at all.
|
|
50
|
+
```tsx
|
|
51
|
+
import { Stack, Text } from "@slashsuite/ui-react";
|
|
52
|
+
|
|
53
|
+
<Stack gap="xs">
|
|
54
|
+
<Text tone="accent">Saved.</Text>
|
|
55
|
+
<Text tone="muted">Could not save: the name is taken.</Text>
|
|
56
|
+
</Stack>
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
An `Overline` is a `span`, not a heading: a section titled by one has no place in the page outline. Use `SectionHeading`.
|
|
60
|
+
```tsx
|
|
61
|
+
import { Overline, Stack, Text } from "@slashsuite/ui-react";
|
|
62
|
+
|
|
63
|
+
<Stack gap="xs">
|
|
64
|
+
<Overline>Invoices</Overline>
|
|
65
|
+
<Text>Two invoices are due this week.</Text>
|
|
66
|
+
</Stack>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
A bare `<p>` in a Card has its own colour and size, so it drifts from every other empty Card: use `Text tone="muted"`.
|
|
70
|
+
```tsx
|
|
71
|
+
import { Card } from "@slashsuite/ui-react";
|
|
72
|
+
|
|
73
|
+
<Card title="Done" count={0}>
|
|
74
|
+
<p>Nothing finished yet.</p>
|
|
75
|
+
</Card>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
One muted line is not a view: with a button under it nothing says what the page is for. Use `EmptyState`.
|
|
79
|
+
```tsx
|
|
80
|
+
import { Button, Stack, Text } from "@slashsuite/ui-react";
|
|
81
|
+
|
|
82
|
+
<Stack>
|
|
83
|
+
<Text tone="muted">No projects yet.</Text>
|
|
84
|
+
<Button>Create a project</Button>
|
|
85
|
+
</Stack>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Accessibility
|
|
89
|
+
- `Text`, `Caption` and `Lead` render a `p`, and `Overline` a `span`. `as` changes the element: a `span` for `Text` or `Caption` inside a row or a sentence, an `li`, or a `label` for an `Overline` with `htmlFor`.
|
|
90
|
+
- `Overline` is a label, not a heading: it adds nothing to the page outline. A small section title is `Section size="sm"`, not `Overline as="h2"`.
|
|
91
|
+
- `lines` sets the full text as the `title` when the content is plain text, so a pointer user can read what was cut. Give a `title` of your own when the content is not.
|
|
92
|
+
- A `tone` changes only the colour. The wording has to carry the meaning.
|
|
93
|
+
|
|
94
|
+
### Props
|
|
95
|
+
### Text
|
|
96
|
+
Running text. A paragraph (`p`; `as="span"` for a run inside a row, a cell or a sentence), text-base/6 normal, secondary (text-sm/5 under an `AppShell density="compact"`, text-base/7 inside a `Prose`). A block of it stops at a readable line length (`max-w-[72ch]`), wherever it sits. `strong` emphasises it: font-medium in the primary ink, unless `tone` says otherwise. `preserveNewlines` keeps the line breaks in the text (a user-typed note); runs of spaces still collapse. `tone` colours it by meaning (`positive` for "Saved.", `danger` for an error, `muted` for a quieter line), `numeric` sets tabular figures, `mono` the monospace face, and `lines` shows at most 1 to 4 lines, ending in an ellipsis (the full text becomes its `title`). `align` sets it at `start`, `center` or `end`. `italic` slants it, `breakWords` breaks a long unbroken string at the edge of its box, and `minWidth="amount"` fixes a width and right-aligns the figure in it (a column of amounts lines up); it does not take `align`.
|
|
97
|
+
- align: "center" | "end" | "start". Set the text at `start`, `center` or `end` of its block. The run becomes block-level, so the
|
|
98
|
+
alignment has a box to act on (a table header cell, a right-hand column).
|
|
99
|
+
- as: ElementType. The element to render (each role has a semantic default); the other props follow it.
|
|
100
|
+
- breakWords: boolean. Break a long unbroken string (a URL, a token) where the container ends, instead of overflowing.
|
|
101
|
+
- italic: boolean. Italic: a muted hint or a caption.
|
|
102
|
+
- lines: 2 | 3 | 4 | 1. Show at most this many lines (1 to 4) and end in an ellipsis: `1` cuts the run where its
|
|
103
|
+
container ends, `2` to `4` wrap and stop. With plain-text content the full text becomes the
|
|
104
|
+
`title`. A "Show all" toggle is the app's own state: `lines={open ? undefined : 3}`.
|
|
105
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
106
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
107
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
108
|
+
- minWidth: "amount". A fixed width: `amount` is a right-aligned money figure, min-w-24, in tabular figures.
|
|
109
|
+
- mono: boolean. The monospace face, for an id, a path or a command.
|
|
110
|
+
- numeric: boolean. Tabular figures, so a column of amounts lines up.
|
|
111
|
+
- preserveNewlines: boolean. Keep the line breaks in the text (a user-typed note); runs of spaces still collapse.
|
|
112
|
+
- strong: boolean. Emphasis: font-medium in the primary ink (`tone` still wins).
|
|
113
|
+
- tone: "neutral" | "info" | "positive" | "warn" | "danger" | "muted" | "accent". The ink: `neutral`, the default, is the role's own; `muted` and `accent` set the hierarchy of
|
|
114
|
+
the text; `positive`, `warn`, `danger` and `info` say what a run means (see `TextTone`).
|
|
115
|
+
|
|
116
|
+
### Caption
|
|
117
|
+
Fine print / metadata. A paragraph (`p`; `as="span"` inline), text-sm/5 normal, tertiary (text-xs/4 under an `AppShell density="compact"`). Takes `tone`, `numeric`, `mono`, `lines` and `align` like `Text`, and `italic` for a muted hint and `breakWords` for a long unbroken string such as a URL.
|
|
118
|
+
- align: "center" | "end" | "start". Set the text at `start`, `center` or `end` of its block. The run becomes block-level, so the
|
|
119
|
+
alignment has a box to act on (a table header cell, a right-hand column).
|
|
120
|
+
- as: ElementType. The element to render (each role has a semantic default); the other props follow it.
|
|
121
|
+
- breakWords: boolean. Break a long unbroken string (a URL, a token) where the container ends, instead of overflowing.
|
|
122
|
+
- italic: boolean. Italic: a muted hint or a caption.
|
|
123
|
+
- lines: 2 | 3 | 4 | 1. Show at most this many lines (1 to 4) and end in an ellipsis: `1` cuts the run where its
|
|
124
|
+
container ends, `2` to `4` wrap and stop. With plain-text content the full text becomes the
|
|
125
|
+
`title`. A "Show all" toggle is the app's own state: `lines={open ? undefined : 3}`.
|
|
126
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
127
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
128
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
129
|
+
- mono: boolean. The monospace face, for an id, a path or a command.
|
|
130
|
+
- numeric: boolean. Tabular figures, so a column of amounts lines up.
|
|
131
|
+
- tone: "neutral" | "info" | "positive" | "warn" | "danger" | "muted" | "accent". The ink: `neutral`, the default, is the role's own; `muted` and `accent` set the hierarchy of
|
|
132
|
+
the text; `positive`, `warn`, `danger` and `info` say what a run means (see `TextTone`).
|
|
133
|
+
|
|
134
|
+
### Overline
|
|
135
|
+
Small all-caps label above a group. `span`, text-xs semibold uppercase, tertiary. `tone`, `numeric`, `mono` and `align` are opt-in, as on `Text`.
|
|
136
|
+
- align: "center" | "end" | "start". Set the text at `start`, `center` or `end` of its block. The run becomes block-level, so the
|
|
137
|
+
alignment has a box to act on (a table header cell, a right-hand column).
|
|
138
|
+
- as: ElementType. The element to render (each role has a semantic default); the other props follow it.
|
|
139
|
+
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
140
|
+
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
141
|
+
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
|
142
|
+
- mono: boolean. The monospace face, for an id, a path or a command.
|
|
143
|
+
- numeric: boolean. Tabular figures, so a column of amounts lines up.
|
|
144
|
+
- tone: "neutral" | "info" | "positive" | "warn" | "danger" | "muted" | "accent". The ink: `neutral`, the default, is the role's own; `muted` and `accent` set the hierarchy of
|
|
145
|
+
the text; `positive`, `warn`, `danger` and `info` say what a run means (see `TextTone`).
|
|
146
|
+
|
|
147
|
+
### Lead
|
|
148
|
+
The supporting sentence under a `Display`. `p`, text-lg/7 normal, secondary.
|
|
149
|
+
- as: ElementType. The element to render (each role has a semantic default); the other props follow it.
|
|
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
|
+
|
|
154
|
+
### Types
|
|
155
|
+
- TextAlign: `"center" | "start" | "end"`. Where a run of text sits across its block.
|
|
156
|
+
- TextLines: `1 | 2 | 3 | 4`. How many lines a clamped run shows before it ends in an ellipsis.
|
|
157
|
+
- TextMinWidth: `"amount"`. A fixed width for a run of text: `amount` is a money figure, right-aligned, at a width that lines a column up.
|
|
158
|
+
- TextTone: `Tone | "accent" | "muted"`. The meaning of a run of inline text: the library's `Tone`, plus `muted` for a quieter line and `accent` for the theme's accent ink. `neutral` (the default) is the role's own ink. Colour alone does not say a meaning, so the words do too.
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
## BottomSheet
|
|
2
|
+
|
|
3
|
+
Group: Feedback
|
|
4
|
+
|
|
5
|
+
When to use: A list or details over a full-screen view (a map, a canvas) that must stay usable behind it.
|
|
6
|
+
|
|
7
|
+
### Use instead
|
|
8
|
+
- Dialog (dialog.md): A question must be answered before going on: modal.
|
|
9
|
+
- Drawer (drawer.md): A record or a long form, modal, beside the page.
|
|
10
|
+
|
|
11
|
+
### The one right way
|
|
12
|
+
The heading and the count go in `header`: they stay put while the list scrolls under them.
|
|
13
|
+
```tsx
|
|
14
|
+
import { useState } from "react";
|
|
15
|
+
import { BottomSheet, ListRow, Pill, SectionHeading } from "@slashsuite/ui-react";
|
|
16
|
+
|
|
17
|
+
function Example() {
|
|
18
|
+
const [snap, setSnap] = useState(1);
|
|
19
|
+
return (
|
|
20
|
+
<BottomSheet
|
|
21
|
+
label="Shops"
|
|
22
|
+
snaps={[0.3, 0.75]}
|
|
23
|
+
snap={snap}
|
|
24
|
+
onSnapChange={setSnap}
|
|
25
|
+
header={
|
|
26
|
+
<>
|
|
27
|
+
<SectionHeading>Shops nearby</SectionHeading>
|
|
28
|
+
<Pill>12</Pill>
|
|
29
|
+
</>
|
|
30
|
+
}
|
|
31
|
+
>
|
|
32
|
+
{Array.from({ length: 12 }, (_, i) => (
|
|
33
|
+
<ListRow key={i} divided={i > 0} trailing={`${i + 2}00 m`}>
|
|
34
|
+
Shop {i + 1}
|
|
35
|
+
</ListRow>
|
|
36
|
+
))}
|
|
37
|
+
</BottomSheet>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Do
|
|
43
|
+
- Put it in a positioned parent (`relative`) that holds the full-screen view; it docks to that parent's bottom edge, full width on a phone and a panel at the start edge from `md` up.
|
|
44
|
+
- Hold `snap` in your state and set it in `onSnapChange`: `<BottomSheet snap={snap} onSnapChange={setSnap} …>`.
|
|
45
|
+
- List `snaps` lowest first, at least two: a number from 0 to 1 is a share of the parent's height, a `"120px"` string is pixels.
|
|
46
|
+
- The heading and a count go in `header`, never first in the body, so they stay put while the list scrolls.
|
|
47
|
+
- Pad the map camera by the height `onHeightChange` reports, so a pin is never hidden under the sheet.
|
|
48
|
+
- A record or a form that stops the page is a `Drawer`; a question is a `Dialog`.
|
|
49
|
+
- Render the first snap first: the server render, and a page with no JavaScript, show a static panel at it.
|
|
50
|
+
|
|
51
|
+
### Don't
|
|
52
|
+
Do not put the heading first in the body: it scrolls away with the list.
|
|
53
|
+
```tsx
|
|
54
|
+
import { useState } from "react";
|
|
55
|
+
import { BottomSheet, ListRow, SectionHeading } from "@slashsuite/ui-react";
|
|
56
|
+
|
|
57
|
+
function Example() {
|
|
58
|
+
const [snap, setSnap] = useState(1);
|
|
59
|
+
return (
|
|
60
|
+
<BottomSheet label="Shops" snaps={[0.3, 0.75]} snap={snap} onSnapChange={setSnap}>
|
|
61
|
+
<SectionHeading>Shops nearby</SectionHeading>
|
|
62
|
+
{Array.from({ length: 12 }, (_, i) => (
|
|
63
|
+
<ListRow key={i} divided={i > 0} trailing={`${i + 2}00 m`}>
|
|
64
|
+
Shop {i + 1}
|
|
65
|
+
</ListRow>
|
|
66
|
+
))}
|
|
67
|
+
</BottomSheet>
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Accessibility
|
|
73
|
+
- It is a region named by `label`.
|
|
74
|
+
- The handle is a button named by `label`, with `aria-expanded` and `aria-controls` on the body. Enter and Space step through the snaps, and Escape inside the sheet returns it to the first.
|
|
75
|
+
- Nothing behind it is inert, and focus is never trapped or moved.
|
|
76
|
+
- The settle between snaps is switched off under `prefers-reduced-motion: reduce`.
|
|
77
|
+
- The body scrolls on its own and never scrolls the page.
|
|
78
|
+
|
|
79
|
+
### Props
|
|
80
|
+
### BottomSheet
|
|
81
|
+
A non-modal panel docked to the bottom edge of its positioned parent, over a full-screen view (a map, a canvas) that stays usable behind it. It rests at one of its `snaps`; the handle steps through them (Enter and Space), a drag of the handle moves it and releases to the nearest snap (a fling steps on), and Escape inside it returns it to the first. Nothing is made inert and focus never moves. Full width below `md`, a panel at the start edge from `md` up.
|
|
82
|
+
- children: ReactNode. The scrolling body.
|
|
83
|
+
- footer: ReactNode. Actions pinned under the scrolling body.
|
|
84
|
+
- header: ReactNode. The row under the handle: a heading and a count. It stays put while the body scrolls.
|
|
85
|
+
- id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
|
|
86
|
+
- label: string (required). The sheet's accessible name, as a region, and its handle button's.
|
|
87
|
+
- onHeightChange: (px: number) => void. Called with the height (px) the sheet rests at: on mount, on every change of `snap` and when the
|
|
88
|
+
parent resizes. Pad a map camera by it.
|
|
89
|
+
- onSnapChange: (snap: number) => void (required). Called with the snap to move to: from the handle, a drag, or Escape (back to 0). Set `snap` here.
|
|
90
|
+
- snap: number (required). The current snap, an index into `snaps`. Render the first (0) first and a page with no JavaScript shows it.
|
|
91
|
+
- snaps: readonly [BottomSheetSnap, BottomSheetSnap, ...BottomSheetSnap[]] (required). The heights it rests at, lowest first, at least two: a number from 0 to 1 is a share of the
|
|
92
|
+
parent's height, a `"120px"` string is pixels. A snap taller than the parent is held at its height.
|
|
93
|
+
|
|
94
|
+
### Types
|
|
95
|
+
- BottomSheetSnap: `number | `${number}px``. A snap height: a number from 0 to 1 is a share of the parent's height, a `"120px"` string is pixels.
|