@warp-ds/elements 2.9.0-next.3 → 2.9.0-next.4
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 +84 -170
- package/dist/docs/affix/accessibility.md +1 -0
- package/dist/docs/affix/affix.md +6 -4
- package/dist/docs/affix/api.md +0 -4
- package/dist/docs/affix/examples.md +1 -0
- package/dist/docs/affix/usage.md +1 -0
- package/dist/docs/attention/accessibility.md +1 -0
- package/dist/docs/attention/attention.md +6 -0
- package/dist/docs/attention/examples.md +1 -0
- package/dist/docs/attention/usage.md +1 -0
- package/dist/docs/badge/accessibility.md +1 -0
- package/dist/docs/badge/badge.md +6 -0
- package/dist/docs/badge/examples.md +1 -0
- package/dist/docs/badge/usage.md +1 -0
- package/dist/docs/box/accessibility.md +1 -0
- package/dist/docs/box/box.md +6 -0
- package/dist/docs/box/examples.md +1 -0
- package/dist/docs/box/usage.md +1 -0
- package/dist/docs/breadcrumbs/accessibility.md +1 -0
- package/dist/docs/breadcrumbs/breadcrumbs.md +6 -0
- package/dist/docs/breadcrumbs/examples.md +1 -0
- package/dist/docs/breadcrumbs/usage.md +1 -0
- package/dist/docs/button/accessibility.md +1 -0
- package/dist/docs/button/button.md +6 -0
- package/dist/docs/button/examples.md +1 -0
- package/dist/docs/button/usage.md +1 -0
- package/dist/docs/card/accessibility.md +1 -0
- package/dist/docs/card/card.md +6 -0
- package/dist/docs/card/examples.md +1 -0
- package/dist/docs/card/usage.md +1 -0
- package/dist/docs/combobox/accessibility.md +1 -0
- package/dist/docs/combobox/api.md +15 -15
- package/dist/docs/combobox/combobox.md +21 -15
- package/dist/docs/combobox/examples.md +1 -0
- package/dist/docs/combobox/usage.md +1 -0
- package/dist/docs/datepicker/accessibility.md +1 -0
- package/dist/docs/datepicker/api.md +1 -9
- package/dist/docs/datepicker/datepicker.md +7 -9
- package/dist/docs/datepicker/examples.md +1 -0
- package/dist/docs/datepicker/usage.md +1 -0
- package/dist/docs/expandable/accessibility.md +1 -0
- package/dist/docs/expandable/examples.md +1 -0
- package/dist/docs/expandable/expandable.md +6 -0
- package/dist/docs/expandable/usage.md +1 -0
- package/dist/docs/link/accessibility.md +1 -0
- package/dist/docs/link/examples.md +1 -0
- package/dist/docs/link/link.md +6 -0
- package/dist/docs/link/usage.md +1 -0
- package/dist/docs/page-indicator/accessibility.md +1 -0
- package/dist/docs/page-indicator/api.md +2 -2
- package/dist/docs/page-indicator/examples.md +1 -0
- package/dist/docs/page-indicator/page-indicator.md +8 -2
- package/dist/docs/page-indicator/usage.md +1 -0
- package/dist/docs/pagination/accessibility.md +1 -0
- package/dist/docs/pagination/examples.md +1 -0
- package/dist/docs/pagination/pagination.md +6 -0
- package/dist/docs/pagination/usage.md +1 -0
- package/dist/docs/pill/accessibility.md +1 -0
- package/dist/docs/pill/examples.md +1 -0
- package/dist/docs/pill/pill.md +6 -0
- package/dist/docs/pill/usage.md +1 -0
- package/dist/docs/select/accessibility.md +1 -0
- package/dist/docs/select/api.md +19 -11
- package/dist/docs/select/examples.md +1 -0
- package/dist/docs/select/select.md +25 -11
- package/dist/docs/select/usage.md +1 -0
- package/dist/docs/slider/accessibility.md +1 -0
- package/dist/docs/slider/api.md +15 -9
- package/dist/docs/slider/examples.md +1 -0
- package/dist/docs/slider/slider.md +21 -9
- package/dist/docs/slider/usage.md +1 -0
- package/dist/docs/slider-thumb/accessibility.md +1 -0
- package/dist/docs/slider-thumb/api.md +48 -0
- package/dist/docs/slider-thumb/examples.md +1 -0
- package/dist/docs/slider-thumb/slider-thumb.md +54 -0
- package/dist/docs/slider-thumb/usage.md +1 -0
- package/dist/docs/step/accessibility.md +1 -0
- package/dist/docs/step/examples.md +1 -0
- package/dist/docs/step/step.md +6 -0
- package/dist/docs/step/usage.md +1 -0
- package/dist/docs/step-indicator/accessibility.md +1 -0
- package/dist/docs/step-indicator/examples.md +1 -0
- package/dist/docs/step-indicator/step-indicator.md +6 -0
- package/dist/docs/step-indicator/usage.md +1 -0
- package/dist/docs/switch/accessibility.md +1 -0
- package/dist/docs/switch/examples.md +1 -0
- package/dist/docs/switch/switch.md +6 -0
- package/dist/docs/switch/usage.md +1 -0
- package/dist/docs/tab/accessibility.md +1 -0
- package/dist/docs/tab/api.md +16 -0
- package/dist/docs/tab/examples.md +1 -0
- package/dist/docs/tab/tab.md +22 -0
- package/dist/docs/tab/usage.md +1 -0
- package/dist/docs/tab-panel/accessibility.md +1 -0
- package/dist/docs/tab-panel/api.md +16 -0
- package/dist/docs/tab-panel/examples.md +1 -0
- package/dist/docs/tab-panel/tab-panel.md +22 -0
- package/dist/docs/tab-panel/usage.md +1 -0
- package/dist/docs/tabs/accessibility.md +1 -0
- package/dist/docs/tabs/examples.md +1 -0
- package/dist/docs/tabs/tabs.md +6 -0
- package/dist/docs/tabs/usage.md +1 -0
- package/dist/docs/textarea/accessibility.md +1 -0
- package/dist/docs/textarea/examples.md +1 -0
- package/dist/docs/textarea/textarea.md +6 -0
- package/dist/docs/textarea/usage.md +1 -0
- package/dist/docs/textfield/accessibility.md +1 -0
- package/dist/docs/textfield/api.md +16 -6
- package/dist/docs/textfield/examples.md +1 -0
- package/dist/docs/textfield/textfield.md +22 -6
- package/dist/docs/textfield/usage.md +1 -0
- package/dist/docs/toast/accessibility.md +9 -0
- package/dist/docs/toast/api.md +71 -0
- package/dist/docs/toast/examples.md +29 -0
- package/dist/docs/toast/toast.md +150 -0
- package/dist/docs/toast/usage.md +31 -0
- package/dist/index.d.ts +104 -97
- package/dist/packages/affix/affix.d.ts +16 -2
- package/dist/packages/affix/affix.js.map +2 -2
- package/dist/packages/attention/attention.d.ts +52 -0
- package/dist/packages/attention/attention.js.map +2 -2
- package/dist/packages/badge/badge.d.ts +8 -0
- package/dist/packages/badge/badge.js.map +2 -2
- package/dist/packages/box/box.d.ts +20 -0
- package/dist/packages/box/box.js.map +2 -2
- package/dist/packages/button/button.d.ts +60 -2
- package/dist/packages/button/button.js.map +2 -2
- package/dist/packages/card/card.d.ts +12 -0
- package/dist/packages/card/card.js.map +2 -2
- package/dist/packages/combobox/combobox.d.ts +60 -15
- package/dist/packages/combobox/combobox.js.map +2 -2
- package/dist/packages/datepicker/datepicker.d.ts +32 -5
- package/dist/packages/datepicker/datepicker.js.map +2 -2
- package/dist/packages/expandable/expandable.d.ts +44 -0
- package/dist/packages/expandable/expandable.js.map +2 -2
- package/dist/packages/link/link.d.ts +32 -0
- package/dist/packages/link/link.js.map +2 -2
- package/dist/packages/page-indicator/page-indicator.d.ts +8 -2
- package/dist/packages/page-indicator/page-indicator.js.map +2 -2
- package/dist/packages/pagination/pagination.d.ts +16 -0
- package/dist/packages/pagination/pagination.js.map +2 -2
- package/dist/packages/pill/pill.d.ts +24 -2
- package/dist/packages/pill/pill.js.map +2 -2
- package/dist/packages/select/select.d.ts +56 -12
- package/dist/packages/select/select.js.map +2 -2
- package/dist/packages/slider/slider.d.ts +65 -8
- package/dist/packages/slider/slider.js +7 -7
- package/dist/packages/slider/slider.js.map +3 -3
- package/dist/packages/slider/slider.test.js +68 -0
- package/dist/packages/slider-thumb/slider-thumb.d.ts +44 -6
- package/dist/packages/slider-thumb/slider-thumb.js +24 -23
- package/dist/packages/slider-thumb/slider-thumb.js.map +3 -3
- package/dist/packages/step/step.d.ts +8 -0
- package/dist/packages/step/step.js.map +2 -2
- package/dist/packages/step-indicator/step-indicator.d.ts +8 -0
- package/dist/packages/step-indicator/step-indicator.js.map +2 -2
- package/dist/packages/switch/switch.d.ts +16 -0
- package/dist/packages/switch/switch.js.map +2 -2
- package/dist/packages/tab/tab.d.ts +28 -3
- package/dist/packages/tab/tab.js.map +2 -2
- package/dist/packages/tab-panel/tab-panel.d.ts +8 -2
- package/dist/packages/tab-panel/tab-panel.js.map +2 -2
- package/dist/packages/tabs/tabs.d.ts +4 -0
- package/dist/packages/tabs/tabs.js.map +2 -2
- package/dist/packages/textarea/textarea.d.ts +52 -1
- package/dist/packages/textarea/textarea.js.map +2 -2
- package/dist/packages/textfield/textfield.d.ts +92 -4
- package/dist/packages/textfield/textfield.js.map +2 -2
- package/dist/packages/toast-container/toast-container.d.ts +14 -0
- package/dist/packages/toast-container/toast-container.js.map +2 -2
- package/dist/web-types.json +60 -221
- package/package.json +2 -2
- package/dist/docs/toast-container/api.md +0 -14
- package/dist/docs/toast-container/toast-container.md +0 -20
package/dist/docs/tab/tab.md
CHANGED
|
@@ -6,6 +6,12 @@ Individual tab component used within w-tabs container.
|
|
|
6
6
|
|
|
7
7
|
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/tabs--docs)
|
|
8
8
|
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
## Accessibility
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
9
15
|
## API Documentation
|
|
10
16
|
|
|
11
17
|
### Properties
|
|
@@ -20,6 +26,8 @@ Individual tab component used within w-tabs container.
|
|
|
20
26
|
| ariaSelected | `'true' | 'false'` | `-` | - |
|
|
21
27
|
| active | `boolean` | `false` | - |
|
|
22
28
|
| over | `boolean` | `false` | - |
|
|
29
|
+
| _parentTabIndex | `unknown` | `-` | - |
|
|
30
|
+
| _parentAriaSelected | `unknown` | `-` | - |
|
|
23
31
|
|
|
24
32
|
### Property Details
|
|
25
33
|
|
|
@@ -79,6 +87,20 @@ Computed aria-selected: prefers parent-managed, falls back to own property
|
|
|
79
87
|
- Type: `boolean`
|
|
80
88
|
- Default: `false`
|
|
81
89
|
|
|
90
|
+
#### _parentTabIndex
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
- Type: `unknown`
|
|
95
|
+
- Default: `-`
|
|
96
|
+
|
|
97
|
+
#### _parentAriaSelected
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
- Type: `unknown`
|
|
102
|
+
- Default: `-`
|
|
103
|
+
|
|
82
104
|
### Types
|
|
83
105
|
|
|
84
106
|
No types documented.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
| Name | Type | Default | Summary |
|
|
6
6
|
|-|-|-|-|
|
|
7
7
|
| active | `boolean` | `-` | - |
|
|
8
|
+
| _parentActive | `unknown` | `-` | - |
|
|
9
|
+
| _parentAriaLabelledBy | `unknown` | `-` | - |
|
|
8
10
|
|
|
9
11
|
### Property Details
|
|
10
12
|
|
|
@@ -16,6 +18,20 @@ Set by parent w-tabs via the _parentActive property.
|
|
|
16
18
|
- Type: `boolean`
|
|
17
19
|
- Default: `-`
|
|
18
20
|
|
|
21
|
+
#### _parentActive
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
- Type: `unknown`
|
|
26
|
+
- Default: `-`
|
|
27
|
+
|
|
28
|
+
#### _parentAriaLabelledBy
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
- Type: `unknown`
|
|
33
|
+
- Default: `-`
|
|
34
|
+
|
|
19
35
|
### Types
|
|
20
36
|
|
|
21
37
|
No types documented.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
|
@@ -7,6 +7,12 @@ Each tab panel should have a name that matches a corresponding tab.
|
|
|
7
7
|
|
|
8
8
|
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/tabs--docs)
|
|
9
9
|
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
## Accessibility
|
|
13
|
+
|
|
14
|
+
## Examples
|
|
15
|
+
|
|
10
16
|
## API Documentation
|
|
11
17
|
|
|
12
18
|
### Properties
|
|
@@ -14,6 +20,8 @@ Each tab panel should have a name that matches a corresponding tab.
|
|
|
14
20
|
| Name | Type | Default | Summary |
|
|
15
21
|
|-|-|-|-|
|
|
16
22
|
| active | `boolean` | `-` | - |
|
|
23
|
+
| _parentActive | `unknown` | `-` | - |
|
|
24
|
+
| _parentAriaLabelledBy | `unknown` | `-` | - |
|
|
17
25
|
|
|
18
26
|
### Property Details
|
|
19
27
|
|
|
@@ -25,6 +33,20 @@ Set by parent w-tabs via the _parentActive property.
|
|
|
25
33
|
- Type: `boolean`
|
|
26
34
|
- Default: `-`
|
|
27
35
|
|
|
36
|
+
#### _parentActive
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
- Type: `unknown`
|
|
41
|
+
- Default: `-`
|
|
42
|
+
|
|
43
|
+
#### _parentAriaLabelledBy
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
- Type: `unknown`
|
|
48
|
+
- Default: `-`
|
|
49
|
+
|
|
28
50
|
### Types
|
|
29
51
|
|
|
30
52
|
No types documented.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
package/dist/docs/tabs/tabs.md
CHANGED
|
@@ -6,6 +6,12 @@ Tabs are used to organize content by grouping similar information on the same pa
|
|
|
6
6
|
|
|
7
7
|
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/tabs--docs)
|
|
8
8
|
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
## Accessibility
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
9
15
|
## API Documentation
|
|
10
16
|
|
|
11
17
|
### Properties
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Accessibility
|
|
@@ -26,6 +26,8 @@
|
|
|
26
26
|
| step | `number` | `-` | - |
|
|
27
27
|
| autocomplete | `string | undefined` | `-` | - |
|
|
28
28
|
| formatter | `(value: string) => string` | `-` | - |
|
|
29
|
+
| _hasPrefix | `unknown` | `-` | - |
|
|
30
|
+
| _hasSuffix | `unknown` | `-` | - |
|
|
29
31
|
|
|
30
32
|
### Property Details
|
|
31
33
|
|
|
@@ -178,17 +180,25 @@
|
|
|
178
180
|
|
|
179
181
|
#### formatter
|
|
180
182
|
|
|
181
|
-
Function to format value when the input field.
|
|
182
183
|
|
|
183
|
-
Only active when the input field does not have focus,
|
|
184
|
-
similar to the accessible input masking example from Filament Group
|
|
185
|
-
|
|
186
|
-
https://css-tricks.com/input-masking/
|
|
187
|
-
https://filamentgroup.github.io/politespace/demo/demo.html
|
|
188
184
|
|
|
189
185
|
- Type: `(value: string) => string`
|
|
190
186
|
- Default: `-`
|
|
191
187
|
|
|
188
|
+
#### _hasPrefix
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
- Type: `unknown`
|
|
193
|
+
- Default: `-`
|
|
194
|
+
|
|
195
|
+
#### _hasSuffix
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
- Type: `unknown`
|
|
200
|
+
- Default: `-`
|
|
201
|
+
|
|
192
202
|
### Types
|
|
193
203
|
|
|
194
204
|
No types documented.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Examples
|
|
@@ -6,6 +6,12 @@ A single line text input element.
|
|
|
6
6
|
|
|
7
7
|
[See Storybook for usage examples](https://warp-ds.github.io/elements/?path=/docs/forms-textfield--docs)
|
|
8
8
|
|
|
9
|
+
## Usage
|
|
10
|
+
|
|
11
|
+
## Accessibility
|
|
12
|
+
|
|
13
|
+
## Examples
|
|
14
|
+
|
|
9
15
|
## API Documentation
|
|
10
16
|
|
|
11
17
|
### Properties
|
|
@@ -34,6 +40,8 @@ A single line text input element.
|
|
|
34
40
|
| step | `number` | `-` | - |
|
|
35
41
|
| autocomplete | `string | undefined` | `-` | - |
|
|
36
42
|
| formatter | `(value: string) => string` | `-` | - |
|
|
43
|
+
| _hasPrefix | `unknown` | `-` | - |
|
|
44
|
+
| _hasSuffix | `unknown` | `-` | - |
|
|
37
45
|
|
|
38
46
|
### Property Details
|
|
39
47
|
|
|
@@ -186,17 +194,25 @@ A single line text input element.
|
|
|
186
194
|
|
|
187
195
|
#### formatter
|
|
188
196
|
|
|
189
|
-
Function to format value when the input field.
|
|
190
|
-
|
|
191
|
-
Only active when the input field does not have focus,
|
|
192
|
-
similar to the accessible input masking example from Filament Group
|
|
193
197
|
|
|
194
|
-
https://css-tricks.com/input-masking/
|
|
195
|
-
https://filamentgroup.github.io/politespace/demo/demo.html
|
|
196
198
|
|
|
197
199
|
- Type: `(value: string) => string`
|
|
198
200
|
- Default: `-`
|
|
199
201
|
|
|
202
|
+
#### _hasPrefix
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
- Type: `unknown`
|
|
207
|
+
- Default: `-`
|
|
208
|
+
|
|
209
|
+
#### _hasSuffix
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
- Type: `unknown`
|
|
214
|
+
- Default: `-`
|
|
215
|
+
|
|
200
216
|
### Types
|
|
201
217
|
|
|
202
218
|
No types documented.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
## Usage
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
## Accessibility
|
|
2
|
+
|
|
3
|
+
From an accessibility perspective, toasts should never contain interactive elements, as these should always appear in the same location as the action that triggered them.
|
|
4
|
+
|
|
5
|
+
Auto-clearing toasts based on a timeout violate WCAG 2 success criteria 2.2.1, unless the information they contain is either redundant (i.e. also available elsewhere in a persistent manner) or insignificant to all people.
|
|
6
|
+
|
|
7
|
+
You are also advised to avoid putting information in a toast that cannot be re-accessed in any other way due to the impermanent nature of the current toast implementation.
|
|
8
|
+
|
|
9
|
+
Because of these points we consider the use of toasts to be somewhat of an anti-pattern, and recommend exploring alternative approaches wherever possible. That said, you may still use toasts, as long as you avoid interactive elements like links or close buttons.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
## API Documentation
|
|
2
|
+
|
|
3
|
+
### toast
|
|
4
|
+
|
|
5
|
+
```js
|
|
6
|
+
import { toast } from '@warp-ds/elements/toast';
|
|
7
|
+
|
|
8
|
+
const theToast = toast('Toasts are somewhat of an anti-pattern');
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Returns [ToastOptions](#toastoptions), which includes the ID you need for [updateToast](#updatetoast) and [removeToast](#removetoast).
|
|
12
|
+
|
|
13
|
+
If you can't pass the result from `toast` to where you call `updateToast` or `removeToast` you can set a known ID manually.
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
toast('Toasts are somewhat of an anti-pattern', {
|
|
17
|
+
id: 'something-unique-but-stable',
|
|
18
|
+
});
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
| Parameter | Type | Summary |
|
|
22
|
+
| --- | --- | --- |
|
|
23
|
+
| message | `string` | The text content |
|
|
24
|
+
| options | [ToastOptions](#toastoptions) (optional) | |
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
### updateToast
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import { toast, updateToast } from '@warp-ds/elements/toast';
|
|
31
|
+
|
|
32
|
+
const theToast = toast('The toast function returns an ID');
|
|
33
|
+
|
|
34
|
+
updateToast(theToast.id, 'Use it to update the text');
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Returns [ToastOptions](#toastoptions).
|
|
38
|
+
|
|
39
|
+
| Parameter | Type | Summary |
|
|
40
|
+
| --- | --- | --- |
|
|
41
|
+
| id | `string` | The ID of the toast you want to update |
|
|
42
|
+
| message | `string` | The new text content |
|
|
43
|
+
| options | [ToastOptions](#toastoptions) (optional) | |
|
|
44
|
+
|
|
45
|
+
### removeToast
|
|
46
|
+
|
|
47
|
+
Toasts disappear after a set time, but if you need to remove one before that happens you can do so.
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
import { toast, removeToast } from '@warp-ds/elements/toast';
|
|
51
|
+
|
|
52
|
+
const theToast = toast('The toast function returns an ID');
|
|
53
|
+
|
|
54
|
+
removeToast(theToast.id);
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Types
|
|
58
|
+
|
|
59
|
+
#### ToastOptions
|
|
60
|
+
|
|
61
|
+
| Name | Type | Default | Summary |
|
|
62
|
+
| --- | --- | --- | --- |
|
|
63
|
+
| id | `string` | Random | Random generated unique ID for the toast element |
|
|
64
|
+
| type | [`ToastVariants`](#toastvariants) | `'success'` | Visual style of the toast |
|
|
65
|
+
| text | `string` | `-` | The given toast message |
|
|
66
|
+
| duration | `number` | `5000` | Duration of toast in milliseconds |
|
|
67
|
+
| canclose | `boolean` | `false` | See [Dismissable toast](#dismissable-toast) |
|
|
68
|
+
|
|
69
|
+
#### ToastVariants
|
|
70
|
+
|
|
71
|
+
`'success' | 'warning' | 'error'`
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
## Examples
|
|
2
|
+
|
|
3
|
+
### Success / positive
|
|
4
|
+
|
|
5
|
+
This is the default.
|
|
6
|
+
|
|
7
|
+
<style-isolate id="toast-usage">
|
|
8
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern')">Show a success toast</w-button>
|
|
9
|
+
</style-isolate>
|
|
10
|
+
|
|
11
|
+
### Warning
|
|
12
|
+
|
|
13
|
+
If the user should be warned about something, a toast is probably not the right way to do so. Consider an [Alert](/docs/components/alert/overview) instead.
|
|
14
|
+
|
|
15
|
+
A toast is easy to miss, especially on larger screens. Toasts that automatically close are also an accessibility problem if the information is not available elsewhere, or is insignificant (which shouldn't be the case for warnings).
|
|
16
|
+
|
|
17
|
+
<style-isolate id="toast-usage">
|
|
18
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern', { type: 'warning' })">Show a warning toast</w-button>
|
|
19
|
+
</style-isolate>
|
|
20
|
+
|
|
21
|
+
### Error / negative
|
|
22
|
+
|
|
23
|
+
If the user should be told about an error, a toast is probably not the right way to do so. Consider an [Alert](/docs/components/alert/overview) instead.
|
|
24
|
+
|
|
25
|
+
A toast is easy to miss, especially on larger screens. Toasts that automatically close are also an accessibility problem if the information is not available elsewhere, or is insignificant (which shouldn't be the case for errors).
|
|
26
|
+
|
|
27
|
+
<style-isolate id="toast-usage">
|
|
28
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern', { type: 'error' })">Show an error toast</w-button>
|
|
29
|
+
</style-isolate>
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# Toast
|
|
2
|
+
|
|
3
|
+
## Description
|
|
4
|
+
|
|
5
|
+
Toasts are brief user feedback messages that overlay content.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
You should not use the toast components directly. Instead use the JavaScript API exported from Warp Elements to create, update and remove toasts
|
|
10
|
+
|
|
11
|
+
<style-isolate id="toast-usage">
|
|
12
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern')">Show toast</w-button>
|
|
13
|
+
</style-isolate>
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
import { toast } from '@warp-ds/elements/toast';
|
|
18
|
+
|
|
19
|
+
const showBtn = document.getElementById("toast-btn");
|
|
20
|
+
showBtn.onclick = () => {
|
|
21
|
+
toast("Toasts are somewhat of an anti-pattern");
|
|
22
|
+
};
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Dismissable toast
|
|
26
|
+
|
|
27
|
+
The toast automatically closes by default, so you don't need to have a close button.
|
|
28
|
+
|
|
29
|
+
From an accessibility perspective, toasts should never contain interactive elements such as close buttons, as interactive elements should always appear in the same location as the action that triggered them.
|
|
30
|
+
|
|
31
|
+
It might be tempting to use this option and a high duration if you have a warning or error toast to "solve" the WCAG 2 success criteria 2.2.1, but please consider showing warnings and errors as a persistent [Alert](/docs/components/alert/overview) instead.
|
|
32
|
+
|
|
33
|
+
If the toast absolutely must be dismissible by the user, set the `canclose` property to `true`.
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
toast('message goes here', { type: 'success', canclose: true });
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Accessibility
|
|
40
|
+
|
|
41
|
+
From an accessibility perspective, toasts should never contain interactive elements, as these should always appear in the same location as the action that triggered them.
|
|
42
|
+
|
|
43
|
+
Auto-clearing toasts based on a timeout violate WCAG 2 success criteria 2.2.1, unless the information they contain is either redundant (i.e. also available elsewhere in a persistent manner) or insignificant to all people.
|
|
44
|
+
|
|
45
|
+
You are also advised to avoid putting information in a toast that cannot be re-accessed in any other way due to the impermanent nature of the current toast implementation.
|
|
46
|
+
|
|
47
|
+
Because of these points we consider the use of toasts to be somewhat of an anti-pattern, and recommend exploring alternative approaches wherever possible. That said, you may still use toasts, as long as you avoid interactive elements like links or close buttons.
|
|
48
|
+
|
|
49
|
+
## Examples
|
|
50
|
+
|
|
51
|
+
### Success / positive
|
|
52
|
+
|
|
53
|
+
This is the default.
|
|
54
|
+
|
|
55
|
+
<style-isolate id="toast-usage">
|
|
56
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern')">Show a success toast</w-button>
|
|
57
|
+
</style-isolate>
|
|
58
|
+
|
|
59
|
+
### Warning
|
|
60
|
+
|
|
61
|
+
If the user should be warned about something, a toast is probably not the right way to do so. Consider an [Alert](/docs/components/alert/overview) instead.
|
|
62
|
+
|
|
63
|
+
A toast is easy to miss, especially on larger screens. Toasts that automatically close are also an accessibility problem if the information is not available elsewhere, or is insignificant (which shouldn't be the case for warnings).
|
|
64
|
+
|
|
65
|
+
<style-isolate id="toast-usage">
|
|
66
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern', { type: 'warning' })">Show a warning toast</w-button>
|
|
67
|
+
</style-isolate>
|
|
68
|
+
|
|
69
|
+
### Error / negative
|
|
70
|
+
|
|
71
|
+
If the user should be told about an error, a toast is probably not the right way to do so. Consider an [Alert](/docs/components/alert/overview) instead.
|
|
72
|
+
|
|
73
|
+
A toast is easy to miss, especially on larger screens. Toasts that automatically close are also an accessibility problem if the information is not available elsewhere, or is insignificant (which shouldn't be the case for errors).
|
|
74
|
+
|
|
75
|
+
<style-isolate id="toast-usage">
|
|
76
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern', { type: 'error' })">Show an error toast</w-button>
|
|
77
|
+
</style-isolate>
|
|
78
|
+
|
|
79
|
+
## API Documentation
|
|
80
|
+
|
|
81
|
+
### toast
|
|
82
|
+
|
|
83
|
+
```js
|
|
84
|
+
import { toast } from '@warp-ds/elements/toast';
|
|
85
|
+
|
|
86
|
+
const theToast = toast('Toasts are somewhat of an anti-pattern');
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Returns [ToastOptions](#toastoptions), which includes the ID you need for [updateToast](#updatetoast) and [removeToast](#removetoast).
|
|
90
|
+
|
|
91
|
+
If you can't pass the result from `toast` to where you call `updateToast` or `removeToast` you can set a known ID manually.
|
|
92
|
+
|
|
93
|
+
```js
|
|
94
|
+
toast('Toasts are somewhat of an anti-pattern', {
|
|
95
|
+
id: 'something-unique-but-stable',
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
| Parameter | Type | Summary |
|
|
100
|
+
| --- | --- | --- |
|
|
101
|
+
| message | `string` | The text content |
|
|
102
|
+
| options | [ToastOptions](#toastoptions) (optional) | |
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### updateToast
|
|
106
|
+
|
|
107
|
+
```js
|
|
108
|
+
import { toast, updateToast } from '@warp-ds/elements/toast';
|
|
109
|
+
|
|
110
|
+
const theToast = toast('The toast function returns an ID');
|
|
111
|
+
|
|
112
|
+
updateToast(theToast.id, 'Use it to update the text');
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Returns [ToastOptions](#toastoptions).
|
|
116
|
+
|
|
117
|
+
| Parameter | Type | Summary |
|
|
118
|
+
| --- | --- | --- |
|
|
119
|
+
| id | `string` | The ID of the toast you want to update |
|
|
120
|
+
| message | `string` | The new text content |
|
|
121
|
+
| options | [ToastOptions](#toastoptions) (optional) | |
|
|
122
|
+
|
|
123
|
+
### removeToast
|
|
124
|
+
|
|
125
|
+
Toasts disappear after a set time, but if you need to remove one before that happens you can do so.
|
|
126
|
+
|
|
127
|
+
```js
|
|
128
|
+
import { toast, removeToast } from '@warp-ds/elements/toast';
|
|
129
|
+
|
|
130
|
+
const theToast = toast('The toast function returns an ID');
|
|
131
|
+
|
|
132
|
+
removeToast(theToast.id);
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
### Types
|
|
136
|
+
|
|
137
|
+
#### ToastOptions
|
|
138
|
+
|
|
139
|
+
| Name | Type | Default | Summary |
|
|
140
|
+
| --- | --- | --- | --- |
|
|
141
|
+
| id | `string` | Random | Random generated unique ID for the toast element |
|
|
142
|
+
| type | [`ToastVariants`](#toastvariants) | `'success'` | Visual style of the toast |
|
|
143
|
+
| text | `string` | `-` | The given toast message |
|
|
144
|
+
| duration | `number` | `5000` | Duration of toast in milliseconds |
|
|
145
|
+
| canclose | `boolean` | `false` | See [Dismissable toast](#dismissable-toast) |
|
|
146
|
+
|
|
147
|
+
#### ToastVariants
|
|
148
|
+
|
|
149
|
+
`'success' | 'warning' | 'error'`
|
|
150
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
## Usage
|
|
2
|
+
|
|
3
|
+
You should not use the toast components directly. Instead use the JavaScript API exported from Warp Elements to create, update and remove toasts
|
|
4
|
+
|
|
5
|
+
<style-isolate id="toast-usage">
|
|
6
|
+
<w-button id="toast-btn" onclick="toast('Toasts are somewhat of an anti-pattern')">Show toast</w-button>
|
|
7
|
+
</style-isolate>
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import { toast } from '@warp-ds/elements/toast';
|
|
12
|
+
|
|
13
|
+
const showBtn = document.getElementById("toast-btn");
|
|
14
|
+
showBtn.onclick = () => {
|
|
15
|
+
toast("Toasts are somewhat of an anti-pattern");
|
|
16
|
+
};
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Dismissable toast
|
|
20
|
+
|
|
21
|
+
The toast automatically closes by default, so you don't need to have a close button.
|
|
22
|
+
|
|
23
|
+
From an accessibility perspective, toasts should never contain interactive elements such as close buttons, as interactive elements should always appear in the same location as the action that triggered them.
|
|
24
|
+
|
|
25
|
+
It might be tempting to use this option and a high duration if you have a warning or error toast to "solve" the WCAG 2 success criteria 2.2.1, but please consider showing warnings and errors as a persistent [Alert](/docs/components/alert/overview) instead.
|
|
26
|
+
|
|
27
|
+
If the toast absolutely must be dismissible by the user, set the `canclose` property to `true`.
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
toast('message goes here', { type: 'success', canclose: true });
|
|
31
|
+
```
|