@workday/canvas-kit-docs 15.0.0-alpha.1301-next.0 → 15.0.0-alpha.1326-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.
- package/dist/es6/lib/docs.js +8234 -64
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/14.0-UPGRADE-GUIDE.mdx +36 -5
- package/dist/mdx/15.0-UPGRADE-GUIDE.mdx +8 -0
- package/dist/mdx/preview-react/avatar/examples/Decorative.tsx +1 -1
- package/dist/mdx/preview-react/avatar/examples/nicholas-avatar.jpg +0 -0
- package/dist/mdx/react/_examples/mdx/ContextualHelp.mdx +36 -0
- package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusRedirect.tsx +75 -0
- package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusTrap.tsx +77 -0
- package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpTooltip.tsx +42 -0
- package/dist/mdx/react/common/mdx/Theming.mdx +30 -0
- package/dist/mdx/style-props/STYLE_PROPS.mdx +1 -1
- package/dist/mdx/style-props/stylePropsMigrationCodemod.mdx +99 -0
- package/dist/mdx/style-props/stylePropsMigrationOverview.mdx +424 -0
- package/package.json +7 -7
- package/dist/mdx/preview-react/avatar/examples/nicholas-avatar.png +0 -0
|
@@ -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.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.
|
|
23
|
-
"@workday/canvas-kit-react": "14.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.1.10",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.1.10",
|
|
23
|
+
"@workday/canvas-kit-react": "14.1.10",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.1.10",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.1.10",
|
|
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.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.
|
|
23
|
-
"@workday/canvas-kit-react": "14.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.1.10",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.1.10",
|
|
23
|
+
"@workday/canvas-kit-react": "14.1.10",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.1.10",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.1.10",
|
|
26
26
|
"@workday/canvas-system-icons-web": "3.0.36",
|
|
27
27
|
"@workday/canvas-tokens-web": "3.1.2"
|
|
28
28
|
},
|
|
@@ -38,6 +38,7 @@ visual reference of what's changed.**
|
|
|
38
38
|
- [Expandable](#expandable)
|
|
39
39
|
- [Hyperlink and External Hyperlink](#hyperlink-and-external-hyperlink)
|
|
40
40
|
- [Loading Dots](#loading-dots)
|
|
41
|
+
- [Modals and Dialogs](#modals-and-dialogs)
|
|
41
42
|
- [Pill (Preview)](#pill-preview)
|
|
42
43
|
- [Search Form (Labs)](#search-form-labs-)
|
|
43
44
|
- [Status Indicator (Preview)](#status-indicator-preview-)
|
|
@@ -55,7 +56,7 @@ visual reference of what's changed.**
|
|
|
55
56
|
- [Deprecated Buttons](#deprecated-buttons)
|
|
56
57
|
- [Input Provider](#input-provider)
|
|
57
58
|
- [Menu (Preview)](#menu-preview)
|
|
58
|
-
- [
|
|
59
|
+
- [readOnlyPillStencil and removeablePillStencil](#readonlypillstencil-and-removeablepillstencil)
|
|
59
60
|
- [Text Area (Labs)](#text-area)
|
|
60
61
|
- [Text Input (Labs)](#text-input)
|
|
61
62
|
- [Troubleshooting](#troubleshooting)
|
|
@@ -629,7 +630,7 @@ provide a value for the `name` prop.
|
|
|
629
630
|
The `Pill` component no longer supports `default` as a value for the `variant` prop. If the
|
|
630
631
|
`variant` prop is not provided, the component will use its default styling.
|
|
631
632
|
|
|
632
|
-
`
|
|
633
|
+
`readOnlyPillStencil` and `removeablePillStencil` have been removed. Please use `pillStencil`
|
|
633
634
|
instead.
|
|
634
635
|
|
|
635
636
|
**Before in v13**
|
|
@@ -650,6 +651,36 @@ instead.
|
|
|
650
651
|
</Pill>
|
|
651
652
|
```
|
|
652
653
|
|
|
654
|
+
### Modals and Dialogs
|
|
655
|
+
|
|
656
|
+
Previously, the `usePopupStack` hook created a CSS class name that was passed to our Popups. We attached those theme styles to that class name. This allowed the theme to be available in our Popups. But it also created a cascade barrier that blocked the global theme from being applied to our Popup components.
|
|
657
|
+
Because we now use global CSS variables, we no longer need this class name to provide the global theme to Popups. But we have to remove this generated class name to allow the global theme to be applied to Popups.
|
|
658
|
+
|
|
659
|
+
|
|
660
|
+
> **Important:** Passing a `theme` to the `CanvasProvider` **will not** theme components in Modals
|
|
661
|
+
> and Dialogs. You can either pass a `className` or define CSS variables at the root.
|
|
662
|
+
|
|
663
|
+
**Before in v13**
|
|
664
|
+
|
|
665
|
+
```tsx
|
|
666
|
+
// When passing a theme to the Canvas Provider, the `usePopupStack` would grab the theme and generate a class to forward the theme to Modals and Dialogs. This would create a cascade barrier for any CSS variables deinfed at the root.
|
|
667
|
+
<CanvasProvider theme={{canvas: {palette: {primary: {main: 'blue'}}}}}>
|
|
668
|
+
<Modal>//... rest of modal code</Modal>
|
|
669
|
+
</CanvasProvider>
|
|
670
|
+
```
|
|
671
|
+
|
|
672
|
+
**After in v14**
|
|
673
|
+
|
|
674
|
+
```tsx
|
|
675
|
+
// If you wish to still theme you application and Modals, you can either define the CSS variables at the root level of your application or define a className and pass it to the CanvasProvider.
|
|
676
|
+
:root {
|
|
677
|
+
--cnvs-brand-primary-base: blue;
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
<CanvasProvider>
|
|
681
|
+
<Modal>//... rest of modal code</Modal>
|
|
682
|
+
</CanvasProvider>
|
|
683
|
+
```
|
|
653
684
|
### Search Form (Labs) 🚨
|
|
654
685
|
|
|
655
686
|
**PR:** [#3303](https://github.com/Workday/canvas-kit/pull/3303)
|
|
@@ -908,9 +939,9 @@ const buttonStyles = createStyles({
|
|
|
908
939
|
We've removed `Menu` from `@workday/canvas-kit-preview-react`. Please use
|
|
909
940
|
[Menu](/components/popups/menu/) from `@workday/canvas-kit-react` instead.
|
|
910
941
|
|
|
911
|
-
###
|
|
942
|
+
### readOnlyPillStencil and removeablePillStencil
|
|
912
943
|
|
|
913
|
-
The `
|
|
944
|
+
The `readOnlyPillStencil` and `removeablePillStencil` utilities have been removed from the Pill
|
|
914
945
|
package. Please use `pillStencil` instead.
|
|
915
946
|
|
|
916
947
|
### Text Area (Preview)
|
|
@@ -966,7 +997,7 @@ import {TextInput} from '@workday/canvas-kit-preview-react/text-input';
|
|
|
966
997
|
**After in v14**
|
|
967
998
|
|
|
968
999
|
```tsx
|
|
969
|
-
import {TextArea} from '@workday/canvas-kit-react/text-
|
|
1000
|
+
import {TextArea} from '@workday/canvas-kit-react/text-area';
|
|
970
1001
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
971
1002
|
|
|
972
1003
|
<FormField>
|
|
@@ -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.
|
|
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';
|
|
Binary file
|
|
@@ -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} />
|
package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusRedirect.tsx
ADDED
|
@@ -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
|
+
}
|
package/dist/mdx/react/_examples/mdx/examples/ContextualHelp/ContextualHelpDialogFocusTrap.tsx
ADDED
|
@@ -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
|
+
}
|
|
@@ -134,6 +134,36 @@ const themedBrand = createStyles({
|
|
|
134
134
|
</CanvasProvider>
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
+
### Theming Modals and Dialogs
|
|
138
|
+
|
|
139
|
+
Previously, the `usePopupStack` hook created a CSS class name that was passed to our Popups. We attached those theme styles to that class name. This allowed the theme to be available in our Popups. But it also created a cascade barrier that blocked the global theme from being applied to our Popup components.
|
|
140
|
+
Because we now use global CSS variables, we no longer need this class name to provide the global theme to Popups. But we have to remove this generated class name to allow the global theme to be applied to Popups.
|
|
141
|
+
|
|
142
|
+
> **Important:** Passing a `theme` to the `CanvasProvider` **will not** theme components in Modals
|
|
143
|
+
> and Dialogs. You can either pass a `className` or define CSS variables at the root.
|
|
144
|
+
|
|
145
|
+
**Before in v13**
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
// When passing a theme to the Canvas Provider, the `usePopupStack` would grab the theme and generate a class to forward the theme to Modals and Dialogs. This would create a cascade barrier for any CSS variables deinfed at the root.
|
|
149
|
+
<CanvasProvider theme={{canvas: {palette: {primary: {main: 'blue'}}}}}>
|
|
150
|
+
<Modal>//... rest of modal code</Modal>
|
|
151
|
+
</CanvasProvider>
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**After in v14**
|
|
155
|
+
|
|
156
|
+
```tsx
|
|
157
|
+
// If you wish to still theme you application and Modals, you can either define the CSS variables at the root level of your application or define a className and pass it to the CanvasProvider.
|
|
158
|
+
:root {
|
|
159
|
+
--cnvs-brand-primary-base: blue;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
<CanvasProvider>
|
|
163
|
+
<Modal>//... rest of modal code</Modal>
|
|
164
|
+
</CanvasProvider>
|
|
165
|
+
```
|
|
166
|
+
|
|
137
167
|
## CSS Token Structure
|
|
138
168
|
|
|
139
169
|
Canvas Kit provides three layers of CSS variables.
|
|
@@ -47,7 +47,7 @@ with props.
|
|
|
47
47
|
<InformationHighlight.Body>
|
|
48
48
|
As we transition away from Emotion's runtime costs, we advise to move away from using style props. Please use our [styling utilities](https://workday.github.io/canvas-kit/?path=/docs/styling-getting-started-overview--docs) instead. For more information on this change, view our discussion on the [Future of Styling](https://github.com/Workday/canvas-kit/discussions/2265).
|
|
49
49
|
|
|
50
|
-
You can use `14.1` codemod to automatic migration to `cs` prop. [
|
|
50
|
+
You can use `14.1` codemod to automatic migration to `cs` prop. [Migration Docs](https://workday.github.io/canvas-kit/?path=/docs/guides-codemods--docs)
|
|
51
51
|
|
|
52
52
|
</InformationHighlight.Body>
|
|
53
53
|
</InformationHighlight>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
|
|
2
|
+
import {StorybookStatusIndicator, DownloadLLMFile} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Canvas Kit Style Props Migration Codemod
|
|
6
|
+
|
|
7
|
+
This codemod helps migrate style props to `cs` prop. It also automatically transforms token usage in
|
|
8
|
+
your codebase to use the new token system.
|
|
9
|
+
|
|
10
|
+
## Important Notes
|
|
11
|
+
|
|
12
|
+
- **Run on Small Batches**: We recommend running the codemod on a small number of files in batches
|
|
13
|
+
instead of your entire repository all at once. This makes the changes easier to review and allows
|
|
14
|
+
you to catch issues more quickly with less frustration.
|
|
15
|
+
- **Codemod Limitations**: The codemod does not cover every possible token usage or migration
|
|
16
|
+
scenario. Please review the codemod's changes and be prepared to update style props as needed.
|
|
17
|
+
Some manual changes will be required, especially for:
|
|
18
|
+
- Custom or dynamic style usage
|
|
19
|
+
- Updating documentation, comments, or non-code files
|
|
20
|
+
|
|
21
|
+
## Required Dependencies
|
|
22
|
+
|
|
23
|
+
The codemod requires the following packages to be installed:
|
|
24
|
+
|
|
25
|
+
- `@workday/canvas-kit-styling`
|
|
26
|
+
- `@workday/canvas-tokens-web`
|
|
27
|
+
|
|
28
|
+
## Installation
|
|
29
|
+
|
|
30
|
+
You can run the codemod using npx:
|
|
31
|
+
|
|
32
|
+
```sh
|
|
33
|
+
npx @workday/canvas-kit-codemod v14.1 [path]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or install the package and run it directly. But remember to uninstall the package after you have
|
|
37
|
+
completed the upgrade.
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
yarn add @workday/canvas-kit-codemod
|
|
41
|
+
canvas-kit-codemod v14.1 [path]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
> Note: These codemods only work on .js, .jsx, .ts, and .tsx extensions. You may need to make some
|
|
45
|
+
> manual changes in other file types (.json, .mdx, .md, etc.).
|
|
46
|
+
|
|
47
|
+
> Note: You may need to run your linter after executing the codemod, as its resulting formatting
|
|
48
|
+
> (spacing, quotes, etc.) may not match your project's styling.
|
|
49
|
+
|
|
50
|
+
## What This Codemod Does
|
|
51
|
+
|
|
52
|
+
The Canvas Kit codemod automates the migration from **deprecated style props** and **Emotion-based
|
|
53
|
+
styling** to the new **Canvas Kit Styling** system. It is designed to handle the majority of
|
|
54
|
+
migration cases safely and efficiently, minimizing manual refactoring.
|
|
55
|
+
|
|
56
|
+
### Goals
|
|
57
|
+
|
|
58
|
+
- Accelerate migration to `@workday/canvas-kit-styling`
|
|
59
|
+
- Maintain visual parity between old and new implementations
|
|
60
|
+
- Reduce developer effort and manual code changes
|
|
61
|
+
- Ensure consistent use of `cs` prop
|
|
62
|
+
|
|
63
|
+
## What to Expect
|
|
64
|
+
|
|
65
|
+
After running the codemod, your code will:
|
|
66
|
+
|
|
67
|
+
1. Use the new `cs` props in CK components instead of style props
|
|
68
|
+
2. Transform token names used as style prop value to a new v3 token
|
|
69
|
+
3. Have correct token import
|
|
70
|
+
|
|
71
|
+
## Example Transformations
|
|
72
|
+
|
|
73
|
+
### Before
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
77
|
+
|
|
78
|
+
<Flex depth={1} marginX={10} background="frenchVanilla100" />;
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### After
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
85
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
86
|
+
|
|
87
|
+
<Flex
|
|
88
|
+
cs={{
|
|
89
|
+
boxShadow: system.depth[1],
|
|
90
|
+
marginInline: 10,
|
|
91
|
+
background: system.color.bg.default,
|
|
92
|
+
}}
|
|
93
|
+
/>;
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## What the Codemod Does Not Do
|
|
97
|
+
|
|
98
|
+
The codemod will not hoist your styles to the top of the file. While we don't expect you to do this
|
|
99
|
+
immediately, we strongly encourage you to do this in the future and at a gradual pace.
|