@workday/canvas-kit-docs 15.0.0-alpha.0056-next.0 → 15.0.0-alpha.0060-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/StorybookStatusIndicator.d.ts +1 -1
- package/dist/es6/lib/StorybookStatusIndicator.d.ts.map +1 -1
- package/dist/es6/lib/StorybookStatusIndicator.js +12 -14
- package/dist/es6/lib/docs.js +3406 -100
- 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/labs-react/side-panel/SidePanel.mdx +256 -0
- package/dist/mdx/labs-react/side-panel/examples/AlwaysOpen.tsx +52 -0
- package/dist/mdx/labs-react/side-panel/examples/Basic.tsx +55 -0
- package/dist/mdx/labs-react/side-panel/examples/ExternalControl.tsx +75 -0
- package/dist/mdx/labs-react/side-panel/examples/HiddenName.tsx +41 -0
- package/dist/mdx/labs-react/side-panel/examples/OnStateTransition.tsx +49 -0
- package/dist/mdx/labs-react/side-panel/examples/RightOrigin.tsx +73 -0
- package/dist/mdx/labs-react/side-panel/examples/Variant.tsx +60 -0
- package/dist/mdx/labs-react/side-panel/examples/useDirection.ts +23 -0
- package/dist/mdx/preview-react/side-panel/SidePanel.mdx +15 -3
- 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/lib/StorybookStatusIndicator.tsx +17 -14
- package/package.json +6 -6
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
2
|
+
import {SidePanel, useSidePanelModel} from '@workday/canvas-kit-labs-react/side-panel';
|
|
3
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import {Heading, Text} from '@workday/canvas-kit-react/text';
|
|
5
|
+
import {CanvasProvider} from '@workday/canvas-kit-react/common';
|
|
6
|
+
import {createStyles, px2rem} from '@workday/canvas-kit-styling';
|
|
7
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
8
|
+
|
|
9
|
+
// local helper hook for setting content direction;
|
|
10
|
+
import {useDirection} from './useDirection';
|
|
11
|
+
|
|
12
|
+
const stylesOverride = {
|
|
13
|
+
viewport: createStyles({
|
|
14
|
+
height: px2rem(320),
|
|
15
|
+
backgroundColor: system.color.bg.alt.default,
|
|
16
|
+
}),
|
|
17
|
+
panel: createStyles({
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
padding: system.space.x4,
|
|
20
|
+
}),
|
|
21
|
+
main: createStyles({
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
justifyContent: 'center',
|
|
24
|
+
flexDirection: 'column',
|
|
25
|
+
flex: 1,
|
|
26
|
+
flexBasis: 'auto',
|
|
27
|
+
}),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default () => {
|
|
31
|
+
const {direction, toggleDirection} = useDirection();
|
|
32
|
+
const model = useSidePanelModel({});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<CanvasProvider dir={direction}>
|
|
36
|
+
<Flex cs={stylesOverride.viewport}>
|
|
37
|
+
<SidePanel model={model} variant="alternate">
|
|
38
|
+
<SidePanel.ToggleButton />
|
|
39
|
+
<Flex cs={stylesOverride.panel}>
|
|
40
|
+
<Heading
|
|
41
|
+
size="small"
|
|
42
|
+
hidden={model.state.transitionState === 'collapsed' ? true : undefined}
|
|
43
|
+
id={model.state.labelId}
|
|
44
|
+
>
|
|
45
|
+
Alternate Panel
|
|
46
|
+
</Heading>
|
|
47
|
+
</Flex>
|
|
48
|
+
</SidePanel>
|
|
49
|
+
<Flex as="main" cs={stylesOverride.main}>
|
|
50
|
+
<Text as="p" typeLevel="body.large">
|
|
51
|
+
Toggle the content direction
|
|
52
|
+
</Text>
|
|
53
|
+
<SecondaryButton onClick={toggleDirection}>
|
|
54
|
+
Set to {direction === 'ltr' ? 'Right-to-Left' : 'Left-to-Right'}
|
|
55
|
+
</SecondaryButton>
|
|
56
|
+
</Flex>
|
|
57
|
+
</Flex>
|
|
58
|
+
</CanvasProvider>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {ContentDirection} from '@workday/canvas-kit-react/common';
|
|
3
|
+
|
|
4
|
+
export function useDirection(initialDirection = ContentDirection.LTR) {
|
|
5
|
+
const [direction, setDirection] = React.useState(initialDirection);
|
|
6
|
+
|
|
7
|
+
return {
|
|
8
|
+
direction,
|
|
9
|
+
toggleDirection() {
|
|
10
|
+
if (direction === ContentDirection.LTR) {
|
|
11
|
+
setDirection(ContentDirection.RTL);
|
|
12
|
+
} else {
|
|
13
|
+
setDirection(ContentDirection.LTR);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
setLTR() {
|
|
17
|
+
setDirection(ContentDirection.LTR);
|
|
18
|
+
},
|
|
19
|
+
setRTL() {
|
|
20
|
+
setDirection(ContentDirection.RTL);
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {ExampleCodeBlock, SymbolDoc, Specifications} from '@workday/canvas-kit-docs';
|
|
1
|
+
import {ExampleCodeBlock, SymbolDoc, Specifications, StorybookStatusIndicator} from '@workday/canvas-kit-docs';import {InformationHighlight} from '@workday/canvas-kit-react/information-highlight'
|
|
2
|
+
|
|
2
3
|
import Basic from './examples/Basic';
|
|
3
4
|
import HiddenName from './examples/HiddenName';
|
|
4
5
|
import AlternatePanel from './examples/Variant';
|
|
@@ -9,9 +10,20 @@ import OnExpandedChange from './examples/OnExpandedChange';
|
|
|
9
10
|
import OnStateTransition from './examples/OnStateTransition';
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
# Canvas Kit Side Panel
|
|
13
|
+
# Canvas Kit Side Panel <StorybookStatusIndicator type="deprecated" />
|
|
14
|
+
|
|
15
|
+
<InformationHighlight className="sb-unstyled" variant="caution" cs={{p: {marginBlock: 0}}}>
|
|
16
|
+
<InformationHighlight.Icon />
|
|
17
|
+
<InformationHighlight.Body>
|
|
18
|
+
`SidePanel` in Preview has been deprecated and will be removed in a future major version. Please
|
|
19
|
+
use `SidePanel` in Labs instead.
|
|
20
|
+
</InformationHighlight.Body>
|
|
21
|
+
<InformationHighlight.Link href="https://workday.github.io/canvas-kit/?path=/docs/labs-side-panel--docs">
|
|
22
|
+
View SidePanel Docs
|
|
23
|
+
</InformationHighlight.Link>
|
|
24
|
+
</InformationHighlight>
|
|
13
25
|
|
|
14
|
-
`SidePanel` is a
|
|
26
|
+
`SidePanel` is a collapsible container that anchors to the left or right side of the screen.
|
|
15
27
|
|
|
16
28
|
[> Workday Design Reference](https://design.workday.com/components/containers/side-panel)
|
|
17
29
|
|
|
@@ -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
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
StatusIndicator,
|
|
3
|
+
type StatusIndicatorVariant,
|
|
4
|
+
} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
2
5
|
import {system} from '@workday/canvas-tokens-web';
|
|
3
6
|
import {sparkleSingleSmallIcon} from '@workday/canvas-system-icons-web';
|
|
4
7
|
import {createStencil} from '@workday/canvas-kit-styling';
|
|
@@ -10,18 +13,6 @@ const storybookStatusIndicatorStencil = createStencil({
|
|
|
10
13
|
padding: `${system.space.zero} ${system.space.x2}`,
|
|
11
14
|
[systemIconStencil.vars.color]: 'currentColor',
|
|
12
15
|
},
|
|
13
|
-
modifiers: {
|
|
14
|
-
type: {
|
|
15
|
-
ai: {
|
|
16
|
-
background: system.color.bg.ai.default,
|
|
17
|
-
color: system.color.fg.ai,
|
|
18
|
-
},
|
|
19
|
-
deprecated: {
|
|
20
|
-
background: system.color.static.amber.soft,
|
|
21
|
-
color: system.color.static.amber.stronger,
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
16
|
});
|
|
26
17
|
|
|
27
18
|
const content = {
|
|
@@ -33,14 +24,26 @@ const content = {
|
|
|
33
24
|
icon: undefined,
|
|
34
25
|
label: 'Deprecated',
|
|
35
26
|
},
|
|
27
|
+
new: {
|
|
28
|
+
icon: undefined,
|
|
29
|
+
label: 'New',
|
|
30
|
+
},
|
|
36
31
|
};
|
|
37
32
|
|
|
38
|
-
export const StorybookStatusIndicator = ({type}: {type: 'ai' | 'deprecated'}) => {
|
|
33
|
+
export const StorybookStatusIndicator = ({type}: {type: 'ai' | 'deprecated' | 'new'}) => {
|
|
39
34
|
const {icon, label} = content[type];
|
|
35
|
+
const variantMapping = {
|
|
36
|
+
ai: 'ai',
|
|
37
|
+
deprecated: 'caution',
|
|
38
|
+
new: 'positive',
|
|
39
|
+
};
|
|
40
|
+
console.log(variantMapping[type]);
|
|
40
41
|
return (
|
|
41
42
|
<StatusIndicator
|
|
42
43
|
className="sb-unstyled cnvs-title-status-indicator"
|
|
43
44
|
cs={storybookStatusIndicatorStencil({type})}
|
|
45
|
+
variant={variantMapping[type] as StatusIndicatorVariant}
|
|
46
|
+
emphasis="low"
|
|
44
47
|
>
|
|
45
48
|
{icon && <StatusIndicator.Icon icon={icon} />}
|
|
46
49
|
<StatusIndicator.Label>{label}</StatusIndicator.Label>
|
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.0060-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.0060-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^15.0.0-alpha.0060-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^15.0.0-alpha.0060-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^15.0.0-alpha.0060-next.0",
|
|
52
52
|
"@workday/canvas-system-icons-web": "^3.0.36",
|
|
53
53
|
"@workday/canvas-tokens-web": "4.0.0-alpha.3",
|
|
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": "34d5076dcc1f6b3d605fc3bf5b36ce5f97917686"
|
|
65
65
|
}
|