@workday/canvas-kit-docs 15.0.0-alpha.1295-next.0 → 15.0.0-alpha.1303-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/ExampleCodeBlock.d.ts.map +1 -1
- package/dist/es6/lib/ExampleCodeBlock.js +4 -1
- package/dist/es6/lib/docs.js +219 -1
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- 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/lib/ExampleCodeBlock.tsx +4 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExampleCodeBlock.d.ts","sourceRoot":"","sources":["../../../lib/ExampleCodeBlock.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ExampleCodeBlock.d.ts","sourceRoot":"","sources":["../../../lib/ExampleCodeBlock.tsx"],"names":[],"mappings":"AAsEA,eAAO,MAAM,gBAAgB,aAAY,GAAG,4CAkH3C,CAAC"}
|
|
@@ -27,6 +27,9 @@ const cardStencil = createStencil({
|
|
|
27
27
|
position: 'relative',
|
|
28
28
|
overflow: 'auto', // This allows for the entire ExampleCodeBlock to scroll on smaller viewports
|
|
29
29
|
},
|
|
30
|
+
'[data-part="example-block-container"]': {
|
|
31
|
+
overflow: 'auto',
|
|
32
|
+
},
|
|
30
33
|
'[data-part="code-block"]': {
|
|
31
34
|
display: 'none',
|
|
32
35
|
boxShadow: system.depth[1],
|
|
@@ -111,7 +114,7 @@ export const ExampleCodeBlock = ({ code }) => {
|
|
|
111
114
|
openFile: 'src/Demo.tsx',
|
|
112
115
|
});
|
|
113
116
|
};
|
|
114
|
-
return (_jsxs("div", { ...cardStencil({ opened: isCodeDisplayed }), children: [_jsx(Card, { "data-part": "example-block", className: "sb-unstyled", children: _jsx(Card.Body, {
|
|
117
|
+
return (_jsxs("div", { ...cardStencil({ opened: isCodeDisplayed }), children: [_jsx(Card, { "data-part": "example-block", className: "sb-unstyled", children: _jsx(Card.Body, { "data-part": "example-block-container", children: _jsxs(CanvasProvider, { className: defaultBranding, children: [React.createElement(code), code && (_jsxs("div", { "data-part": "code-toggle-stackblitz-btn-container", children: [_jsx(TertiaryButton, { size: "extraSmall", onClick: () => openProjectInStackblitz(), children: "\u26A1\uFE0F Edit in Stackblitz" }), _jsx(TertiaryButton, { size: "extraSmall", onClick: () => setCodeDisplayed(!isCodeDisplayed), children: !isCodeDisplayed ? 'Show Code' : 'Hide Code' })] }))] }) }) }), _jsx(Card, { "data-part": "code-block", padding: 0, children: _jsx(Card.Body, { cs: { position: 'relative' }, children: _jsxs(CanvasProvider, { className: defaultBranding, children: [code && (_jsx("div", { ref: textInput, children: _jsx(SyntaxHighlighter, { className: "sb-unstyled", language: "jsx", style: vscDarkPlus, customStyle: {
|
|
115
118
|
fontSize: cssVar(system.fontSize.subtext.large),
|
|
116
119
|
lineHeight: cssVar(system.lineHeight.subtext.large),
|
|
117
120
|
margin: '0',
|
package/dist/es6/lib/docs.js
CHANGED
|
@@ -5336,7 +5336,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
|
|
|
5336
5336
|
},
|
|
5337
5337
|
"defaultValue": {
|
|
5338
5338
|
"kind": "string",
|
|
5339
|
-
"value": "
|
|
5339
|
+
"value": "contain"
|
|
5340
5340
|
}
|
|
5341
5341
|
},
|
|
5342
5342
|
{
|
|
@@ -194433,6 +194433,176 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
|
|
|
194433
194433
|
}
|
|
194434
194434
|
}
|
|
194435
194435
|
},
|
|
194436
|
+
{
|
|
194437
|
+
"name": "forwardFitTokens",
|
|
194438
|
+
"fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts",
|
|
194439
|
+
"description": "This file is NOT INTENDED to be used by consumers, only internally by Canvas Kit.",
|
|
194440
|
+
"declarations": [
|
|
194441
|
+
{
|
|
194442
|
+
"name": "forwardFitTokens",
|
|
194443
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194444
|
+
}
|
|
194445
|
+
],
|
|
194446
|
+
"tags": {},
|
|
194447
|
+
"type": {
|
|
194448
|
+
"kind": "object",
|
|
194449
|
+
"properties": [
|
|
194450
|
+
{
|
|
194451
|
+
"kind": "property",
|
|
194452
|
+
"name": "system",
|
|
194453
|
+
"defaultValue": {
|
|
194454
|
+
"kind": "object",
|
|
194455
|
+
"properties": [
|
|
194456
|
+
{
|
|
194457
|
+
"kind": "property",
|
|
194458
|
+
"name": "shape",
|
|
194459
|
+
"defaultValue": {
|
|
194460
|
+
"kind": "object",
|
|
194461
|
+
"properties": [
|
|
194462
|
+
{
|
|
194463
|
+
"kind": "property",
|
|
194464
|
+
"name": "sm",
|
|
194465
|
+
"defaultValue": {
|
|
194466
|
+
"kind": "string",
|
|
194467
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194468
|
+
},
|
|
194469
|
+
"type": {
|
|
194470
|
+
"kind": "string",
|
|
194471
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194472
|
+
},
|
|
194473
|
+
"required": true,
|
|
194474
|
+
"description": "",
|
|
194475
|
+
"declarations": [
|
|
194476
|
+
{
|
|
194477
|
+
"name": "sm",
|
|
194478
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194479
|
+
}
|
|
194480
|
+
],
|
|
194481
|
+
"tags": {}
|
|
194482
|
+
}
|
|
194483
|
+
]
|
|
194484
|
+
},
|
|
194485
|
+
"type": {
|
|
194486
|
+
"kind": "object",
|
|
194487
|
+
"properties": [
|
|
194488
|
+
{
|
|
194489
|
+
"kind": "property",
|
|
194490
|
+
"name": "sm",
|
|
194491
|
+
"defaultValue": {
|
|
194492
|
+
"kind": "string",
|
|
194493
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194494
|
+
},
|
|
194495
|
+
"type": {
|
|
194496
|
+
"kind": "string",
|
|
194497
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194498
|
+
},
|
|
194499
|
+
"required": true,
|
|
194500
|
+
"description": "",
|
|
194501
|
+
"declarations": [
|
|
194502
|
+
{
|
|
194503
|
+
"name": "sm",
|
|
194504
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194505
|
+
}
|
|
194506
|
+
],
|
|
194507
|
+
"tags": {}
|
|
194508
|
+
}
|
|
194509
|
+
]
|
|
194510
|
+
},
|
|
194511
|
+
"required": true,
|
|
194512
|
+
"description": "",
|
|
194513
|
+
"declarations": [
|
|
194514
|
+
{
|
|
194515
|
+
"name": "shape",
|
|
194516
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194517
|
+
}
|
|
194518
|
+
],
|
|
194519
|
+
"tags": {}
|
|
194520
|
+
}
|
|
194521
|
+
]
|
|
194522
|
+
},
|
|
194523
|
+
"type": {
|
|
194524
|
+
"kind": "object",
|
|
194525
|
+
"properties": [
|
|
194526
|
+
{
|
|
194527
|
+
"kind": "property",
|
|
194528
|
+
"name": "shape",
|
|
194529
|
+
"defaultValue": {
|
|
194530
|
+
"kind": "object",
|
|
194531
|
+
"properties": [
|
|
194532
|
+
{
|
|
194533
|
+
"kind": "property",
|
|
194534
|
+
"name": "sm",
|
|
194535
|
+
"defaultValue": {
|
|
194536
|
+
"kind": "string",
|
|
194537
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194538
|
+
},
|
|
194539
|
+
"type": {
|
|
194540
|
+
"kind": "string",
|
|
194541
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194542
|
+
},
|
|
194543
|
+
"required": true,
|
|
194544
|
+
"description": "",
|
|
194545
|
+
"declarations": [
|
|
194546
|
+
{
|
|
194547
|
+
"name": "sm",
|
|
194548
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194549
|
+
}
|
|
194550
|
+
],
|
|
194551
|
+
"tags": {}
|
|
194552
|
+
}
|
|
194553
|
+
]
|
|
194554
|
+
},
|
|
194555
|
+
"type": {
|
|
194556
|
+
"kind": "object",
|
|
194557
|
+
"properties": [
|
|
194558
|
+
{
|
|
194559
|
+
"kind": "property",
|
|
194560
|
+
"name": "sm",
|
|
194561
|
+
"defaultValue": {
|
|
194562
|
+
"kind": "string",
|
|
194563
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194564
|
+
},
|
|
194565
|
+
"type": {
|
|
194566
|
+
"kind": "string",
|
|
194567
|
+
"value": "var(--cnvs-sys-shape-sm, var(--cnvs-sys-shape-x1-half))"
|
|
194568
|
+
},
|
|
194569
|
+
"required": true,
|
|
194570
|
+
"description": "",
|
|
194571
|
+
"declarations": [
|
|
194572
|
+
{
|
|
194573
|
+
"name": "sm",
|
|
194574
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194575
|
+
}
|
|
194576
|
+
],
|
|
194577
|
+
"tags": {}
|
|
194578
|
+
}
|
|
194579
|
+
]
|
|
194580
|
+
},
|
|
194581
|
+
"required": true,
|
|
194582
|
+
"description": "",
|
|
194583
|
+
"declarations": [
|
|
194584
|
+
{
|
|
194585
|
+
"name": "shape",
|
|
194586
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194587
|
+
}
|
|
194588
|
+
],
|
|
194589
|
+
"tags": {}
|
|
194590
|
+
}
|
|
194591
|
+
]
|
|
194592
|
+
},
|
|
194593
|
+
"required": true,
|
|
194594
|
+
"description": "",
|
|
194595
|
+
"declarations": [
|
|
194596
|
+
{
|
|
194597
|
+
"name": "system",
|
|
194598
|
+
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/forwardFitTokens.ts"
|
|
194599
|
+
}
|
|
194600
|
+
],
|
|
194601
|
+
"tags": {}
|
|
194602
|
+
}
|
|
194603
|
+
]
|
|
194604
|
+
}
|
|
194605
|
+
},
|
|
194436
194606
|
{
|
|
194437
194607
|
"name": "GenericStyles",
|
|
194438
194608
|
"fileName": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/genericStyles.ts",
|
|
@@ -272670,6 +272840,54 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
|
|
|
272670
272840
|
"returnType": {
|
|
272671
272841
|
"kind": "object",
|
|
272672
272842
|
"properties": [
|
|
272843
|
+
{
|
|
272844
|
+
"kind": "property",
|
|
272845
|
+
"name": "id",
|
|
272846
|
+
"required": true,
|
|
272847
|
+
"type": {
|
|
272848
|
+
"kind": "primitive",
|
|
272849
|
+
"value": "string"
|
|
272850
|
+
},
|
|
272851
|
+
"description": "",
|
|
272852
|
+
"tags": {},
|
|
272853
|
+
"declarations": []
|
|
272854
|
+
},
|
|
272855
|
+
{
|
|
272856
|
+
"kind": "property",
|
|
272857
|
+
"name": "role",
|
|
272858
|
+
"required": true,
|
|
272859
|
+
"type": {
|
|
272860
|
+
"kind": "string",
|
|
272861
|
+
"value": "menuitem"
|
|
272862
|
+
},
|
|
272863
|
+
"description": "",
|
|
272864
|
+
"tags": {},
|
|
272865
|
+
"declarations": []
|
|
272866
|
+
},
|
|
272867
|
+
{
|
|
272868
|
+
"kind": "property",
|
|
272869
|
+
"name": "aria-haspopup",
|
|
272870
|
+
"required": true,
|
|
272871
|
+
"type": {
|
|
272872
|
+
"kind": "string",
|
|
272873
|
+
"value": "true"
|
|
272874
|
+
},
|
|
272875
|
+
"description": "",
|
|
272876
|
+
"tags": {},
|
|
272877
|
+
"declarations": []
|
|
272878
|
+
},
|
|
272879
|
+
{
|
|
272880
|
+
"kind": "property",
|
|
272881
|
+
"name": "aria-expanded",
|
|
272882
|
+
"required": true,
|
|
272883
|
+
"type": {
|
|
272884
|
+
"kind": "primitive",
|
|
272885
|
+
"value": "boolean"
|
|
272886
|
+
},
|
|
272887
|
+
"description": "",
|
|
272888
|
+
"tags": {},
|
|
272889
|
+
"declarations": []
|
|
272890
|
+
},
|
|
272673
272891
|
{
|
|
272674
272892
|
"kind": "property",
|
|
272675
272893
|
"name": "onMouseDown",
|
|
@@ -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.0.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.0.
|
|
23
|
-
"@workday/canvas-kit-react": "14.0.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.0.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.0.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.0.17",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.0.17",
|
|
23
|
+
"@workday/canvas-kit-react": "14.0.17",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.0.17",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.0.17",
|
|
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.0.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.0.
|
|
23
|
-
"@workday/canvas-kit-react": "14.0.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.0.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.0.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.0.17",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.0.17",
|
|
23
|
+
"@workday/canvas-kit-react": "14.0.17",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.0.17",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.0.17",
|
|
26
26
|
"@workday/canvas-system-icons-web": "3.0.36",
|
|
27
27
|
"@workday/canvas-tokens-web": "3.1.2"
|
|
28
28
|
},
|
|
@@ -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.
|
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
import {InformationHighlight} from '@workday/canvas-kit-preview-react/information-highlight';
|
|
2
|
+
import {StorybookStatusIndicator, DownloadLLMFile} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Style Props Deprecation Overview
|
|
6
|
+
|
|
7
|
+
### Purpose
|
|
8
|
+
|
|
9
|
+
As part of the Canvas Kit’s modernization process, we’re moving away from Emotion’s runtime styling
|
|
10
|
+
and promoting a custom CSS-in-JS solution: `@workday/canvas-kit-styling`. This change improves
|
|
11
|
+
**performance**, **consistency**, and **maintainability** across our codebase. For more information,
|
|
12
|
+
view our [Future of](https://github.com/Workday/canvas-kit/discussions/2265) discussion.
|
|
13
|
+
|
|
14
|
+
### Goals
|
|
15
|
+
|
|
16
|
+
- **Reduce runtime overhead** by removing Emotion’s runtime from `@emotion/react`
|
|
17
|
+
- **Promote prescriptive, opinionated styling** across Workday
|
|
18
|
+
- **Enable static CSS compilation** for faster load times and smaller bundles
|
|
19
|
+
- **Support new design tokens and CSS Variables** for scalable theming
|
|
20
|
+
- **Ensure proper style merging** and stable selector behavior
|
|
21
|
+
- **Support advanced styling patterns** like compound styles, modifiers, and `data-parts`
|
|
22
|
+
|
|
23
|
+
> Emotion dynamically injects styles at runtime, causing costly re-renders and cache invalidations.
|
|
24
|
+
> The new system statically compiles styles at build time for optimal performance.
|
|
25
|
+
|
|
26
|
+
### Timeline
|
|
27
|
+
|
|
28
|
+
- **Deprecation introduced:** Canvas Kit **v14.1**
|
|
29
|
+
- **Removal:** _Not immediate_ — style props and `styled()` will continue to function in upcoming
|
|
30
|
+
releases
|
|
31
|
+
- **Migration timeline:** Gradual; no immediate codebase-wide update required
|
|
32
|
+
|
|
33
|
+
## LLM Assisted Migration <StorybookStatusIndicator type="ai" />
|
|
34
|
+
|
|
35
|
+
We've provided an **LLM migration mapping file** (`llm-style-props-migration.txt`) specifically
|
|
36
|
+
designed for use with LLM-based code assistants such as [Cursor](https://www.cursor.so/). It
|
|
37
|
+
contains a compiled LLM consumption version of this v14 Upgrade Guide. It is not intended for direct
|
|
38
|
+
human reference or team documentation, but rather as structured input for LLMs to automate and
|
|
39
|
+
assist with your migration process.
|
|
40
|
+
|
|
41
|
+
> **Important:** LLMs can make mistakes. Please verify changes using this Migration Guide.
|
|
42
|
+
|
|
43
|
+
**How to use:**
|
|
44
|
+
|
|
45
|
+
- **View raw file**: Open the file in a new tab to see the complete migration mapping
|
|
46
|
+
- **Download LLM File**: Save the file locally to upload or paste into your LLM/code assistant
|
|
47
|
+
- **Use with LLM**: Provide the raw content to your LLM/code assistant as context for automated
|
|
48
|
+
migration
|
|
49
|
+
|
|
50
|
+
<DownloadLLMFile
|
|
51
|
+
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm-txt/llm-style-props-migration.txt"
|
|
52
|
+
filename="llm-style-props-migration.txt"
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
## Changes Overview
|
|
56
|
+
|
|
57
|
+
### Replacements
|
|
58
|
+
|
|
59
|
+
Use the new **Canvas Kit Styling** utilities:
|
|
60
|
+
|
|
61
|
+
| Old API | New API | Purpose |
|
|
62
|
+
| -------------------------------------------------- | -------------------------------- | ------------------------------------------ |
|
|
63
|
+
| `styled()` | `createStyles` / `createStencil` | Define static or component-level styles |
|
|
64
|
+
| Inline style props, like `background` or `padding` | `cs` prop | Safely merge class names and styles |
|
|
65
|
+
| Dynamic values | `createVars` | Manage CSS variables for runtime overrides |
|
|
66
|
+
| Emotion modifiers | `modifiers`, `compound` | Define consistent appearance variants |
|
|
67
|
+
|
|
68
|
+
## Canvas Kit Styling
|
|
69
|
+
|
|
70
|
+
<InformationHighlight className="sb-unstyled" cs={{p: {marginBlock: 0}}}>
|
|
71
|
+
<InformationHighlight.Icon />
|
|
72
|
+
<InformationHighlight.Heading>Canvas Kit Styling Docs</InformationHighlight.Heading>
|
|
73
|
+
For a detailed overview of our styling approach, view our styling docs.
|
|
74
|
+
<InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/styling-getting-started-overview--docs">
|
|
75
|
+
Read more
|
|
76
|
+
</InformationHighlight.Link>
|
|
77
|
+
</InformationHighlight>
|
|
78
|
+
|
|
79
|
+
Canvas Kit’s styling utilities are built for **static CSS generation**, **token integration**, and
|
|
80
|
+
**predictable composition**.
|
|
81
|
+
|
|
82
|
+
### Core APIs
|
|
83
|
+
|
|
84
|
+
- **`createStyles`** — define reusable, static CSS objects.
|
|
85
|
+
- **`createStencil`** — define reusable, dynamic component styles with parts, vars, and modifiers
|
|
86
|
+
- **`cs` prop** — apply multiple styles and handle merges consistently to Canvas Kit components
|
|
87
|
+
|
|
88
|
+
### Best Practices
|
|
89
|
+
|
|
90
|
+
These best practices ensure your components remain **performant**, **consistent**, and
|
|
91
|
+
**maintainable** under the new Canvas Kit Styling system.
|
|
92
|
+
|
|
93
|
+
#### Define Styles Outside the Render Function
|
|
94
|
+
|
|
95
|
+
Always declare styles at the module level. Creating styles inside the render or component function
|
|
96
|
+
will trigger component re-render.
|
|
97
|
+
|
|
98
|
+
✅ **Do**
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
// `createStyles` returns a string of className
|
|
102
|
+
const buttonStyles = createStyles({
|
|
103
|
+
backgroundColor: system.color.bg.primary.default,
|
|
104
|
+
color: system.color.text.inverse,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
export const MyButton = () => <button className={buttonStyles}>Click me</button>;
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
❌ **Don’t**
|
|
111
|
+
|
|
112
|
+
```tsx
|
|
113
|
+
export const MyButton = () => {
|
|
114
|
+
const buttonStyles = createStyles({backgroundColor: 'red'}); // bad
|
|
115
|
+
return <button cs={buttonStyles}>Click me</button>;
|
|
116
|
+
};
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### Use `createStyles` for Static Styling
|
|
120
|
+
|
|
121
|
+
Use `createStyles` for simple, reusable style objects that do **not** depend on dynamic data or
|
|
122
|
+
props.
|
|
123
|
+
|
|
124
|
+
✅ Ideal for:
|
|
125
|
+
|
|
126
|
+
- Defining base styles
|
|
127
|
+
- Applying static overrides
|
|
128
|
+
- Styling tokens-based components
|
|
129
|
+
|
|
130
|
+
`createStyles` returns a string of className that can be applied to a React element. If you're
|
|
131
|
+
applying the class to a Canvas Kit component, you can use the `cs` prop.
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import {BaseButton} from '@workday/canvas-kit-react/button';
|
|
135
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
136
|
+
// `createStyles` returns a string of className
|
|
137
|
+
const buttonStyles = createStyles({
|
|
138
|
+
backgroundColor: system.color.bg.primary.default,
|
|
139
|
+
color: system.color.text.inverse,
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
export const MyButton = () => <BaseButton cs={buttonStyles}>Click me</button>;
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### Use `createStencil` for Dynamic or Complex Styling
|
|
146
|
+
|
|
147
|
+
Use `createStencil` when styles depend on **props**, **variants**, or **component parts**.
|
|
148
|
+
|
|
149
|
+
Examples:
|
|
150
|
+
|
|
151
|
+
- Size or color variants (`primary`, `secondary`)
|
|
152
|
+
- Compound state combinations (`size=small`, `iconPosition=end`)
|
|
153
|
+
- Multi-part components (e.g. `Button`, `Card`, `MenuItem`)
|
|
154
|
+
|
|
155
|
+
✅ **Do**
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
const buttonStencil = createStencil({
|
|
159
|
+
vars: {color: '', background: ''},
|
|
160
|
+
base: ({color, backgroundColor}) => ({
|
|
161
|
+
color: cssVar(color, system.color.text.default),
|
|
162
|
+
backgroundColor: cssVar(backgroundColor, system.color.bg.default),
|
|
163
|
+
}),
|
|
164
|
+
modifiers: {
|
|
165
|
+
variant: {
|
|
166
|
+
primary: {background: system.color.bg.primary.default},
|
|
167
|
+
secondary: {background: system.color.bg.muted.default},
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
- **vars**: If you initialize the variable with an empty string, it will allow the variable to
|
|
174
|
+
cascade and be defined.
|
|
175
|
+
|
|
176
|
+
```tsx
|
|
177
|
+
const customButtonStencil = createStencil({
|
|
178
|
+
base: {
|
|
179
|
+
// Set the color variable to the primary color
|
|
180
|
+
[buttonStencil.vars.color]: system.color.fg.primary.default,
|
|
181
|
+
},
|
|
182
|
+
});
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
- **cssVar**: The `cssVar` function is used when you want to add a default value if the CSS Variable
|
|
186
|
+
is not defined.
|
|
187
|
+
- **modifiers**: The `modifiers` property is used to define the styles for the different variants of
|
|
188
|
+
the component.
|
|
189
|
+
|
|
190
|
+
#### Use `cs` Prop to Merge Styles
|
|
191
|
+
|
|
192
|
+
The `cs` prop merges `className` and `style` attributes safely and consistently. Use this over using
|
|
193
|
+
style props or className concatenation.
|
|
194
|
+
|
|
195
|
+
✅ **Do**
|
|
196
|
+
|
|
197
|
+
```tsx
|
|
198
|
+
<PrimaryButton cs={[baseStyles, variantStyles]} />
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
❌ **Don’t**
|
|
202
|
+
|
|
203
|
+
```tsx
|
|
204
|
+
<PrimaryButton className={`${baseStyles} ${variantStyles}`} />
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
#### Use Variables for Dynamic Values
|
|
208
|
+
|
|
209
|
+
Instead of inline styles or runtime calculations, use stencil variables.
|
|
210
|
+
|
|
211
|
+
✅ **Do**
|
|
212
|
+
|
|
213
|
+
```tsx
|
|
214
|
+
const primaryButtonStencil = createStencil({
|
|
215
|
+
base: {
|
|
216
|
+
// Use the buttonStencil variable to set the background color
|
|
217
|
+
[buttonStencil.vars.background]: 'orange',
|
|
218
|
+
}
|
|
219
|
+
})
|
|
220
|
+
<PrimaryButton cs={primaryButtonStencil} />
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
❌ **Don’t**
|
|
224
|
+
|
|
225
|
+
```tsx
|
|
226
|
+
<PrimaryButton cs={{backgroundColor: 'orange'}} /> // breaks static optimization
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### Extend Existing Stencils Instead of Overriding Styles
|
|
230
|
+
|
|
231
|
+
When modifying Canvas Kit components, extend the provided `Stencil` instead of creating your own
|
|
232
|
+
from scratch.
|
|
233
|
+
|
|
234
|
+
✅ **Do**
|
|
235
|
+
|
|
236
|
+
```tsx
|
|
237
|
+
const customIconStencil = createStencil({
|
|
238
|
+
extends: systemIconStencil,
|
|
239
|
+
base: {
|
|
240
|
+
margin: system.space.x2,
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
This will inherit both the styles and variables from the `systemIconStencil`.
|
|
246
|
+
|
|
247
|
+
#### Use Modifiers for Variants and States
|
|
248
|
+
|
|
249
|
+
Define component variations (size, color, emphasis) using **modifiers** rather than conditional
|
|
250
|
+
logic.
|
|
251
|
+
|
|
252
|
+
✅ **Do**
|
|
253
|
+
|
|
254
|
+
```tsx
|
|
255
|
+
const badgeStencil = createStencil({
|
|
256
|
+
modifiers: {
|
|
257
|
+
status: {
|
|
258
|
+
success: {background: system.color.bg.success.default},
|
|
259
|
+
error: {background: system.color.bg.negative.default},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
});
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
#### Use Compound Modifiers for Complex Conditions
|
|
266
|
+
|
|
267
|
+
When two or more modifiers combine to produce a new style, define a **compound modifier**.
|
|
268
|
+
|
|
269
|
+
✅ **Do**
|
|
270
|
+
|
|
271
|
+
```tsx
|
|
272
|
+
const myCustomStencil = createStencil({
|
|
273
|
+
base: {
|
|
274
|
+
//base styles
|
|
275
|
+
},
|
|
276
|
+
modifiers: {
|
|
277
|
+
variant: {
|
|
278
|
+
primary: {
|
|
279
|
+
// primary variant styles
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
size: {
|
|
283
|
+
large: {
|
|
284
|
+
// large size styles
|
|
285
|
+
},
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
compound: [
|
|
289
|
+
{
|
|
290
|
+
// apply styles when the variant is primary AND the size is large
|
|
291
|
+
modifiers: {variant: 'primary', size: 'large'},
|
|
292
|
+
styles: {paddingInline: system.space.x5},
|
|
293
|
+
},
|
|
294
|
+
],
|
|
295
|
+
});
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### Avoid Nested Stencils Unless Necessary
|
|
299
|
+
|
|
300
|
+
Each Stencil should map to one semantic component. Nested stencils can increase CSS specificity and
|
|
301
|
+
complexity. Use **parts** instead of deep nesting.
|
|
302
|
+
|
|
303
|
+
✅ **Do**
|
|
304
|
+
|
|
305
|
+
```tsx
|
|
306
|
+
const cardStencil = createStencil({
|
|
307
|
+
parts: {header: 'card-header', body: 'card-body'},
|
|
308
|
+
base: ({headerPart}) => ({
|
|
309
|
+
[headerPart]: {
|
|
310
|
+
fontWeight: 'bold',
|
|
311
|
+
},
|
|
312
|
+
}),
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
<Card cs={cardStencil}>
|
|
316
|
+
<Card.Heading {...cardStencil.parts.header}>Card Title</Card.Heading>
|
|
317
|
+
<Card.Body {...cardStencil.parts.body}>Card Body</Card.Body>
|
|
318
|
+
</Card>;
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
#### Prefer Tokens and System Variables
|
|
322
|
+
|
|
323
|
+
Always use design tokens (`system`) for spacing, colors, typography, etc., instead of raw values.
|
|
324
|
+
View our System Tokens
|
|
325
|
+
[docs](https://workday.github.io/canvas-tokens/?path=/docs/docs-system-tokens-overview--docs) for
|
|
326
|
+
more information.
|
|
327
|
+
|
|
328
|
+
✅ **Do**
|
|
329
|
+
|
|
330
|
+
```tsx
|
|
331
|
+
color: system.color.text.default;
|
|
332
|
+
margin: system.space.x2;
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
❌ **Don’t**
|
|
336
|
+
|
|
337
|
+
```tsx
|
|
338
|
+
color: '#333';
|
|
339
|
+
margin: '8px';
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
#### Debugging and Static Compilation
|
|
343
|
+
|
|
344
|
+
- Enable static compilation during development to catch type or value errors early.
|
|
345
|
+
- Use `as const` for static objects to ensure values are type-locked for the compiler.
|
|
346
|
+
|
|
347
|
+
✅ **Do**
|
|
348
|
+
|
|
349
|
+
```tsx
|
|
350
|
+
const reusableStyles = {
|
|
351
|
+
position: 'absolute',
|
|
352
|
+
} as const;
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
#### Don’t Mix Emotion and Static Styling
|
|
356
|
+
|
|
357
|
+
Avoid combining Emotion’s `styled` or `css` with `createStyles` or `createStencil`. It reintroduces
|
|
358
|
+
runtime style recalculations and negates static benefits.
|
|
359
|
+
|
|
360
|
+
❌ **Don’t**
|
|
361
|
+
|
|
362
|
+
```tsx
|
|
363
|
+
const StyledButton = styled(Button)(styles);
|
|
364
|
+
<StyledButton cs={createStyles({padding: 8})} />;
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
## Migration Example
|
|
368
|
+
|
|
369
|
+
### Style Props
|
|
370
|
+
|
|
371
|
+
#### Before
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
375
|
+
|
|
376
|
+
<Flex depth={1} marginX={10} background="frenchVanilla100" />;
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
#### After
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
383
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
384
|
+
import {px2rem} from '@workday/canvas-kit-styling';
|
|
385
|
+
|
|
386
|
+
<Flex
|
|
387
|
+
cs={{
|
|
388
|
+
boxShadow: system.depth[1],
|
|
389
|
+
marginInline: px2rem(10),
|
|
390
|
+
background: system.color.bg.default,
|
|
391
|
+
}}
|
|
392
|
+
/>;
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
- **px2rem**: The `px2rem` function is used to convert a pixel value to a rem value.
|
|
396
|
+
- Use [CSS logical
|
|
397
|
+
properties](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_logical_properties_and_values
|
|
398
|
+
- Use `system` tokens over `base` tokens for better theming support.
|
|
399
|
+
|
|
400
|
+
### Emotion styled
|
|
401
|
+
|
|
402
|
+
#### Before (Emotion)
|
|
403
|
+
|
|
404
|
+
```tsx
|
|
405
|
+
const StyledButton = styled('button')({
|
|
406
|
+
backgroundColor: 'blue',
|
|
407
|
+
color: 'white',
|
|
408
|
+
});
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
#### After (Canvas Kit Styling)
|
|
412
|
+
|
|
413
|
+
```tsx
|
|
414
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
415
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
416
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
417
|
+
|
|
418
|
+
const primaryButtonStyles = createStyles({
|
|
419
|
+
backgroundColor: system.color.bg.primary.default,
|
|
420
|
+
color: system.color.text.inverse,
|
|
421
|
+
});
|
|
422
|
+
|
|
423
|
+
<PrimaryButton cs={primaryButtonStyles}>Click me</PrimaryButton>;
|
|
424
|
+
```
|
package/lib/ExampleCodeBlock.tsx
CHANGED
|
@@ -28,6 +28,9 @@ const cardStencil = createStencil({
|
|
|
28
28
|
position: 'relative',
|
|
29
29
|
overflow: 'auto', // This allows for the entire ExampleCodeBlock to scroll on smaller viewports
|
|
30
30
|
},
|
|
31
|
+
'[data-part="example-block-container"]': {
|
|
32
|
+
overflow: 'auto',
|
|
33
|
+
},
|
|
31
34
|
'[data-part="code-block"]': {
|
|
32
35
|
display: 'none',
|
|
33
36
|
boxShadow: system.depth[1],
|
|
@@ -125,7 +128,7 @@ export const ExampleCodeBlock = ({code}: any) => {
|
|
|
125
128
|
<div {...cardStencil({opened: isCodeDisplayed})}>
|
|
126
129
|
<Card data-part="example-block" className="sb-unstyled">
|
|
127
130
|
{/* This allows for the div to scroll on smaller viewports while not allowing the components to overflow over the container */}
|
|
128
|
-
<Card.Body
|
|
131
|
+
<Card.Body data-part="example-block-container">
|
|
129
132
|
<CanvasProvider className={defaultBranding}>
|
|
130
133
|
{React.createElement(code)}
|
|
131
134
|
{code && (
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "15.0.0-alpha.
|
|
3
|
+
"version": "15.0.0-alpha.1303-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",
|
|
@@ -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": "^15.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-react": "^15.0.0-alpha.
|
|
51
|
-
"@workday/canvas-kit-styling": "^15.0.0-alpha.
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^15.0.0-alpha.1303-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.1303-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^15.0.0-alpha.1303-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^15.0.0-alpha.1303-next.0",
|
|
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": "
|
|
64
|
+
"gitHead": "4dc1e2083d2767fd402c2d014bedd8b35a014490"
|
|
65
65
|
}
|