@nanisoft/prism-llms 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/THIRD-PARTY-NOTICES.md +48 -0
- package/dist/data.json +3998 -375
- package/dist/demo-graph.d.ts +21 -12
- package/dist/demo-graph.js +37 -21
- package/dist/extractor.d.ts +24 -17
- package/dist/extractor.js +269 -153
- package/dist/index.d.ts +12 -7
- package/dist/index.js +9 -7
- package/dist/llms-full.txt +7988 -1989
- package/dist/llms.txt +97 -91
- package/dist/markdown.d.ts +69 -23
- package/dist/markdown.js +131 -72
- package/dist/md/blocks/app-shell-01.md +135 -0
- package/dist/md/blocks/auth-form-01.md +135 -0
- package/dist/md/blocks/cta-01.md +88 -0
- package/dist/md/blocks/data-table-01.md +196 -0
- package/dist/md/blocks/feature-grid-01.md +92 -0
- package/dist/md/blocks/hero-01.md +90 -0
- package/dist/md/blocks/instrument-panel-01.md +109 -0
- package/dist/md/blocks/logo-strip-01.md +97 -0
- package/dist/md/blocks/note-grid-01.md +102 -0
- package/dist/md/blocks/page-header-01.md +97 -0
- package/dist/md/blocks/pricing-01.md +91 -0
- package/dist/md/blocks/process-rail-01.md +106 -0
- package/dist/md/blocks/product-grid-01.md +113 -0
- package/dist/md/blocks/settings-panel-01.md +148 -0
- package/dist/md/blocks/site-footer.md +111 -0
- package/dist/md/blocks/site-header.md +119 -0
- package/dist/md/blocks/stack-grid-01.md +108 -0
- package/dist/md/blocks/stats-01.md +89 -0
- package/dist/md/blocks/status-ledger-01.md +121 -0
- package/dist/md/changelogs/prism-llms.md +206 -0
- package/dist/md/changelogs/prism-mcp-server.md +88 -0
- package/dist/md/changelogs/prism-tokens.md +126 -0
- package/dist/md/changelogs/prism-ui.md +429 -0
- package/dist/md/components/accordion.md +108 -0
- package/dist/md/components/alert.md +90 -7
- package/dist/md/components/avatar.md +89 -7
- package/dist/md/components/badge.md +74 -7
- package/dist/md/components/breadcrumb.md +84 -7
- package/dist/md/components/button.md +90 -7
- package/dist/md/components/card.md +90 -7
- package/dist/md/components/checkbox.md +101 -7
- package/dist/md/components/cta-link.md +98 -0
- package/dist/md/components/diagram.md +124 -0
- package/dist/md/components/dialog.md +128 -0
- package/dist/md/components/dropdown-menu.md +125 -0
- package/dist/md/components/fact-list.md +85 -0
- package/dist/md/components/field.md +116 -0
- package/dist/md/components/input.md +86 -7
- package/dist/md/components/kbd.md +77 -0
- package/dist/md/components/pagination.md +95 -7
- package/dist/md/components/popover.md +95 -7
- package/dist/md/components/product-mark.md +123 -0
- package/dist/md/components/product-switcher.md +88 -0
- package/dist/md/components/progress.md +88 -7
- package/dist/md/components/prose.md +91 -0
- package/dist/md/components/radio-group.md +111 -0
- package/dist/md/components/section.md +91 -0
- package/dist/md/components/select.md +143 -7
- package/dist/md/components/separator.md +77 -0
- package/dist/md/components/skeleton.md +71 -7
- package/dist/md/components/slider.md +90 -7
- package/dist/md/components/switch.md +104 -7
- package/dist/md/components/table.md +104 -7
- package/dist/md/components/tabs.md +105 -7
- package/dist/md/components/textarea.md +101 -0
- package/dist/md/components/tooltip.md +95 -7
- package/dist/md/components/typography.md +82 -7
- package/dist/md/content/about-content.md +36 -0
- package/dist/md/content/audience.md +43 -0
- package/dist/md/content/glossary.md +69 -0
- package/dist/md/content/product-vocabulary.md +53 -0
- package/dist/md/content/voice.md +52 -0
- package/dist/md/content/writing-mechanics.md +58 -0
- package/dist/md/foundation/colors.md +10 -0
- package/dist/md/foundation/iconography.md +14 -0
- package/dist/md/foundation/motion.md +10 -0
- package/dist/md/foundation/radii.md +9 -0
- package/dist/md/foundation/shadows.md +9 -0
- package/dist/md/foundation/spacings.md +8 -0
- package/dist/md/foundation/typography.md +9 -0
- package/dist/md/foundation/variables.md +9 -0
- package/dist/md/overview/architecture.md +76 -0
- package/dist/md/overview/brand.md +41 -0
- package/dist/md/overview/composition.md +77 -0
- package/dist/md/overview/quickstart.md +97 -0
- package/dist/md/overview/theming.md +89 -0
- package/dist/md/overview/using-llms.md +83 -0
- package/dist/md/pages/auth-page.md +149 -0
- package/dist/md/pages/blog-post-page.md +136 -0
- package/dist/md/pages/dashboard-page.md +241 -0
- package/dist/md/pages/marketing-page.md +199 -0
- package/dist/md/pages/not-found-page.md +105 -0
- package/dist/md/pages/settings-page.md +206 -0
- package/dist/prism-skill.md +50 -0
- package/dist/store.d.ts +203 -0
- package/dist/store.js +317 -0
- package/package.json +29 -26
- package/dist/demo-graph.d.ts.map +0 -1
- package/dist/demo-graph.js.map +0 -1
- package/dist/extractor.d.ts.map +0 -1
- package/dist/extractor.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/markdown.d.ts.map +0 -1
- package/dist/markdown.js.map +0 -1
- package/dist/md/blocks/component-demo.md +0 -19
- package/dist/md/blocks/page-header.md +0 -19
- package/dist/md/components/affix.md +0 -14
- package/dist/md/components/anchor.md +0 -14
- package/dist/md/components/auto-complete.md +0 -14
- package/dist/md/components/back-top.md +0 -14
- package/dist/md/components/border-beam.md +0 -14
- package/dist/md/components/calendar.md +0 -14
- package/dist/md/components/carousel.md +0 -14
- package/dist/md/components/cascader.md +0 -14
- package/dist/md/components/col.md +0 -14
- package/dist/md/components/collapse.md +0 -14
- package/dist/md/components/color-picker.md +0 -14
- package/dist/md/components/date-picker.md +0 -14
- package/dist/md/components/descriptions.md +0 -14
- package/dist/md/components/display-title.md +0 -20
- package/dist/md/components/divider.md +0 -14
- package/dist/md/components/drawer.md +0 -14
- package/dist/md/components/dropdown.md +0 -14
- package/dist/md/components/empty.md +0 -14
- package/dist/md/components/flex.md +0 -14
- package/dist/md/components/float-button.md +0 -14
- package/dist/md/components/form.md +0 -14
- package/dist/md/components/grid.md +0 -14
- package/dist/md/components/image.md +0 -14
- package/dist/md/components/input-number.md +0 -14
- package/dist/md/components/layout.md +0 -14
- package/dist/md/components/list.md +0 -14
- package/dist/md/components/listy.md +0 -14
- package/dist/md/components/masonry.md +0 -14
- package/dist/md/components/mentions.md +0 -14
- package/dist/md/components/menu.md +0 -14
- package/dist/md/components/modal.md +0 -14
- package/dist/md/components/popconfirm.md +0 -14
- package/dist/md/components/qrcode.md +0 -14
- package/dist/md/components/radio.md +0 -14
- package/dist/md/components/rate.md +0 -14
- package/dist/md/components/result.md +0 -14
- package/dist/md/components/row.md +0 -14
- package/dist/md/components/segmented.md +0 -14
- package/dist/md/components/space.md +0 -14
- package/dist/md/components/spin.md +0 -14
- package/dist/md/components/splitter.md +0 -14
- package/dist/md/components/statistic.md +0 -14
- package/dist/md/components/steps.md +0 -14
- package/dist/md/components/tag.md +0 -14
- package/dist/md/components/time-picker.md +0 -14
- package/dist/md/components/timeline.md +0 -14
- package/dist/md/components/tour.md +0 -14
- package/dist/md/components/transfer.md +0 -14
- package/dist/md/components/tree-select.md +0 -14
- package/dist/md/components/tree.md +0 -14
- package/dist/md/components/upload.md +0 -14
- package/dist/md/components/watermark.md +0 -14
- package/dist/md/docs/brand.md +0 -41
- package/dist/md/pages/blog-layout.md +0 -19
- package/dist/md/pages/docs-shell.md +0 -23
- package/dist/md/theme/blue-dark.md +0 -127
- package/dist/md/theme/blue-light.md +0 -129
- package/dist/md/theme/green-dark.md +0 -127
- package/dist/md/theme/green-light.md +0 -129
- package/dist/md/theme/lavender-dark.md +0 -127
- package/dist/md/theme/lavender-light.md +0 -129
- package/dist/md/theme/peach-dark.md +0 -127
- package/dist/md/theme/peach-light.md +0 -129
- package/dist/md/theme/rose-dark.md +0 -127
- package/dist/md/theme/rose-light.md +0 -129
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Separator
|
|
2
|
+
|
|
3
|
+
A hairline rule that divides content, horizontally or vertically.
|
|
4
|
+
|
|
5
|
+
```tsx
|
|
6
|
+
import { Separator } from '@nanisoft/prism-ui/components/separator'
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
A Separator is a hairline rule that divides content. It renders a single
|
|
12
|
+
`<div>` at either `horizontal` or `vertical` orientation, drawn with the border
|
|
13
|
+
token.
|
|
14
|
+
|
|
15
|
+
The rule is decorative by default, so it is hidden from assistive technology and
|
|
16
|
+
does not enter the reading order. Pass `decorative={false}` when the rule marks a
|
|
17
|
+
real separation in a set of controls, such as between groups in a toolbar, and
|
|
18
|
+
it becomes an ARIA separator with a matching orientation.
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
### When to use
|
|
23
|
+
|
|
24
|
+
Use a Separator to divide two groups of content in a stack, or two items inside
|
|
25
|
+
a horizontal row such as a toolbar or a breadcrumb-style meta line.
|
|
26
|
+
|
|
27
|
+
### When not to use
|
|
28
|
+
|
|
29
|
+
Do not use a Separator where whitespace would do. A rule between two paragraphs
|
|
30
|
+
adds ink without adding structure; space already separates them.
|
|
31
|
+
|
|
32
|
+
Do not use one as a card border or a panel edge. A surface boundary is a border
|
|
33
|
+
on the surface itself, not a rule placed beside it.
|
|
34
|
+
|
|
35
|
+
Do not use a Separator as decoration. A rule that does not divide anything is
|
|
36
|
+
noise the reader has to interpret.
|
|
37
|
+
|
|
38
|
+
### Best practices
|
|
39
|
+
|
|
40
|
+
- Keep the default `horizontal` orientation for stacked content and switch to
|
|
41
|
+
`vertical` only inside a row.
|
|
42
|
+
- Give a vertical Separator a height through its parent. It fills the parent's
|
|
43
|
+
height, so a parent with no height collapses the rule to nothing.
|
|
44
|
+
- Leave the rule decorative unless it marks a boundary a screen reader needs,
|
|
45
|
+
and pass `decorative={false}` only in that case.
|
|
46
|
+
- Use one orientation per region. Mixing rules in a single stack reads as two
|
|
47
|
+
different structures.
|
|
48
|
+
- Prefer the token's hairline and colour. A thicker or tinted rule is a second
|
|
49
|
+
visual language for the same job.
|
|
50
|
+
|
|
51
|
+
**A horizontal rule between rows, and vertical rules inside one row.**
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
import { Separator } from '@nanisoft/prism-ui/components/separator'
|
|
55
|
+
|
|
56
|
+
/** A horizontal rule between rows, and vertical rules inside one row. */
|
|
57
|
+
export default function SeparatorDemo() {
|
|
58
|
+
return (
|
|
59
|
+
<div className="flex max-w-measure flex-col gap-4">
|
|
60
|
+
<p className="text-muted-foreground text-sm">Account</p>
|
|
61
|
+
<Separator />
|
|
62
|
+
<p className="text-muted-foreground text-sm">Notifications</p>
|
|
63
|
+
<div className="flex h-5 items-center gap-4">
|
|
64
|
+
<span className="text-sm">Draft</span>
|
|
65
|
+
<Separator orientation="vertical" />
|
|
66
|
+
<span className="text-sm">Review</span>
|
|
67
|
+
<Separator orientation="vertical" />
|
|
68
|
+
<span className="text-sm">Published</span>
|
|
69
|
+
</div>
|
|
70
|
+
</div>
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Props
|
|
76
|
+
|
|
77
|
+
> Extends: the native `<div>` element. No additional Prism-specific props.
|
|
@@ -1,14 +1,78 @@
|
|
|
1
1
|
# Skeleton
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A placeholder surface that mirrors the shape of content while it loads.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
import { Skeleton } from '@nanisoft/prism-ui/components'
|
|
5
|
+
```tsx
|
|
6
|
+
import { Skeleton } from '@nanisoft/prism-ui/components/skeleton'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
A Skeleton is a placeholder surface that mirrors the shape of content while it
|
|
12
|
+
loads. It renders a single muted `<div>` whose size comes from `className`, so
|
|
13
|
+
one component stands in for a title, a line of text, an avatar or an action.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
It ships without a shimmer on purpose. Prism authors no keyframes, so the
|
|
16
|
+
placeholder is static and the shape, not a pulse, is what tells the reader that
|
|
17
|
+
content is coming. The element is hidden from assistive technology, so a screen
|
|
18
|
+
reader hears the finished content when it arrives rather than an empty box.
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
### When to use
|
|
23
|
+
|
|
24
|
+
Use a Skeleton when content is loading into a layout the reader already knows,
|
|
25
|
+
such as a list, a card grid or a detail panel that reloads in place. The
|
|
26
|
+
placeholder keeps the page from jumping when the content lands.
|
|
27
|
+
|
|
28
|
+
### When not to use
|
|
29
|
+
|
|
30
|
+
Do not use a Skeleton for work the reader has just started. A button that is
|
|
31
|
+
submitting shows its own loading state; a placeholder elsewhere on the page
|
|
32
|
+
implies a different region is loading.
|
|
33
|
+
|
|
34
|
+
Do not use a Skeleton as a loading indicator for the whole application. A
|
|
35
|
+
first paint with no known layout is better served by a spinner or a simple
|
|
36
|
+
progress bar.
|
|
37
|
+
|
|
38
|
+
Do not use one when the load is near instant. A placeholder that appears and
|
|
39
|
+
disappears within a frame reads as a glitch.
|
|
40
|
+
|
|
41
|
+
### Best practices
|
|
42
|
+
|
|
43
|
+
- Match the final shape and size. A skeleton smaller than the content it
|
|
44
|
+
replaces causes a layout shift, which is the problem it exists to prevent.
|
|
45
|
+
- Group the placeholders of one region into a single block, and mirror the real
|
|
46
|
+
structure: a title line, two body lines, an action.
|
|
47
|
+
- Keep the surrounding layout identical to the loaded state, so only the content
|
|
48
|
+
changes.
|
|
49
|
+
- Render the same number of placeholder rows as the content the layout will
|
|
50
|
+
hold. A grid that collapses from six boxes to two is a lie in both states.
|
|
51
|
+
- Do not add a spinner inside a skeleton. One loading signal per region is
|
|
52
|
+
enough.
|
|
53
|
+
- Keep the placeholder decorative. The live region around it, or the arriving
|
|
54
|
+
content, should carry the announcement.
|
|
55
|
+
|
|
56
|
+
**A card-shaped placeholder: title, two body lines and an action.**
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
import { Skeleton } from '@nanisoft/prism-ui/components/skeleton'
|
|
60
|
+
|
|
61
|
+
/** A card-shaped placeholder: title, two body lines and an action. */
|
|
62
|
+
export default function SkeletonDemo() {
|
|
63
|
+
return (
|
|
64
|
+
<div className="flex max-w-measure-narrow flex-col gap-4">
|
|
65
|
+
<Skeleton className="h-5 w-40" />
|
|
66
|
+
<div className="flex flex-col gap-2">
|
|
67
|
+
<Skeleton className="h-4 w-full" />
|
|
68
|
+
<Skeleton className="h-4 w-4/5" />
|
|
69
|
+
</div>
|
|
70
|
+
<Skeleton className="h-9 w-28" />
|
|
71
|
+
</div>
|
|
72
|
+
)
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Props
|
|
77
|
+
|
|
78
|
+
> Extends: the native `<div>` element. No additional Prism-specific props.
|
|
@@ -1,14 +1,97 @@
|
|
|
1
1
|
# Slider
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The control that chooses a number along a range.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
import { Slider } from '@nanisoft/prism-ui/components'
|
|
5
|
+
```tsx
|
|
6
|
+
import { Slider } from '@nanisoft/prism-ui/components/slider'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
A Slider chooses a number along a range. It renders a styled track with a real
|
|
12
|
+
range input beside it, so it is reachable by Tab and moved by the arrow keys,
|
|
13
|
+
with Home and End jumping to the ends. The current value is exposed to assistive
|
|
14
|
+
technology through the input's range semantics.
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
Use the `min`, `max` and `step` props to describe the range, and give the
|
|
17
|
+
control an `aria-label` or a visible label, because a slider with no name tells
|
|
18
|
+
a screen reader nothing about what it changes.
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
### When to use
|
|
23
|
+
|
|
24
|
+
Use a Slider when the value is approximate and the reader benefits from seeing
|
|
25
|
+
where it sits in a range: volume, opacity, a threshold, a size with a sensible
|
|
26
|
+
middle.
|
|
27
|
+
|
|
28
|
+
### When not to use
|
|
29
|
+
|
|
30
|
+
Do not use a Slider when the exact number matters. An Input of type number lets
|
|
31
|
+
the reader type or step to the value and is easier to make precise.
|
|
32
|
+
|
|
33
|
+
Do not use one for a range with only two or three meaningful positions. A
|
|
34
|
+
RadioGroup or a Select names each choice; a slider makes the reader hunt.
|
|
35
|
+
|
|
36
|
+
Do not use a Slider for a value you cannot plot, such as a colour name. Pick the
|
|
37
|
+
control that matches the kind of value.
|
|
38
|
+
|
|
39
|
+
### Best practices
|
|
40
|
+
|
|
41
|
+
- Pair the control with a visible label and an `aria-label`. The label names the
|
|
42
|
+
quantity; the value is read from the control.
|
|
43
|
+
- Snap the range to meaningful steps. `step` should divide the span from `min`
|
|
44
|
+
to `max` evenly, so every reachable value is one the reader would want.
|
|
45
|
+
- Show the current value near the slider when precision matters, and update it
|
|
46
|
+
as the value changes.
|
|
47
|
+
- Set sensible `min` and `max` for the task. An unbounded slider invites values
|
|
48
|
+
the rest of the product cannot use.
|
|
49
|
+
- Use the disabled state with a nearby reason, as with any other control.
|
|
50
|
+
|
|
51
|
+
### Content guidelines
|
|
52
|
+
|
|
53
|
+
- Name the quantity, not the control: "Opacity", "Export size".
|
|
54
|
+
- Keep units out of the label when they can live in the value readout, and
|
|
55
|
+
include them in the readout when they are needed.
|
|
56
|
+
- Avoid phrasing the label as a question. State the value being set.
|
|
57
|
+
|
|
58
|
+
**Sliders for an adjustable value, a stepped value and a disabled one.**
|
|
59
|
+
|
|
60
|
+
```tsx
|
|
61
|
+
'use client'
|
|
62
|
+
|
|
63
|
+
import { Slider } from '@nanisoft/prism-ui/components/slider'
|
|
64
|
+
|
|
65
|
+
/** Sliders for an adjustable value, a stepped value and a disabled one. */
|
|
66
|
+
export default function SliderDemo() {
|
|
67
|
+
return (
|
|
68
|
+
<div className="flex max-w-measure-narrow flex-col gap-8">
|
|
69
|
+
<div className="flex flex-col gap-3">
|
|
70
|
+
<p className="text-sm font-medium">Opacity</p>
|
|
71
|
+
<Slider defaultValue={75} aria-label="Opacity" />
|
|
72
|
+
</div>
|
|
73
|
+
<div className="flex flex-col gap-3">
|
|
74
|
+
<p className="text-sm font-medium">Export size</p>
|
|
75
|
+
<Slider defaultValue={40} aria-label="Export size" min={0} max={100} step={10} />
|
|
76
|
+
</div>
|
|
77
|
+
<div className="flex flex-col gap-3">
|
|
78
|
+
<p className="text-muted-foreground text-sm font-medium">Frame rate</p>
|
|
79
|
+
<Slider defaultValue={60} aria-label="Frame rate" disabled />
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Props
|
|
87
|
+
|
|
88
|
+
**`value`** `number` · optional · default: — — The current value, when the slider is controlled.
|
|
89
|
+
**`defaultValue`** `number` · optional · default: — — The value the slider starts at, for an uncontrolled slider.
|
|
90
|
+
**`min`** `number` · optional · default: `0` — The minimum allowed value.
|
|
91
|
+
**`max`** `number` · optional · default: `100` — The maximum allowed value.
|
|
92
|
+
**`step`** `number` · optional · default: `1` — The granularity the slider steps by.
|
|
93
|
+
**`disabled`** `boolean` · optional · default: — — Whether the slider ignores user interaction.
|
|
94
|
+
**`orientation`** `'horizontal' | 'vertical'` · optional · default: `horizontal` — The axis the slider moves along.
|
|
95
|
+
**`name`** `string` · optional · default: — — The form field name submitted with the form.
|
|
96
|
+
**`form`** `string` · optional · default: — — Identifies the form that owns the hidden input.
|
|
97
|
+
**`onValueChange`** `(value: number) => void` · optional · default: — — Called as the value changes.
|
|
@@ -1,14 +1,111 @@
|
|
|
1
1
|
# Switch
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The control that turns a setting on or off immediately.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
import { Switch } from '@nanisoft/prism-ui/components'
|
|
5
|
+
```tsx
|
|
6
|
+
import { Switch } from '@nanisoft/prism-ui/components/switch'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
A Switch turns a single setting on or off, and the change takes effect at once.
|
|
12
|
+
It renders a styled track with a hidden native checkbox beside it, so it submits
|
|
13
|
+
with a form while reading as a physical toggle. Space toggles the focused
|
|
14
|
+
control, and its on and off states are announced to assistive technology.
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
The difference from a Checkbox is timing, not shape. A Switch is a setting that
|
|
17
|
+
is already in force; a Checkbox is a choice collected before a save.
|
|
18
|
+
|
|
19
|
+
## Guidelines
|
|
20
|
+
|
|
21
|
+
### When to use
|
|
22
|
+
|
|
23
|
+
Use a Switch when flipping the control applies the change immediately and the
|
|
24
|
+
reader expects no further step: enabling notifications, publishing a preview, or
|
|
25
|
+
turning a feature on.
|
|
26
|
+
|
|
27
|
+
### When not to use
|
|
28
|
+
|
|
29
|
+
Do not use a Switch inside a form that still needs a Save action. If the change
|
|
30
|
+
is pending a submit, a Checkbox is the honest control.
|
|
31
|
+
|
|
32
|
+
Do not use one to choose between two named options, such as Light and Dark. That
|
|
33
|
+
is a choice between values, and a RadioGroup or a Select names both.
|
|
34
|
+
|
|
35
|
+
Do not use a Switch for an action that cannot be undone with the same control. A
|
|
36
|
+
one-way action is a Button.
|
|
37
|
+
|
|
38
|
+
### Best practices
|
|
39
|
+
|
|
40
|
+
- Label the setting, not the state. The label describes what the switch
|
|
41
|
+
controls; the on and off positions are conveyed by the control itself.
|
|
42
|
+
- Pair each Switch with a `FieldLabel` and `htmlFor`, and put the consequence in
|
|
43
|
+
an adjacent helper line rather than in the label.
|
|
44
|
+
- For a change that affects a shared resource, confirm or offer an undo. An
|
|
45
|
+
immediate setting with wide effect is easy to flip by accident.
|
|
46
|
+
- Keep the on state visually distinct beyond position alone, so the state is
|
|
47
|
+
legible to a reader who cannot rely on the thumb's movement.
|
|
48
|
+
- Use `disabled` with a reason in reach, and prefer an explanatory line over a
|
|
49
|
+
silent greyed row.
|
|
50
|
+
|
|
51
|
+
### Content guidelines
|
|
52
|
+
|
|
53
|
+
- Write the label as the thing being controlled, in sentence case: "Release
|
|
54
|
+
notifications", "Preview builds".
|
|
55
|
+
- Keep helper text to one sentence that states the effect, including who is
|
|
56
|
+
affected when it is shared.
|
|
57
|
+
- Avoid "Enable" or "Turn on" in the label; the control already says that.
|
|
58
|
+
|
|
59
|
+
**Switches that take effect immediately, one of them already on.**
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
'use client'
|
|
63
|
+
|
|
64
|
+
import { FieldLabel } from '@nanisoft/prism-ui/components/field'
|
|
65
|
+
import { Switch } from '@nanisoft/prism-ui/components/switch'
|
|
66
|
+
|
|
67
|
+
/** Switches that take effect immediately, one of them already on. */
|
|
68
|
+
export default function SwitchDemo() {
|
|
69
|
+
return (
|
|
70
|
+
<div className="flex max-w-measure-narrow flex-col gap-5">
|
|
71
|
+
<div className="flex items-center justify-between gap-4">
|
|
72
|
+
<div className="flex flex-col gap-1">
|
|
73
|
+
<FieldLabel htmlFor="switch-notifications">Release notifications</FieldLabel>
|
|
74
|
+
<span className="text-muted-foreground text-sm">
|
|
75
|
+
A message when a new version is published.
|
|
76
|
+
</span>
|
|
77
|
+
</div>
|
|
78
|
+
<Switch id="switch-notifications" defaultChecked />
|
|
79
|
+
</div>
|
|
80
|
+
<div className="flex items-center justify-between gap-4">
|
|
81
|
+
<div className="flex flex-col gap-1">
|
|
82
|
+
<FieldLabel htmlFor="switch-preview">Preview builds</FieldLabel>
|
|
83
|
+
<span className="text-muted-foreground text-sm">
|
|
84
|
+
Build every pull request on the free plan.
|
|
85
|
+
</span>
|
|
86
|
+
</div>
|
|
87
|
+
<Switch id="switch-preview" />
|
|
88
|
+
</div>
|
|
89
|
+
<div className="flex items-center justify-between gap-4">
|
|
90
|
+
<FieldLabel htmlFor="switch-sso" className="text-muted-foreground">
|
|
91
|
+
Single sign-on
|
|
92
|
+
</FieldLabel>
|
|
93
|
+
<Switch id="switch-sso" disabled />
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Props
|
|
101
|
+
|
|
102
|
+
**`checked`** `boolean` · optional · default: — — The controlled active state.
|
|
103
|
+
**`defaultChecked`** `boolean` · optional · default: — — The initially active state, for an uncontrolled switch.
|
|
104
|
+
**`disabled`** `boolean` · optional · default: — — Whether the control ignores user interaction.
|
|
105
|
+
**`readOnly`** `boolean` · optional · default: — — Whether the user may not change the state.
|
|
106
|
+
**`required`** `boolean` · optional · default: — — Whether the state must be active before the form submits.
|
|
107
|
+
**`name`** `string` · optional · default: — — The form field name submitted with the form.
|
|
108
|
+
**`value`** `string` · optional · default: — — The value submitted when the switch is on.
|
|
109
|
+
**`uncheckedValue`** `string` · optional · default: — — The value submitted when the switch is off.
|
|
110
|
+
**`form`** `string` · optional · default: — — Identifies the form that owns the hidden input.
|
|
111
|
+
**`onCheckedChange`** `(checked: boolean) => void` · optional · default: — — Called when the active state changes.
|
|
@@ -1,14 +1,111 @@
|
|
|
1
1
|
# Table
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The semantic table components for rows, columns and captions.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
import { Table } from '@nanisoft/prism-ui/components'
|
|
5
|
+
```tsx
|
|
6
|
+
import { Table, TableHeader, TableBody, TableFooter, TableRow, TableHead, TableCell, TableCaption } from '@nanisoft/prism-ui/components/table'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
A Table presents tabular data: records compared across named columns. It ships
|
|
12
|
+
as `Table`, `TableHeader`, `TableBody`, `TableFooter`, `TableRow`, `TableHead`,
|
|
13
|
+
`TableCell` and `TableCaption`, all from the same module.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
`Table` renders a real `<table>` inside a container that scrolls horizontally at
|
|
16
|
+
narrow widths, so a wide set of columns stays reachable. `TableHeader`,
|
|
17
|
+
`TableBody` and `TableFooter` map to `<thead>`, `<tbody>` and `<tfoot>`;
|
|
18
|
+
`TableHead` is a `<th>` and `TableCell` is a `<td>`. `TableCaption` names the
|
|
19
|
+
table for every reader, and it is read before the data.
|
|
20
|
+
|
|
21
|
+
## Guidelines
|
|
22
|
+
|
|
23
|
+
### When to use
|
|
24
|
+
|
|
25
|
+
Use a Table when records share the same set of attributes and the reader needs
|
|
26
|
+
to compare them down a column: invoices, members, deployments, line items.
|
|
27
|
+
|
|
28
|
+
### When not to use
|
|
29
|
+
|
|
30
|
+
Do not use a Table for page layout. It was a layout tool once, and every reader
|
|
31
|
+
and crawler now interprets a table as data.
|
|
32
|
+
|
|
33
|
+
Do not use one for a few key and value pairs. A description list states a record
|
|
34
|
+
better than a table with two columns.
|
|
35
|
+
|
|
36
|
+
Do not use a Table for a list where every row shows the same fields as prose.
|
|
37
|
+
If there is nothing to compare across columns, a list is the honest unit.
|
|
38
|
+
|
|
39
|
+
### Best practices
|
|
40
|
+
|
|
41
|
+
- Name the table. Use `TableCaption` or an adjacent heading, and do not leave a
|
|
42
|
+
reader to infer the subject from the column labels.
|
|
43
|
+
- Put the identifying column first, so a row is recognisable before it is read
|
|
44
|
+
across.
|
|
45
|
+
- Align numbers to the right through `className` and text to the left. The
|
|
46
|
+
alignment is layout, which is the one use of `className` the system permits.
|
|
47
|
+
- Keep cells terse. A paragraph in a cell is a row that has outgrown the table.
|
|
48
|
+
- Use `TableFooter` for a total or a count, so the summary is part of the table
|
|
49
|
+
rather than a paragraph after it.
|
|
50
|
+
- Add `scope="col"` to `TableHead` and `scope="row"` to a row header when a
|
|
51
|
+
control supplies it. The generated markup makes each cell identifiable.
|
|
52
|
+
- Avoid horizontal scrolling where you can. A table that fits its container is
|
|
53
|
+
easier to read than one the reader has to drag.
|
|
54
|
+
|
|
55
|
+
**A small invoices table with a header, a body and a footer total.**
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import {
|
|
59
|
+
Table,
|
|
60
|
+
TableBody,
|
|
61
|
+
TableCaption,
|
|
62
|
+
TableCell,
|
|
63
|
+
TableFooter,
|
|
64
|
+
TableHead,
|
|
65
|
+
TableHeader,
|
|
66
|
+
TableRow,
|
|
67
|
+
} from '@nanisoft/prism-ui/components/table'
|
|
68
|
+
|
|
69
|
+
/** A small invoices table with a header, a body and a footer total. */
|
|
70
|
+
export default function TableDemo() {
|
|
71
|
+
return (
|
|
72
|
+
<Table>
|
|
73
|
+
<TableCaption>Invoices from the current quarter.</TableCaption>
|
|
74
|
+
<TableHeader>
|
|
75
|
+
<TableRow>
|
|
76
|
+
<TableHead>Invoice</TableHead>
|
|
77
|
+
<TableHead>Status</TableHead>
|
|
78
|
+
<TableHead className="text-right">Amount</TableHead>
|
|
79
|
+
</TableRow>
|
|
80
|
+
</TableHeader>
|
|
81
|
+
<TableBody>
|
|
82
|
+
<TableRow>
|
|
83
|
+
<TableCell className="font-medium">INV-001</TableCell>
|
|
84
|
+
<TableCell>Paid</TableCell>
|
|
85
|
+
<TableCell className="text-right">$250.00</TableCell>
|
|
86
|
+
</TableRow>
|
|
87
|
+
<TableRow>
|
|
88
|
+
<TableCell className="font-medium">INV-002</TableCell>
|
|
89
|
+
<TableCell>Pending</TableCell>
|
|
90
|
+
<TableCell className="text-right">$150.00</TableCell>
|
|
91
|
+
</TableRow>
|
|
92
|
+
<TableRow>
|
|
93
|
+
<TableCell className="font-medium">INV-003</TableCell>
|
|
94
|
+
<TableCell>Draft</TableCell>
|
|
95
|
+
<TableCell className="text-right">$350.00</TableCell>
|
|
96
|
+
</TableRow>
|
|
97
|
+
</TableBody>
|
|
98
|
+
<TableFooter>
|
|
99
|
+
<TableRow>
|
|
100
|
+
<TableCell colSpan={2}>Total</TableCell>
|
|
101
|
+
<TableCell className="text-right">$750.00</TableCell>
|
|
102
|
+
</TableRow>
|
|
103
|
+
</TableFooter>
|
|
104
|
+
</Table>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Props
|
|
110
|
+
|
|
111
|
+
> Extends: the native `<table>` element. No additional Prism-specific props.
|
|
@@ -1,14 +1,112 @@
|
|
|
1
1
|
# Tabs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The set of peer views shown one at a time.
|
|
4
4
|
|
|
5
|
-
```
|
|
6
|
-
import { Tabs } from '@nanisoft/prism-ui/components'
|
|
5
|
+
```tsx
|
|
6
|
+
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@nanisoft/prism-ui/components/tabs'
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Overview
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
Tabs show a set of peer views one at a time. It ships as `Tabs`, `TabsList`,
|
|
12
|
+
`TabsTrigger` and `TabsContent`, all from the same module. Each trigger names a
|
|
13
|
+
panel, and the matching panel shares the trigger's value.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
+
The tab list is a single Tab stop. Arrow keys move between triggers and show the
|
|
16
|
+
matching panel, while Tab moves into the panel itself. The active trigger is
|
|
17
|
+
marked with an active state, and the panel it controls is tied to it for
|
|
18
|
+
assistive technology.
|
|
19
|
+
|
|
20
|
+
## Guidelines
|
|
21
|
+
|
|
22
|
+
### When to use
|
|
23
|
+
|
|
24
|
+
Use Tabs to switch between views of the same subject when the reader only needs
|
|
25
|
+
one at a time: overview and activity, code and preview, one setting group among
|
|
26
|
+
several.
|
|
27
|
+
|
|
28
|
+
### When not to use
|
|
29
|
+
|
|
30
|
+
Do not use Tabs for steps in a process. Order matters there, and steps belong in
|
|
31
|
+
a form or a wizard where progress is visible.
|
|
32
|
+
|
|
33
|
+
Do not use Tabs to hide content that a reader needs to compare across panels.
|
|
34
|
+
Side-by-side sections compare better than tabs.
|
|
35
|
+
|
|
36
|
+
Do not use more tabs than fit on one line. If the list wraps, a Select or a
|
|
37
|
+
sidebar section is the better control.
|
|
38
|
+
|
|
39
|
+
### Best practices
|
|
40
|
+
|
|
41
|
+
- Give every `TabsTrigger` a matching `TabsContent` with the same value, and
|
|
42
|
+
keep the order the same in both.
|
|
43
|
+
- Choose a sensible default panel. The first tab is a fine default only if it is
|
|
44
|
+
the view most readers want.
|
|
45
|
+
- Keep panel content structurally similar so switching does not move the
|
|
46
|
+
reader's place on the page.
|
|
47
|
+
- On a narrow screen, let a long tab list scroll rather than wrap, and keep the
|
|
48
|
+
active tab in view.
|
|
49
|
+
- Do not nest tabs inside tabs. One tab set per region keeps the keyboard model
|
|
50
|
+
predictable.
|
|
51
|
+
|
|
52
|
+
### Content guidelines
|
|
53
|
+
|
|
54
|
+
- Label tabs with a noun or a short noun phrase: "Overview", "Activity",
|
|
55
|
+
"Settings".
|
|
56
|
+
- Use sentence case and no trailing periods.
|
|
57
|
+
- Keep labels to one or two words so the row scans at a glance.
|
|
58
|
+
- If a tab needs a count, keep it short and place it after the label, such as
|
|
59
|
+
"Activity 4".
|
|
60
|
+
|
|
61
|
+
**Tabs that switch between three peer views of one subject.**
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
'use client'
|
|
65
|
+
|
|
66
|
+
import {
|
|
67
|
+
Tabs,
|
|
68
|
+
TabsContent,
|
|
69
|
+
TabsList,
|
|
70
|
+
TabsTrigger,
|
|
71
|
+
} from '@nanisoft/prism-ui/components/tabs'
|
|
72
|
+
|
|
73
|
+
/** Tabs that switch between three peer views of one subject. */
|
|
74
|
+
export default function TabsDemo() {
|
|
75
|
+
return (
|
|
76
|
+
<Tabs defaultValue="overview" className="max-w-measure-narrow">
|
|
77
|
+
<TabsList>
|
|
78
|
+
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
79
|
+
<TabsTrigger value="activity">Activity</TabsTrigger>
|
|
80
|
+
<TabsTrigger value="settings">Settings</TabsTrigger>
|
|
81
|
+
</TabsList>
|
|
82
|
+
<TabsContent value="overview">
|
|
83
|
+
<p className="text-muted-foreground pt-2 text-sm">
|
|
84
|
+
Release 2.4 shipped three fixes and one new block, with no token
|
|
85
|
+
changes.
|
|
86
|
+
</p>
|
|
87
|
+
</TabsContent>
|
|
88
|
+
<TabsContent value="activity">
|
|
89
|
+
<p className="text-muted-foreground pt-2 text-sm">
|
|
90
|
+
Four deploys this week, all from the main branch.
|
|
91
|
+
</p>
|
|
92
|
+
</TabsContent>
|
|
93
|
+
<TabsContent value="settings">
|
|
94
|
+
<p className="text-muted-foreground pt-2 text-sm">
|
|
95
|
+
The workspace uses the Blush pack in light mode.
|
|
96
|
+
</p>
|
|
97
|
+
</TabsContent>
|
|
98
|
+
</Tabs>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Props
|
|
104
|
+
|
|
105
|
+
**`value`** `string` · optional · default: — — The active panel's value, when the tabs are controlled.
|
|
106
|
+
**`defaultValue`** `string` · optional · default: — — The panel shown initially, for uncontrolled tabs.
|
|
107
|
+
**`onValueChange`** `(value: string) => void` · optional · default: — — Called when the active panel changes.
|
|
108
|
+
**`orientation`** `'horizontal' | 'vertical'` · optional · default: `horizontal` — The direction the tab list flows.
|
|
109
|
+
**`activateOnFocus`** `boolean` · optional · default: `false` — Whether arrow-key focus also activates the tab.
|
|
110
|
+
**`loopFocus`** `boolean` · optional · default: `true` — Whether arrow keys wrap at the ends of the list.
|
|
111
|
+
**`disabled`** `boolean` · optional · default: — — Whether the trigger ignores user interaction.
|
|
112
|
+
**`keepMounted`** `boolean` · optional · default: `false` — Whether the panel stays in the DOM while hidden.
|