@warp-ds/elements 2.9.0-next.6 → 2.9.1-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/custom-elements.json +80 -21
- package/dist/docs/affix/affix.md +24 -38
- package/dist/docs/affix/examples.md +24 -38
- package/dist/docs/alert/accessibility.md +4 -9
- package/dist/docs/alert/alert.md +24 -39
- package/dist/docs/alert/examples.md +20 -30
- package/dist/docs/attention/accessibility.md +50 -0
- package/dist/docs/attention/api.md +40 -27
- package/dist/docs/attention/attention.md +276 -27
- package/dist/docs/attention/examples.md +91 -0
- package/dist/docs/attention/usage.md +91 -0
- package/dist/docs/badge/badge.md +23 -36
- package/dist/docs/badge/examples.md +23 -36
- package/dist/docs/box/accessibility.md +29 -0
- package/dist/docs/box/api.md +16 -11
- package/dist/docs/box/box.md +189 -11
- package/dist/docs/box/examples.md +98 -0
- package/dist/docs/box/usage.md +47 -0
- package/dist/docs/textarea/accessibility.md +5 -0
- package/dist/docs/textarea/api.md +32 -47
- package/dist/docs/textarea/examples.md +81 -0
- package/dist/docs/textarea/textarea.md +133 -49
- package/dist/docs/textarea/usage.md +9 -0
- package/dist/docs/textfield/examples.md +32 -49
- package/dist/docs/textfield/textfield.md +39 -60
- package/dist/docs/textfield/usage.md +7 -11
- package/dist/index.d.ts +276 -154
- 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/box/box.d.ts +15 -14
- package/dist/packages/box/box.js +6 -6
- package/dist/packages/box/box.js.map +4 -4
- package/dist/packages/box/box.react.stories.d.ts +1 -1
- package/dist/packages/box/box.stories.d.ts +1 -0
- package/dist/packages/box/box.stories.js +12 -5
- package/dist/packages/textarea/textarea.d.ts +38 -29
- package/dist/packages/textarea/textarea.js.map +2 -2
- package/dist/web-types.json +216 -44
- package/package.json +1 -2
|
@@ -2,14 +2,250 @@
|
|
|
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
|
|
|
106
|
+
`w-attention` provides built-in accessibility helpers for tooltip/popover/callout messaging:
|
|
107
|
+
|
|
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.
|
|
111
|
+
|
|
112
|
+
### Authoring Guidance
|
|
113
|
+
|
|
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.
|
|
117
|
+
|
|
118
|
+
### Reading Order and Placement
|
|
119
|
+
|
|
120
|
+
For left/top placements, placing the attention message before the target in DOM order can improve screen reader flow.
|
|
121
|
+
|
|
122
|
+
### Precise ARIA Targeting
|
|
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`.
|
|
125
|
+
|
|
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
|
+
```
|
|
137
|
+
|
|
138
|
+
### Dismissible Attention
|
|
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.
|
|
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>
|
|
147
|
+
|
|
148
|
+
<script>
|
|
149
|
+
const attention = document.getElementById('dismissible');
|
|
150
|
+
attention.addEventListener('close', () => {
|
|
151
|
+
attention.show = false;
|
|
152
|
+
});
|
|
153
|
+
</script>
|
|
154
|
+
```
|
|
155
|
+
|
|
11
156
|
## Examples
|
|
12
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>
|
|
248
|
+
|
|
13
249
|
## API Documentation
|
|
14
250
|
|
|
15
251
|
### Properties
|
|
@@ -18,19 +254,19 @@
|
|
|
18
254
|
|-|-|-|-|
|
|
19
255
|
| _actualDirection | `unknown` | `-` | - |
|
|
20
256
|
| _initialPlacement | `unknown` | `-` | - |
|
|
21
|
-
| callout | `boolean` | `false` |
|
|
22
|
-
| canClose | `boolean` | `false` |
|
|
23
|
-
| crossAxis | `boolean` | `false` |
|
|
24
|
-
| distance | `number` | `8` |
|
|
25
|
-
| fallbackPlacements | `Directions[]` |
|
|
26
|
-
| flip | `boolean` | `false` |
|
|
27
|
-
| highlight | `boolean` | `false` |
|
|
28
|
-
| noArrow | `boolean` | `false` |
|
|
29
|
-
| placement | `Directions` | `'bottom'` |
|
|
30
|
-
| popover | `boolean` | `false` |
|
|
31
|
-
| show | `boolean` | `false` |
|
|
32
|
-
| skidding | `number` | `0` | - |
|
|
33
|
-
| tooltip | `boolean` | `false` |
|
|
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. |
|
|
34
270
|
|
|
35
271
|
### Property Details
|
|
36
272
|
|
|
@@ -50,91 +286,104 @@
|
|
|
50
286
|
|
|
51
287
|
#### callout
|
|
52
288
|
|
|
53
|
-
|
|
289
|
+
Renders the component as an inline callout.
|
|
290
|
+
Callout mode is used for always-in-flow informational content instead of floating overlay behavior.
|
|
54
291
|
|
|
55
292
|
- Type: `boolean`
|
|
56
293
|
- Default: `false`
|
|
57
294
|
|
|
58
295
|
#### canClose
|
|
59
296
|
|
|
60
|
-
|
|
297
|
+
Shows a close button inside the attention component.
|
|
298
|
+
Adds an internal dismiss action that lets users close the attention panel.
|
|
61
299
|
|
|
62
300
|
- Type: `boolean`
|
|
63
301
|
- Default: `false`
|
|
64
302
|
|
|
65
303
|
#### crossAxis
|
|
66
304
|
|
|
67
|
-
|
|
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.
|
|
68
307
|
|
|
69
308
|
- Type: `boolean`
|
|
70
309
|
- Default: `false`
|
|
71
310
|
|
|
72
311
|
#### distance
|
|
73
312
|
|
|
74
|
-
|
|
313
|
+
Distance offset between trigger and attention panel.
|
|
314
|
+
Defines the main-axis spacing in pixels from the anchor element.
|
|
75
315
|
|
|
76
316
|
- Type: `number`
|
|
77
317
|
- Default: `8`
|
|
78
318
|
|
|
79
319
|
#### fallbackPlacements
|
|
80
320
|
|
|
81
|
-
|
|
321
|
+
Ordered list of fallback placements.
|
|
322
|
+
Provides explicit alternative placements to try when `flip` is enabled and the preferred placement does not fit.
|
|
82
323
|
|
|
83
324
|
- Type: `Directions[]`
|
|
84
|
-
- Default:
|
|
325
|
+
- Default: `[]`
|
|
85
326
|
|
|
86
327
|
#### flip
|
|
87
328
|
|
|
88
|
-
|
|
329
|
+
Enables automatic flipping when placement has no space.
|
|
330
|
+
Allows the component to choose an alternative side if the preferred placement would overflow.
|
|
89
331
|
|
|
90
332
|
- Type: `boolean`
|
|
91
333
|
- Default: `false`
|
|
92
334
|
|
|
93
335
|
#### highlight
|
|
94
336
|
|
|
95
|
-
|
|
337
|
+
Renders the component with highlight styling.
|
|
338
|
+
Use highlight mode to visually emphasize important contextual information.
|
|
96
339
|
|
|
97
340
|
- Type: `boolean`
|
|
98
341
|
- Default: `false`
|
|
99
342
|
|
|
100
343
|
#### noArrow
|
|
101
344
|
|
|
102
|
-
|
|
345
|
+
Hides the directional arrow of the attention component.
|
|
346
|
+
Disable the arrow when the visual connection to the trigger should not be shown.
|
|
103
347
|
|
|
104
348
|
- Type: `boolean`
|
|
105
349
|
- Default: `false`
|
|
106
350
|
|
|
107
351
|
#### placement
|
|
108
352
|
|
|
109
|
-
|
|
353
|
+
Preferred placement relative to the trigger element.
|
|
354
|
+
Sets the initial direction for positioning, for example `top`, `right`, `bottom`, or `left` variants.
|
|
110
355
|
|
|
111
356
|
- Type: `Directions`
|
|
112
357
|
- Default: `'bottom'`
|
|
113
358
|
|
|
114
359
|
#### popover
|
|
115
360
|
|
|
116
|
-
|
|
361
|
+
Enables native popover behavior for the attention element.
|
|
362
|
+
When enabled, the component uses popover semantics and styling suitable for floating surface UI.
|
|
117
363
|
|
|
118
364
|
- Type: `boolean`
|
|
119
365
|
- Default: `false`
|
|
120
366
|
|
|
121
367
|
#### show
|
|
122
368
|
|
|
123
|
-
|
|
369
|
+
Controls whether the attention panel is visible.
|
|
370
|
+
Set to `true` to show the attention content and `false` to hide it.
|
|
124
371
|
|
|
125
372
|
- Type: `boolean`
|
|
126
373
|
- Default: `false`
|
|
127
374
|
|
|
128
375
|
#### skidding
|
|
129
376
|
|
|
130
|
-
|
|
377
|
+
Cross-axis offset for fine-grained positioning.
|
|
378
|
+
Moves the panel along the cross axis in pixels to adjust alignment with the trigger.
|
|
131
379
|
|
|
132
380
|
- Type: `number`
|
|
133
381
|
- Default: `0`
|
|
134
382
|
|
|
135
383
|
#### tooltip
|
|
136
384
|
|
|
137
|
-
|
|
385
|
+
Renders the component with tooltip styling and behavior.
|
|
386
|
+
Use for compact, non-modal contextual hints anchored to another element.
|
|
138
387
|
|
|
139
388
|
- Type: `boolean`
|
|
140
389
|
- Default: `false`
|
|
@@ -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
|
+
```
|
package/dist/docs/badge/badge.md
CHANGED
|
@@ -109,26 +109,17 @@ If the same information is already available in nearby accessible text and the b
|
|
|
109
109
|
|
|
110
110
|
### Basic
|
|
111
111
|
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
</style-isolate>
|
|
115
|
-
|
|
112
|
+
<elements-example>
|
|
113
|
+
|
|
116
114
|
```html
|
|
117
115
|
<w-badge>New</w-badge>
|
|
118
116
|
```
|
|
119
117
|
|
|
118
|
+
</elements-example>
|
|
119
|
+
|
|
120
120
|
### Status Variants
|
|
121
121
|
|
|
122
|
-
<
|
|
123
|
-
<div style="display: flex; flex-wrap: wrap; gap: 8px; align-items: center;">
|
|
124
|
-
<w-badge variant="neutral">Neutral</w-badge>
|
|
125
|
-
<w-badge variant="info">Info</w-badge>
|
|
126
|
-
<w-badge variant="positive">Approved</w-badge>
|
|
127
|
-
<w-badge variant="warning">Pending</w-badge>
|
|
128
|
-
<w-badge variant="negative">Rejected</w-badge>
|
|
129
|
-
<w-badge variant="disabled">Unavailable</w-badge>
|
|
130
|
-
</div>
|
|
131
|
-
</style-isolate>
|
|
122
|
+
<elements-example>
|
|
132
123
|
|
|
133
124
|
```html
|
|
134
125
|
<w-badge variant="neutral">Neutral</w-badge>
|
|
@@ -139,56 +130,52 @@ If the same information is already available in nearby accessible text and the b
|
|
|
139
130
|
<w-badge variant="disabled">Unavailable</w-badge>
|
|
140
131
|
```
|
|
141
132
|
|
|
142
|
-
|
|
133
|
+
</elements-example>
|
|
143
134
|
|
|
144
|
-
|
|
145
|
-
<w-badge variant="price">1 200 kr</w-badge>
|
|
146
|
-
</style-isolate>
|
|
135
|
+
### Price
|
|
147
136
|
|
|
137
|
+
<elements-example>
|
|
138
|
+
|
|
148
139
|
```html
|
|
149
140
|
<w-badge variant="price">1 200 kr</w-badge>
|
|
150
141
|
```
|
|
151
142
|
|
|
152
|
-
|
|
143
|
+
</elements-example>
|
|
153
144
|
|
|
154
|
-
|
|
155
|
-
<w-badge variant="sponsored">Sponsored</w-badge>
|
|
156
|
-
</style-isolate>
|
|
145
|
+
### Sponsored
|
|
157
146
|
|
|
147
|
+
<elements-example>
|
|
148
|
+
|
|
158
149
|
```html
|
|
159
150
|
<w-badge variant="sponsored">Sponsored</w-badge>
|
|
160
151
|
```
|
|
161
152
|
|
|
153
|
+
</elements-example>
|
|
154
|
+
|
|
162
155
|
### Positioned
|
|
163
156
|
|
|
164
|
-
<
|
|
165
|
-
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
166
|
-
<w-badge variant="price" position="top-right">1 200 kr</w-badge>
|
|
167
|
-
</div>
|
|
168
|
-
</style-isolate>
|
|
157
|
+
<elements-example>
|
|
169
158
|
|
|
170
159
|
```html
|
|
171
|
-
<div style="position: relative;">
|
|
172
|
-
<img src="listing.jpg" alt="Living room with large windows" />
|
|
160
|
+
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
173
161
|
<w-badge variant="price" position="top-right">1 200 kr</w-badge>
|
|
174
162
|
</div>
|
|
175
163
|
```
|
|
176
164
|
|
|
165
|
+
</elements-example>
|
|
166
|
+
|
|
177
167
|
### Positioned Sponsored Badge
|
|
178
168
|
|
|
179
|
-
<
|
|
180
|
-
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
181
|
-
<w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
|
|
182
|
-
</div>
|
|
183
|
-
</style-isolate>
|
|
169
|
+
<elements-example>
|
|
184
170
|
|
|
185
171
|
```html
|
|
186
|
-
<div style="position: relative;">
|
|
187
|
-
<img src="listing.jpg" alt="Living room with large windows" />
|
|
172
|
+
<div style="position: relative; width: 220px; height: 124px; border-radius: 8px; overflow: hidden; background: #e5e7eb;">
|
|
188
173
|
<w-badge variant="sponsored" position="bottom-left">Sponsored</w-badge>
|
|
189
174
|
</div>
|
|
190
175
|
```
|
|
191
176
|
|
|
177
|
+
</elements-example>
|
|
178
|
+
|
|
192
179
|
## API Documentation
|
|
193
180
|
|
|
194
181
|
### Properties
|