@workday/canvas-kit-docs 7.2.11 → 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.
@@ -1225,6 +1225,68 @@ module.exports = {specifications: [
1225
1225
  }
1226
1226
  ]
1227
1227
  },
1228
+ {
1229
+ "type": "file",
1230
+ "name": "ExpandableContainer.spec.ts",
1231
+ "children": [
1232
+ {
1233
+ "type": "describe",
1234
+ "name": "ExpandableContainer",
1235
+ "children": [
1236
+ {
1237
+ "type": "describe",
1238
+ "name": "given the [Labs/Expandable/React, Long Title] story is rendered",
1239
+ "children": [
1240
+ {
1241
+ "type": "it",
1242
+ "name": "should pass axe checks"
1243
+ },
1244
+ {
1245
+ "type": "it",
1246
+ "name": "should have aria-expanded set to false"
1247
+ },
1248
+ {
1249
+ "type": "it",
1250
+ "name": "should not show expanded content"
1251
+ },
1252
+ {
1253
+ "type": "describe",
1254
+ "name": "when the container is clicked",
1255
+ "children": [
1256
+ {
1257
+ "type": "it",
1258
+ "name": "should set aria-expanded to true"
1259
+ },
1260
+ {
1261
+ "type": "it",
1262
+ "name": "should show expanded content"
1263
+ },
1264
+ {
1265
+ "type": "it",
1266
+ "name": "should have an aria-controls attribute pointing to the id of content"
1267
+ },
1268
+ {
1269
+ "type": "describe",
1270
+ "name": "when the container is clicked again",
1271
+ "children": [
1272
+ {
1273
+ "type": "it",
1274
+ "name": "should hide expanded content"
1275
+ },
1276
+ {
1277
+ "type": "it",
1278
+ "name": "should have aria-expanded set to false"
1279
+ }
1280
+ ]
1281
+ }
1282
+ ]
1283
+ }
1284
+ ]
1285
+ }
1286
+ ]
1287
+ }
1288
+ ]
1289
+ },
1228
1290
  {
1229
1291
  "type": "file",
1230
1292
  "name": "FormField.spec.ts",
@@ -6110,6 +6172,102 @@ module.exports = {specifications: [
6110
6172
  }
6111
6173
  ]
6112
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
+ },
6113
6271
  {
6114
6272
  "type": "file",
6115
6273
  "name": "Tooltip.spec.ts",
@@ -1225,6 +1225,68 @@ module.exports = {specifications: [
1225
1225
  }
1226
1226
  ]
1227
1227
  },
