@workday/canvas-kit-docs 14.2.0-0044-next.0 → 14.2.0-0052-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 +3 -7
- 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 +1 -1
- package/dist/mdx/react/common/mdx/Theming.mdx +16 -31
- package/dist/mdx/react/common/mdx/examples/Theming.tsx +25 -7
- package/dist/mdx/style-props/stylePropsMigrationOverview.mdx +1 -1
- package/dist/mdx/tokens/TokenMigrationOverview.mdx +1 -1
- package/package.json +6 -6
package/dist/es6/lib/docs.js
CHANGED
|
@@ -202477,16 +202477,14 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
|
|
|
202477
202477
|
"name": "PartialEmotionCanvasTheme",
|
|
202478
202478
|
"value": "PartialEmotionCanvasTheme"
|
|
202479
202479
|
},
|
|
202480
|
-
"description": "",
|
|
202480
|
+
"description": "⚠️ Only use this prop if you intent to to theme a part of your application that is different from global theming.\nFor more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#global-vs-scoped-theming).\n\nWhile we support theme overrides, we advise to use global theming via CSS Variables.",
|
|
202481
202481
|
"declarations": [
|
|
202482
202482
|
{
|
|
202483
202483
|
"name": "theme",
|
|
202484
202484
|
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/CanvasProvider.tsx"
|
|
202485
202485
|
}
|
|
202486
202486
|
],
|
|
202487
|
-
"tags": {
|
|
202488
|
-
"deprecated": "⚠️ `theme` is deprecated. In previous versions of Canvas Kit, we allowed teams to pass a theme object, this supported [Emotion's theming](https://emotion.sh/docs/theming). Now that we're shifting to a global theming approach based on CSS variables, we advise to no longer using the theme prop. For more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#-preferred-approach-v14)."
|
|
202489
|
-
}
|
|
202487
|
+
"tags": {}
|
|
202490
202488
|
}
|
|
202491
202489
|
]
|
|
202492
202490
|
}
|
|
@@ -205386,9 +205384,7 @@ export const docs = (typeof window !== 'undefined' && window.__docs) ||
|
|
|
205386
205384
|
"filePath": "/home/runner/work/canvas-kit/canvas-kit/modules/react/common/lib/theming/types.ts"
|
|
205387
205385
|
}
|
|
205388
205386
|
],
|
|
205389
|
-
"tags": {
|
|
205390
|
-
"deprecated": "⚠️ `PartialEmotionCanvasTheme` is deprecated. In previous versions of Canvas Kit, we allowed teams to pass a theme object, this supported [Emotion's theming](https://emotion.sh/docs/theming). Now that we're shifting to a global theming approach based on CSS variables, we advise to no longer using the theme prop. For more information, view our [Theming Docs](https://workday.github.io/canvas-kit/?path=/docs/features-theming-overview--docs#-preferred-approach-v14)."
|
|
205391
|
-
},
|
|
205387
|
+
"tags": {},
|
|
205392
205388
|
"type": {
|
|
205393
205389
|
"kind": "object",
|
|
205394
205390
|
"properties": [
|
|
@@ -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.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.1.
|
|
23
|
-
"@workday/canvas-kit-react": "14.1.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.1.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.1.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.1.27",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.1.27",
|
|
23
|
+
"@workday/canvas-kit-react": "14.1.27",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.1.27",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.1.27",
|
|
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.
|
|
22
|
-
"@workday/canvas-kit-preview-react": "14.1.
|
|
23
|
-
"@workday/canvas-kit-react": "14.1.
|
|
24
|
-
"@workday/canvas-kit-react-fonts": "^14.1.
|
|
25
|
-
"@workday/canvas-kit-styling": "14.1.
|
|
21
|
+
"@workday/canvas-kit-labs-react": "14.1.27",
|
|
22
|
+
"@workday/canvas-kit-preview-react": "14.1.27",
|
|
23
|
+
"@workday/canvas-kit-react": "14.1.27",
|
|
24
|
+
"@workday/canvas-kit-react-fonts": "^14.1.27",
|
|
25
|
+
"@workday/canvas-kit-styling": "14.1.27",
|
|
26
26
|
"@workday/canvas-system-icons-web": "3.0.36",
|
|
27
27
|
"@workday/canvas-tokens-web": "3.1.2"
|
|
28
28
|
},
|
|
@@ -83,7 +83,7 @@ input for LLMs to automate and assist with your migration process.
|
|
|
83
83
|
migration
|
|
84
84
|
|
|
85
85
|
<DownloadLLMFile
|
|
86
|
-
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm
|
|
86
|
+
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm/llm-canvas-kit-upgrade-guide-v14.txt"
|
|
87
87
|
filename="llm-canvas-kit-upgrade-guide-v14.txt"
|
|
88
88
|
/>
|
|
89
89
|
|
|
@@ -5,14 +5,19 @@ import Theming from './examples/Theming';
|
|
|
5
5
|
|
|
6
6
|
# Canvas Kit Theming Guide
|
|
7
7
|
|
|
8
|
-
> **Deprecation Notice:** The `theme` prop on `CanvasProvider` and all associated theming utilities (`useTheme`, `getTheme`, `styled`, `defaultCanvasTheme`, etc.) are deprecated. Please use CSS variables from `@workday/canvas-tokens-web` for theming. See the [Preferred Approach](#-preferred-approach-v14) section below.
|
|
9
|
-
|
|
10
8
|
## Overview
|
|
11
9
|
|
|
12
10
|
Canvas Kit v14 introduces a significant shift in our approach to theming: we've moved away from
|
|
13
11
|
JavaScript-based theme objects to CSS variables. This change provides better performance, improved
|
|
14
12
|
developer experience, and greater flexibility for theming applications.
|
|
15
13
|
|
|
14
|
+
> **📌 Quick Start:**
|
|
15
|
+
> 1. **Import CSS variables once** at the root level of your application (e.g., in `index.css`)
|
|
16
|
+
> 2. **Override tokens at `:root`** for global theming — this is the recommended approach
|
|
17
|
+
> 3. **Use `CanvasProvider` scoped theming only** for specific scenarios like multi-brand sections or embedded components
|
|
18
|
+
>
|
|
19
|
+
> If your application renders within an environment that already imports these CSS variables, **do not re-import them**.
|
|
20
|
+
|
|
16
21
|
## Migration from v10 Theme Prop to v14 CSS Variables
|
|
17
22
|
|
|
18
23
|
### The Evolution
|
|
@@ -49,6 +54,8 @@ via a `className` scoping those brand variables to a wrapping div. In order for
|
|
|
49
54
|
better solution to theming that is scalable and is more aligned with our CSS variables, we changed
|
|
50
55
|
this approach.
|
|
51
56
|
|
|
57
|
+
**Note:** While we support theme overrides, we advise to use global theming via CSS Variables.
|
|
58
|
+
|
|
52
59
|
## What is a Cascade Barrier?
|
|
53
60
|
|
|
54
61
|
When we say "cascade barrier", we're talking about how
|
|
@@ -71,6 +78,8 @@ and scoped to the `div` that the `CanvasProvider` created. This meant that anyth
|
|
|
71
78
|
or outside of the `CanvasProvider` would not be able to cascade down to the components within the
|
|
72
79
|
`CanvasProvider`.
|
|
73
80
|
|
|
81
|
+
If you provide a `theme` to the `CanvasProvider`, it will create a scoped theme. Note that in v14, global CSS variables are the recommended way to theme Popups and Modals consistently.
|
|
82
|
+
|
|
74
83
|
## Global vs Scoped Theming
|
|
75
84
|
|
|
76
85
|
Canvas Kit v14 supports two theming strategies: **global theming** and **scoped theming**. Understanding the difference is important to avoid unexpected behavior.
|
|
@@ -80,7 +89,9 @@ Canvas Kit v14 supports two theming strategies: **global theming** and **scoped
|
|
|
80
89
|
Global theming applies CSS variables at the `:root` level, making them available throughout your entire application. This is the **recommended approach** for most use cases.
|
|
81
90
|
|
|
82
91
|
```css
|
|
92
|
+
@import '@workday/canvas-tokens-web/css/base/_variables.css';
|
|
83
93
|
:root {
|
|
94
|
+
// This is showing how you can change the value of a token at the root level of your application.
|
|
84
95
|
--cnvs-brand-primary-base: var(--cnvs-base-palette-magenta-600);
|
|
85
96
|
}
|
|
86
97
|
```
|
|
@@ -90,13 +101,13 @@ Global theming applies CSS variables at the `:root` level, making them available
|
|
|
90
101
|
Scoped theming applies CSS variables to a specific section of your application using the `CanvasProvider` with either a `className` or `theme` prop. The theme only affects components within that provider.
|
|
91
102
|
|
|
92
103
|
```tsx
|
|
93
|
-
// Using the theme prop for scoped theming
|
|
104
|
+
// Using the theme prop for scoped theming. This will set the [brand.primary.**] tokens to shades of purple.
|
|
94
105
|
<CanvasProvider theme={{canvas: {palette: {primary: {main: 'purple'}}}}}>
|
|
95
106
|
<ScopedSection />
|
|
96
107
|
</CanvasProvider>
|
|
97
108
|
```
|
|
98
109
|
|
|
99
|
-
> **⚠️ Warning:** Scoped theming creates a cascade barrier that **will break global theming
|
|
110
|
+
> **⚠️ Warning:** Scoped theming creates a cascade barrier that **will break global theming**. Any CSS variables defined at `:root` will be overridden by the scoped theme. Only the tokens explicitly defined in the `theme` prop will be changed - other tokens will use their default values, not your global overrides.
|
|
100
111
|
|
|
101
112
|
### When to Use Scoped Theming
|
|
102
113
|
|
|
@@ -178,13 +189,10 @@ const themedBrand = createStyles({
|
|
|
178
189
|
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.
|
|
179
190
|
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.
|
|
180
191
|
|
|
181
|
-
> **Important:** Passing a `theme` to the `CanvasProvider` **will not** theme components in Modals
|
|
182
|
-
> and Dialogs. You can either pass a `className` or define CSS variables at the root.
|
|
183
|
-
|
|
184
192
|
**Before in v13**
|
|
185
193
|
|
|
186
194
|
```tsx
|
|
187
|
-
// 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
|
|
195
|
+
// 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 defined at the root.
|
|
188
196
|
<CanvasProvider theme={{canvas: {palette: {primary: {main: 'blue'}}}}}>
|
|
189
197
|
<Modal>//... rest of modal code</Modal>
|
|
190
198
|
</CanvasProvider>
|
|
@@ -261,29 +269,6 @@ System tokens define component-specific values.
|
|
|
261
269
|
}
|
|
262
270
|
```
|
|
263
271
|
|
|
264
|
-
### App-Specific Theming
|
|
265
|
-
|
|
266
|
-
```tsx
|
|
267
|
-
import {createStyles} from '@workday/canvas-kit-styling';
|
|
268
|
-
import {brand, base} from '@workday/canvas-tokens-web';
|
|
269
|
-
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
270
|
-
import {CanvasProvider} from '@workday/canvas-kit-react/common';
|
|
271
|
-
|
|
272
|
-
const greenTheme = createStyles({
|
|
273
|
-
[brand.primary.base]: base.green600,
|
|
274
|
-
[brand.primary.dark]: base.green700,
|
|
275
|
-
[brand.primary.darkest]: base.green800,
|
|
276
|
-
[brand.primary.light]: base.green200,
|
|
277
|
-
[brand.primary.lighter]: base.green50,
|
|
278
|
-
[brand.primary.lightest]: base.green25,
|
|
279
|
-
[brand.primary.accent]: base.neutral0,
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
<CanvasProvider className={greenTheme}>
|
|
283
|
-
<PrimaryButton>Click me</PrimaryButton>
|
|
284
|
-
</CanvasProvider>;
|
|
285
|
-
```
|
|
286
|
-
|
|
287
272
|
<ExampleCodeBlock code={Theming} />
|
|
288
273
|
|
|
289
274
|
### Dark Mode Implementation
|
|
@@ -15,13 +15,31 @@ const customTheme = createStyles({
|
|
|
15
15
|
|
|
16
16
|
const App = () => {
|
|
17
17
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
<CanvasProvider
|
|
19
|
+
theme={{
|
|
20
|
+
canvas: {
|
|
21
|
+
palette: {
|
|
22
|
+
primary: {
|
|
23
|
+
main: base.green600,
|
|
24
|
+
dark: base.green700,
|
|
25
|
+
darkest: base.green800,
|
|
26
|
+
light: base.green200,
|
|
27
|
+
lighter: base.green50,
|
|
28
|
+
lightest: base.green25,
|
|
29
|
+
contrast: base.neutral0,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
<Card>
|
|
36
|
+
<Card.Heading>Theming</Card.Heading>
|
|
37
|
+
<Card.Body>
|
|
38
|
+
<PrimaryButton>Theming</PrimaryButton>
|
|
39
|
+
<input />
|
|
40
|
+
</Card.Body>
|
|
41
|
+
</Card>
|
|
42
|
+
</CanvasProvider>
|
|
25
43
|
);
|
|
26
44
|
};
|
|
27
45
|
|
|
@@ -48,7 +48,7 @@ assist with your migration process.
|
|
|
48
48
|
migration
|
|
49
49
|
|
|
50
50
|
<DownloadLLMFile
|
|
51
|
-
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm
|
|
51
|
+
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm/llm-style-props-migration.txt"
|
|
52
52
|
filename="llm-style-props-migration.txt"
|
|
53
53
|
/>
|
|
54
54
|
|
|
@@ -41,7 +41,7 @@ LLM consumption.
|
|
|
41
41
|
migration
|
|
42
42
|
|
|
43
43
|
<DownloadLLMFile
|
|
44
|
-
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm
|
|
44
|
+
rawFileLink="https://raw.githubusercontent.com/Workday/canvas-kit/master/modules/docs/llm/llm-token-migration-14.txt"
|
|
45
45
|
filename="llm-token-migration-14.0.0.txt"
|
|
46
46
|
/>
|
|
47
47
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "14.2.0-
|
|
3
|
+
"version": "14.2.0-0052-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": "^14.2.0-
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^14.2.0-
|
|
50
|
-
"@workday/canvas-kit-react": "^14.2.0-
|
|
51
|
-
"@workday/canvas-kit-styling": "^14.2.0-
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^14.2.0-0052-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^14.2.0-0052-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^14.2.0-0052-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^14.2.0-0052-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": "b1fc1f892afd637a9840c355759407aa0b579878"
|
|
65
65
|
}
|