@workday/canvas-kit-docs 7.3.0-next.1 → 7.3.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.
@@ -6172,6 +6172,102 @@ module.exports = {specifications: [
6172
6172
  }
6173
6173
  ]
6174
6174
  },
6175
+ {
6176
+ "type": "file",
6177
+ "name": "ToastLabs.spec.ts",
6178
+ "children": [
6179
+ {
6180
+ "type": "describe",
6181
+ "name": "Toast",
6182
+ "children": [
6183
+ {
6184
+ "type": "describe",
6185
+ "name": "given the 'Basic' story is rendered",
6186
+ "children": [
6187
+ {
6188
+ "type": "it",
6189
+ "name": "should not have any axe errors"
6190
+ }
6191
+ ]
6192
+ },
6193
+ {
6194
+ "type": "describe",
6195
+ "name": "given the 'Toast Alert' story is rendered",
6196
+ "children": [
6197
+ {
6198
+ "type": "it",
6199
+ "name": "should not have any axe errors"
6200
+ }
6201
+ ]
6202
+ },
6203
+ {
6204
+ "type": "describe",
6205
+ "name": "given the 'Toast Dialog' story is rendered",
6206
+ "children": [
6207
+ {
6208
+ "type": "it",
6209
+ "name": "should not have any axe errors"
6210
+ }
6211
+ ]
6212
+ },
6213
+ {
6214
+ "type": "describe",
6215
+ "name": "given the toast with no close icon or action button",
6216
+ "children": [
6217
+ {
6218
+ "type": "it",
6219
+ "name": "should have a role of status"
6220
+ },
6221
+ {
6222
+ "type": "it",
6223
+ "name": "should have aria-live set to polite"
6224
+ },
6225
+ {
6226
+ "type": "it",
6227
+ "name": "should have aria-atomic set to true"
6228
+ }
6229
+ ]
6230
+ },
6231
+ {
6232
+ "type": "describe",
6233
+ "name": "given the toast with an alert",
6234
+ "children": [
6235
+ {
6236
+ "type": "it",
6237
+ "name": "should have a role of alert"
6238
+ },
6239
+ {
6240
+ "type": "it",
6241
+ "name": "should have aria-live set to assertive"
6242
+ },
6243
+ {
6244
+ "type": "it",
6245
+ "name": "should have aria-atomic set to true"
6246
+ }
6247
+ ]
6248
+ },
6249
+ {
6250
+ "type": "describe",
6251
+ "name": "given the toast with a close button and action button",
6252
+ "children": [
6253
+ {
6254
+ "type": "it",
6255
+ "name": "should have a role of dialog"
6256
+ },
6257
+ {
6258
+ "type": "it",
6259
+ "name": "should have aria-label set to notification"
6260
+ },
6261
+ {
6262
+ "type": "it",
6263
+ "name": "should have aria-describedby"
6264
+ }
6265
+ ]
6266
+ }
6267
+ ]
6268
+ }
6269
+ ]
6270
+ },
6175
6271
  {
6176
6272
  "type": "file",
6177
6273
  "name": "Tooltip.spec.ts",
@@ -6172,6 +6172,102 @@ module.exports = {specifications: [
6172
6172
  }
6173
6173
  ]
6174
6174
  },
