@reliability-design/web 1.4.6 → 1.4.7
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/CHANGELOG.md +211 -49
- package/dist/components/rel-accordion/README.md +132 -132
- package/dist/components/rel-alert/README.md +145 -141
- package/dist/components/rel-autocomplete/README.md +156 -61
- package/dist/components/rel-avatar/README.md +116 -130
- package/dist/components/rel-badge/README.md +98 -93
- package/dist/components/rel-breadcrumb/README.md +96 -102
- package/dist/components/rel-button/README.md +160 -130
- package/dist/components/rel-calendar/README.md +109 -109
- package/dist/components/rel-card/README.md +75 -94
- package/dist/components/rel-cardmedia/README.md +100 -127
- package/dist/components/rel-carousel/README.md +184 -166
- package/dist/components/rel-checkbox/README.md +93 -75
- package/dist/components/rel-chip/README.md +132 -121
- package/dist/components/rel-container/README.md +107 -99
- package/dist/components/rel-date-picker/README.md +200 -289
- package/dist/components/rel-divider/README.md +78 -100
- package/dist/components/rel-drawer/README.md +187 -200
- package/dist/components/rel-kbd/README.md +141 -151
- package/dist/components/rel-menu/README.md +178 -151
- package/dist/components/rel-menubar/README.md +218 -329
- package/dist/components/rel-otp/README.md +170 -440
- package/dist/components/rel-pagination/README.md +100 -424
- package/dist/components/rel-popover/README.md +203 -568
- package/dist/components/rel-progress/README.md +88 -110
- package/dist/components/rel-radio/README.md +131 -138
- package/dist/components/rel-range-picker/README.md +162 -0
- package/dist/components/rel-resizable/README.md +199 -140
- package/dist/components/rel-segmented-button/README.md +155 -141
- package/dist/components/rel-select/README.md +154 -93
- package/dist/components/rel-sheet/README.md +168 -224
- package/dist/components/rel-skeleton/README.md +103 -0
- package/dist/components/rel-slider/README.md +130 -135
- package/dist/components/rel-snackbar/README.md +162 -134
- package/dist/components/rel-stepper/README.md +158 -160
- package/dist/components/rel-switch/README.md +108 -102
- package/dist/components/rel-tab/README.md +171 -163
- package/dist/components/rel-textfield/README.md +159 -69
- package/dist/components/rel-time-picker/README.md +122 -157
- package/dist/components/rel-toast/README.md +157 -148
- package/dist/components/rel-tooltip/README.md +108 -111
- package/dist/components/rel-upload/README.md +220 -0
- package/dist/index.d.mts +1147 -340
- package/dist/index.d.ts +1147 -340
- package/dist/index.js +3451 -3163
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3416 -3118
- package/dist/index.mjs.map +1 -1
- package/dist/styles/vars.css +877 -866
- package/dist/{vars-XNMTSRVN.css → vars-JHTUGNRG.css} +877 -866
- package/package.json +3 -2
- package/dist/components/rel-accordion/rel-accordion.ts +0 -336
- package/dist/components/rel-alert/rel-alert.ts +0 -305
- package/dist/components/rel-autocomplete/rel-autocomplete.ts +0 -720
- package/dist/components/rel-avatar/rel-avatar.ts +0 -142
- package/dist/components/rel-badge/rel-badge.ts +0 -175
- package/dist/components/rel-breadcrumb/rel-breadcrumb.ts +0 -106
- package/dist/components/rel-button/rel-button.ts +0 -560
- package/dist/components/rel-calendar/index.ts +0 -1
- package/dist/components/rel-calendar/rel-calendar.ts +0 -565
- package/dist/components/rel-card/rel-card.ts +0 -88
- package/dist/components/rel-cardmedia/rel-cardmedia.ts +0 -88
- package/dist/components/rel-carousel/index.ts +0 -1
- package/dist/components/rel-carousel/rel-carousel.ts +0 -723
- package/dist/components/rel-chart/README.md +0 -286
- package/dist/components/rel-chart/index.ts +0 -1
- package/dist/components/rel-chart/rel-chart.ts +0 -754
- package/dist/components/rel-checkbox/rel-checkbox.ts +0 -382
- package/dist/components/rel-chip/rel-chip.ts +0 -483
- package/dist/components/rel-container/rel-container.ts +0 -95
- package/dist/components/rel-date-picker/date-format.test.ts +0 -43
- package/dist/components/rel-date-picker/date-format.ts +0 -47
- package/dist/components/rel-date-picker/date-parse.test.ts +0 -116
- package/dist/components/rel-date-picker/date-parse.ts +0 -178
- package/dist/components/rel-date-picker/index.ts +0 -1
- package/dist/components/rel-date-picker/rel-date-picker.ts +0 -1676
- package/dist/components/rel-divider/rel-divider.ts +0 -54
- package/dist/components/rel-drawer/index.ts +0 -1
- package/dist/components/rel-drawer/rel-drawer-footer.ts +0 -27
- package/dist/components/rel-drawer/rel-drawer.ts +0 -607
- package/dist/components/rel-kbd/rel-kbd.ts +0 -188
- package/dist/components/rel-layout/rel-layout.ts +0 -49
- package/dist/components/rel-menu/rel-menu.ts +0 -541
- package/dist/components/rel-menubar/index.ts +0 -2
- package/dist/components/rel-menubar/rel-menubar-menu.css +0 -3
- package/dist/components/rel-menubar/rel-menubar-menu.ts +0 -17
- package/dist/components/rel-menubar/rel-menubar.ts +0 -777
- package/dist/components/rel-nav-menu/README.md +0 -289
- package/dist/components/rel-nav-menu/index.ts +0 -3
- package/dist/components/rel-nav-menu/rel-nav-menu-item.ts +0 -243
- package/dist/components/rel-nav-menu/rel-nav-menu-panel.ts +0 -72
- package/dist/components/rel-nav-menu/rel-nav-menu.ts +0 -270
- package/dist/components/rel-navbar/README.md +0 -126
- package/dist/components/rel-navbar/rel-navbar.ts +0 -105
- package/dist/components/rel-otp/index.ts +0 -1
- package/dist/components/rel-otp/rel-otp.ts +0 -527
- package/dist/components/rel-pagination/index.ts +0 -1
- package/dist/components/rel-pagination/rel-pagination.ts +0 -522
- package/dist/components/rel-popover/index.ts +0 -2
- package/dist/components/rel-popover/rel-popover-content.ts +0 -81
- package/dist/components/rel-popover/rel-popover.ts +0 -475
- package/dist/components/rel-progress/rel-progress.ts +0 -234
- package/dist/components/rel-radio/rel-radio.ts +0 -481
- package/dist/components/rel-range-picker/rel-range-picker.ts +0 -1688
- package/dist/components/rel-resizable/index.ts +0 -3
- package/dist/components/rel-resizable/rel-resizable-group.ts +0 -405
- package/dist/components/rel-resizable/rel-resizable-handle.ts +0 -150
- package/dist/components/rel-resizable/rel-resizable-panel.ts +0 -58
- package/dist/components/rel-segmented-button/rel-segmented-button.ts +0 -217
- package/dist/components/rel-select/rel-select.ts +0 -1416
- package/dist/components/rel-sheet/rel-sheet.ts +0 -610
- package/dist/components/rel-sidebar/README.md +0 -209
- package/dist/components/rel-sidebar/rel-sidebar.ts +0 -1191
- package/dist/components/rel-skeleton/rel-skeleton.ts +0 -143
- package/dist/components/rel-slider/rel-slider.ts +0 -673
- package/dist/components/rel-snackbar/rel-snackbar.ts +0 -329
- package/dist/components/rel-stepper/rel-stepper.ts +0 -567
- package/dist/components/rel-switch/rel-switch.ts +0 -199
- package/dist/components/rel-tab/rel-tab.ts +0 -264
- package/dist/components/rel-table/README.md +0 -178
- package/dist/components/rel-table/rel-table-body.ts +0 -22
- package/dist/components/rel-table/rel-table-caption.ts +0 -30
- package/dist/components/rel-table/rel-table-cell.ts +0 -43
- package/dist/components/rel-table/rel-table-footer.ts +0 -24
- package/dist/components/rel-table/rel-table-head.ts +0 -47
- package/dist/components/rel-table/rel-table-header.ts +0 -22
- package/dist/components/rel-table/rel-table-row.ts +0 -37
- package/dist/components/rel-table/rel-table.ts +0 -62
- package/dist/components/rel-textfield/rel-textfield.ts +0 -1054
- package/dist/components/rel-time-picker/rel-time-picker.ts +0 -1482
- package/dist/components/rel-time-picker/time-parse.test.ts +0 -67
- package/dist/components/rel-time-picker/time-parse.ts +0 -85
- package/dist/components/rel-toast/rel-toast.ts +0 -206
- package/dist/components/rel-tooltip/rel-tooltip.ts +0 -193
- package/dist/components/rel-topbar/rel-topbar-actions.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-brand.ts +0 -54
- package/dist/components/rel-topbar/rel-topbar-dropdown-item.ts +0 -69
- package/dist/components/rel-topbar/rel-topbar-dropdown.ts +0 -31
- package/dist/components/rel-topbar/rel-topbar-item.ts +0 -324
- package/dist/components/rel-topbar/rel-topbar-mobile-panel.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar-profile.ts +0 -243
- package/dist/components/rel-topbar/rel-topbar-utilities.ts +0 -27
- package/dist/components/rel-topbar/rel-topbar.ts +0 -446
- package/dist/components/rel-upload/UPLOAD-DESIGN-CHANGES.md +0 -134
- package/dist/components/rel-upload/rel-upload-actions.ts +0 -163
- package/dist/components/rel-upload/rel-upload.ts +0 -968
|
@@ -1,148 +1,157 @@
|
|
|
1
|
-
# rel-toast
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!--
|
|
9
|
-
<rel-toast id="
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
<rel-toast
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
<
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
## API
|
|
71
|
-
|
|
72
|
-
### Attributes/Properties
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
|
76
|
-
| `
|
|
77
|
-
| `
|
|
78
|
-
| `
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
-
|
|
134
|
-
|
|
135
|
-
##
|
|
136
|
-
|
|
137
|
-
- The
|
|
138
|
-
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
-
|
|
146
|
-
-
|
|
147
|
-
-
|
|
148
|
-
|
|
1
|
+
# rel-toast
|
|
2
|
+
|
|
3
|
+
`<rel-toast>` is the transient notification of the Reliability Design System: a dark pill fixed to the bottom centre of the viewport that shows a short message, an optional action button ("Undo", "Retry") and a dismiss button, then hides itself after `duration` milliseconds. It has two tones — `default` and `destructive` — and is driven by the `show` property (or `open()` / `close()`). Use it for brief confirmations that need no reply; use `<rel-snackbar>` when you need the status tones, a stacked layout or your own positioning, and `<rel-alert>` for messages that must stay on the page.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Hidden until `show` is set (or open() is called) -->
|
|
9
|
+
<rel-toast id="saved" message="File saved"></rel-toast>
|
|
10
|
+
|
|
11
|
+
<!-- Initially visible; auto-hides after the default 4000 ms -->
|
|
12
|
+
<rel-toast show message="Welcome back"></rel-toast>
|
|
13
|
+
|
|
14
|
+
<!-- Destructive tone: danger fill, announced assertively -->
|
|
15
|
+
<rel-toast id="failed" tone="destructive" message="Upload failed"></rel-toast>
|
|
16
|
+
|
|
17
|
+
<!-- Action button (attribute is lower-case: actionlabel) -->
|
|
18
|
+
<rel-toast id="deleted" message="Item deleted" actionlabel="Undo"></rel-toast>
|
|
19
|
+
|
|
20
|
+
<!-- Longer and persistent toasts -->
|
|
21
|
+
<rel-toast id="slow" message="Download complete" duration="7000"></rel-toast>
|
|
22
|
+
<rel-toast id="sticky" message="Reconnecting…" duration="0"></rel-toast>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```js
|
|
26
|
+
const saved = document.getElementById("saved");
|
|
27
|
+
saved.open(); // same as saved.show = true — starts the auto-dismiss timer
|
|
28
|
+
saved.addEventListener("dismissed", () => {
|
|
29
|
+
saved.show; // false — fired by close(), the ✕ button, the action button and the timer
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const deleted = document.getElementById("deleted");
|
|
33
|
+
deleted.addEventListener("action", () => {
|
|
34
|
+
// undo the deletion… the toast closes itself right after (a `dismissed` event follows)
|
|
35
|
+
});
|
|
36
|
+
deleted.open();
|
|
37
|
+
|
|
38
|
+
const sticky = document.getElementById("sticky");
|
|
39
|
+
sticky.open();
|
|
40
|
+
sticky.close(); // the only way to hide a duration="0" toast from script
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
```css
|
|
44
|
+
/* Lift the toast above an open modal / drawer layer */
|
|
45
|
+
rel-toast { --rel-toast-z: 10000; }
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Deprecated aliases
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<!-- type= is the deprecated alias of tone= (tone wins when both are set). Logs once per page:
|
|
52
|
+
[rel-toast] "type" is deprecated and will be removed in 3.0 — use "tone" instead. Note: tone="destructive" replaces type="error". -->
|
|
53
|
+
<rel-toast type="error" message="Upload failed"></rel-toast>
|
|
54
|
+
|
|
55
|
+
<!-- tone="error" | "danger" | "critical" are deprecated spellings of tone="destructive". Logs once per spelling:
|
|
56
|
+
[rel-toast] "tone="error"" is deprecated and will be removed in 3.0 — use "tone="destructive"" instead. -->
|
|
57
|
+
<rel-toast tone="error" message="Upload failed"></rel-toast>
|
|
58
|
+
<rel-toast tone="danger" message="Upload failed"></rel-toast>
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
```css
|
|
62
|
+
/* --rel-z-toast is the deprecated alias of --rel-toast-z; it is still read as the fallback (no console notice). */
|
|
63
|
+
rel-toast { --rel-z-toast: 10000; }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
<!-- readme-gen:start -->
|
|
67
|
+
|
|
68
|
+
<!-- Generated from rel-toast.ts — do not edit; run readme-generate.mjs -->
|
|
69
|
+
|
|
70
|
+
## API
|
|
71
|
+
|
|
72
|
+
### Attributes / Properties
|
|
73
|
+
|
|
74
|
+
| Property | Attribute | Type | Default | Description |
|
|
75
|
+
| --- | --- | --- | --- | --- |
|
|
76
|
+
| `message` | `message` | `string` | `""` | Text of the toast. It is also announced to screen readers through the shared live-region announcer each time `show` becomes true. |
|
|
77
|
+
| `tone` | `tone` | `"default" \| "destructive" \| "error" \| "danger" \| "critical"` | `undefined` | Semantic tone: `"default"` (dark neutral pill) \| `"destructive"` (danger fill, announced assertively). `"error"`, `"danger"` and `"critical"` are deprecated aliases of `"destructive"` and log a one-time console notice. Takes precedence over the deprecated `type` prop. |
|
|
78
|
+
| `actionLabel` | `actionlabel` | `string` | `undefined` | Label of the optional action button rendered between the message and the dismiss button; the button is omitted when unset. Clicking it fires `action` and then closes the toast. |
|
|
79
|
+
| `duration` | `duration` | `number` | `4000` | Auto-dismiss delay in milliseconds, started each time `show` becomes true. `0` (or a negative value) disables auto-dismiss so the toast stays until `close()` or the dismiss button. Changing it while the toast is visible does not restart the running timer. |
|
|
80
|
+
| `show` | `show` | `boolean` | `false` | Whether the toast is visible. Set it to true (or call `open()`) to show the toast and start the auto-dismiss timer; it is set back to false by `close()`, the dismiss button, the action button and the timer. Reflected. |
|
|
81
|
+
|
|
82
|
+
#### Deprecated (still supported — removal targeted for 3.0)
|
|
83
|
+
|
|
84
|
+
| Property | Attribute | Type | Use instead |
|
|
85
|
+
| --- | --- | --- | --- |
|
|
86
|
+
| `type` | `type` | `"default" \| "destructive" \| "error" \| "danger" \| "critical"` | Deprecated since 1.4.7 — alias of `tone`; use `tone`. Same values as `tone`; `type="error"` maps to `tone="destructive"`. Ignored when `tone` is set. Logs a one-time console notice. |
|
|
87
|
+
|
|
88
|
+
### Public fields / accessors
|
|
89
|
+
|
|
90
|
+
| Name | Type | Description |
|
|
91
|
+
| --- | --- | --- |
|
|
92
|
+
| `resolvedTone` | `ToastTone` | Read-only canonical tone actually rendered: explicit `tone` wins, else `type`, else `"default"`; deprecated aliases are resolved to `"destructive"`. |
|
|
93
|
+
|
|
94
|
+
### Methods
|
|
95
|
+
|
|
96
|
+
| Method | Signature | Description |
|
|
97
|
+
| --- | --- | --- |
|
|
98
|
+
| `open` | `open()` | Shows the toast: sets `show = true`, which starts the auto-dismiss timer and announces `message`. |
|
|
99
|
+
| `close` | `close()` | Hides the toast, clears the auto-dismiss timer and fires `dismissed`. It fires `dismissed` even when the toast was already hidden. |
|
|
100
|
+
|
|
101
|
+
## Events
|
|
102
|
+
|
|
103
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
104
|
+
| --- | --- | --- | --- |
|
|
105
|
+
| `action` | — | bubbles / composed | Fired when the action button is clicked, before the toast closes itself (a `dismissed` event follows). No detail. |
|
|
106
|
+
| `dismissed` | — | bubbles / composed | Fired whenever the toast is closed — by `close()`, the dismiss button, the action button or the auto-dismiss timer. No detail. |
|
|
107
|
+
|
|
108
|
+
## Slots
|
|
109
|
+
|
|
110
|
+
| Slot | Description |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| — | This element has no slots. |
|
|
113
|
+
|
|
114
|
+
## CSS Parts
|
|
115
|
+
|
|
116
|
+
| Part | Description |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| `base` | The `role="status"` toast container that carries the tone class |
|
|
119
|
+
| `label` | The message text span |
|
|
120
|
+
| `action` | The action button; rendered only when `actionlabel` is set |
|
|
121
|
+
| `close-button` | The dismiss (✕) button |
|
|
122
|
+
|
|
123
|
+
## Tokens / CSS Variables
|
|
124
|
+
|
|
125
|
+
### Component hooks
|
|
126
|
+
|
|
127
|
+
Set these on the host (or an ancestor) to customise the element without touching design tokens.
|
|
128
|
+
|
|
129
|
+
| Custom property | Default | Description |
|
|
130
|
+
| --- | --- | --- |
|
|
131
|
+
| `--rel-toast-z` | `var(--rel-z-toast, 9000)` | `z-index` of the fixed host (default `9000`); raise it when a modal or drawer layer covers the toast |
|
|
132
|
+
|
|
133
|
+
<!-- readme-gen:end -->
|
|
134
|
+
|
|
135
|
+
## Accessibility
|
|
136
|
+
|
|
137
|
+
- The toast container (part `base`) is always in the shadow DOM with `role="status"`, `aria-live="polite"` and `aria-atomic="true"`; it is hidden with `display: none` while `show` is false. Because toggling `display` is not reliably announced, the component also pushes `message` into the shared off-screen live-region announcer (`utils/announce`) every time `show` becomes true — politely for `default`, assertively for `destructive`. Focus is never moved.
|
|
138
|
+
- Two native `<button>`s: the optional action button (labelled by `actionlabel`) and the dismiss button with `aria-label="Dismiss"`. Both are in the Tab order; the component registers no key handlers (there is no Escape-to-close):
|
|
139
|
+
|
|
140
|
+
| Key | Action |
|
|
141
|
+
| --- | --- |
|
|
142
|
+
| Tab / Shift + Tab | Move between the action button (if any) and the dismiss button; the toast sits in the Tab order at its DOM position, not at the end of the page |
|
|
143
|
+
| Enter / Space | Activate the focused button: action fires `action` then `dismissed`; dismiss fires `dismissed` |
|
|
144
|
+
|
|
145
|
+
- Keyboard focus on either button is a 2px `--rel-text-static-light` outline with 2px offset and `--rel-border-radius-xs` corners (`:focus-visible` only).
|
|
146
|
+
- The 0.25s fade-in-up animation is disabled under `prefers-reduced-motion: reduce`.
|
|
147
|
+
- A toast that auto-dismisses while a button inside it has focus drops focus to `<body>`; give important actions a `duration="0"` toast or a persistent control elsewhere.
|
|
148
|
+
|
|
149
|
+
## Notes / Edge Cases
|
|
150
|
+
|
|
151
|
+
- `show` is a boolean **property**, not a method: `toast.show()` throws. Use `toast.show = true` or `toast.open()`; the old README's `show()` call was wrong.
|
|
152
|
+
- The host is `position: fixed; bottom: 24px; left: 50%` with `pointer-events: none` (the pill itself restores `pointer-events: all`), so it never blocks clicks around it. There is no stacking manager: two visible toasts overlap at the same spot — reuse one element and update `message`.
|
|
153
|
+
- The auto-dismiss timer starts only when `show` changes to true; changing `duration` on a visible toast does not restart it. Re-showing a visible toast (setting `show = true` again) is a no-op because the value did not change — `close()` it first.
|
|
154
|
+
- `close()` always fires `dismissed`, even when the toast was already hidden.
|
|
155
|
+
- The action button's hover state swaps to `--rel-bg-neutral` / `--rel-text-default` at 75% opacity.
|
|
156
|
+
- Layering: the host's `z-index` is `--rel-toast-z` (default 9000; the pre-rename `--rel-z-toast` still works as its fallback). Raise it on the element or an ancestor if an overlay with a higher `z-index` covers the toast; anything rendered in the browser top layer (native `<dialog>` / Popover API content) always paints above it regardless of `z-index`.
|
|
157
|
+
- `resolvedTone` is the tone actually rendered after alias resolution; use it (not `tone` / `type`) if you branch on tone in script.
|
|
@@ -1,111 +1,108 @@
|
|
|
1
|
-
# rel-tooltip
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
```html
|
|
8
|
-
<!--
|
|
9
|
-
<rel-tooltip text="
|
|
10
|
-
<button>
|
|
11
|
-
</rel-tooltip>
|
|
12
|
-
|
|
13
|
-
<!--
|
|
14
|
-
<rel-tooltip text="
|
|
15
|
-
<
|
|
16
|
-
</rel-tooltip>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</rel-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
- **
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
-
|
|
108
|
-
- The
|
|
109
|
-
- `:host` is `display: inline-block` to size to slotted content
|
|
110
|
-
- Transition duration is `0.2s ease` for opacity changes
|
|
111
|
-
- For very long tooltip text, consider wrapping or alternative UI patterns (max-width not set by default)
|
|
1
|
+
# rel-tooltip
|
|
2
|
+
|
|
3
|
+
Hover/focus tooltip implementing the Figma "Tooltip" component: wraps a trigger element and fades in a short inverse-coloured text bubble above, below, left or right of it, in the Figma `single-line` or `multi-line` **Type**, optionally with a pointing tail. Use it for brief supplementary hints on icon buttons and truncated labels. Do not put critical or interactive content in it — it is not reachable on touch, cannot be focused, and disappears on hover-out.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<!-- Default: above the trigger -->
|
|
9
|
+
<rel-tooltip text="Save your changes">
|
|
10
|
+
<rel-button variant="primary">Save</rel-button>
|
|
11
|
+
</rel-tooltip>
|
|
12
|
+
|
|
13
|
+
<!-- Positions -->
|
|
14
|
+
<rel-tooltip text="Appears below" position="below">
|
|
15
|
+
<rel-button variant="secondary">Below</rel-button>
|
|
16
|
+
</rel-tooltip>
|
|
17
|
+
<rel-tooltip text="Appears on the left" position="left">
|
|
18
|
+
<rel-button variant="secondary">Left</rel-button>
|
|
19
|
+
</rel-tooltip>
|
|
20
|
+
<rel-tooltip text="Appears on the right" position="right">
|
|
21
|
+
<rel-button variant="secondary">Right</rel-button>
|
|
22
|
+
</rel-tooltip>
|
|
23
|
+
|
|
24
|
+
<!-- With the pointing tail -->
|
|
25
|
+
<rel-tooltip text="Edit" show-tail>
|
|
26
|
+
<rel-button variant="ghost" icon-only aria-label="Edit">
|
|
27
|
+
<rel-icon name="edit"></rel-icon>
|
|
28
|
+
</rel-button>
|
|
29
|
+
</rel-tooltip>
|
|
30
|
+
|
|
31
|
+
<!-- Multi-line: wraps inside a 220px bubble -->
|
|
32
|
+
<rel-tooltip
|
|
33
|
+
type="multi-line"
|
|
34
|
+
position="below"
|
|
35
|
+
show-tail
|
|
36
|
+
text="Exports the current view as CSV. Filters and sorting are preserved."
|
|
37
|
+
>
|
|
38
|
+
<rel-button variant="secondary">Export</rel-button>
|
|
39
|
+
</rel-tooltip>
|
|
40
|
+
|
|
41
|
+
<!-- Restyle the bubble through its part -->
|
|
42
|
+
<style>
|
|
43
|
+
.wide::part(panel) {
|
|
44
|
+
max-width: 320px;
|
|
45
|
+
}
|
|
46
|
+
</style>
|
|
47
|
+
<rel-tooltip class="wide" type="multi-line" text="A longer explanation that needs more room than the default bubble.">
|
|
48
|
+
<rel-button variant="ghost">Details</rel-button>
|
|
49
|
+
</rel-tooltip>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
<!-- readme-gen:start -->
|
|
53
|
+
|
|
54
|
+
<!-- Generated from rel-tooltip.ts — do not edit; run readme-generate.mjs -->
|
|
55
|
+
|
|
56
|
+
## API
|
|
57
|
+
|
|
58
|
+
### Attributes / Properties
|
|
59
|
+
|
|
60
|
+
| Property | Attribute | Type | Default | Description |
|
|
61
|
+
| --- | --- | --- | --- | --- |
|
|
62
|
+
| `text` | `text` | `string` | `""` | Plain-text content of the bubble. Empty text still renders an (empty) bubble on hover, so always set it. |
|
|
63
|
+
| `position` | `position` | `"above" \| "below" \| "left" \| "right"` | `"above"` | Side of the trigger the bubble appears on, 6px away and centred: `above`, `below`, `left` or `right`. No collision detection — pick a side with room in the viewport. |
|
|
64
|
+
| `showTail` | `show-tail` | `boolean` | `false` | Renders the triangular tail (`indicator` part) on the bubble's edge facing the trigger. |
|
|
65
|
+
| `type` | `type` | `"single-line" \| "multi-line"` | `"single-line"` | Figma "Type": `single-line` keeps the text on one line and sizes to content; `multi-line` wraps inside a 220px max-width bubble. Reflected. |
|
|
66
|
+
|
|
67
|
+
## Events
|
|
68
|
+
|
|
69
|
+
| Event | Detail | Bubbles / composed | Description |
|
|
70
|
+
| --- | --- | --- | --- |
|
|
71
|
+
| — | — | — | This element emits no custom events. |
|
|
72
|
+
|
|
73
|
+
## Slots
|
|
74
|
+
|
|
75
|
+
| Slot | Description |
|
|
76
|
+
| --- | --- |
|
|
77
|
+
| (default) | The trigger element (one focusable element such as a button or icon button). It receives `aria-describedby` pointing at the bubble. |
|
|
78
|
+
|
|
79
|
+
## CSS Parts
|
|
80
|
+
|
|
81
|
+
| Part | Description |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| `panel` | The tooltip bubble (`role="tooltip"`): background, padding, radius, shadow and max-width. |
|
|
84
|
+
| `indicator` | The triangular tail pointing at the trigger, rendered only when `show-tail` is set. |
|
|
85
|
+
|
|
86
|
+
<!-- readme-gen:end -->
|
|
87
|
+
|
|
88
|
+
## Accessibility
|
|
89
|
+
|
|
90
|
+
- The bubble is a `role="tooltip"` element with a stable generated `id`; the first slotted element is given `aria-describedby` pointing at it (re-linked on `slotchange`), so screen readers read the hint as the trigger's description.
|
|
91
|
+
- The bubble is shown while the host is hovered **or** has focus within (`:focus-within`), so keyboard users see it when the slotted trigger is focused. The trigger therefore must be focusable — wrap a button or link, not plain text.
|
|
92
|
+
- The bubble never takes focus and has `pointer-events: none`.
|
|
93
|
+
|
|
94
|
+
| Key | Action |
|
|
95
|
+
| --- | --- |
|
|
96
|
+
| `Tab` | Focus the slotted trigger; the tooltip appears |
|
|
97
|
+
| `Escape` | Dismiss the tooltip (APG pattern). The key is not swallowed, so an enclosing dialog may also react to it |
|
|
98
|
+
|
|
99
|
+
After `Escape` the tooltip stays hidden until the pointer leaves and returns or focus leaves and returns (`mouseleave` / `focusout` clear the dismissed state).
|
|
100
|
+
|
|
101
|
+
## Notes / Edge Cases
|
|
102
|
+
|
|
103
|
+
- **Attribute spelling is `show-tail`** (kebab-case). `showTail="…"` as an HTML attribute does nothing; set the property in code.
|
|
104
|
+
- **Positioning is static.** The bubble is `position: absolute` relative to the host (which is `display: inline-block; position: relative`), 6px from the trigger, centred on it, with `z-index: 1000`. There is no flipping or viewport collision detection, and ancestors with `overflow: hidden` or their own stacking context will clip it — for popover-style panels use `rel-popover`.
|
|
105
|
+
- `single-line` bubbles use `white-space: nowrap` and grow with the text; `multi-line` wraps at a 220px `max-width` (override it via `::part(panel)`).
|
|
106
|
+
- The bubble's shadow is applied with `filter: drop-shadow` so the tail (`indicator` part) casts the same shadow as the panel.
|
|
107
|
+
- Colours use the inverse neutral tokens, so the tooltip flips automatically (dark bubble on light themes, light bubble under `data-theme="dark"` / `.dark`).
|
|
108
|
+
- The hint is read from `text` only; slotted content is the trigger, not the tooltip body.
|