1228
+ {
1229
+ "type": "file",
1230
+ "name": "ExpandableContainer.spec.ts",
1231
+ "children": [
1232
+ {
1233
+ "type": "describe",
1234
+ "name": "ExpandableContainer",
1235
+ "children": [
1236
+ {
1237
+ "type": "describe",
1238
+ "name": "given the [Labs/Expandable/React, Long Title] story is rendered",
1239
+ "children": [
1240
+ {
1241
+ "type": "it",
1242
+ "name": "should pass axe checks"
1243
+ },
1244
+ {
1245
+ "type": "it",
1246
+ "name": "should have aria-expanded set to false"
1247
+ },
1248
+ {
1249
+ "type": "it",
1250
+ "name": "should not show expanded content"
1251
+ },
1252
+ {
1253
+ "type": "describe",
1254
+ "name": "when the container is clicked",
1255
+ "children": [
1256
+ {
1257
+ "type": "it",
1258
+ "name": "should set aria-expanded to true"
1259
+ },
1260
+ {
1261
+ "type": "it",
1262
+ "name": "should show expanded content"
1263
+ },
1264
+ {
1265
+ "type": "it",
1266
+ "name": "should have an aria-controls attribute pointing to the id of content"
1267
+ },
1268
+ {
1269
+ "type": "describe",
1270
+ "name": "when the container is clicked again",
1271
+ "children": [
1272
+ {
1273
+ "type": "it",
1274
+ "name": "should hide expanded content"
1275
+ },
1276
+ {
1277
+ "type": "it",
1278
+ "name": "should have aria-expanded set to false"
1279
+ }
1280
+ ]
1281
+ }
1282
+ ]
1283
+ }
1284
+ ]
1285
+ }
1286
+ ]
1287
+ }
1288
+ ]
1289
+ },
1228
1290
  {
1229
1291
  "type": "file",
1230
1292
  "name": "FormField.spec.ts",
@@ -6110,6 +6172,102 @@ module.exports = {specifications: [
6110
6172
  }
6111
6173
  ]
6112
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
+ },
6113
6271
  {
6114
6272
  "type": "file",
6115
6273
  "name": "Tooltip.spec.ts",
@@ -0,0 +1,152 @@
1
+ import {Specifications} from '@workday/canvas-kit-docs';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+
5
+ import StartIcon from './examples/StartIcon';
6
+ import EndIcon from './examples/EndIcon';
7
+ import Avatar from './examples/Avatar';
8
+ import Depth from './examples/Depth';
9
+ import RTL from './examples/RTL';
10
+ import LongTitle from './examples/LongTitle';
11
+
12
+
13
+ # Canvas Kit Expandable
14
+
15
+ `Expandable` is a compound component that creates a header to expand or collapse related content.
16
+
17
+ ## Installation
18
+
19
+ ```sh
20
+ yarn add @workday/canvas-kit-labs-react
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ### Start Icon
26
+
27
+ For a basic expandable container with a chevron icon before the title, place`Expandable.Icon`
28
+ before `Expandable.Title` as children of `Expandable.Target` and pass the `iconPosition` prop to
29
+ `Expandable.Icon` with a value of `start`. `Expandable.Icon` will use a right chevron icon
30
+ when collapsed and a down chevron icon when expanded.
31
+
32
+ <ExampleCodeBlock code={StartIcon} />
33
+
34
+ ### End Icon
35
+
36
+ For an expandable container with a chevron icon after the title, place `Expandable.Title`
37
+ before `Expandable.Icon` as children of `Expandable.Target` and pass the `iconPosition` prop to
38
+ `Expandable.Icon` with a value of `end`. `Expandable.Icon` will use a down chevron icon
39
+ when collapsed and an up chevron icon when expanded.
40
+
41
+ <ExampleCodeBlock code={EndIcon} />
42
+
43
+ ### With Avatar
44
+
45
+ To include an avatar image, `Expandable.Avatar` should be placed between `Expandable.Icon` and
46
+ `Expandable.Title`. An `iconPosition` prop with a value of either `start` or `end` should be
47
+ passed to `Expandable.Icon` depending on whether the `Expandable.Icon` is placed before or after
48
+ `Expandable.Title`.
49
+
50
+ <ExampleCodeBlock code={Avatar} />
51
+
52
+ ### Right to Left (RTL)
53
+
54
+ Expandable container has bidirectional support and should function as expected with RTL languages
55
+ as long as the content direction is set in your Canvas theme.
56
+
57
+ <ExampleCodeBlock code={RTL} />
58
+
59
+ ### Depth
60
+
61
+ The `depth` prop passed to `Expandable` allows you to adjust the visual elevation of a component
62
+ using our depth tokens.
63
+
64
+ <ExampleCodeBlock code={Depth} />
65
+
66
+ ### Title Wrap
67
+
68
+ Long titles will wrap to the next line and increase the height of the container.
69
+
70
+ <ExampleCodeBlock code={LongTitle} />
71
+
72
+ ## Components
73
+
74
+ ### Expandable
75
+
76
+ #### Usage
77
+
78
+ `Expandable` wraps an `Expandable.Target` and an `Expandable.Content`. By default, it provides a
79
+ `DisclosureModel` for its sub components. Alternatively, a model may be passed in using the hoisted
80
+ model pattern.
81
+
82
+ #### Props
83
+
84
+ <!-- <ArgsTable of={Expandable} /> -->
85
+
86
+ ### Expandable.Target
87
+
88
+ #### Usage
89
+
90
+ `Expandable.Target` creates a heading and a button. The heading is a semantic heading to describe
91
+ the associated content. The button provides users the ability to toggle the associated content.
92
+
93
+ As according to the
94
+ [W3 disclosure specification](https://www.w3.org/TR/wai-aria-practices-1.1/#disclosure), the button
95
+ has `aria-expanded` and `aria-controls` attributes set by default
96
+
97
+ This component should hold an `Expandable.Icon`, an optional `Expandable.Avatar`, and an
98
+ `Expandable.Title`.
99
+
100
+ #### Props
101
+
102
+ `headingLevel` is the only prop spread to the underlying heading. All other props are spread to the
103
+ button.
104
+
105
+ <!-- <ArgsTable of={Expandable.Target} /> -->
106
+
107
+ ### Expandable.Title
108
+
109
+ #### Usage
110
+
111
+ `Expandable.Title` styles the target text that describes the content.
112
+
113
+ #### Props
114
+
115
+ <!-- <ArgsTable of={Expandable.Title} /> -->
116
+
117
+ ### Expandable.Icon
118
+
119
+ #### Usage
120
+
121
+ `Expandable.Icon` creates an icon to visually indicate the state of the content. It takes an
122
+ `iconPosition` prop to determine which chevron icon to use.
123
+
124
+ #### Props
125
+
126
+ `iconPosition` takes a value of either `start` or `end`. If no value is provided, it will default to
127
+ `start`. Given a value of `start` it will use a chevron that points down when the container is
128
+ expanded and right when the container is collapsed. Given a value of `end`, it will use a chevron
129
+ that points up when the container is expanded and down when the container is collapsed.
130
+
131
+ <!-- <ArgsTable of={Expandable.Icon} /> -->
132
+
133
+ ### Expandable.Avatar
134
+
135
+ #### Usage
136
+
137
+ `Expandable.Avatar` is an optional component that creates an `Avatar` to display a decorative image.
138
+
139
+ #### Props
140
+
141
+ <!-- <ArgsTable of={Expandable.Avatar} /> -->
142
+
143
+ ### Expandable.Content
144
+
145
+ #### Usage
146
+
147
+ `Expandable.Content` holds the content that will be conditionally expanded and collapsed. It has an
148
+ `id` to ensure the `Expandable.Target` properly set it to the `aria-controls` attribute.
149
+
150
+ #### Props
151
+
152
+ <!-- <ArgsTable of={Expandable.Content} /> -->
@@ -0,0 +1,28 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+ // @ts-ignore: Cannot find module error
5
+ import testAvatar from './test-avatar.png';
6
+
7
+ export default () => (
8
+ <>
9
+ <Expandable>
10
+ <Expandable.Target headingLevel="h4">
11
+ <Expandable.Icon iconPosition="start" />
12
+ <Expandable.Avatar url={testAvatar} />
13
+ <Expandable.Title>Title</Expandable.Title>
14
+ </Expandable.Target>
15
+
16
+ <Expandable.Content>Content</Expandable.Content>
17
+ </Expandable>
18
+ <Expandable>
19
+ <Expandable.Target headingLevel="h4">
20
+ <Expandable.Avatar url={testAvatar} />
21
+ <Expandable.Title>Title</Expandable.Title>
22
+ <Expandable.Icon iconPosition="end" />
23
+ </Expandable.Target>
24
+
25
+ <Expandable.Content>Content</Expandable.Content>
26
+ </Expandable>
27
+ </>
28
+ );
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+ import {space} from '@workday/canvas-kit-react/tokens';
5
+
6
+ export default () => {
7
+ return (
8
+ <Expandable borderRadius="l" depth={3} margin="xxxs" padding="xs">
9
+ <Expandable.Target headingLevel="h4">
10
+ <Expandable.Title>Additional Information</Expandable.Title>
11
+ <Expandable.Icon iconPosition="end" />
12
+ </Expandable.Target>
13
+
14
+ <Expandable.Content>This Expandable Container has a depth of 3.</Expandable.Content>
15
+ </Expandable>
16
+ );
17
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+
5
+ export default () => (
6
+ <Expandable>
7
+ <Expandable.Target headingLevel="h4">
8
+ <Expandable.Title>Title</Expandable.Title>
9
+ <Expandable.Icon iconPosition="end" />
10
+ </Expandable.Target>
11
+
12
+ <Expandable.Content>Content</Expandable.Content>
13
+ </Expandable>
14
+ );
@@ -0,0 +1,20 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+ // @ts-ignore: Cannot find module error
5
+ import testAvatar from './test-avatar.png';
6
+
7
+ export default () => (
8
+ <Expandable>
9
+ <Expandable.Target aria-label="expand container" headingLevel="h4">
10
+ <Expandable.Icon iconPosition="start" />
11
+ <Expandable.Avatar url={testAvatar} />
12
+ <Expandable.Title>
13
+ Our house special supreme pizza includes pepperoni, sausage, bell peppers, mushrooms,
14
+ onions, and oregano.
15
+ </Expandable.Title>
16
+ </Expandable.Target>
17
+
18
+ <Expandable.Content>Content</Expandable.Content>
19
+ </Expandable>
20
+ );
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+ import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';
5
+
6
+ export default () => {
7
+ const theme = {
8
+ canvas: {
9
+ direction: ContentDirection.RTL,
10
+ },
11
+ };
12
+ return (
13
+ <CanvasProvider theme={theme}>
14
+ <Expandable>
15
+ <Expandable.Target headingLevel="h4">
16
+ <Expandable.Icon iconPosition="start" />
17
+ <Expandable.Avatar />
18
+ <Expandable.Title>Title</Expandable.Title>
19
+ </Expandable.Target>
20
+
21
+ <Expandable.Content>Content</Expandable.Content>
22
+ </Expandable>
23
+ <Expandable>
24
+ <Expandable.Target headingLevel="h4">
25
+ <Expandable.Avatar />
26
+ <Expandable.Title>Title</Expandable.Title>
27
+ <Expandable.Icon iconPosition="end" />
28
+ </Expandable.Target>
29
+
30
+ <Expandable.Content>Content</Expandable.Content>
31
+ </Expandable>
32
+ </CanvasProvider>
33
+ );
34
+ };
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+
3
+ import {Expandable} from '@workday/canvas-kit-labs-react/expandable';
4
+
5
+ export default () => (
6
+ <Expandable>
7
+ <Expandable.Target headingLevel="h4">
8
+ <Expandable.Icon iconPosition="start" />
9
+ <Expandable.Title>Title</Expandable.Title>
10
+ </Expandable.Target>
11
+
12
+ <Expandable.Content>Content</Expandable.Content>
13
+ </Expandable>
14
+ );
@@ -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.2.11",
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.2.11"
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": "359ab1ae25e3397a5293f11d40b3abf517919db4"
53
+ "gitHead": "ea5edda9b7a9f66cf7238bfdc1de77ad822db7b2"
54
54
  }