@workday/canvas-kit-docs 14.1.1 → 14.1.5

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,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "14.1.1",
22
- "@workday/canvas-kit-preview-react": "14.1.1",
23
- "@workday/canvas-kit-react": "14.1.1",
24
- "@workday/canvas-kit-react-fonts": "^14.1.1",
25
- "@workday/canvas-kit-styling": "14.1.1",
21
+ "@workday/canvas-kit-labs-react": "14.1.5",
22
+ "@workday/canvas-kit-preview-react": "14.1.5",
23
+ "@workday/canvas-kit-react": "14.1.5",
24
+ "@workday/canvas-kit-react-fonts": "^14.1.5",
25
+ "@workday/canvas-kit-styling": "14.1.5",
26
26
  "@workday/canvas-system-icons-web": "3.0.36",
27
27
  "@workday/canvas-tokens-web": "3.1.2"
28
28
  },
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "14.1.1",
22
- "@workday/canvas-kit-preview-react": "14.1.1",
23
- "@workday/canvas-kit-react": "14.1.1",
24
- "@workday/canvas-kit-react-fonts": "^14.1.1",
25
- "@workday/canvas-kit-styling": "14.1.1",
21
+ "@workday/canvas-kit-labs-react": "14.1.5",
22
+ "@workday/canvas-kit-preview-react": "14.1.5",
23
+ "@workday/canvas-kit-react": "14.1.5",
24
+ "@workday/canvas-kit-react-fonts": "^14.1.5",
25
+ "@workday/canvas-kit-styling": "14.1.5",
26
26
  "@workday/canvas-system-icons-web": "3.0.36",
27
27
  "@workday/canvas-tokens-web": "3.1.2"
28
28
  },
@@ -1,6 +1,6 @@
1
1
  import {Avatar} from '@workday/canvas-kit-preview-react/avatar';
2
2
  // @ts-ignore
3
- import nicholasAvatar from './nicholas-avatar.png';
3
+ import nicholasAvatar from './nicholas-avatar.jpg';
4
4
  import {createStyles} from '@workday/canvas-kit-styling';
5
5
  import {Text} from '@workday/canvas-kit-react/text';
6
6
  import {system} from '@workday/canvas-tokens-web';
