@nyxwire/css 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +133 -2
- package/dist/base.css +850 -0
- package/dist/components.css +10508 -0
- package/dist/docs/components/accordion.md +83 -0
- package/dist/docs/components/alert.md +52 -0
- package/dist/docs/components/avatar.md +55 -0
- package/dist/docs/components/badge.md +64 -0
- package/dist/docs/components/breadcrumbs.md +64 -0
- package/dist/docs/components/button.md +197 -0
- package/dist/docs/components/card.md +103 -0
- package/dist/docs/components/checkbox.md +45 -0
- package/dist/docs/components/chip.md +30 -0
- package/dist/docs/components/cluster.md +33 -0
- package/dist/docs/components/code.md +65 -0
- package/dist/docs/components/container.md +24 -0
- package/dist/docs/components/dialog.md +199 -0
- package/dist/docs/components/divider.md +31 -0
- package/dist/docs/components/dl.md +24 -0
- package/dist/docs/components/effect-utilities.md +82 -0
- package/dist/docs/components/empty.md +40 -0
- package/dist/docs/components/frame.md +27 -0
- package/dist/docs/components/grid.md +31 -0
- package/dist/docs/components/hud.md +75 -0
- package/dist/docs/components/input-group.md +28 -0
- package/dist/docs/components/input.md +52 -0
- package/dist/docs/components/kbd.md +42 -0
- package/dist/docs/components/label-and-field.md +31 -0
- package/dist/docs/components/link.md +41 -0
- package/dist/docs/components/list.md +67 -0
- package/dist/docs/components/menu.md +85 -0
- package/dist/docs/components/meter.md +77 -0
- package/dist/docs/components/navbar.md +66 -0
- package/dist/docs/components/pagination.md +64 -0
- package/dist/docs/components/popover.md +59 -0
- package/dist/docs/components/progress.md +32 -0
- package/dist/docs/components/prose.md +29 -0
- package/dist/docs/components/select.md +51 -0
- package/dist/docs/components/sidebar.md +35 -0
- package/dist/docs/components/sidenav.md +45 -0
- package/dist/docs/components/skeleton.md +36 -0
- package/dist/docs/components/slider.md +32 -0
- package/dist/docs/components/spinner.md +30 -0
- package/dist/docs/components/stack.md +26 -0
- package/dist/docs/components/steps.md +49 -0
- package/dist/docs/components/switch.md +19 -0
- package/dist/docs/components/table.md +83 -0
- package/dist/docs/components/tabs.md +207 -0
- package/dist/docs/components/textarea.md +13 -0
- package/dist/docs/components/toast.md +86 -0
- package/dist/docs/components/tooltip.md +39 -0
- package/dist/docs/components/typography-classes.md +38 -0
- package/dist/docs/families/data-display.md +15 -0
- package/dist/docs/families/feedback.md +13 -0
- package/dist/docs/families/forms.md +141 -0
- package/dist/docs/families/layout-typography.md +17 -0
- package/dist/docs/families/navigation.md +13 -0
- package/dist/docs/families/overlays.md +13 -0
- package/dist/docs/families/surfaces.md +11 -0
- package/dist/docs/foundations/accessibility.md +71 -0
- package/dist/docs/foundations/color-roles.md +114 -0
- package/dist/docs/foundations/effects-motion.md +150 -0
- package/dist/docs/foundations/flavors.md +156 -0
- package/dist/docs/foundations/icons.md +45 -0
- package/dist/docs/foundations/palette.md +180 -0
- package/dist/docs/foundations/spacing-elevation.md +168 -0
- package/dist/docs/foundations/typography.md +80 -0
- package/dist/docs/index.md +233 -0
- package/dist/docs/manifest.json +859 -0
- package/dist/fonts/inter-OFL.txt +93 -0
- package/dist/fonts/inter-latin-ext-wght-italic.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-italic.woff2 +0 -0
- package/dist/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/martian-mono-OFL.txt +93 -0
- package/dist/fonts/martian-mono-latin-ext-wdth-normal.woff2 +0 -0
- package/dist/fonts/martian-mono-latin-wdth-normal.woff2 +0 -0
- package/dist/fonts/space-grotesk-OFL.txt +93 -0
- package/dist/fonts/space-grotesk-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/space-grotesk-latin-wght-normal.woff2 +0 -0
- package/dist/fonts.css +73 -0
- package/dist/nyxwire.css +12183 -0
- package/dist/tokens.css +579 -0
- package/dist/utilities.css +176 -0
- package/nyxwire.d.ts +2 -0
- package/package.json +66 -3
- package/skills/nyxwire/SKILL.md +63 -0
- package/src/base.css +158 -0
- package/src/components/accordion.css +280 -0
- package/src/components/alert.css +176 -0
- package/src/components/avatar.css +262 -0
- package/src/components/badge.css +193 -0
- package/src/components/breadcrumbs.css +209 -0
- package/src/components/btn.css +517 -0
- package/src/components/card.css +327 -0
- package/src/components/checkbox.css +202 -0
- package/src/components/chip.css +345 -0
- package/src/components/code.css +340 -0
- package/src/components/dialog.css +411 -0
- package/src/components/divider.css +201 -0
- package/src/components/empty.css +216 -0
- package/src/components/field.css +161 -0
- package/src/components/hud.css +212 -0
- package/src/components/index.css +50 -0
- package/src/components/input.css +383 -0
- package/src/components/kbd.css +197 -0
- package/src/components/layout.css +344 -0
- package/src/components/link.css +178 -0
- package/src/components/list.css +353 -0
- package/src/components/menu.css +347 -0
- package/src/components/meter.css +238 -0
- package/src/components/navbar.css +309 -0
- package/src/components/pagination.css +302 -0
- package/src/components/popover.css +352 -0
- package/src/components/progress.css +241 -0
- package/src/components/select.css +121 -0
- package/src/components/sidenav.css +326 -0
- package/src/components/skeleton.css +193 -0
- package/src/components/slider.css +201 -0
- package/src/components/spinner.css +200 -0
- package/src/components/stat.css +263 -0
- package/src/components/steps.css +311 -0
- package/src/components/switch.css +183 -0
- package/src/components/table.css +290 -0
- package/src/components/tabs.css +271 -0
- package/src/components/toast.css +413 -0
- package/src/components/tooltip.css +288 -0
- package/src/fonts.css +92 -0
- package/src/index.css +6 -0
- package/src/motion.css +177 -0
- package/src/semantic.css +85 -0
- package/src/tokens.css +276 -0
- package/src/typography.css +430 -0
- package/src/utilities.css +198 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Slider: .nw-slider
|
|
2
|
+
|
|
3
|
+
Part of [Forms](../families/forms.md).
|
|
4
|
+
|
|
5
|
+
`nw-slider` styles `<input type="range">`, so keys, touch and assistive technology keep working. The track fills up to the thumb in the intent color. WebKit and Blink have no progress pseudo-element, so the fill position is an input: set `--_slider-value` to the value as a percentage on every `input` event. Without it, the slider still works and Firefox still fills it natively; only the WebKit fill is missing.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-field">
|
|
9
|
+
<label class="nw-label" for="f-gain">Gain <output for="f-gain">40</output></label>
|
|
10
|
+
<input class="nw-slider" id="f-gain" type="range" min="0" max="100" value="40" />
|
|
11
|
+
</div>
|
|
12
|
+
<div class="nw-field">
|
|
13
|
+
<label class="nw-label" for="f-buffer">Buffer, small and secondary <output for="f-buffer">64</output></label>
|
|
14
|
+
<input class="nw-slider nw-slider-sm nw-slider-secondary" id="f-buffer" type="range" min="16" max="256" step="16" value="64" />
|
|
15
|
+
</div>
|
|
16
|
+
<div class="nw-field">
|
|
17
|
+
<label class="nw-label" for="f-load">Load cap, large and warning <output for="f-load">80</output></label>
|
|
18
|
+
<input class="nw-slider nw-slider-lg nw-slider-warning" id="f-load" type="range" min="0" max="100" value="80" />
|
|
19
|
+
</div>
|
|
20
|
+
<div class="nw-field">
|
|
21
|
+
<label class="nw-label" for="f-locked">Locked</label>
|
|
22
|
+
<input class="nw-slider" id="f-locked" type="range" value="30" disabled />
|
|
23
|
+
</div>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Class / property | Effect |
|
|
27
|
+
| --------------------------------- | ---------------------------------------------------------------------------------------------------------- |
|
|
28
|
+
| `nw-slider` | Track, fill and thumb. The focus ring is on the whole control, so it survives forced colors. |
|
|
29
|
+
| `nw-slider-primary` ... `-danger` | Fill and thumb intent. |
|
|
30
|
+
| `nw-slider-sm`, `-md`, `-lg` | Track and thumb sizes. The hit area stays at least 24px tall. |
|
|
31
|
+
| `nw-slider-vertical` | A vertical control (`writing-mode`), at least 6rem tall; give it a height. |
|
|
32
|
+
| `--_slider-value` | The filled percentage, for example `style="--_slider-value: 40%"`. The demo script below keeps it in sync. |
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# .nw-spinner
|
|
2
|
+
|
|
3
|
+
Part of [Feedback](../families/feedback.md).
|
|
4
|
+
|
|
5
|
+
A spinner shows pending work with no measurable total: a ring by default, dots or bars as variants. Rotation is meaningful motion, so put `nw-motion-essential` on a spinner that reports real pending work; without it the ring freezes as a static arc under reduced motion.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-cluster">
|
|
9
|
+
<span class="nw-spinner nw-spinner-xs nw-motion-essential" role="status" aria-label="Loading"></span>
|
|
10
|
+
<span class="nw-spinner nw-spinner-sm nw-spinner-secondary nw-motion-essential" role="status" aria-label="Loading"></span>
|
|
11
|
+
<span class="nw-spinner nw-motion-essential" role="status" aria-label="Loading"></span>
|
|
12
|
+
<span class="nw-spinner nw-spinner-lg nw-spinner-tertiary nw-motion-essential" role="status" aria-label="Loading"></span>
|
|
13
|
+
<span class="nw-spinner nw-spinner-xl nw-spinner-success nw-motion-essential" role="status" aria-label="Loading"></span>
|
|
14
|
+
<span class="nw-spinner nw-spinner-dots nw-motion-essential" role="status" aria-label="Loading"><i></i><i></i><i></i></span>
|
|
15
|
+
<span class="nw-spinner nw-spinner-bars nw-spinner-warning nw-motion-essential" role="status" aria-label="Loading"><i></i><i></i><i></i><i></i></span>
|
|
16
|
+
</div>
|
|
17
|
+
<div class="nw-card" style="position: relative; min-block-size: 6rem" aria-busy="true">
|
|
18
|
+
<p class="nw-card-description">Refreshing relay list...</p>
|
|
19
|
+
<div class="nw-spinner-overlay"><span class="nw-spinner nw-motion-essential" role="status" aria-label="Refreshing"></span></div>
|
|
20
|
+
</div>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
| Class | Effect |
|
|
24
|
+
| ------------------------------------ | ----------------------------------------------------------------------- |
|
|
25
|
+
| `nw-spinner` | The ring. Give it `role="status"` and an `aria-label`. |
|
|
26
|
+
| `nw-spinner-xs` ... `nw-spinner-xl` | Sizes. |
|
|
27
|
+
| `nw-spinner-primary` ... `-danger` | Arc intent. |
|
|
28
|
+
| `nw-spinner-dots`, `nw-spinner-bars` | Three bouncing dots, or four bars; put that many `<i>` children inside. |
|
|
29
|
+
| `nw-spinner-overlay` | Covers the nearest positioned ancestor while its content is busy. |
|
|
30
|
+
| `nw-motion-essential` | Keeps the spinner moving under `prefers-reduced-motion: reduce`. |
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# .nw-stack and .nw-spacer
|
|
2
|
+
|
|
3
|
+
Part of [Layout and typography](../families/layout-typography.md).
|
|
4
|
+
|
|
5
|
+
`nw-stack` is a column of boxes. `nw-stack-split` pushes the last child to the end; the alignment classes center or end it instead.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-stack">
|
|
9
|
+
<div class="nw-card nw-card-sm">First</div>
|
|
10
|
+
<div class="nw-card nw-card-sm">Second</div>
|
|
11
|
+
<div class="nw-card nw-card-sm">Last, pushed to the end by nw-stack-split</div>
|
|
12
|
+
</div>
|
|
13
|
+
<div class="nw-stack nw-stack-sm">
|
|
14
|
+
<div class="nw-card nw-card-sm">A small gap (0.5rem)</div>
|
|
15
|
+
<div class="nw-card nw-card-sm">Between these two cards</div>
|
|
16
|
+
</div>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Class / property | Effect |
|
|
20
|
+
| --------------------------------------------------- | --------------------------------------------------------- |
|
|
21
|
+
| `nw-stack` | A column with a 1rem gap. |
|
|
22
|
+
| `nw-stack-split` | The last child sits at the end (a footer in a sidebar). |
|
|
23
|
+
| `nw-stack-start`, `nw-stack-center`, `nw-stack-end` | Alignment of the children. |
|
|
24
|
+
| `nw-stack-xs` ... `nw-stack-xl` | Gaps 0.25rem, 0.5rem, 1rem (default), 1.5rem and 2.5rem. |
|
|
25
|
+
| `nw-gap-none` | No gap, on any of the three primitives. |
|
|
26
|
+
| `nw-spacer` | `flex: 1`: an invisible child that pushes the rest apart. |
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# .nw-steps
|
|
2
|
+
|
|
3
|
+
Part of [Navigation](../families/navigation.md).
|
|
4
|
+
|
|
5
|
+
Steps show where a user is in a sequence. Markers number themselves with a CSS counter; a completed marker swaps the number for a check, and the connector between markers fills as steps complete.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<ol class="nw-steps">
|
|
9
|
+
<li class="nw-step" data-state="complete">
|
|
10
|
+
<span class="nw-step-marker" aria-hidden="true"></span>
|
|
11
|
+
<div class="nw-step-body"><span class="nw-step-title">Connect</span><span class="nw-step-description">Link a node to the grid.</span></div>
|
|
12
|
+
</li>
|
|
13
|
+
<li class="nw-step" aria-current="step">
|
|
14
|
+
<span class="nw-step-marker" aria-hidden="true"></span>
|
|
15
|
+
<div class="nw-step-body"><span class="nw-step-title">Check route</span><span class="nw-step-description">The marker numbers itself; the current one glows.</span></div>
|
|
16
|
+
</li>
|
|
17
|
+
<li class="nw-step" data-state="upcoming">
|
|
18
|
+
<span class="nw-step-marker" aria-hidden="true"></span>
|
|
19
|
+
<div class="nw-step-body"><span class="nw-step-title">Go live</span></div>
|
|
20
|
+
</li>
|
|
21
|
+
</ol>
|
|
22
|
+
<ol class="nw-steps nw-steps-vertical nw-steps-sm nw-steps-secondary">
|
|
23
|
+
<li class="nw-step" data-state="complete"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Connected</span></div></li>
|
|
24
|
+
<li class="nw-step" data-state="error"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Route check failed</span><span class="nw-step-description">Error state.</span></div></li>
|
|
25
|
+
<li class="nw-step"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Go live</span></div></li>
|
|
26
|
+
</ol>
|
|
27
|
+
<ol class="nw-steps nw-steps-dots nw-steps-lg nw-steps-success">
|
|
28
|
+
<li class="nw-step" data-state="complete"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Done</span></div></li>
|
|
29
|
+
<li class="nw-step" aria-current="step"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Dots</span></div></li>
|
|
30
|
+
<li class="nw-step"><span class="nw-step-marker" aria-hidden="true"></span><div class="nw-step-body"><span class="nw-step-title">Next</span></div></li>
|
|
31
|
+
</ol>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
| Class / selector | Effect |
|
|
35
|
+
| ---------------------------------------------------------------- | ----------------------------------------------------------------------------- |
|
|
36
|
+
| `nw-steps` | The row of steps. |
|
|
37
|
+
| `nw-step` | One step: a marker and its body. |
|
|
38
|
+
| `nw-step-marker` | The numbered marker; render it as a `<button>` or `<a>` to make it clickable. |
|
|
39
|
+
| `nw-step-body`, `-title`, `-description` | The text beside the marker. |
|
|
40
|
+
| `data-state="complete"`, `nw-step-complete` | Completed: check marker, filled connector. |
|
|
41
|
+
| `aria-current="step"`, `data-state="current"`, `nw-step-current` | The current step: glowing marker, intent title. |
|
|
42
|
+
| `data-state="error"` | A failed step in the danger intent. |
|
|
43
|
+
| `nw-steps-vertical` | The flow runs downward. |
|
|
44
|
+
| `nw-steps-dots` | Shrinks the markers to dots. |
|
|
45
|
+
| `nw-steps-cut` | Chamfered markers. |
|
|
46
|
+
| `nw-steps-sm`, `-md`, `-lg` | Marker and title sizes. |
|
|
47
|
+
| `nw-steps-primary` ... `-danger` | Ink of completed and current steps. |
|
|
48
|
+
|
|
49
|
+
A marker is decorative: the step's state must also be readable as text, for example through the title, or it is lost to assistive technology and forced colors.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Switch: .nw-switch
|
|
2
|
+
|
|
3
|
+
Part of [Forms](../families/forms.md).
|
|
4
|
+
|
|
5
|
+
A switch is a checkbox with `role="switch"`, for a setting that applies at once. Off is a well with a neutral thumb, on is the intent with the on-accent thumb. The thumb moves on the compositor and squashes under the pointer without changing the track's box. For a setting that only applies on submit, use a checkbox.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<label class="nw-label"><input class="nw-switch" type="checkbox" role="switch" checked /> Live telemetry</label>
|
|
9
|
+
<label class="nw-label"><input class="nw-switch nw-switch-sm nw-switch-success" type="checkbox" role="switch" /> Auto-failover (small, success)</label>
|
|
10
|
+
<label class="nw-label"><input class="nw-switch nw-switch-lg nw-switch-secondary" type="checkbox" role="switch" checked /> Night mode (large, secondary)</label>
|
|
11
|
+
<label class="nw-label"><input class="nw-switch" type="checkbox" role="switch" disabled /> Maintenance lock (disabled)</label>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
| Class | Effect |
|
|
15
|
+
| --------------------------------- | --------------------------------------------------------------- |
|
|
16
|
+
| `nw-switch` | The track and thumb on `<input type="checkbox" role="switch">`. |
|
|
17
|
+
| `nw-switch-primary` ... `-danger` | Intent of the on state. |
|
|
18
|
+
| `nw-switch-sm`, `-md`, `-lg` | Track sizes. |
|
|
19
|
+
| `[dir="rtl"]` | The thumb travels the other way. |
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# .nw-table
|
|
2
|
+
|
|
3
|
+
Part of [Data display](../families/data-display.md).
|
|
4
|
+
|
|
5
|
+
A table is dense data rows with hairline rules, mono column labels and tabular numerals. The `nw-table-wrap` div supplies the border, the radius and the scroll area; the table itself is unboxed, so it also works bare.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-table-wrap">
|
|
9
|
+
<table class="nw-table nw-table-hover nw-table-sticky">
|
|
10
|
+
<caption>Six relays on the night grid</caption>
|
|
11
|
+
<thead>
|
|
12
|
+
<tr>
|
|
13
|
+
<th scope="col">Node</th>
|
|
14
|
+
<th scope="col" aria-sort="ascending"><button type="button" class="nw-table-sort">Region</button></th>
|
|
15
|
+
<th scope="col" aria-sort="none"><button type="button" class="nw-table-sort">Latency</button></th>
|
|
16
|
+
<th scope="col">Status</th>
|
|
17
|
+
</tr>
|
|
18
|
+
</thead>
|
|
19
|
+
<tbody>
|
|
20
|
+
<tr>
|
|
21
|
+
<th scope="row">hel-01</th>
|
|
22
|
+
<td>Helsinki</td>
|
|
23
|
+
<td class="nw-table-num">12 ms</td>
|
|
24
|
+
<td class="nw-table-ink nw-table-success">Online</td>
|
|
25
|
+
</tr>
|
|
26
|
+
<tr aria-selected="true">
|
|
27
|
+
<th scope="row">ams-03</th>
|
|
28
|
+
<td>Amsterdam</td>
|
|
29
|
+
<td class="nw-table-num">9 ms</td>
|
|
30
|
+
<td class="nw-table-ink nw-table-success">Online</td>
|
|
31
|
+
</tr>
|
|
32
|
+
<tr>
|
|
33
|
+
<th scope="row">fra-02</th>
|
|
34
|
+
<td>Frankfurt</td>
|
|
35
|
+
<td class="nw-table-num">31 ms</td>
|
|
36
|
+
<td class="nw-table-ink nw-table-warning">Degraded</td>
|
|
37
|
+
</tr>
|
|
38
|
+
<tr data-disabled>
|
|
39
|
+
<th scope="row">sto-04</th>
|
|
40
|
+
<td>Stockholm</td>
|
|
41
|
+
<td class="nw-table-num">—</td>
|
|
42
|
+
<td>Offline</td>
|
|
43
|
+
</tr>
|
|
44
|
+
</tbody>
|
|
45
|
+
<tfoot>
|
|
46
|
+
<tr><th scope="row">Average</th><td></td><td class="nw-table-num">17 ms</td><td></td></tr>
|
|
47
|
+
</tfoot>
|
|
48
|
+
</table>
|
|
49
|
+
</div>
|
|
50
|
+
<table class="nw-table nw-table-sm nw-table-striped nw-table-bordered">
|
|
51
|
+
<caption>Small, striped and bordered, no wrapper</caption>
|
|
52
|
+
<thead><tr><th>Node</th><th class="nw-table-num">Load</th></tr></thead>
|
|
53
|
+
<tbody>
|
|
54
|
+
<tr><td>hel-01</td><td class="nw-table-num">41%</td></tr>
|
|
55
|
+
<tr><td>ams-03</td><td class="nw-table-num">67%</td></tr>
|
|
56
|
+
<tr><td>fra-02</td><td class="nw-table-num">95%</td></tr>
|
|
57
|
+
<tr class="nw-table-danger"><td colspan="2">A row wash: fra-02 is over capacity</td></tr>
|
|
58
|
+
</tbody>
|
|
59
|
+
</table>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
| Class / selector | Effect |
|
|
63
|
+
| -------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
64
|
+
| `nw-table` | The table: mono uppercase labels, tabular numerals, hairlines between rows. |
|
|
65
|
+
| `nw-table-wrap` | Scroll wrapper with the border and radius; put the table inside for wide data. |
|
|
66
|
+
| `nw-table-sm`, `-md`, `-lg` | Cell padding and type. |
|
|
67
|
+
| `nw-table-striped` | Every second row washed. |
|
|
68
|
+
| `nw-table-hover` | Row hover; a selected row keeps its intent wash while hovered. |
|
|
69
|
+
| `nw-table-bordered` | Hairlines between columns too. |
|
|
70
|
+
| `nw-table-sticky` | The header stays put while the body scrolls (inside the wrapper). |
|
|
71
|
+
| `nw-table-num` | A numeric column: tabular figures, aligned to the end. |
|
|
72
|
+
| `nw-table-center` | A centered column. |
|
|
73
|
+
| `nw-table-empty` | An empty-state cell: generous padding, centered, subtle ink. |
|
|
74
|
+
| `nw-table-caption-top` | Moves the caption above the table. |
|
|
75
|
+
| `nw-table-sort` | A sort button inside a `th`; the arrow comes from the `th`'s `aria-sort`. |
|
|
76
|
+
| `th[aria-sort]` | Draws the direction arrow; `aria-sort="none"` draws nothing. |
|
|
77
|
+
| `tr[aria-selected="true"]`, `tr[data-selected]` | The selected row: a soft intent wash. |
|
|
78
|
+
| `tr[data-disabled]` | Muted row. |
|
|
79
|
+
| `tr:focus-visible` | A row can be a target (with `tabindex`); focus draws a ring. |
|
|
80
|
+
| `nw-table-primary` ... `-danger` on a `tr`, `th` or `td` | A soft intent wash on the row or cell. |
|
|
81
|
+
| `nw-table-ink` | Pair it with an intent class: the cell's text carries the intent ink too. |
|
|
82
|
+
|
|
83
|
+
A bare `<td>` wash without `.nw-table-ink` colors only the background; add the ink class when the text itself must carry the color.
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# .nw-tabs
|
|
2
|
+
|
|
3
|
+
Part of [Navigation](../families/navigation.md).
|
|
4
|
+
|
|
5
|
+
Tabs follow the WAI-ARIA tabs pattern: a `role="tablist"` of `role="tab"` buttons and one `role="tabpanel"` per tab. The CSS keys on the roles and on `aria-selected`, so the markup is the API. Tabs switch panels with JavaScript; the CSS hides panels that carry `hidden`.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-tabs" data-tabs>
|
|
9
|
+
<div role="tablist" aria-label="Relay">
|
|
10
|
+
<button type="button" role="tab" id="t-load" aria-selected="true" aria-controls="p-load">Load <span class="nw-tab-count">12</span></button>
|
|
11
|
+
<button type="button" role="tab" id="t-routes" aria-selected="false" aria-controls="p-routes" tabindex="-1">Routes</button>
|
|
12
|
+
<button type="button" role="tab" id="t-log" aria-selected="false" aria-controls="p-log" tabindex="-1">Log</button>
|
|
13
|
+
<button type="button" role="tab" id="t-locked" aria-selected="false" aria-controls="p-locked" tabindex="-1" disabled>Locked</button>
|
|
14
|
+
</div>
|
|
15
|
+
<div role="tabpanel" id="p-load" aria-labelledby="t-load" tabindex="0">Load: twelve metrics, sampled every second.</div>
|
|
16
|
+
<div role="tabpanel" id="p-routes" aria-labelledby="t-routes" tabindex="0" hidden>Routes panel.</div>
|
|
17
|
+
<div role="tabpanel" id="p-log" aria-labelledby="t-log" tabindex="0" hidden>Log panel.</div>
|
|
18
|
+
<div role="tabpanel" id="p-locked" aria-labelledby="t-locked" tabindex="0" hidden>Locked.</div>
|
|
19
|
+
</div>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
| Selector / class | Effect |
|
|
23
|
+
| ------------------------------------------------------------------ | ----------------------------------------------------------------------------- |
|
|
24
|
+
| `nw-tabs` | The wrapper. The selected tab sits on a tonal wash in the intent ink. |
|
|
25
|
+
| `[role="tablist"]`, `nw-tabs-list` | The row, or column when vertical, of tabs. |
|
|
26
|
+
| `[role="tab"]`, `nw-tab` | A tab. |
|
|
27
|
+
| `[aria-selected="true"]`, `[data-state="active"]`, `nw-tab-active` | The selected tab. |
|
|
28
|
+
| `[role="tabpanel"]`, `nw-tabs-panel` | A panel. Hidden while it has `hidden` or `data-state="inactive"`. |
|
|
29
|
+
| `:disabled`, `[aria-disabled="true"]` | Dimmed, not clickable. |
|
|
30
|
+
| `nw-tab-icon` | Leading icon slot; mark it `aria-hidden`. |
|
|
31
|
+
| `nw-tab-count` | A small count chip inside a tab; it takes the intent ink on the selected tab. |
|
|
32
|
+
|
|
33
|
+
## Variants and sizes
|
|
34
|
+
|
|
35
|
+
```html
|
|
36
|
+
<div class="nw-tabs nw-tabs-pill nw-tabs-sm" data-tabs>
|
|
37
|
+
<div role="tablist" aria-label="Range">
|
|
38
|
+
<button type="button" role="tab" id="t-p1" aria-selected="true" aria-controls="p-p1">Day</button>
|
|
39
|
+
<button type="button" role="tab" id="t-p2" aria-selected="false" aria-controls="p-p2" tabindex="-1">Week</button>
|
|
40
|
+
<button type="button" role="tab" id="t-p3" aria-selected="false" aria-controls="p-p3" tabindex="-1">Month</button>
|
|
41
|
+
</div>
|
|
42
|
+
<div role="tabpanel" id="p-p1" aria-labelledby="t-p1" tabindex="0">Pill variant, small.</div>
|
|
43
|
+
<div role="tabpanel" id="p-p2" aria-labelledby="t-p2" tabindex="0" hidden>Week.</div>
|
|
44
|
+
<div role="tabpanel" id="p-p3" aria-labelledby="t-p3" tabindex="0" hidden>Month.</div>
|
|
45
|
+
</div>
|
|
46
|
+
<div class="nw-tabs nw-tabs-pill nw-tabs-cut nw-tabs-stretch nw-tabs-lg nw-tabs-secondary" data-tabs>
|
|
47
|
+
<div role="tablist" aria-label="Journal">
|
|
48
|
+
<button type="button" role="tab" id="t-s1" aria-selected="false" aria-controls="p-s1" tabindex="-1">Map</button>
|
|
49
|
+
<button type="button" role="tab" id="t-s2" aria-selected="true" aria-controls="p-s2">Journal</button>
|
|
50
|
+
<button type="button" role="tab" id="t-s3" aria-selected="false" aria-controls="p-s3" tabindex="-1">Shards</button>
|
|
51
|
+
</div>
|
|
52
|
+
<div role="tabpanel" id="p-s1" aria-labelledby="t-s1" tabindex="0" hidden>Map.</div>
|
|
53
|
+
<div role="tabpanel" id="p-s2" aria-labelledby="t-s2" tabindex="0">Pill, cut, stretch and large, in the secondary intent.</div>
|
|
54
|
+
<div role="tabpanel" id="p-s3" aria-labelledby="t-s3" tabindex="0" hidden>Shards.</div>
|
|
55
|
+
</div>
|
|
56
|
+
<div class="nw-tabs nw-tabs-vertical" data-tabs>
|
|
57
|
+
<div role="tablist" aria-label="Settings" aria-orientation="vertical">
|
|
58
|
+
<button type="button" role="tab" id="t-v1" aria-selected="true" aria-controls="p-v1">Audio</button>
|
|
59
|
+
<button type="button" role="tab" id="t-v2" aria-selected="false" aria-controls="p-v2" tabindex="-1">Video</button>
|
|
60
|
+
<button type="button" role="tab" id="t-v3" aria-selected="false" aria-controls="p-v3" tabindex="-1">Controls</button>
|
|
61
|
+
</div>
|
|
62
|
+
<div role="tabpanel" id="p-v1" aria-labelledby="t-v1" tabindex="0">Vertical tabs: the up and down arrows move the selection.</div>
|
|
63
|
+
<div role="tabpanel" id="p-v2" aria-labelledby="t-v2" tabindex="0" hidden>Video.</div>
|
|
64
|
+
<div role="tabpanel" id="p-v3" aria-labelledby="t-v3" tabindex="0" hidden>Controls.</div>
|
|
65
|
+
</div>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Class | Effect |
|
|
69
|
+
| --------------------------------- | ----------------------------------------------------------------------------------------------- |
|
|
70
|
+
| `nw-tabs-pill` | A segmented control on a sunken track; the selected segment is solid and glows. |
|
|
71
|
+
| `nw-tabs-cut` | Folder tabs with the top-right corner chamfered; the selected tab is a solid intent panel. |
|
|
72
|
+
| `nw-tabs-vertical` | The list runs down the inline-start side. Set `aria-orientation="vertical"` on the tablist too. |
|
|
73
|
+
| `nw-tabs-stretch` | Tabs share the available width. |
|
|
74
|
+
| `nw-tabs-xs`, `-sm`, `-md`, `-lg` | Tab sizes. |
|
|
75
|
+
| `nw-tabs-primary` ... `-danger` | The intent of the wash, the count and the selected segment. |
|
|
76
|
+
|
|
77
|
+
## Link-based tabs
|
|
78
|
+
|
|
79
|
+
The same look works for navigation between pages. `nw-tabs-list` is a plain container, `nw-tab` styles an `<a>` or `<button>`, `nw-tab-active` marks the current one and `nw-tabs-panel` wraps the content. Use `aria-current="page"` rather than the ARIA tab roles here, because the items are links.
|
|
80
|
+
|
|
81
|
+
```html
|
|
82
|
+
<div class="nw-tabs">
|
|
83
|
+
<nav class="nw-tabs-list" aria-label="Relay docs">
|
|
84
|
+
<a class="nw-tab nw-tab-active" href="#link-based-tabs" aria-current="page">Overview</a>
|
|
85
|
+
<a class="nw-tab" href="#link-based-tabs"><span class="nw-tab-icon" aria-hidden="true"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><circle cx="12" cy="12" r="9"/><path d="M12 8v4l3 2"/></svg></span>Metrics</a>
|
|
86
|
+
<a class="nw-tab" href="#link-based-tabs" aria-disabled="true">Changelog</a>
|
|
87
|
+
</nav>
|
|
88
|
+
<div class="nw-tabs-panel">Link-based tabs navigate between pages instead of toggling panels.</div>
|
|
89
|
+
</div>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Tab behavior script
|
|
93
|
+
|
|
94
|
+
The CSS does not switch tabs. The demos on this page use a small delegated script (`data-tabs` on the wrapper) that sets `aria-selected`, the roving `tabindex` and the panels' `hidden`, and handles the arrow, Home and End keys. In a framework, use the Vue components or your own state; the markup contract stays the same.
|
|
95
|
+
|
|
96
|
+
```js title="native-behaviors.js"
|
|
97
|
+
// Native behaviors for the plain-HTML component demos. The nw-* classes need none of this; it only
|
|
98
|
+
// wires the platform features and the documented state attributes the markup relies on.
|
|
99
|
+
export function bindNativeBehaviors() {
|
|
100
|
+
document.addEventListener('click', (event) => {
|
|
101
|
+
const target = event.target
|
|
102
|
+
if (!(target instanceof Element)) return
|
|
103
|
+
|
|
104
|
+
// [data-open="#id"] opens a modal <dialog>; [data-close] closes the dialog it sits in.
|
|
105
|
+
const opener = target.closest('[data-open]')
|
|
106
|
+
if (opener) {
|
|
107
|
+
const dialog = document.querySelector(opener.getAttribute('data-open'))
|
|
108
|
+
if (dialog instanceof HTMLDialogElement && !dialog.open) dialog.showModal()
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
const closer = target.closest('[data-close]')
|
|
112
|
+
if (closer) {
|
|
113
|
+
closer.closest('dialog')?.close()
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// [data-toggle="#id"] flips aria-expanded on the trigger and data-state on the target, the
|
|
118
|
+
// contract of the navbar collapse region and of collapsible sidenav groups.
|
|
119
|
+
const toggle = target.closest('[data-toggle]')
|
|
120
|
+
if (toggle) {
|
|
121
|
+
const region = document.querySelector(toggle.getAttribute('data-toggle'))
|
|
122
|
+
const open = toggle.getAttribute('aria-expanded') !== 'true'
|
|
123
|
+
toggle.setAttribute('aria-expanded', String(open))
|
|
124
|
+
region?.setAttribute('data-state', open ? 'open' : 'closed')
|
|
125
|
+
return
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// [data-toast="#template"] stamps the template's toast into the region that holds the template;
|
|
129
|
+
// [data-dismiss] plays the toast's exit (data-state="closed") and removes it once it ends.
|
|
130
|
+
const notifier = target.closest('[data-toast]')
|
|
131
|
+
if (notifier) {
|
|
132
|
+
const template = document.querySelector(notifier.getAttribute('data-toast'))
|
|
133
|
+
if (template instanceof HTMLTemplateElement) {
|
|
134
|
+
template.parentElement?.append(template.content.cloneNode(true))
|
|
135
|
+
}
|
|
136
|
+
return
|
|
137
|
+
}
|
|
138
|
+
const toast = target.closest('[data-dismiss]')?.closest('.nw-toast')
|
|
139
|
+
if (toast) {
|
|
140
|
+
toast.setAttribute('data-state', 'closed')
|
|
141
|
+
Promise.all(toast.getAnimations().map((animation) => animation.finished)).then(() =>
|
|
142
|
+
toast.remove(),
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Range inputs: WebKit and Blink have no progress pseudo-element, so the fill reads
|
|
148
|
+
// --_slider-value. An <output for="id"> mirrors the value.
|
|
149
|
+
const paintSlider = (slider) => {
|
|
150
|
+
const min = Number(slider.min || 0)
|
|
151
|
+
const max = Number(slider.max || 100)
|
|
152
|
+
const percent = ((Number(slider.value) - min) / (max - min)) * 100
|
|
153
|
+
slider.style.setProperty('--_slider-value', `${percent}%`)
|
|
154
|
+
for (const output of document.querySelectorAll('output')) {
|
|
155
|
+
if (output.htmlFor.contains(slider.id)) output.value = slider.value
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (const slider of document.querySelectorAll('input.nw-slider')) paintSlider(slider)
|
|
159
|
+
document.addEventListener('input', (event) => {
|
|
160
|
+
if (event.target instanceof HTMLInputElement && event.target.matches('.nw-slider'))
|
|
161
|
+
paintSlider(event.target)
|
|
162
|
+
})
|
|
163
|
+
|
|
164
|
+
// Tab lists: click and arrow keys move selection (roving tabindex), Home and End jump.
|
|
165
|
+
for (const tabs of document.querySelectorAll('[data-tabs]')) {
|
|
166
|
+
const list = tabs.querySelector('[role="tablist"]')
|
|
167
|
+
if (!list) continue
|
|
168
|
+
const vertical = list.getAttribute('aria-orientation') === 'vertical'
|
|
169
|
+
const enabledTabs = () => [...list.querySelectorAll('[role="tab"]:not(:disabled)')]
|
|
170
|
+
|
|
171
|
+
const select = (tab, focus) => {
|
|
172
|
+
for (const item of list.querySelectorAll('[role="tab"]')) {
|
|
173
|
+
const selected = item === tab
|
|
174
|
+
item.setAttribute('aria-selected', String(selected))
|
|
175
|
+
item.tabIndex = selected ? 0 : -1
|
|
176
|
+
const panel = document.getElementById(item.getAttribute('aria-controls'))
|
|
177
|
+
if (panel) panel.hidden = !selected
|
|
178
|
+
}
|
|
179
|
+
if (focus) tab.focus()
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
list.addEventListener('click', (event) => {
|
|
183
|
+
const tab = event.target instanceof Element ? event.target.closest('[role="tab"]') : null
|
|
184
|
+
if (tab && !tab.disabled) select(tab, false)
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
list.addEventListener('keydown', (event) => {
|
|
188
|
+
const all = enabledTabs()
|
|
189
|
+
const index = all.indexOf(document.activeElement)
|
|
190
|
+
if (index < 0) return
|
|
191
|
+
const previousKey = vertical ? 'ArrowUp' : 'ArrowLeft'
|
|
192
|
+
const nextKey = vertical ? 'ArrowDown' : 'ArrowRight'
|
|
193
|
+
let next
|
|
194
|
+
if (event.key === nextKey) next = all[(index + 1) % all.length]
|
|
195
|
+
else if (event.key === previousKey) next = all[(index - 1 + all.length) % all.length]
|
|
196
|
+
else if (event.key === 'Home') next = all[0]
|
|
197
|
+
else if (event.key === 'End') next = all[all.length - 1]
|
|
198
|
+
if (!next) return
|
|
199
|
+
event.preventDefault()
|
|
200
|
+
select(next, true)
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// The indeterminate state of a checkbox has no attribute; it is a DOM property.
|
|
205
|
+
for (const box of document.querySelectorAll('[data-indeterminate]')) box.indeterminate = true
|
|
206
|
+
}
|
|
207
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Textarea
|
|
2
|
+
|
|
3
|
+
Part of [Forms](../families/forms.md).
|
|
4
|
+
|
|
5
|
+
There is no separate class: `textarea.nw-input` uses the same well with no fixed height and vertical resizing.
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<div class="nw-field">
|
|
9
|
+
<label class="nw-label" for="f-notes">Change notes</label>
|
|
10
|
+
<textarea class="nw-input" id="f-notes" rows="3" placeholder="What changed on this relay?"></textarea>
|
|
11
|
+
<p class="nw-field-hint">Markdown is supported.</p>
|
|
12
|
+
</div>
|
|
13
|
+
```
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# .nw-toast
|
|
2
|
+
|
|
3
|
+
Part of [Overlays](../families/overlays.md).
|
|
4
|
+
|
|
5
|
+
A toast is a transient message. The CSS styles the elements; a script adds them to a `nw-toast-region`, removes them and sets `data-state="closed"` for the leave motion. The region is `position: fixed`, pinned to a corner; the demo overrides that inline so it can sit inside the page. In the demo the region also holds the `<template>` elements: a button stamps a template's toast into the region (`data-toast="#tpl-id"`) and the close buttons play the exit (`data-dismiss`).
|
|
6
|
+
|
|
7
|
+
Use `role="status"` for routine messages and `role="alert"` for errors. Do not put an action that exists nowhere else in a toast: it disappears.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<div class="nw-cluster nw-cluster-top">
|
|
11
|
+
<button type="button" class="nw-btn nw-btn-soft" data-toast="#tpl-success">Success toast</button>
|
|
12
|
+
<button type="button" class="nw-btn nw-btn-soft nw-btn-warning" data-toast="#tpl-warning">Warning toast</button>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="nw-toast-region" role="region" aria-label="Notifications" style="position: static; width: auto; translate: none">
|
|
15
|
+
<div class="nw-toast nw-toast-success" role="status" data-state="open">
|
|
16
|
+
<svg class="nw-toast-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 13l4 4L19 7"/></svg>
|
|
17
|
+
<div class="nw-toast-body">
|
|
18
|
+
<p class="nw-toast-title">Deployed</p>
|
|
19
|
+
<p class="nw-toast-description">Build 412 is live on every relay.</p>
|
|
20
|
+
</div>
|
|
21
|
+
<button type="button" class="nw-toast-close" data-dismiss aria-label="Dismiss"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
|
|
22
|
+
<span class="nw-toast-timer" aria-hidden="true"></span>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="nw-toast" role="status" data-state="open">
|
|
25
|
+
<div class="nw-toast-body">
|
|
26
|
+
<p class="nw-toast-title">Default (primary)</p>
|
|
27
|
+
<p class="nw-toast-description">The timer drains over --nw-toast-duration.</p>
|
|
28
|
+
<div class="nw-toast-actions"><button type="button" class="nw-btn nw-btn-sm nw-btn-ghost">View</button></div>
|
|
29
|
+
</div>
|
|
30
|
+
<button type="button" class="nw-toast-close" data-dismiss aria-label="Dismiss"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
|
|
31
|
+
<span class="nw-toast-timer" aria-hidden="true"></span>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="nw-toast nw-toast-warning nw-toast-solid" role="alert" data-state="open">
|
|
34
|
+
<div class="nw-toast-body">
|
|
35
|
+
<p class="nw-toast-title">Uplink degraded</p>
|
|
36
|
+
<p class="nw-toast-description">Solid variant, warning intent.</p>
|
|
37
|
+
</div>
|
|
38
|
+
<button type="button" class="nw-toast-close" data-dismiss aria-label="Dismiss"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
|
|
39
|
+
</div>
|
|
40
|
+
<template id="tpl-success">
|
|
41
|
+
<div class="nw-toast nw-toast-success" role="status">
|
|
42
|
+
<svg class="nw-toast-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 13l4 4L19 7"/></svg>
|
|
43
|
+
<div class="nw-toast-body">
|
|
44
|
+
<p class="nw-toast-title">Deployed</p>
|
|
45
|
+
<p class="nw-toast-description">A fresh toast, stamped into this region.</p>
|
|
46
|
+
<div class="nw-toast-actions"><button type="button" class="nw-btn nw-btn-sm nw-btn-ghost" data-dismiss>Dismiss</button></div>
|
|
47
|
+
</div>
|
|
48
|
+
<button type="button" class="nw-toast-close" data-dismiss aria-label="Dismiss"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
|
|
49
|
+
<span class="nw-toast-timer nw-motion-essential" aria-hidden="true"></span>
|
|
50
|
+
</div>
|
|
51
|
+
</template>
|
|
52
|
+
<template id="tpl-warning">
|
|
53
|
+
<div class="nw-toast nw-toast-warning" role="alert">
|
|
54
|
+
<div class="nw-toast-body">
|
|
55
|
+
<p class="nw-toast-title">Uplink degraded</p>
|
|
56
|
+
<p class="nw-toast-description">role="alert", for messages that need attention now.</p>
|
|
57
|
+
</div>
|
|
58
|
+
<button type="button" class="nw-toast-close" data-dismiss aria-label="Dismiss"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg></button>
|
|
59
|
+
<span class="nw-toast-timer nw-motion-essential" aria-hidden="true"></span>
|
|
60
|
+
</div>
|
|
61
|
+
</template>
|
|
62
|
+
</div>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
| Class / attribute | Effect |
|
|
66
|
+
| ----------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
67
|
+
| `nw-toast-region` | Fixed stack container (`role="region"` with an `aria-label`). Bottom-right by default; top regions reverse the stacking order. |
|
|
68
|
+
| `nw-toast-region-top-left`, `-top-center`, `-top-right`, `-bottom-left`, `-bottom-center` | Region position; the default region is the bottom-right one. |
|
|
69
|
+
| `nw-toast` | The toast: sunken fill, hairline, slide-in, a draining timer along the bottom edge. Primary by default. |
|
|
70
|
+
| `nw-toast-primary` ... `-danger` | Intent of the icon and the timer. |
|
|
71
|
+
| `nw-toast-solid` | Opaque panel for pages without a backdrop. |
|
|
72
|
+
| `nw-toast-soft` | A soft intent tint over the panel instead of the sunken fill. |
|
|
73
|
+
| `nw-toast-icon` | Leading icon; mark it `aria-hidden`. Without it the body starts at the edge. |
|
|
74
|
+
| `nw-toast-body` | The text column. |
|
|
75
|
+
| `nw-toast-title`, `nw-toast-description` | Text parts. |
|
|
76
|
+
| `nw-toast-actions` | Action buttons. |
|
|
77
|
+
| `nw-toast-close` | Dismiss button; needs an `aria-label`. |
|
|
78
|
+
| `nw-toast-timer` | Countdown bar. It drains over `--nw-toast-duration` (5s by default) and pauses while the toast is hovered or holds focus. |
|
|
79
|
+
| `nw-toast-wire`, `-glow`, `-cut` | The gradient edge, a bloom, and cut corners. |
|
|
80
|
+
| `nw-toast-xs`, `-sm`, `-md`, `-lg` | Toast sizes. |
|
|
81
|
+
| `[data-state="open"]`, `[data-state="closed"]` | Enter and leave motion; play `closed`, then remove the node. |
|
|
82
|
+
| `[data-toast="#template-id"]` | Demo wiring: stamps the template's toast into the region that holds the template. |
|
|
83
|
+
| `[data-dismiss]` | Demo wiring: plays `data-state="closed"`, then removes the toast once its animations end. |
|
|
84
|
+
| `[data-swipe="move"]`, `"cancel"`, `"end"` | Swipe-to-dismiss states, following the region's swipe axis. |
|
|
85
|
+
|
|
86
|
+
The timer is meaningful motion: mark the timer of a toast that really auto-dismisses with `nw-motion-essential` so the countdown keeps its duration under reduced motion; otherwise the track is hidden rather than frozen at a misleading width.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# .nw-tooltip
|
|
2
|
+
|
|
3
|
+
Part of [Overlays](../families/overlays.md).
|
|
4
|
+
|
|
5
|
+
There are two tooltips, for two kinds of control.
|
|
6
|
+
|
|
7
|
+
**`[data-tooltip]` (CSS only)** needs no markup. The text comes from the attribute and shows on hover and `:focus-visible` after a short delay. Placement is `data-side` (`top` by default, then `bottom`, `left`, `right`); an empty attribute renders nothing. The label is an absolutely positioned pseudo-element, so near the edge of a narrow page it can widen the page: keep it away from `overflow: hidden` ancestors and edge-of-screen triggers. It has no touch path and is not announced as a description, so keep the same information in a visible label or `aria-label` for essential controls.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<div class="nw-cluster">
|
|
11
|
+
<button type="button" class="nw-btn nw-btn-outline nw-btn-neutral" data-tooltip="Default placement: top">Top</button>
|
|
12
|
+
<button type="button" class="nw-btn nw-btn-outline nw-btn-neutral" data-tooltip="Placement: bottom" data-side="bottom">Bottom</button>
|
|
13
|
+
<button type="button" class="nw-btn nw-btn-outline nw-btn-neutral" data-tooltip="Placement: left" data-side="left">Left</button>
|
|
14
|
+
<button type="button" class="nw-btn nw-btn-outline nw-btn-neutral" data-tooltip="Placement: right" data-side="right">Right</button>
|
|
15
|
+
<button type="button" class="nw-btn nw-btn-outline nw-btn-neutral" data-tooltip="A longer tooltip that wraps onto a second line once it passes its measure" data-side="bottom">Long text</button>
|
|
16
|
+
</div>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
**`.nw-tooltip` (positioned box)** is the box itself. A script (the Vue `NwTooltip`, Floating UI) positions it next to its anchor and sets `data-state` and `data-side`. It carries `role="tooltip"` and should be referenced from the anchor with `aria-describedby`. Shown here statically:
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<div class="nw-cluster nw-cluster-top">
|
|
23
|
+
<span class="nw-tooltip" role="tooltip" data-state="open" data-side="top">Reroute the sector<kbd class="nw-tooltip-kbd">R</kbd></span>
|
|
24
|
+
<span class="nw-tooltip" role="tooltip" data-state="open" data-side="bottom">data-side="bottom"</span>
|
|
25
|
+
<span class="nw-tooltip nw-tooltip-sm nw-tooltip-warning" role="tooltip" data-state="open" data-side="bottom">Warning tooltip<span class="nw-tooltip-arrow" data-side="top" style="bottom: 100%; left: 50%; translate: -50% 0"></span></span>
|
|
26
|
+
</div>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
| Class / attribute | Effect |
|
|
30
|
+
| ---------------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
31
|
+
| `[data-tooltip]` | Adds a CSS-only tooltip from the attribute value. |
|
|
32
|
+
| `[data-side]` | `top` (default), `bottom`, `left` or `right`, on both the pseudo-element and the box. |
|
|
33
|
+
| `nw-tooltip` | The box: sunken fill, strong hairline, small type, no pointer events. |
|
|
34
|
+
| `nw-tooltip-kbd` | A trailing key hint inside the box. |
|
|
35
|
+
| `nw-tooltip-arrow` | An element arrow: a rotated square in the box's own fill; give it the box's `data-side`. |
|
|
36
|
+
| `nw-tooltip-xs`, `-sm`, `-md`, `-lg` | Type and padding. |
|
|
37
|
+
| `nw-tooltip-primary` ... `-danger` | Intents color the border and the kbd. |
|
|
38
|
+
| `nw-tooltip-glow` | A bloom around the box. |
|
|
39
|
+
| `[data-state="open"]`, `[data-state="closed"]` | Enter and leave animation. |
|