@warp-ds/elements 2.9.0-next.5 → 2.9.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/dist/custom-elements.json +221 -118
- package/dist/docs/affix/affix.md +49 -61
- package/dist/docs/affix/api.md +25 -23
- package/dist/docs/affix/examples.md +24 -38
- package/dist/docs/alert/accessibility.md +4 -9
- package/dist/docs/alert/alert.md +36 -51
- package/dist/docs/alert/api.md +12 -12
- package/dist/docs/alert/examples.md +20 -30
- package/dist/docs/attention/accessibility.md +50 -0
- package/dist/docs/attention/api.md +72 -59
- package/dist/docs/attention/attention.md +305 -56
- package/dist/docs/attention/examples.md +91 -0
- package/dist/docs/attention/usage.md +91 -0
- package/dist/docs/badge/accessibility.md +44 -0
- package/dist/docs/badge/api.md +12 -8
- package/dist/docs/badge/badge.md +178 -10
- package/dist/docs/badge/examples.md +69 -0
- package/dist/docs/badge/usage.md +53 -0
- package/dist/docs/button/api.md +46 -42
- package/dist/docs/button/button.md +46 -42
- package/dist/docs/card/api.md +11 -11
- package/dist/docs/card/card.md +11 -11
- package/dist/docs/combobox/api.md +62 -62
- package/dist/docs/combobox/combobox.md +62 -62
- package/dist/docs/datepicker/api.md +74 -66
- package/dist/docs/datepicker/datepicker.md +74 -66
- package/dist/docs/expandable/api.md +26 -26
- package/dist/docs/expandable/expandable.md +26 -26
- package/dist/docs/link/api.md +28 -28
- package/dist/docs/link/link.md +28 -28
- package/dist/docs/page-indicator/api.md +6 -6
- package/dist/docs/page-indicator/page-indicator.md +6 -6
- package/dist/docs/pagination/api.md +3 -3
- package/dist/docs/pagination/pagination.md +3 -3
- package/dist/docs/pill/api.md +19 -15
- package/dist/docs/pill/pill.md +19 -15
- package/dist/docs/select/api.md +44 -44
- package/dist/docs/select/select.md +44 -44
- package/dist/docs/slider/api.md +80 -78
- package/dist/docs/slider/slider.md +80 -78
- package/dist/docs/slider-thumb/api.md +28 -76
- package/dist/docs/slider-thumb/slider-thumb.md +28 -76
- package/dist/docs/switch/api.md +16 -16
- package/dist/docs/switch/switch.md +16 -16
- package/dist/docs/tab/api.md +26 -40
- package/dist/docs/tab/tab.md +26 -40
- package/dist/docs/tab-panel/api.md +1 -17
- package/dist/docs/tab-panel/tab-panel.md +1 -17
- package/dist/docs/tabs/api.md +3 -3
- package/dist/docs/tabs/tabs.md +3 -3
- package/dist/docs/textarea/accessibility.md +5 -0
- package/dist/docs/textarea/api.md +52 -65
- package/dist/docs/textarea/examples.md +81 -0
- package/dist/docs/textarea/textarea.md +151 -65
- package/dist/docs/textarea/usage.md +9 -0
- package/dist/docs/textfield/accessibility.md +15 -0
- package/dist/docs/textfield/api.md +86 -83
- package/dist/docs/textfield/examples.md +130 -0
- package/dist/docs/textfield/textfield.md +258 -86
- package/dist/docs/textfield/usage.md +26 -0
- package/dist/index.d.ts +456 -330
- package/dist/packages/attention/attention.d.ts +46 -37
- package/dist/packages/attention/attention.js +20 -20
- package/dist/packages/attention/attention.js.map +3 -3
- package/dist/packages/badge/badge.d.ts +7 -5
- package/dist/packages/badge/badge.js.map +2 -2
- package/dist/packages/datepicker/datepicker.js +1 -1
- package/dist/packages/datepicker/datepicker.js.map +2 -2
- package/dist/packages/datepicker/datepicker.react.stories.d.ts +9 -1
- package/dist/packages/datepicker/react.d.ts +4 -0
- package/dist/packages/datepicker/react.js +4 -0
- package/dist/packages/textarea/textarea.d.ts +38 -29
- package/dist/packages/textarea/textarea.js.map +2 -2
- package/dist/packages/textfield/textfield.d.ts +57 -60
- package/dist/packages/textfield/textfield.js +5 -5
- package/dist/packages/textfield/textfield.js.map +2 -2
- package/dist/packages/textfield/textfield.react.stories.d.ts +1 -1
- package/dist/web-types.json +573 -153
- package/package.json +1 -2
|
@@ -2,142 +2,391 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
+
Attention is a versatile component for displaying contextual information and messages. It can be used for a wide range of purposes, such as tooltips, callouts, popovers, and highlights.
|
|
5
6
|
|
|
7
|
+
The component is designed to be anchored to a trigger element, providing contextual information related to that element. It supports various placements and styling options to accommodate different use cases and design needs.
|
|
8
|
+
|
|
9
|
+
Note: attention will soon be split into multiple components (tooltip, callout, popover, highlight) at which time this component will be deprecated. For now, use the `tooltip`, `callout`, `popover`, and `highlight` boolean properties to achieve the desired style and behavior.
|
|
6
10
|
|
|
7
11
|
## Usage
|
|
8
12
|
|
|
13
|
+
`w-attention` is used to show contextual messaging anchored to a target element.
|
|
14
|
+
|
|
15
|
+
### Basic Structure
|
|
16
|
+
|
|
17
|
+
Use the `target` slot for the trigger/anchor element and the `message` slot for the content.
|
|
18
|
+
|
|
19
|
+
```html
|
|
20
|
+
<w-attention placement="bottom" popover>
|
|
21
|
+
<w-button slot="target" variant="secondary">Open message</w-button>
|
|
22
|
+
<span slot="message">I'm a popover</span>
|
|
23
|
+
</w-attention>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Visibility (`show`)
|
|
27
|
+
|
|
28
|
+
`w-attention` visibility is controlled with the `show` property. Toggle it based on user interaction.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<w-attention id="my-attention" placement="bottom" popover>
|
|
32
|
+
<w-button id="my-trigger" slot="target" variant="secondary">Toggle</w-button>
|
|
33
|
+
<span slot="message">I'm a popover</span>
|
|
34
|
+
</w-attention>
|
|
35
|
+
|
|
36
|
+
<script>
|
|
37
|
+
const trigger = document.getElementById('my-trigger');
|
|
38
|
+
const attention = document.getElementById('my-attention');
|
|
39
|
+
trigger.addEventListener('click', () => {
|
|
40
|
+
attention.show = !attention.show;
|
|
41
|
+
});
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Variants
|
|
46
|
+
|
|
47
|
+
`w-attention` supports four visual variants:
|
|
48
|
+
|
|
49
|
+
- `tooltip`
|
|
50
|
+
- `popover`
|
|
51
|
+
- `callout`
|
|
52
|
+
- `highlight`
|
|
53
|
+
|
|
54
|
+
Use one variant at a time.
|
|
55
|
+
|
|
56
|
+
```html
|
|
57
|
+
<w-attention tooltip placement="right">
|
|
58
|
+
<w-button slot="target" variant="secondary">Hover me</w-button>
|
|
59
|
+
<span slot="message">Short helper text</span>
|
|
60
|
+
</w-attention>
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Placement and Collision Handling
|
|
64
|
+
|
|
65
|
+
Use `placement` to define preferred direction. For overlays, `flip`, `cross-axis`, and `fallback-placements` can improve placement in constrained layouts.
|
|
66
|
+
|
|
67
|
+
```html
|
|
68
|
+
<w-attention
|
|
69
|
+
popover
|
|
70
|
+
placement="right"
|
|
71
|
+
flip
|
|
72
|
+
cross-axis
|
|
73
|
+
fallback-placements='["bottom","left","top"]'
|
|
74
|
+
>
|
|
75
|
+
<w-button slot="target" variant="secondary">Open</w-button>
|
|
76
|
+
<span slot="message">Smartly positioned message</span>
|
|
77
|
+
</w-attention>
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Dismissible Messages
|
|
81
|
+
|
|
82
|
+
Use `can-close` for an internal close button, and listen for the `close` event.
|
|
83
|
+
|
|
84
|
+
```html
|
|
85
|
+
<w-attention id="dismissible-attention" highlight can-close placement="right">
|
|
86
|
+
<w-button id="dismissible-trigger" slot="target" variant="secondary">Show message</w-button>
|
|
87
|
+
<span slot="message">You can dismiss this message.</span>
|
|
88
|
+
</w-attention>
|
|
89
|
+
|
|
90
|
+
<script>
|
|
91
|
+
const trigger = document.getElementById('dismissible-trigger');
|
|
92
|
+
const attention = document.getElementById('dismissible-attention');
|
|
93
|
+
|
|
94
|
+
trigger.addEventListener('click', () => {
|
|
95
|
+
attention.show = true;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
attention.addEventListener('close', () => {
|
|
99
|
+
attention.show = false;
|
|
100
|
+
});
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
|
|
9
104
|
## Accessibility
|
|
10
105
|
|
|
11
|
-
|
|
106
|
+
`w-attention` provides built-in accessibility helpers for tooltip/popover/callout messaging:
|
|
12
107
|
|
|
13
|
-
|
|
108
|
+
- It sets `role="tooltip"` for tooltip mode.
|
|
109
|
+
- It sets `role="img"` for non-tooltip variants.
|
|
110
|
+
- It provides a default localized `aria-label` describing the attention type and arrow direction.
|
|
14
111
|
|
|
15
|
-
###
|
|
112
|
+
### Authoring Guidance
|
|
16
113
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
| placement | `Directions` | `'bottom'` | - |
|
|
21
|
-
| tooltip | `boolean` | `false` | - |
|
|
22
|
-
| callout | `boolean` | `false` | - |
|
|
23
|
-
| popover | `boolean` | `false` | - |
|
|
24
|
-
| highlight | `boolean` | `false` | - |
|
|
25
|
-
| canClose | `boolean` | `false` | - |
|
|
26
|
-
| noArrow | `boolean` | `false` | - |
|
|
27
|
-
| distance | `number` | `8` | - |
|
|
28
|
-
| skidding | `number` | `0` | - |
|
|
29
|
-
| flip | `boolean` | `false` | - |
|
|
30
|
-
| crossAxis | `boolean` | `false` | - |
|
|
31
|
-
| fallbackPlacements | `Directions[]` | `-` | - |
|
|
32
|
-
| _initialPlacement | `unknown` | `-` | - |
|
|
33
|
-
| _actualDirection | `unknown` | `-` | - |
|
|
114
|
+
- Provide meaningful text in the `message` slot.
|
|
115
|
+
- Ensure the `target` slot content is keyboard-accessible (for example `w-button` or a native button).
|
|
116
|
+
- For hover-triggered tooltips, also support focus/blur so keyboard users receive the same information.
|
|
34
117
|
|
|
35
|
-
###
|
|
118
|
+
### Reading Order and Placement
|
|
36
119
|
|
|
37
|
-
|
|
120
|
+
For left/top placements, placing the attention message before the target in DOM order can improve screen reader flow.
|
|
38
121
|
|
|
122
|
+
### Precise ARIA Targeting
|
|
39
123
|
|
|
124
|
+
If only part of the message should be announced as details, set an explicit id on the relevant message content and reference it from the target with `aria-details`.
|
|
40
125
|
|
|
41
|
-
|
|
42
|
-
-
|
|
126
|
+
```html
|
|
127
|
+
<w-attention id="accessible-attention" placement="right" popover>
|
|
128
|
+
<div slot="message">
|
|
129
|
+
<p id="aria-content" role="tooltip">Important contextual text</p>
|
|
130
|
+
<p>Secondary text</p>
|
|
131
|
+
</div>
|
|
132
|
+
<w-button aria-details="aria-content" slot="target" variant="secondary">
|
|
133
|
+
Open
|
|
134
|
+
</w-button>
|
|
135
|
+
</w-attention>
|
|
136
|
+
```
|
|
43
137
|
|
|
44
|
-
|
|
138
|
+
### Dismissible Attention
|
|
45
139
|
|
|
140
|
+
When `can-close` is used, ensure your app listens to the `close` event and updates `show` accordingly so the UI and assistive technology state stay in sync.
|
|
46
141
|
|
|
142
|
+
```html
|
|
143
|
+
<w-attention id="dismissible" can-close highlight>
|
|
144
|
+
<w-button slot="target" variant="secondary">Show message</w-button>
|
|
145
|
+
<span slot="message">Dismissible message</span>
|
|
146
|
+
</w-attention>
|
|
47
147
|
|
|
48
|
-
|
|
49
|
-
|
|
148
|
+
<script>
|
|
149
|
+
const attention = document.getElementById('dismissible');
|
|
150
|
+
attention.addEventListener('close', () => {
|
|
151
|
+
attention.show = false;
|
|
152
|
+
});
|
|
153
|
+
</script>
|
|
154
|
+
```
|
|
50
155
|
|
|
51
|
-
|
|
156
|
+
## Examples
|
|
52
157
|
|
|
158
|
+
### Popover (Click To Toggle)
|
|
159
|
+
|
|
160
|
+
<elements-example>
|
|
161
|
+
|
|
162
|
+
```html
|
|
163
|
+
<w-attention id="example-popover" placement="bottom" popover flip>
|
|
164
|
+
<w-button id="example-popover-trigger" slot="target" variant="secondary">Click to toggle a popover</w-button>
|
|
165
|
+
<span slot="message">I'm a popover</span>
|
|
166
|
+
</w-attention>
|
|
167
|
+
<script>
|
|
168
|
+
(() => {
|
|
169
|
+
const trigger = document.getElementById('example-popover-trigger');
|
|
170
|
+
const attention = document.getElementById('example-popover');
|
|
171
|
+
trigger.addEventListener('click', () => {
|
|
172
|
+
attention.show = !attention.show;
|
|
173
|
+
});
|
|
174
|
+
})();
|
|
175
|
+
</script>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
</elements-example>
|
|
179
|
+
|
|
180
|
+
### Tooltip (Hover and Focus)
|
|
181
|
+
|
|
182
|
+
<elements-example>
|
|
183
|
+
|
|
184
|
+
```html
|
|
185
|
+
<w-attention id="example-tooltip" placement="right" tooltip flip>
|
|
186
|
+
<w-button id="example-tooltip-trigger" slot="target" variant="secondary">Hover or focus me</w-button>
|
|
187
|
+
<span slot="message">I'm a tooltip</span>
|
|
188
|
+
</w-attention>
|
|
189
|
+
<script>
|
|
190
|
+
(() => {
|
|
191
|
+
const trigger = document.getElementById('example-tooltip-trigger');
|
|
192
|
+
const attention = document.getElementById('example-tooltip');
|
|
193
|
+
trigger.addEventListener('mouseenter', () => {
|
|
194
|
+
attention.show = true;
|
|
195
|
+
});
|
|
196
|
+
trigger.addEventListener('mouseleave', () => {
|
|
197
|
+
attention.show = false;
|
|
198
|
+
});
|
|
199
|
+
trigger.addEventListener('focus', () => {
|
|
200
|
+
attention.show = true;
|
|
201
|
+
});
|
|
202
|
+
trigger.addEventListener('blur', () => {
|
|
203
|
+
attention.show = false;
|
|
204
|
+
});
|
|
205
|
+
})();
|
|
206
|
+
</script>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
</elements-example>
|
|
210
|
+
|
|
211
|
+
### Inline Callout
|
|
212
|
+
|
|
213
|
+
<elements-example>
|
|
214
|
+
|
|
215
|
+
```html
|
|
216
|
+
<w-attention callout show placement="right">
|
|
217
|
+
<w-button slot="target" variant="secondary">Inline target</w-button>
|
|
218
|
+
<span slot="message">I'm an inline callout</span>
|
|
219
|
+
</w-attention>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
</elements-example>
|
|
223
|
+
|
|
224
|
+
### Dismissible Highlight
|
|
225
|
+
|
|
226
|
+
<elements-example>
|
|
227
|
+
|
|
228
|
+
```html
|
|
229
|
+
<w-attention id="example-highlight" highlight can-close placement="right" flip>
|
|
230
|
+
<w-button id="example-highlight-trigger" slot="target" variant="secondary">Click me</w-button>
|
|
231
|
+
<span slot="message">I'm highlighted and dismissible</span>
|
|
232
|
+
</w-attention>
|
|
233
|
+
<script>
|
|
234
|
+
(() => {
|
|
235
|
+
const trigger = document.getElementById('example-highlight-trigger');
|
|
236
|
+
const attention = document.getElementById('example-highlight');
|
|
237
|
+
trigger.addEventListener('click', () => {
|
|
238
|
+
attention.show = true;
|
|
239
|
+
});
|
|
240
|
+
attention.addEventListener('close', () => {
|
|
241
|
+
attention.show = false;
|
|
242
|
+
});
|
|
243
|
+
})();
|
|
244
|
+
</script>
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
</elements-example>
|
|
53
248
|
|
|
249
|
+
## API Documentation
|
|
54
250
|
|
|
55
|
-
|
|
56
|
-
- Default: `false`
|
|
251
|
+
### Properties
|
|
57
252
|
|
|
58
|
-
|
|
253
|
+
| Name | Type | Default | Summary |
|
|
254
|
+
|-|-|-|-|
|
|
255
|
+
| _actualDirection | `unknown` | `-` | - |
|
|
256
|
+
| _initialPlacement | `unknown` | `-` | - |
|
|
257
|
+
| callout | `boolean` | `false` | Renders the component as an inline callout. |
|
|
258
|
+
| canClose | `boolean` | `false` | Shows a close button inside the attention component. |
|
|
259
|
+
| crossAxis | `boolean` | `false` | Allows overflow checks on the cross axis when flipping. |
|
|
260
|
+
| distance | `number` | `8` | Distance offset between trigger and attention panel. |
|
|
261
|
+
| fallbackPlacements | `Directions[]` | `[]` | Ordered list of fallback placements. |
|
|
262
|
+
| flip | `boolean` | `false` | Enables automatic flipping when placement has no space. |
|
|
263
|
+
| highlight | `boolean` | `false` | Renders the component with highlight styling. |
|
|
264
|
+
| noArrow | `boolean` | `false` | Hides the directional arrow of the attention component. |
|
|
265
|
+
| placement | `Directions` | `'bottom'` | Preferred placement relative to the trigger element. |
|
|
266
|
+
| popover | `boolean` | `false` | Enables native popover behavior for the attention element. |
|
|
267
|
+
| show | `boolean` | `false` | Controls whether the attention panel is visible. |
|
|
268
|
+
| skidding | `number` | `0` | Cross-axis offset for fine-grained positioning. |
|
|
269
|
+
| tooltip | `boolean` | `false` | Renders the component with tooltip styling and behavior. |
|
|
59
270
|
|
|
271
|
+
### Property Details
|
|
60
272
|
|
|
273
|
+
#### _actualDirection
|
|
61
274
|
|
|
62
|
-
- Type: `boolean`
|
|
63
|
-
- Default: `false`
|
|
64
275
|
|
|
65
|
-
#### popover
|
|
66
276
|
|
|
277
|
+
- Type: `unknown`
|
|
278
|
+
- Default: `-`
|
|
67
279
|
|
|
280
|
+
#### _initialPlacement
|
|
68
281
|
|
|
69
|
-
- Type: `boolean`
|
|
70
|
-
- Default: `false`
|
|
71
282
|
|
|
72
|
-
#### highlight
|
|
73
283
|
|
|
284
|
+
- Type: `unknown`
|
|
285
|
+
- Default: `-`
|
|
286
|
+
|
|
287
|
+
#### callout
|
|
74
288
|
|
|
289
|
+
Renders the component as an inline callout.
|
|
290
|
+
Callout mode is used for always-in-flow informational content instead of floating overlay behavior.
|
|
75
291
|
|
|
76
292
|
- Type: `boolean`
|
|
77
293
|
- Default: `false`
|
|
78
294
|
|
|
79
295
|
#### canClose
|
|
80
296
|
|
|
81
|
-
|
|
297
|
+
Shows a close button inside the attention component.
|
|
298
|
+
Adds an internal dismiss action that lets users close the attention panel.
|
|
82
299
|
|
|
83
300
|
- Type: `boolean`
|
|
84
301
|
- Default: `false`
|
|
85
302
|
|
|
86
|
-
####
|
|
87
|
-
|
|
303
|
+
#### crossAxis
|
|
88
304
|
|
|
305
|
+
Allows overflow checks on the cross axis when flipping.
|
|
306
|
+
Use with `flip` to improve collision handling when space is constrained horizontally or vertically.
|
|
89
307
|
|
|
90
308
|
- Type: `boolean`
|
|
91
309
|
- Default: `false`
|
|
92
310
|
|
|
93
311
|
#### distance
|
|
94
312
|
|
|
95
|
-
|
|
313
|
+
Distance offset between trigger and attention panel.
|
|
314
|
+
Defines the main-axis spacing in pixels from the anchor element.
|
|
96
315
|
|
|
97
316
|
- Type: `number`
|
|
98
317
|
- Default: `8`
|
|
99
318
|
|
|
100
|
-
####
|
|
101
|
-
|
|
319
|
+
#### fallbackPlacements
|
|
102
320
|
|
|
321
|
+
Ordered list of fallback placements.
|
|
322
|
+
Provides explicit alternative placements to try when `flip` is enabled and the preferred placement does not fit.
|
|
103
323
|
|
|
104
|
-
- Type: `
|
|
105
|
-
- Default: `
|
|
324
|
+
- Type: `Directions[]`
|
|
325
|
+
- Default: `[]`
|
|
106
326
|
|
|
107
327
|
#### flip
|
|
108
328
|
|
|
109
|
-
|
|
329
|
+
Enables automatic flipping when placement has no space.
|
|
330
|
+
Allows the component to choose an alternative side if the preferred placement would overflow.
|
|
110
331
|
|
|
111
332
|
- Type: `boolean`
|
|
112
333
|
- Default: `false`
|
|
113
334
|
|
|
114
|
-
####
|
|
335
|
+
#### highlight
|
|
336
|
+
|
|
337
|
+
Renders the component with highlight styling.
|
|
338
|
+
Use highlight mode to visually emphasize important contextual information.
|
|
339
|
+
|
|
340
|
+
- Type: `boolean`
|
|
341
|
+
- Default: `false`
|
|
115
342
|
|
|
343
|
+
#### noArrow
|
|
116
344
|
|
|
345
|
+
Hides the directional arrow of the attention component.
|
|
346
|
+
Disable the arrow when the visual connection to the trigger should not be shown.
|
|
117
347
|
|
|
118
348
|
- Type: `boolean`
|
|
119
349
|
- Default: `false`
|
|
120
350
|
|
|
121
|
-
####
|
|
351
|
+
#### placement
|
|
122
352
|
|
|
353
|
+
Preferred placement relative to the trigger element.
|
|
354
|
+
Sets the initial direction for positioning, for example `top`, `right`, `bottom`, or `left` variants.
|
|
123
355
|
|
|
356
|
+
- Type: `Directions`
|
|
357
|
+
- Default: `'bottom'`
|
|
124
358
|
|
|
125
|
-
|
|
126
|
-
- Default: `-`
|
|
359
|
+
#### popover
|
|
127
360
|
|
|
128
|
-
|
|
361
|
+
Enables native popover behavior for the attention element.
|
|
362
|
+
When enabled, the component uses popover semantics and styling suitable for floating surface UI.
|
|
129
363
|
|
|
364
|
+
- Type: `boolean`
|
|
365
|
+
- Default: `false`
|
|
130
366
|
|
|
367
|
+
#### show
|
|
131
368
|
|
|
132
|
-
|
|
133
|
-
|
|
369
|
+
Controls whether the attention panel is visible.
|
|
370
|
+
Set to `true` to show the attention content and `false` to hide it.
|
|
134
371
|
|
|
135
|
-
|
|
372
|
+
- Type: `boolean`
|
|
373
|
+
- Default: `false`
|
|
136
374
|
|
|
375
|
+
#### skidding
|
|
137
376
|
|
|
377
|
+
Cross-axis offset for fine-grained positioning.
|
|
378
|
+
Moves the panel along the cross axis in pixels to adjust alignment with the trigger.
|
|
138
379
|
|
|
139
|
-
- Type: `
|
|
140
|
-
- Default:
|
|
380
|
+
- Type: `number`
|
|
381
|
+
- Default: `0`
|
|
382
|
+
|
|
383
|
+
#### tooltip
|
|
384
|
+
|
|
385
|
+
Renders the component with tooltip styling and behavior.
|
|
386
|
+
Use for compact, non-modal contextual hints anchored to another element.
|
|
387
|
+
|
|
388
|
+
- Type: `boolean`
|
|
389
|
+
- Default: `false`
|
|
141
390
|
|
|
142
391
|
### Types
|
|
143
392
|
|
|
@@ -1 +1,92 @@
|
|
|
1
1
|
## Examples
|
|
2
|
+
|
|
3
|
+
### Popover (Click To Toggle)
|
|
4
|
+
|
|
5
|
+
<elements-example>
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<w-attention id="example-popover" placement="bottom" popover flip>
|
|
9
|
+
<w-button id="example-popover-trigger" slot="target" variant="secondary">Click to toggle a popover</w-button>
|
|
10
|
+
<span slot="message">I'm a popover</span>
|
|
11
|
+
</w-attention>
|
|
12
|
+
<script>
|
|
13
|
+
(() => {
|
|
14
|
+
const trigger = document.getElementById('example-popover-trigger');
|
|
15
|
+
const attention = document.getElementById('example-popover');
|
|
16
|
+
trigger.addEventListener('click', () => {
|
|
17
|
+
attention.show = !attention.show;
|
|
18
|
+
});
|
|
19
|
+
})();
|
|
20
|
+
</script>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
</elements-example>
|
|
24
|
+
|
|
25
|
+
### Tooltip (Hover and Focus)
|
|
26
|
+
|
|
27
|
+
<elements-example>
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<w-attention id="example-tooltip" placement="right" tooltip flip>
|
|
31
|
+
<w-button id="example-tooltip-trigger" slot="target" variant="secondary">Hover or focus me</w-button>
|
|
32
|
+
<span slot="message">I'm a tooltip</span>
|
|
33
|
+
</w-attention>
|
|
34
|
+
<script>
|
|
35
|
+
(() => {
|
|
36
|
+
const trigger = document.getElementById('example-tooltip-trigger');
|
|
37
|
+
const attention = document.getElementById('example-tooltip');
|
|
38
|
+
trigger.addEventListener('mouseenter', () => {
|
|
39
|
+
attention.show = true;
|
|
40
|
+
});
|
|
41
|
+
trigger.addEventListener('mouseleave', () => {
|
|
42
|
+
attention.show = false;
|
|
43
|
+
});
|
|
44
|
+
trigger.addEventListener('focus', () => {
|
|
45
|
+
attention.show = true;
|
|
46
|
+
});
|
|
47
|
+
trigger.addEventListener('blur', () => {
|
|
48
|
+
attention.show = false;
|
|
49
|
+
});
|
|
50
|
+
})();
|
|
51
|
+
</script>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
</elements-example>
|
|
55
|
+
|
|
56
|
+
### Inline Callout
|
|
57
|
+
|
|
58
|
+
<elements-example>
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<w-attention callout show placement="right">
|
|
62
|
+
<w-button slot="target" variant="secondary">Inline target</w-button>
|
|
63
|
+
<span slot="message">I'm an inline callout</span>
|
|
64
|
+
</w-attention>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
</elements-example>
|
|
68
|
+
|
|
69
|
+
### Dismissible Highlight
|
|
70
|
+
|
|
71
|
+
<elements-example>
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<w-attention id="example-highlight" highlight can-close placement="right" flip>
|
|
75
|
+
<w-button id="example-highlight-trigger" slot="target" variant="secondary">Click me</w-button>
|
|
76
|
+
<span slot="message">I'm highlighted and dismissible</span>
|
|
77
|
+
</w-attention>
|
|
78
|
+
<script>
|
|
79
|
+
(() => {
|
|
80
|
+
const trigger = document.getElementById('example-highlight-trigger');
|
|
81
|
+
const attention = document.getElementById('example-highlight');
|
|
82
|
+
trigger.addEventListener('click', () => {
|
|
83
|
+
attention.show = true;
|
|
84
|
+
});
|
|
85
|
+
attention.addEventListener('close', () => {
|
|
86
|
+
attention.show = false;
|
|
87
|
+
});
|
|
88
|
+
})();
|
|
89
|
+
</script>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
</elements-example>
|
|
@@ -1 +1,92 @@
|
|
|
1
1
|
## Usage
|
|
2
|
+
|
|
3
|
+
`w-attention` is used to show contextual messaging anchored to a target element.
|
|
4
|
+
|
|
5
|
+
### Basic Structure
|
|
6
|
+
|
|
7
|
+
Use the `target` slot for the trigger/anchor element and the `message` slot for the content.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-attention placement="bottom" popover>
|
|
11
|
+
<w-button slot="target" variant="secondary">Open message</w-button>
|
|
12
|
+
<span slot="message">I'm a popover</span>
|
|
13
|
+
</w-attention>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Visibility (`show`)
|
|
17
|
+
|
|
18
|
+
`w-attention` visibility is controlled with the `show` property. Toggle it based on user interaction.
|
|
19
|
+
|
|
20
|
+
```html
|
|
21
|
+
<w-attention id="my-attention" placement="bottom" popover>
|
|
22
|
+
<w-button id="my-trigger" slot="target" variant="secondary">Toggle</w-button>
|
|
23
|
+
<span slot="message">I'm a popover</span>
|
|
24
|
+
</w-attention>
|
|
25
|
+
|
|
26
|
+
<script>
|
|
27
|
+
const trigger = document.getElementById('my-trigger');
|
|
28
|
+
const attention = document.getElementById('my-attention');
|
|
29
|
+
trigger.addEventListener('click', () => {
|
|
30
|
+
attention.show = !attention.show;
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### Variants
|
|
36
|
+
|
|
37
|
+
`w-attention` supports four visual variants:
|
|
38
|
+
|
|
39
|
+
- `tooltip`
|
|
40
|
+
- `popover`
|
|
41
|
+
- `callout`
|
|
42
|
+
- `highlight`
|
|
43
|
+
|
|
44
|
+
Use one variant at a time.
|
|
45
|
+
|
|
46
|
+
```html
|
|
47
|
+
<w-attention tooltip placement="right">
|
|
48
|
+
<w-button slot="target" variant="secondary">Hover me</w-button>
|
|
49
|
+
<span slot="message">Short helper text</span>
|
|
50
|
+
</w-attention>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Placement and Collision Handling
|
|
54
|
+
|
|
55
|
+
Use `placement` to define preferred direction. For overlays, `flip`, `cross-axis`, and `fallback-placements` can improve placement in constrained layouts.
|
|
56
|
+
|
|
57
|
+
```html
|
|
58
|
+
<w-attention
|
|
59
|
+
popover
|
|
60
|
+
placement="right"
|
|
61
|
+
flip
|
|
62
|
+
cross-axis
|
|
63
|
+
fallback-placements='["bottom","left","top"]'
|
|
64
|
+
>
|
|
65
|
+
<w-button slot="target" variant="secondary">Open</w-button>
|
|
66
|
+
<span slot="message">Smartly positioned message</span>
|
|
67
|
+
</w-attention>
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Dismissible Messages
|
|
71
|
+
|
|
72
|
+
Use `can-close` for an internal close button, and listen for the `close` event.
|
|
73
|
+
|
|
74
|
+
```html
|
|
75
|
+
<w-attention id="dismissible-attention" highlight can-close placement="right">
|
|
76
|
+
<w-button id="dismissible-trigger" slot="target" variant="secondary">Show message</w-button>
|
|
77
|
+
<span slot="message">You can dismiss this message.</span>
|
|
78
|
+
</w-attention>
|
|
79
|
+
|
|
80
|
+
<script>
|
|
81
|
+
const trigger = document.getElementById('dismissible-trigger');
|
|
82
|
+
const attention = document.getElementById('dismissible-attention');
|
|
83
|
+
|
|
84
|
+
trigger.addEventListener('click', () => {
|
|
85
|
+
attention.show = true;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
attention.addEventListener('close', () => {
|
|
89
|
+
attention.show = false;
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
92
|
+
```
|
|
@@ -1 +1,45 @@
|
|
|
1
1
|
## Accessibility
|
|
2
|
+
|
|
3
|
+
Badge renders slotted text as regular content. It does not add an ARIA role and it is not announced as a live region.
|
|
4
|
+
|
|
5
|
+
### Use Meaningful Text
|
|
6
|
+
|
|
7
|
+
Do not rely on color alone to communicate meaning. The badge text should describe the status or metadata by itself.
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
<w-badge variant="positive">Approved</w-badge>
|
|
11
|
+
<w-badge variant="negative">Rejected</w-badge>
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Avoid labels that only make sense visually:
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<!-- Avoid -->
|
|
18
|
+
<w-badge variant="positive">Green</w-badge>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Keep Badges Non-Interactive
|
|
22
|
+
|
|
23
|
+
Do not place interactive elements inside `w-badge`. If the user can click, dismiss, filter, or select the item, use an interactive component instead.
|
|
24
|
+
|
|
25
|
+
The `disabled` variant is visual only. It does not disable related controls or remove anything from the tab order.
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<!-- Avoid -->
|
|
29
|
+
<w-badge>
|
|
30
|
+
<button type="button">New</button>
|
|
31
|
+
</w-badge>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Dynamic Changes
|
|
35
|
+
|
|
36
|
+
If a badge value changes after the page has loaded and users need to be notified, announce that change outside the badge with an appropriate live region or use [Alert](/docs/components/alert/overview) for important feedback.
|
|
37
|
+
|
|
38
|
+
### Duplicate or Decorative Badges
|
|
39
|
+
|
|
40
|
+
If the same information is already available in nearby accessible text and the badge is only a visual duplicate, hide the duplicate badge from assistive technologies.
|
|
41
|
+
|
|
42
|
+
```html
|
|
43
|
+
<p>Sponsored listing</p>
|
|
44
|
+
<w-badge aria-hidden="true" variant="sponsored">Sponsored</w-badge>
|
|
45
|
+
```
|