@@ -0,0 +1,36 @@
1
+ import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
2
+ import ContextualHelpTooltip from './examples/ContextualHelp/ContextualHelpTooltip';
3
+ import ContextualHelpDialogFocusRedirect from './examples/ContextualHelp/ContextualHelpDialogFocusRedirect';
4
+ import ContextualHelpDialogFocusTrap from './examples/ContextualHelp/ContextualHelpDialogFocusTrap';
5
+
6
+
7
+
8
+ ## Contextual Help
9
+
10
+ ### Tooltip
11
+ A Canvas Kit `Tooltip` can be used to provide additional information about why an element is disabled.
12
+ We should not, however, put one directly onto a disabled element because disabled elements do not receive focus
13
+ (meaning the tooltip content is not accessible to keyboard users). Instead, we should provide a button next to the disabled
14
+ element and apply the `Tooltip` to the button.
15
+
16
+ **Note: We should avoid passing the `type` prop to the `Tooltip`. The default behavior is to assign an `aria-label` to the button
17
+ (which is what we want)**
18
+ <ExampleCodeBlock code={ContextualHelpTooltip} />
19
+
20
+ ### Contextual Help Popup Without Focus Trap
21
+ If one would like to provide a bit more content than a `Tooltip` will allow (such as buttons or links) a popup should be used.
22
+ In this example, a `Dialog` is used in conjunction with the `useFocusRedirect` hook to display some text and a link. It will
23
+ not trap focus; instead, it will close and focus the next element if the user tabs out or clicks away. A `Tooltip` is still
24
+ used on the `Dialog.Target` component so that it remains accessible for screen readers.
25
+
26
+ `Dialog` inserts an invisible `<div>` element right after the button with an `aria-owns` attribute pointing to the
27
+ `Dialog.Card`. This allows screen readers to read the popup contents in a logical order with the target. In other words, the
28
+ screen reader will announce the `Dialog` right after the open button instead of out of order.
29
+
30
+ Additionally, we apply `aria-describedby` to our `Dialog.Target` to associate it with the `FormField.Label`.
31
+ <ExampleCodeBlock code={ContextualHelpDialogFocusRedirect} />
32
+
33
+ ### Contextual Help Dialog With Focus Trap
34
+ The `useFocusTrap` hook can be used in contextual help where trapping focus within the `Dialog` is the goal. In this case,
35
+ focus will remain in the `Dialog` until it is closed. This example is otherwise identical to the one above.
36
+ <ExampleCodeBlock code={ContextualHelpDialogFocusTrap} />
@@ -0,0 +1,75 @@
1
+ import {Hyperlink, TertiaryButton} from '@workday/canvas-kit-react/button';
2
+ import {infoIcon} from '@workday/canvas-system-icons-web';
3
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+ import {TextInput} from '@workday/canvas-kit-react/text-input';
6
+ import {Flex} from '@workday/canvas-kit-react/layout';
7
+ import {system} from '@workday/canvas-tokens-web';
8
+ import {createStyles} from '@workday/canvas-kit-styling';
9
+ import {Dialog, useDialogModel} from '@workday/canvas-kit-react/dialog';
10
+ import {
11
+ useCloseOnEscape,
12
+ useCloseOnOutsideClick,
13
+ useFocusRedirect,
14
+ useInitialFocus,
15
+ useReturnFocus,
16
+ } from '@workday/canvas-kit-react/popup';
17
+ import {useUniqueId} from '@workday/canvas-kit-react/common';
18
+
19
+ const containerStyles = createStyles({
20
+ flexDirection: 'row',
21
+ gap: system.space.x2,
22
+ });
23
+
24
+ const labelStyles = createStyles({
25
+ minWidth: 'unset',
26
+ width: '100%',
27
+ });
28
+
29
+ export function ContextualHelpDialogFocusRedirect() {
30
+ const dialogModel = useDialogModel();
31
+ useCloseOnOutsideClick(dialogModel);
32
+ useCloseOnEscape(dialogModel);
33
+ useInitialFocus(dialogModel);
34
+ useFocusRedirect(dialogModel);
35
+ useReturnFocus(dialogModel);
36
+
37
+ const labelId = useUniqueId();
38
+
39
+ return (
40
+ <Flex>
41
+ <FormField>
42
+ <Flex className={containerStyles}>
43
+ <FormField.Label className={labelStyles} id={labelId}>
44
+ Country
45
+ </FormField.Label>
46
+ <Dialog model={dialogModel}>
47
+ <Tooltip title="More Info">
48
+ <Dialog.Target
49
+ as={TertiaryButton}
50
+ size="small"
51
+ icon={infoIcon}
52
+ aria-describedby={labelId}
53
+ />
54
+ </Tooltip>
55
+ <Dialog.Popper placement="right">
56
+ <Dialog.Card>
57
+ <Dialog.CloseIcon aria-label="Close" />
58
+ <Dialog.Heading paddingTop={system.space.x6}>Information</Dialog.Heading>
59
+ <Dialog.Body>
60
+ This dialog does not trap focus, so tabbing out of it will cause it to close
61
+ </Dialog.Body>
62
+ <Flex gap={system.space.x4} padding={system.space.x2} marginTop={system.space.x2}>
63
+ <Hyperlink href="/">Link</Hyperlink>
64
+ </Flex>
65
+ </Dialog.Card>
66
+ </Dialog.Popper>
67
+ </Dialog>
68
+ </Flex>
69
+ <FormField.Field>
70
+ <FormField.Input as={TextInput} />
71
+ </FormField.Field>
72
+ </FormField>
73
+ </Flex>
74
+ );
75
+ }
@@ -0,0 +1,77 @@
1
+ import {Hyperlink, TertiaryButton} from '@workday/canvas-kit-react/button';
2
+ import {infoIcon} from '@workday/canvas-system-icons-web';
3
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+ import {TextInput} from '@workday/canvas-kit-react/text-input';
6
+ import {Flex} from '@workday/canvas-kit-react/layout';
7
+ import {system} from '@workday/canvas-tokens-web';
8
+ import {createStyles} from '@workday/canvas-kit-styling';
9
+ import {
10
+ useCloseOnEscape,
11
+ useCloseOnOutsideClick,
12
+ useFocusTrap,
13
+ useInitialFocus,
14
+ usePopupModel,
15
+ useReturnFocus,
16
+ } from '@workday/canvas-kit-react/popup';
17
+ import {Dialog} from '@workday/canvas-kit-react/dialog';
18
+ import {useUniqueId} from '@workday/canvas-kit-react/common';
19
+
20
+ const containerStyles = createStyles({
21
+ flexDirection: 'row',
22
+ gap: system.space.x2,
23
+ });
24
+
25
+ const labelStyles = createStyles({
26
+ minWidth: 'unset',
27
+ width: '100%',
28
+ });
29
+
30
+ export function ContextualHelpDialogFocusTrap() {
31
+ const dialogModel = usePopupModel();
32
+ useCloseOnOutsideClick(dialogModel);
33
+ useCloseOnEscape(dialogModel);
34
+ useInitialFocus(dialogModel);
35
+ useFocusTrap(dialogModel);
36
+ useReturnFocus(dialogModel);
37
+
38
+ const labelId = useUniqueId();
39
+
40
+ return (
41
+ <Flex>
42
+ <FormField>
43
+ <Flex className={containerStyles}>
44
+ <FormField.Label className={labelStyles} id={labelId}>
45
+ Name
46
+ </FormField.Label>
47
+ <Dialog model={dialogModel}>
48
+ <Tooltip title="More Info">
49
+ <Dialog.Target
50
+ as={TertiaryButton}
51
+ size="small"
52
+ icon={infoIcon}
53
+ aria-describedby={labelId}
54
+ />
55
+ </Tooltip>
56
+ <Dialog.Popper placement="right">
57
+ <Dialog.Card>
58
+ <Dialog.CloseIcon aria-label="Close" />
59
+ <Dialog.Heading paddingTop={system.space.x6}>Information</Dialog.Heading>
60
+ <Dialog.Body>
61
+ This dialog traps focus. Focus will only return to the rest of the page when the
62
+ dialog is closed
63
+ </Dialog.Body>
64
+ <Flex gap={system.space.x4} padding={system.space.x2} marginTop={system.space.x2}>
65
+ <Hyperlink href="/">Link</Hyperlink>
66
+ </Flex>
67
+ </Dialog.Card>
68
+ </Dialog.Popper>
69
+ </Dialog>
70
+ </Flex>
71
+ <FormField.Field>
72
+ <FormField.Input as={TextInput} />
73
+ </FormField.Field>
74
+ </FormField>
75
+ </Flex>
76
+ );
77
+ }
@@ -0,0 +1,42 @@
1
+ import {PrimaryButton, TertiaryButton} from '@workday/canvas-kit-react/button';
2
+ import {infoIcon} from '@workday/canvas-system-icons-web';
3
+ import {Tooltip} from '@workday/canvas-kit-react/tooltip';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+ import {TextInput} from '@workday/canvas-kit-react/text-input';
6
+ import {Flex} from '@workday/canvas-kit-react/layout';
7
+ import {createStyles} from '@workday/canvas-kit-styling';
8
+ import {system} from '@workday/canvas-tokens-web';
9
+ import React from 'react';
10
+
11
+ const outerContainerStyles = createStyles({
12
+ flexDirection: 'column',
13
+ });
14
+
15
+ const buttonContainerStyles = createStyles({
16
+ flexDirection: 'row',
17
+ gap: system.space.x1,
18
+ alignItems: 'center',
19
+ });
20
+
21
+ export function ContextualHelpTooltip() {
22
+ const [value, setValue] = React.useState('');
23
+
24
+ const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
25
+ setValue(event.target.value);
26
+ };
27
+
28
+ return (
29
+ <Flex className={outerContainerStyles}>
30
+ <FormField isRequired>
31
+ <FormField.Label>Favorite Food</FormField.Label>
32
+ <FormField.Input as={TextInput} onChange={handleChange}></FormField.Input>
33
+ </FormField>
34
+ <Flex className={buttonContainerStyles}>
35
+ <PrimaryButton disabled={!value}>Submit</PrimaryButton>
36
+ <Tooltip title="All fields must be filled before submitting" placement="right">
37
+ <TertiaryButton icon={infoIcon} size="small" aria-label="Info" disabled={!!value} />
38
+ </Tooltip>
39
+ </Flex>
40
+ </Flex>
41
+ );
42
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "14.1.1",
3
+ "version": "14.1.5",
4
4
  "description": "Documentation components of Canvas Kit components",