6175
+ {
6176
+ "type": "file",
6177
+ "name": "ToastLabs.spec.ts",
6178
+ "children": [
6179
+ {
6180
+ "type": "describe",
6181
+ "name": "Toast",
6182
+ "children": [
6183
+ {
6184
+ "type": "describe",
6185
+ "name": "given the 'Basic' story is rendered",
6186
+ "children": [
6187
+ {
6188
+ "type": "it",
6189
+ "name": "should not have any axe errors"
6190
+ }
6191
+ ]
6192
+ },
6193
+ {
6194
+ "type": "describe",
6195
+ "name": "given the 'Toast Alert' story is rendered",
6196
+ "children": [
6197
+ {
6198
+ "type": "it",
6199
+ "name": "should not have any axe errors"
6200
+ }
6201
+ ]
6202
+ },
6203
+ {
6204
+ "type": "describe",
6205
+ "name": "given the 'Toast Dialog' story is rendered",
6206
+ "children": [
6207
+ {
6208
+ "type": "it",
6209
+ "name": "should not have any axe errors"
6210
+ }
6211
+ ]
6212
+ },
6213
+ {
6214
+ "type": "describe",
6215
+ "name": "given the toast with no close icon or action button",
6216
+ "children": [
6217
+ {
6218
+ "type": "it",
6219
+ "name": "should have a role of status"
6220
+ },
6221
+ {
6222
+ "type": "it",
6223
+ "name": "should have aria-live set to polite"
6224
+ },
6225
+ {
6226
+ "type": "it",
6227
+ "name": "should have aria-atomic set to true"
6228
+ }
6229
+ ]
6230
+ },
6231
+ {
6232
+ "type": "describe",
6233
+ "name": "given the toast with an alert",
6234
+ "children": [
6235
+ {
6236
+ "type": "it",
6237
+ "name": "should have a role of alert"
6238
+ },
6239
+ {
6240
+ "type": "it",
6241
+ "name": "should have aria-live set to assertive"
6242
+ },
6243
+ {
6244
+ "type": "it",
6245
+ "name": "should have aria-atomic set to true"
6246
+ }
6247
+ ]
6248
+ },
6249
+ {
6250
+ "type": "describe",
6251
+ "name": "given the toast with a close button and action button",
6252
+ "children": [
6253
+ {
6254
+ "type": "it",
6255
+ "name": "should have a role of dialog"
6256
+ },
6257
+ {
6258
+ "type": "it",
6259
+ "name": "should have aria-label set to notification"
6260
+ },
6261
+ {
6262
+ "type": "it",
6263
+ "name": "should have aria-describedby"
6264
+ }
6265
+ ]
6266
+ }
6267
+ ]
6268
+ }
6269
+ ]
6270
+ },
6175
6271
  {
6176
6272
  "type": "file",
6177
6273
  "name": "Tooltip.spec.ts",
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ return (
9
+ <Toast>
10
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
11
+ <Toast.Body>
12
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
13
+ </Toast.Body>
14
+ </Toast>
15
+ );
16
+ };
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+ import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';
7
+
8
+ export default () => {
9
+ const handleClose = () => console.log('close button clicked');
10
+
11
+ return (
12
+ <CanvasProvider theme={{canvas: {direction: ContentDirection.RTL}}}>
13
+ <Toast mode="dialog">
14
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
15
+ <Toast.Body>
16
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
17
+ </Toast.Body>
18
+ <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
19
+ </Toast>
20
+ </CanvasProvider>
21
+ );
22
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {exclamationCircleIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => (
8
+ <Toast mode="alert">
9
+ <Toast.Icon icon={exclamationCircleIcon} color={colors.cinnamon500} />
10
+ <Toast.Body>
11
+ <Toast.Message>There was an error with your workbook.</Toast.Message>
12
+ </Toast.Body>
13
+ </Toast>
14
+ );
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => (
8
+ <Toast mode="dialog">
9
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
10
+ <Toast.Body>
11
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
12
+ <Toast.Link href="#hreflink">Custom Link</Toast.Link>
13
+ </Toast.Body>
14
+ </Toast>
15
+ );
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ const handleClose = () => console.log('close button clicked');
9
+
10
+ return (
11
+ <Toast mode="dialog">
12
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
13
+ <Toast.Body>
14
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
15
+ <Toast.Link href="#hyperlink">Custom Link</Toast.Link>
16
+ </Toast.Body>
17
+ <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
18
+ </Toast>
19
+ );
20
+ };
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ export default () => {
8
+ const handleClose = () => console.log('close button clicked');
9
+
10
+ return (
11
+ <Toast>
12
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
13
+ <Toast.Body>
14
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
15
+ </Toast.Body>
16
+ <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
17
+ </Toast>
18
+ );
19
+ };
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import {checkIcon} from '@workday/canvas-system-icons-web';
5
+ import {colors} from '@workday/canvas-kit-react/tokens';
6
+
7
+ import {Popper, SecondaryButton} from '@workday/canvas-kit-react';
8
+
9
+ export default () => {
10
+ const [open, setOpen] = React.useState(false);
11
+ const containerRef = React.useRef(null);
12
+
13
+ const handleClose = () => {
14
+ setOpen(false);
15
+ };
16
+
17
+ const handleOpen = () => {
18
+ setOpen(true);
19
+ };
20
+
21
+ return (
22
+ <div ref={containerRef}>
23
+ <SecondaryButton onClick={handleOpen}>Show Toast</SecondaryButton>
24
+ <Popper placement="bottom-end" open={open} anchorElement={containerRef}>
25
+ <Toast mode="dialog">
26
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
27
+ <Toast.Body>
28
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
29
+ </Toast.Body>
30
+ <Toast.CloseIcon aria-label="Close" onClick={handleClose} />
31
+ </Toast>
32
+ </Popper>
33
+ </div>
34
+ );
35
+ };
@@ -0,0 +1,185 @@
1
+ import {Meta} from '@storybook/addon-docs/blocks';
2
+
3
+ import {Toast} from '@workday/canvas-kit-labs-react/toast';
4
+ import Basic from './examples/Basic';
5
+ import ToastAlert from './examples/ToastAlert';
6
+ import WithCloseButton from './examples/WithCloseButton';
7
+ import ToastDialog from './examples/ToastDialog';
8
+ import WithActionLinkAndCloseIcon from './examples/WithActionLinkAndCloseIcon';
9
+ import WithPopper from './examples/WithPopper';
10
+ import RTL from './examples/RTL';
11
+
12
+
13
+ # Canvas Kit Toast
14
+
15
+ `Toast` is a [compound component](/getting-started/for-developers/resources/compound-components/)
16
+ that contains updates or messages about the status of an application's process.
17
+
18
+ ## Installation
19
+
20
+ ```sh
21
+ yarn add @workday/canvas-kit-labs-react
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ ### Basic Example
27
+
28
+ `Toast` includes a container `Toast` component and the following subcomponents: `Toast.Body`,
29
+ `Toast.CloseIcon`, `Toast.Icon`, `Toast.Message`, and `Toast.Link`.
30
+
31
+ `Toast` supports different modes through the `mode` prop: `status`, `alert`, and `dialog`. Each mode
32
+ conveys a different purpose of the message and assigns the necessary ARIA attributes to support that
33
+ purpose and provide an accessible experience.
34
+
35
+ By default, `mode` is set to `status`, which indicates the message contains advisory information
36
+ such as a successful action.
37
+
38
+ <ExampleCodeBlock code={Basic} />
39
+
40
+ A `status` `Toast` will wrap the message within a `polite` ARIA live region with a `role` of
41
+ `status`.
42
+
43
+ Here's a more complete example with a button which triggers a dismissable `Toast`. The `Toast` is
44
+ positioned using `Popper`.
45
+
46
+ <ExampleCodeBlock code={WithPopper} />
47
+
48
+ ### Alert
49
+
50
+ Set the `mode` prop to `alert` to convey urgent and important information such as an error.
51
+
52
+ <ExampleCodeBlock code={ToastAlert} />
53
+
54
+ An `alert` `Toast` will wrap the message within an `assertive` ARIA live region with a `role` of
55
+ `alert`.
56
+
57
+ ### Dialog
58
+
59
+ Set the `mode` prop to `dialog` to convey the presence of a follow-up action.
60
+
61
+ <ExampleCodeBlock code={ToastDialog} />
62
+
63
+ The `Toast` will be given a role of `dialog` along with an `aria-label` to indicate that it's a
64
+ notification.
65
+
66
+ > **Note**: You must use the `Toast.Message` subcomponent when the `mode` is `dialog` so that `id`
67
+ > is tied to the message for accessibility. You can also pass in a `model` with `useToastModel` to
68
+ > provide a specific `id` for the `Toast.Message`:
69
+
70
+ ```tsx
71
+ export const CustomIDToast = () => {
72
+ const model = useToastModel({
73
+ id: '12df5',
74
+ mode: 'dialog',
75
+ });
76
+ return (
77
+ <Toast model={model}>
78
+ <Toast.Icon icon={checkIcon} color={colors.greenApple400} />
79
+ <Toast.Body>
80
+ <Toast.Message>Your workbook was successfully processed.</Toast.Message>
81
+ <Toast.Link href="#href">View More Details</Toast.Link>
82
+ </Toast.Body>
83
+ </Toast>
84
+ );
85
+ };
86
+ ```
87
+
88
+ ### Close Icon Button
89
+
90
+ Include the `Toast.CloseIcon` subcomponent to display a close button within the Toast.
91
+
92
+ <ExampleCodeBlock code={WithCloseButton} />
93
+
94
+ `Toast.CloseIcon` may be included within a `dialog` `Toast` to create a `Toast` with both an action
95
+ link and a close button.
96
+
97
+ <ExampleCodeBlock code={WithActionLinkAndCloseIcon} />
98
+
99
+ ### Right-to-Left (RTL)
100
+
101
+ `Toast` supports right-to-left languages when specified in the `CanvasProvider` `theme`.
102
+
103
+ <ExampleCodeBlock code={RTL} />
104
+
105
+ ## Components
106
+
107
+ ### Toast
108
+
109
+ #### Usage
110
+
111
+ `Toast` defines a container for all `Toast` subcomponents. `Toast` will render with the appropriate
112
+ ARIA attributes based on which `mode` is selected. It also accepts a `model` if you wish to provide
113
+ a specific `id`.
114
+
115
+ `Toast` renders a `Popup.Card` under the hood.
116
+
117
+ #### Props
118
+
119
+ <ArgsTable of={Toast} />
120
+
121
+ ### Toast.Body
122
+
123
+ #### Usage
124
+
125
+ `Toast.Body` defines a container for the contents of the `Toast`, including `Toast.Message` and
126
+ `Toast.Link`.
127
+
128
+ `Toast.Body` renders a `Popup.Body` under the hood.
129
+
130
+ #### Props
131
+
132
+ <ArgsTable of={Toast.Body} />
133
+
134
+ ### Toast.Icon
135
+
136
+ #### Usage
137
+
138
+ `Toast.Icon` renders a decorative icon for the `Toast`. When using `Toast.Icon`, be sure to set a
139
+ complementary `mode` to the `Toast`. For example, if the icon conveys an error, set the `mode` to
140
+ `alert`.
141
+
142
+ `Toast.Icon` renders a `SystemIcon` under the hood.
143
+
144
+ #### Props
145
+
146
+ <ArgsTable of={Toast.Icon} />
147
+
148
+ ### Toast.Message
149
+
150
+ #### Usage
151
+
152
+ `Toast.Message` defines a container for the message of the `Toast`. It accepts any `React.ReactNode`
153
+ as its children. `Toast.Message` is assigned a unique `id` so that it may be read aloud by screen
154
+ readers when the `Toast` `mode` is set to `dialog`.
155
+
156
+ `Toast.Message` renders a `Box` under the hood.
157
+
158
+ #### Props
159
+
160
+ <ArgsTable of={Toast.Message} />
161
+
162
+ ### Toast.Link
163
+
164
+ #### Usage
165
+
166
+ Use `Toast.Link` to provide an action in the `Toast`. `Toast.Link` should always be used in
167
+ conjunction with `dialog` `mode` to provide an accessible experience.
168
+
169
+ `Toast.Link` renders a `Hyperlink` under the hood.
170
+
171
+ #### Props
172
+
173
+ <ArgsTable of={Toast.Link} />
174
+
175
+ ### Toast.CloseIcon
176
+
177
+ #### Usage
178
+
179
+ Use `Toast.CloseIcon` to provide a close button to dismiss the `Toast`.
180
+
181
+ `Toast.Link` renders a `Popup.CloseIcon` under the hood.
182
+
183
+ #### Props
184
+
185
+ <ArgsTable of={Toast.CloseIcon} />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "7.3.0-next.1+c96313b9",
3
+ "version": "7.3.0",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -42,7 +42,7 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@storybook/csf": "0.0.1",
45
- "@workday/canvas-kit-react": "^7.3.0-next.1+c96313b9"
45
+ "@workday/canvas-kit-react": "^7.3.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "fs-extra": "^10.0.0",
@@ -50,5 +50,5 @@
50
50
  "mkdirp": "^1.0.3",
51
51
  "typescript": "4.1"
52
52
  },
53
- "gitHead": "c96313b967a2e828d395426fd103f1ab2b9781f7"
53
+ "gitHead": "ea5edda9b7a9f66cf7238bfdc1de77ad822db7b2"
54
54
  }