@workday/canvas-kit-docs 11.0.0-alpha.767-next.0 → 11.0.0-alpha.770-next.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.
@@ -18,8 +18,8 @@ any questions.
18
18
  - [Text Area (Preview)](#text-area-preview)
19
19
  - [Text Input (Preview)](#text-input-preview)
20
20
  - [Component Style Updates](#component-style-updates)
21
- - [Component Token Updates](#component-token-updates)
22
21
  - [Component Updates](#component-updates)
22
+ - [Buttons](#buttons)
23
23
  - [Card](#card)
24
24
  - [Checkbox](#checkbox)
25
25
  - [Combobox](#combobox)
@@ -241,14 +241,6 @@ See below:
241
241
  </Table.Row>
242
242
  </Table.Head>
243
243
  <Table.Body>
244
- <Table.Row>
245
- <Table.Cell>Table (Header)</Table.Cell>
246
- <Table.Cell />
247
- <Table.Cell />
248
- <Table.Cell>borderColor</Table.Cell>
249
- <Table.Cell backgroundColor="soap400">soap400</Table.Cell>
250
- <Table.Cell backgroundColor="soap500">soap500</Table.Cell>
251
- </Table.Row>
252
244
  <Table.Row>
253
245
  <Table.Cell>Checkbox</Table.Cell>
254
246
  <Table.Cell />
@@ -268,6 +260,22 @@ See below:
268
260
  <Table.Cell color="frenchVanilla100" backgroundColor="licorice100">
269
261
  licorice100
270
262
  </Table.Cell>
263
+ </Table.Row>
264
+ <Table.Row>
265
+ <Table.Cell>DeleteButton</Table.Cell>
266
+ <Table.Cell />
267
+ <Table.Cell>disabled</Table.Cell>
268
+ <Table.Cell>backgroundColor</Table.Cell>
269
+ <Table.Cell backgroundColor={cssVar(brand.error.light)}>error.light</Table.Cell>
270
+ <Table.Cell backgroundColor="rgba(222,46,33,0.4)">error.base</Table.Cell>
271
+ </Table.Row>
272
+ <Table.Row>
273
+ <Table.Cell>DeleteButton</Table.Cell>
274
+ <Table.Cell />
275
+ <Table.Cell>disabled</Table.Cell>
276
+ <Table.Cell>opacity</Table.Cell>
277
+ <Table.Cell>1</Table.Cell>
278
+ <Table.Cell>0.4</Table.Cell>
271
279
  </Table.Row>
272
280
  <Table.Row>
273
281
  <Table.Cell>Radio</Table.Cell>
@@ -283,7 +291,19 @@ See below:
283
291
  <Table.Cell>SecondaryButton</Table.Cell>
284
292
  <Table.Cell>Inverse</Table.Cell>
285
293
  <Table.Cell>focus</Table.Cell>
286
- <Table.Cell>color</Table.Cell>
294
+ <Table.Cell>border</Table.Cell>
295
+ <Table.Cell color="blackPepper400" backgroundColor="soap400">
296
+ soap400
297
+ </Table.Cell>
298
+ <Table.Cell color="blackPepper400" backgroundColor="transparent">
299
+ transparent
300
+ </Table.Cell>
301
+ </Table.Row>
302
+ <Table.Row>
303
+ <Table.Cell>SecondaryButton</Table.Cell>
304
+ <Table.Cell>Inverse</Table.Cell>
305
+ <Table.Cell>focus</Table.Cell>
306
+ <Table.Cell>boxShdaow (Inner Color)</Table.Cell>
287
307
  <Table.Cell color="frenchVanilla100" backgroundColor="blackPepper500">
288
308
  blackPepper500
289
309
  </Table.Cell>
@@ -295,7 +315,7 @@ See below:
295
315
  <Table.Cell>SecondaryButton</Table.Cell>
296
316
  <Table.Cell>Inverse</Table.Cell>
297
317
  <Table.Cell>focus</Table.Cell>
298
- <Table.Cell>boxShdaow (Inner Color)</Table.Cell>
318
+ <Table.Cell>color</Table.Cell>
299
319
  <Table.Cell color="frenchVanilla100" backgroundColor="blackPepper500">
300
320
  blackPepper500
301
321
  </Table.Cell>
@@ -315,6 +335,14 @@ See below:
315
335
  blackPepper400
316
336
  </Table.Cell>
317
337
  </Table.Row>
338
+ <Table.Row>
339
+ <Table.Cell>Table (Header)</Table.Cell>
340
+ <Table.Cell />
341
+ <Table.Cell />
342
+ <Table.Cell>borderColor</Table.Cell>
343
+ <Table.Cell backgroundColor="soap400">soap400</Table.Cell>
344
+ <Table.Cell backgroundColor="soap500">soap500</Table.Cell>
345
+ </Table.Row>
318
346
  <Table.Row>
319
347
  <Table.Cell>TertiaryButton</Table.Cell>
320
348
  <Table.Cell />
@@ -376,23 +404,7 @@ See below:
376
404
  </Table.Cell>
377
405
  </Table.Row>
378
406
  <Table.Row>
379
- <Table.Cell>DeleteButton</Table.Cell>
380
- <Table.Cell />
381
- <Table.Cell>disabled</Table.Cell>
382
- <Table.Cell>backgroundColor</Table.Cell>
383
- <Table.Cell backgroundColor={cssVar(brand.error.light)}>error.light</Table.Cell>
384
- <Table.Cell backgroundColor="rgba(222,46,33,0.4)">error.base</Table.Cell>
385
- </Table.Row>
386
- <Table.Row>
387
- <Table.Cell>DeleteButton</Table.Cell>
388
- <Table.Cell />
389
- <Table.Cell>disabled</Table.Cell>
390
- <Table.Cell>opacity</Table.Cell>
391
- <Table.Cell>1</Table.Cell>
392
- <Table.Cell>0.4</Table.Cell>
393
- </Table.Row>
394
- <Table.Row>
395
- <Table.Cell>TextInput</Table.Cell>
407
+ <Table.Cell>TextArea</Table.Cell>
396
408
  <Table.Cell />
397
409
  <Table.Cell>disabled</Table.Cell>
398
410
  <Table.Cell>borderColor</Table.Cell>
@@ -402,7 +414,7 @@ See below:
402
414
  </Table.Cell>
403
415
  </Table.Row>
404
416
  <Table.Row>
405
- <Table.Cell>TextArea</Table.Cell>
417
+ <Table.Cell>TextInput</Table.Cell>
406
418
  <Table.Cell />
407
419
  <Table.Cell>disabled</Table.Cell>
408
420
  <Table.Cell>borderColor</Table.Cell>
@@ -414,13 +426,19 @@ See below:
414
426
  </Table.Body>
415
427
  </Table>
416
428
 
417
- ### Component Token Updates
429
+ ## Component Updates
430
+
431
+ ### Buttons
418
432
 
419
- The following components have been updated to use our [new system tokens](insert link).
433
+ **PR:** [#2666](https://github.com/Workday/canvas-kit/pull/2666)
420
434
 
421
- - Text
435
+ `PrimaryButton`, `SecondaryButton`, `TertiaryButton` and `DeleteButton` have been refactored to use our
436
+ [new styling utilities](https://workday.github.io/canvas-kit/?path=/docs/styling-basics--create-modifiers#createstyles-api)
437
+ and [tokens](https://workday.github.io/canvas-tokens/?path=/docs/docs-getting-started--docs). The
438
+ components now support the `cs` prop, but otherwise the API has not changed.
422
439
 
423
- ## Component Updates
440
+ > #### Visual Breaking Change
441
+ > The `border` color for `SecondaryButton` on the `focus` state is now `transparent` and may cause a small visual difference in visual tests.
424
442
 
425
443
  ### Card
426
444
 
@@ -808,4 +826,5 @@ experimental code and is analagous to code in alpha.
808
826
 
809
827
  Breaking changes can be deployed to Labs at any time without triggering a major version update and
810
828
  may not be subject to the same rigor in communcation and migration strategies reserved for breaking
811
- changes in [Preview](#preview) and [Main](#main).
829
+ changes in [Preview](#preview) and [Main](#main).
830
+ import { opacity } from "@workday/canvas-tokens-web/dist/es6/system"
@@ -0,0 +1,75 @@
1
+ import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
2
+ import FilterListWithLiveStatus from './examples/common/FilterListWithLiveStatus';
3
+ import VisibleLiveRegion from './examples/common/VisibleLiveRegion';
4
+ import HiddenLiveRegion from './examples/common/HiddenLiveRegion';
5
+ import TextInputWithLiveError from './examples/common/TextInputWithLiveError';
6
+ import IconButtonsWithLiveBadges from './examples/common/IconButtonsWithLiveBadges';
7
+
8
+
9
+ # ARIA Live Regions
10
+
11
+ These examples are provided to demonstrate a variety of different use cases for the `AriaLiveRegion`
12
+ component. For the full experience, get started by first turning on your favorite screen reading
13
+ software. On Windows, we recommend the open source
14
+ [NVDA (Non-Visual Desktop Access)](https://www.nvaccess.org/download/) software, or
15
+ [JAWS (Job Access With Speech)](https://support.freedomscientific.com/Downloads/JAWS) if you have
16
+ purchased a license. MacOS and iOS include VoiceOver, which can be turned on in your settings.
17
+
18
+ Live regions work by designating specific DOM nodes for screen readers to monitor for any content
19
+ updates inside the node. When an update occurs, screen readers will announce the update to users in
20
+ real time, based on a few rules:
21
+
22
+ 1. `polite` will “politely” wait for users to finish what they are doing before announcing an update
23
+ 2. `assertive` will interrupt what users are doing (or reading) by immediately announcing an update
24
+
25
+ ### CAUTION: Don't get carried away
26
+
27
+ Key things to understand about live regions:
28
+
29
+ 1. A live region update will only be announced once. Users are unable to repeat them or re-examine
30
+ them if the announcement was not understood.
31
+ 2. Users may be able to pause a live region announcement, but they cannot prevent a live region
32
+ announcement from occurring. Sending frequent, repetitive, or simply too much information to a
33
+ live region can be very disruptive to users.
34
+ 3. Users cannot act on, or navigate to, a live region. Live regions must only contain plain text.
35
+ (No images, links, buttons, or other input.)
36
+ 4. Support for live regions is limited across platforms, browsers, and screen reader software. Real
37
+ time announcements may not be perfectly reliable.
38
+
39
+ ## Visible Live Regions
40
+
41
+ Live regions can be applied to dynamic text on the UI. When the dynamic text is updated, screen
42
+ readers can describe the text update in live time as it occurs. In the example below, type text into
43
+ the input field and activate the "Send Message" button. Listen and observe the screen reader
44
+ automatically announce the text update.
45
+
46
+ <ExampleCodeBlock code={VisibleLiveRegion} />
47
+
48
+ ## Hidden Live Regions
49
+
50
+ Live regions don't need to be visible UI text, they can be used to assist the non-visual listening
51
+ experience when moving the keyboard focus to a new element on screen isn't feasible.
52
+
53
+ <ExampleCodeBlock code={HiddenLiveRegion} />
54
+
55
+ ## Filtering lists with a live status
56
+
57
+ In this example, a live region is applied to a short UI text describing the number of items shown in
58
+ the list. As you type characters into the input, listen for the screen reader to automatically
59
+ describe how many items in the list or shown.
60
+
61
+ <ExampleCodeBlock code={FilterListWithLiveStatus} />
62
+
63
+ ## Text input with live inline error
64
+
65
+ In this example, a live region is applied to the inline error message that will appear below the
66
+ text input. Listen for the screen reader to automatically describe the error message as you leave
67
+ the input field blank.
68
+
69
+ **Note:** Use this example with discretion. Using live regions for automatically announcing form
70
+ errors to screen reader users can be a nice experience for simple forms with a very limited number
71
+ of error conditions. As forms increase in complexity, live regions on each error message can become
72
+ increasingly distracting and disruptive to the experience, especially if users are trying to first
73
+ understand the information that is required of them to complete the task.
74
+
75
+ <ExampleCodeBlock code={TextInputWithLiveError} />
@@ -0,0 +1,65 @@
1
+ import React, {useState} from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
+ import {BodyText, Heading} from '@workday/canvas-kit-react/text';
4
+ import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
5
+ import {Flex} from '@workday/canvas-kit-react/layout';
6
+ import {system, base} from '@workday/canvas-tokens-web';
7
+ import {createStyles, px2rem} from '@workday/canvas-kit-styling';
8
+
9
+ const fruits = [
10
+ 'Apples',
11
+ 'Oranges',
12
+ 'Bananas',
13
+ 'Lemons',
14
+ 'Limes',
15
+ 'Strawberries',
16
+ 'Raspberries',
17
+ 'Blackberries',
18
+ ];
19
+
20
+ const liveRegionStyle = createStyles({
21
+ border: `${px2rem(1)} solid ${base.cantaloupe400}`,
22
+ backgroundColor: base.cantaloupe100,
23
+ padding: system.space.x2,
24
+ });
25
+
26
+ const listStyles = {paddingLeft: '0px'};
27
+
28
+ const listItemStyles = createStyles({
29
+ listStyle: 'none',
30
+ paddingLeft: system.space.zero,
31
+ });
32
+
33
+ let filteredFruits = fruits;
34
+
35
+ export default () => {
36
+ const [filter, setFilter] = useState('');
37
+ function handleFilter(e) {
38
+ filteredFruits = fruits.filter(i => i.toUpperCase().indexOf(e.target.value.toUpperCase()) >= 0);
39
+ setFilter(e.target.value);
40
+ }
41
+
42
+ return (
43
+ <>
44
+ <Flex gap="1rem">
45
+ <Heading size="small">Fruits</Heading>
46
+ <AriaLiveRegion>
47
+ <BodyText size="small" cs={liveRegionStyle}>
48
+ {`Showing ${filteredFruits.length} of ${fruits.length}`}
49
+ </BodyText>
50
+ </AriaLiveRegion>
51
+ </Flex>
52
+ <TextInput orientation="vertical">
53
+ <TextInput.Label>Filter Items:</TextInput.Label>
54
+ <TextInput.Field value={filter} onChange={handleFilter} />
55
+ </TextInput>
56
+ <ul style={listStyles}>
57
+ {filteredFruits.map(i => (
58
+ <BodyText size="small" as="li" cs={listItemStyles} key={i}>
59
+ {i}
60
+ </BodyText>
61
+ ))}
62
+ </ul>
63
+ </>
64
+ );
65
+ };
@@ -0,0 +1,30 @@
1
+ import React, {useState, useRef} from 'react';
2
+ import {AriaLiveRegion, AccessibleHide} from '@workday/canvas-kit-react/common';
3
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
4
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
5
+ import {Flex} from '@workday/canvas-kit-react/layout';
6
+ import {system} from '@workday/canvas-tokens-web';
7
+
8
+ export default () => {
9
+ const [message, setMessage] = useState('This is an ARIA Live Region!');
10
+ const inputRef = useRef();
11
+ function handleSendMessage() {
12
+ setMessage(inputRef.current.value);
13
+ inputRef.current.value = '';
14
+ }
15
+
16
+ return (
17
+ <>
18
+ <Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
19
+ <TextInput orientation="vertical">
20
+ <TextInput.Label>Type your message:</TextInput.Label>
21
+ <TextInput.Field ref={inputRef} />
22
+ </TextInput>
23
+ <PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
24
+ </Flex>
25
+ <AriaLiveRegion>
26
+ <AccessibleHide>{message}</AccessibleHide>
27
+ </AriaLiveRegion>
28
+ </>
29
+ );
30
+ };
@@ -0,0 +1,98 @@
1
+ import React, {useState} from 'react';
2
+ import {AccessibleHide, AriaLiveRegion, useUniqueId} from '@workday/canvas-kit-react/common';
3
+ import {notificationsIcon, inboxIcon, assistantIcon} from '@workday/canvas-system-icons-web';
4
+ import {space} from '@workday/canvas-kit-react/tokens';
5
+ import {SecondaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
6
+ import {Flex} from '@workday/canvas-kit-react/layout';
7
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
8
+ import {CountBadge} from '@workday/canvas-kit-react/badge';
9
+
10
+ const MyTasksLiveBadge = ({cnt}) => {
11
+ // use tooltip to assign name,
12
+ // use AriaLiveRegion inside button,
13
+ // assign name to live region referencing the button,
14
+ // use BadgeCount inside live region,
15
+ // use AccessibleHide to create invisible word "new" after badge
16
+ // use aria-describedby on button, referencing live region container to set description
17
+ // Safari + VO => not working at all
18
+ // JAWS 2024 + Chrome / Edge => works as expected :)
19
+ // NVDA + Chrome / Edge => works as expected :)
20
+ // Firefox => isn't announcing description on focus, only announces "X New" live (missing button name)
21
+ const badgeID = useUniqueId();
22
+ const myTasksID = useUniqueId();
23
+
24
+ return (
25
+ <Tooltip title="My Tasks">
26
+ <TertiaryButton icon={inboxIcon} id={myTasksID} aria-describedby={badgeID}>
27
+ <AriaLiveRegion id={badgeID} aria-labelledby={myTasksID}>
28
+ <CountBadge count={cnt} />
29
+ <AccessibleHide>New</AccessibleHide>
30
+ </AriaLiveRegion>
31
+ </TertiaryButton>
32
+ </Tooltip>
33
+ );
34
+ };
35
+
36
+ // use AriaLiveRegion around the button,
37
+ // use Tooltip to assign the name of the button,
38
+ // make sure Tooltip title string includes count value
39
+ // Chrome + VO => Announces name "notifications X new" and innerText 'X'
40
+ // Safari + VO => Works as expected :)
41
+ // JAWS 2024 => Announces full button name twice (previous state, then new state)
42
+ // JAWS 2024 + Firefox => Works as expected :)
43
+ // NVDA (All Browsers) => Atomic property isn't working, only announcing number change, announces twice
44
+ const NotificationsLiveBadge = ({cnt}) => (
45
+ <AriaLiveRegion>
46
+ <Tooltip title={`Notifications ${cnt} new`}>
47
+ <TertiaryButton icon={notificationsIcon}>
48
+ <CountBadge count={cnt} />
49
+ </TertiaryButton>
50
+ </Tooltip>
51
+ </AriaLiveRegion>
52
+ );
53
+
54
+ const AssistantLiveBadge = ({cnt}) => {
55
+ // use AriaLiveRegion around the button
56
+ // use muted type Tooltip (avoid using aria-label to name button)
57
+ // use AccessibleHide inside of button to compose name
58
+ // Chrome + VO => announces twice
59
+ // Safari + VO => works as expected :)
60
+ const lbl = 'Workday Assistant';
61
+
62
+ return (
63
+ <AriaLiveRegion>
64
+ <Tooltip title={lbl} type="muted">
65
+ <TertiaryButton icon={assistantIcon}>
66
+ <AccessibleHide>{lbl}</AccessibleHide>
67
+ <CountBadge count={cnt} />
68
+ <AccessibleHide>New</AccessibleHide>
69
+ </TertiaryButton>
70
+ </Tooltip>
71
+ </AriaLiveRegion>
72
+ );
73
+ };
74
+
75
+ export default () => {
76
+ const [counter, setCounter] = useState(0);
77
+ const [notifications, setNotifications] = useState(0);
78
+ const [assistant, setAssistant] = useState(0);
79
+
80
+ const handleAddTask = () => setCounter(prev => prev + 1);
81
+ const handleAddNotification = () => setNotifications(prev => prev + 1);
82
+ const handleAssistant = () => setAssistant(prev => prev + 1);
83
+
84
+ return (
85
+ <>
86
+ <Flex padding={space.s} gap={space.s} as="header">
87
+ <AssistantLiveBadge cnt={assistant} />
88
+ <NotificationsLiveBadge cnt={notifications} />
89
+ <MyTasksLiveBadge cnt={counter} />
90
+ </Flex>
91
+ <Flex padding={space.s} gap={space.s} as="main">
92
+ <SecondaryButton onClick={handleAssistant}>Add a Message</SecondaryButton>
93
+ <SecondaryButton onClick={handleAddNotification}>Add a Notification</SecondaryButton>
94
+ <SecondaryButton onClick={handleAddTask}>Add an item to My Tasks</SecondaryButton>
95
+ </Flex>
96
+ </>
97
+ );
98
+ };
@@ -0,0 +1,25 @@
1
+ import React, {useState, useRef} from 'react';
2
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
3
+ import {AriaLiveRegion, changeFocus} from '@workday/canvas-kit-react/common';
4
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
5
+
6
+ export default () => {
7
+ const errMsg = 'Error: First name is required.';
8
+ const [hasError, setHasError] = useState(false);
9
+ const inputRef = useRef();
10
+ const handleBlur = e => setHasError(e.target.value.trim().length === 0);
11
+ const handleSubmit = () => hasError && changeFocus(inputRef.current);
12
+
13
+ return (
14
+ <>
15
+ <TextInput orientation="vertical" hasError={hasError} isRequired={true}>
16
+ <TextInput.Label>First Name:</TextInput.Label>
17
+ <TextInput.Field onBlur={handleBlur} ref={inputRef} />
18
+ <TextInput.Hint height={'16px'}>
19
+ <AriaLiveRegion>{hasError && errMsg}</AriaLiveRegion>
20
+ </TextInput.Hint>
21
+ </TextInput>
22
+ <PrimaryButton onClick={handleSubmit}>Continue</PrimaryButton>
23
+ </>
24
+ );
25
+ };
@@ -0,0 +1,40 @@
1
+ import React, {useState, useRef} from 'react';
2
+ import {AriaLiveRegion} from '@workday/canvas-kit-react/common';
3
+ import {PrimaryButton} from '@workday/canvas-kit-react/button';
4
+ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
5
+ import {Flex} from '@workday/canvas-kit-react/layout';
6
+ import {Text} from '@workday/canvas-kit-react/text';
7
+ import {system, base} from '@workday/canvas-tokens-web';
8
+ import {createStyles, px2rem} from '@workday/canvas-kit-styling';
9
+
10
+ const liveRegionStyle = createStyles({
11
+ border: `${px2rem(1)} solid ${base.cantaloupe400}`,
12
+ backgroundColor: base.cantaloupe100,
13
+ padding: system.space.x4,
14
+ display: 'block',
15
+ margin: system.space.x4 + ' 0',
16
+ });
17
+
18
+ export default () => {
19
+ const [message, setMessage] = useState('This is an ARIA Live Region!');
20
+ const inputRef = useRef();
21
+ function handleSendMessage() {
22
+ setMessage(inputRef.current.value);
23
+ inputRef.current.value = '';
24
+ }
25
+
26
+ return (
27
+ <>
28
+ <AriaLiveRegion>
29
+ <Text cs={liveRegionStyle}>{message}</Text>
30
+ </AriaLiveRegion>
31
+ <Flex gap={`var(${system.space.x4})`} alignItems="flex-end">
32
+ <TextInput orientation="vertical">
33
+ <TextInput.Label>Type your message:</TextInput.Label>
34
+ <TextInput.Field ref={inputRef} />
35
+ </TextInput>
36
+ <PrimaryButton onClick={handleSendMessage}>Send Message</PrimaryButton>
37
+ </Flex>
38
+ </>
39
+ );
40
+ };
@@ -28,7 +28,19 @@ yarn add @workday/canvas-kit-react
28
28
 
29
29
  <ExampleCodeBlock code={RTL} />
30
30
 
31
- ### Accessible Example
31
+ ### Adding screen reader support to loading animations
32
+
33
+ Sometimes, letting users know when content has finished loading is just as important as asking users
34
+ to "please wait" while content is loading. The disappearance of an animation is information that
35
+ might need description. In this example, we are using `AriaLiveRegion` and `AccessibleHide`
36
+ components included in Canvas to describe both the appearance and disappearance of `LoadingDots`.
37
+
38
+ - When idle, render an empty live region
39
+ - When loading, render `LoadingDots` inside the live region,
40
+ - When complete, render `AccessibleHide` inside the live region expressing "Complete!"
41
+ - We can assign a name to `AriaLiveRegion` component by passing in `aria-label="Loading"`
42
+ - We can declare `LoadingDots` a labeled graphic by passing `role="img"` and
43
+ `aria-label="Please wait..."` into the component
32
44
 
33
45
  <ExampleCodeBlock code={Accessible} />
34
46
 
@@ -1,6 +1,44 @@
1
1
  import React from 'react';
2
2
  import {LoadingDots} from '@workday/canvas-kit-react/loading-dots';
3
+ import {base, system} from '@workday/canvas-tokens-web';
4
+ import {Flex} from '@workday/canvas-kit-react/layout';
5
+ import {SecondaryButton} from '@workday/canvas-kit-react/button';
6
+ import {createStyles, cssVar} from '@workday/canvas-kit-styling';
7
+ import {AccessibleHide, AriaLiveRegion} from '@workday/canvas-kit-react/common';
8
+
9
+ const loadingStyles = createStyles({
10
+ backgroundColor: base.licorice300,
11
+ padding: system.space.x3,
12
+ });
3
13
 
4
14
  export default () => {
5
- return <LoadingDots aria-live="polite" aria-label="Loading Users" />;
15
+ const [loadingState, setLoadingState] = React.useState('idle');
16
+
17
+ React.useEffect(() => {
18
+ const timer = setTimeout(() => {
19
+ if (loadingState === 'loading') {
20
+ setLoadingState('success');
21
+ }
22
+ }, 4000);
23
+
24
+ return () => {
25
+ clearTimeout(timer);
26
+ };
27
+ }, [loadingState]);
28
+
29
+ const handleLoad = () => {
30
+ setLoadingState('loading');
31
+ };
32
+
33
+ return (
34
+ <Flex gap={cssVar(system.space.x4)}>
35
+ <SecondaryButton onClick={handleLoad}>Start</SecondaryButton>
36
+ <AriaLiveRegion aria-label="Loading">
37
+ {loadingState === 'loading' && (
38
+ <LoadingDots className={loadingStyles} role="img" aria-label="Please wait..." />
39
+ )}
40
+ {loadingState === 'success' && <AccessibleHide>Complete.</AccessibleHide>}
41
+ </AriaLiveRegion>
42
+ </Flex>
43
+ );
6
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "11.0.0-alpha.767-next.0",
3
+ "version": "11.0.0-alpha.770-next.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",
@@ -44,10 +44,10 @@
44
44
  "dependencies": {
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@storybook/csf": "0.0.1",
47
- "@workday/canvas-kit-labs-react": "^11.0.0-alpha.767-next.0",
48
- "@workday/canvas-kit-preview-react": "^11.0.0-alpha.767-next.0",
49
- "@workday/canvas-kit-react": "^11.0.0-alpha.767-next.0",
50
- "@workday/canvas-kit-styling": "^11.0.0-alpha.767-next.0",
47
+ "@workday/canvas-kit-labs-react": "^11.0.0-alpha.770-next.0",
48
+ "@workday/canvas-kit-preview-react": "^11.0.0-alpha.770-next.0",
49
+ "@workday/canvas-kit-react": "^11.0.0-alpha.770-next.0",
50
+ "@workday/canvas-kit-styling": "^11.0.0-alpha.770-next.0",
51
51
  "@workday/canvas-system-icons-web": "^3.0.0",
52
52
  "@workday/canvas-tokens-web": "^1.3.0",
53
53
  "markdown-to-jsx": "^6.10.3",
@@ -59,5 +59,5 @@
59
59
  "mkdirp": "^1.0.3",
60
60
  "typescript": "4.2"
61
61
  },
62
- "gitHead": "d52d032456b050c163ecff6643ece156056e40c8"
62
+ "gitHead": "54f26ac17e2a7d579539ae11adcaa1912faeef2e"
63
63
  }