5
5
  "author": "Workday, Inc. (https://www.workday.com)",
6
6
  "license": "Apache-2.0",
@@ -45,10 +45,10 @@
45
45
  "@emotion/styled": "^11.6.0",
46
46
  "@stackblitz/sdk": "^1.11.0",
47
47
  "@storybook/csf": "0.0.1",
48
- "@workday/canvas-kit-labs-react": "^14.1.1",
49
- "@workday/canvas-kit-preview-react": "^14.1.1",
50
- "@workday/canvas-kit-react": "^14.1.1",
51
- "@workday/canvas-kit-styling": "^14.1.1",
48
+ "@workday/canvas-kit-labs-react": "^14.1.5",
49
+ "@workday/canvas-kit-preview-react": "^14.1.5",
50
+ "@workday/canvas-kit-react": "^14.1.5",
51
+ "@workday/canvas-kit-styling": "^14.1.5",
52
52
  "@workday/canvas-system-icons-web": "^3.0.36",
53
53
  "@workday/canvas-tokens-web": "^3.1.1",
54
54
  "markdown-to-jsx": "^7.2.0",
@@ -61,5 +61,5 @@
61
61
  "mkdirp": "^1.0.3",
62
62
  "typescript": "5.0"
63
63
  },
64
- "gitHead": "eae5ca9d2d556df7d068b0188bb1f00e759d6679"
64
+ "gitHead": "79a0516e51e4855e2b661cf7d7045f972df3570c"
65
65
  }