@workday/canvas-kit-docs 14.0.0-alpha.1149-next.0 → 14.0.0-alpha.1153-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 +55 -16
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
- package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
- package/dist/mdx/styling/mdx/CreateStyles.mdx +111 -0
- package/dist/mdx/styling/mdx/CustomizingStyles.mdx +179 -0
- package/dist/mdx/styling/mdx/FromEmotion.mdx +178 -0
- package/dist/mdx/styling/mdx/MergingStyles.mdx +164 -0
- package/dist/mdx/styling/mdx/Overview.mdx +254 -0
- package/dist/mdx/styling/mdx/Stencils.mdx +459 -0
- package/dist/mdx/styling/mdx/Utilities.mdx +246 -0
- package/dist/mdx/styling/mdx/WhyCanvasStyling.mdx +136 -0
- package/dist/mdx/styling/mdx/examples/CSProp.tsx +36 -0
- package/dist/mdx/styling/mdx/examples/CreateModifiers.tsx +27 -0
- package/dist/mdx/styling/mdx/examples/CreateStencil.tsx +63 -0
- package/dist/mdx/styling/mdx/examples/CreateStyles.tsx +13 -0
- package/dist/mdx/styling/mdx/examples/CreateVars.tsx +20 -0
- package/dist/mdx/styling/mdx/examples/CustomButton.tsx +69 -0
- package/dist/mdx/styling/mdx/examples/CustomIcon.tsx +23 -0
- package/dist/mdx/styling/mdx/examples/EmotionButton.tsx +111 -0
- package/dist/mdx/styling/mdx/examples/ManualStylesButton.tsx +107 -0
- package/dist/mdx/styling/mdx/examples/StyledButton.tsx +31 -0
- package/dist/mdx/styling/mdx/examples/StylingButton.tsx +107 -0
- package/dist/mdx/styling/mdx/examples/StylingOverrides.tsx +158 -0
- package/package.json +6 -6
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createStyles, createModifiers, createVars, cssVar} from '@workday/canvas-kit-styling';
|
|
3
|
+
|
|
4
|
+
interface ButtonProps {
|
|
5
|
+
variant: 'primary' | 'secondary' | 'danger';
|
|
6
|
+
size: 'large' | 'medium' | 'small';
|
|
7
|
+
backgroundColor?: string;
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const variables = createVars('backgroundColor');
|
|
12
|
+
|
|
13
|
+
const baseStyles = createStyles({
|
|
14
|
+
fontSize: '1rem',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
borderRadius: '1rem',
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const modifierStyles = createModifiers({
|
|
20
|
+
variant: {
|
|
21
|
+
primary: createStyles({
|
|
22
|
+
background: cssVar(variables.backgroundColor, 'blue'),
|
|
23
|
+
color: 'white',
|
|
24
|
+
}),
|
|
25
|
+
secondary: createStyles({
|
|
26
|
+
background: cssVar(variables.backgroundColor, 'gray'),
|
|
27
|
+
}),
|
|
28
|
+
danger: createStyles({
|
|
29
|
+
background: cssVar(variables.backgroundColor, 'red'),
|
|
30
|
+
}),
|
|
31
|
+
},
|
|
32
|
+
size: {
|
|
33
|
+
large: createStyles({
|
|
34
|
+
fontSize: '1.4rem',
|
|
35
|
+
height: '2rem',
|
|
36
|
+
}),
|
|
37
|
+
medium: createStyles({
|
|
38
|
+
fontSize: '1rem',
|
|
39
|
+
height: '1.5rem',
|
|
40
|
+
}),
|
|
41
|
+
small: createStyles({
|
|
42
|
+
fontSize: '0.8rem',
|
|
43
|
+
height: '1.2rem',
|
|
44
|
+
}),
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
const Button = ({variant, size, backgroundColor, children}: ButtonProps) => {
|
|
49
|
+
const className = [baseStyles, modifierStyles({variant, size})].join(' ');
|
|
50
|
+
const style = variables({backgroundColor});
|
|
51
|
+
return (
|
|
52
|
+
<button className={className} style={style}>
|
|
53
|
+
{children}
|
|
54
|
+
</button>
|
|
55
|
+
);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default () => {
|
|
59
|
+
return (
|
|
60
|
+
<div style={{display: 'flex', flexDirection: 'column', gap: '1rem'}}>
|
|
61
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
62
|
+
<Button variant="primary" size="large">
|
|
63
|
+
Primary Large
|
|
64
|
+
</Button>
|
|
65
|
+
<Button variant="primary" size="medium">
|
|
66
|
+
Primary Medium
|
|
67
|
+
</Button>
|
|
68
|
+
<Button variant="primary" size="small">
|
|
69
|
+
Primary Small
|
|
70
|
+
</Button>
|
|
71
|
+
</div>
|
|
72
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
73
|
+
<Button variant="secondary" size="large">
|
|
74
|
+
Secondary Large
|
|
75
|
+
</Button>
|
|
76
|
+
<Button variant="secondary" size="medium">
|
|
77
|
+
Secondary Medium
|
|
78
|
+
</Button>
|
|
79
|
+
<Button variant="secondary" size="small">
|
|
80
|
+
Secondary Small
|
|
81
|
+
</Button>
|
|
82
|
+
</div>
|
|
83
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
84
|
+
<Button variant="danger" size="large">
|
|
85
|
+
Danger Large
|
|
86
|
+
</Button>
|
|
87
|
+
<Button variant="danger" size="medium">
|
|
88
|
+
Danger Medium
|
|
89
|
+
</Button>
|
|
90
|
+
<Button variant="danger" size="small">
|
|
91
|
+
Danger Small
|
|
92
|
+
</Button>
|
|
93
|
+
</div>
|
|
94
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
95
|
+
<Button variant="danger" size="large" backgroundColor="orange">
|
|
96
|
+
Custom Large
|
|
97
|
+
</Button>
|
|
98
|
+
<Button variant="danger" size="medium" backgroundColor="orange">
|
|
99
|
+
Custom Medium
|
|
100
|
+
</Button>
|
|
101
|
+
<Button variant="danger" size="small" backgroundColor="orange">
|
|
102
|
+
Custom Small
|
|
103
|
+
</Button>
|
|
104
|
+
</div>
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
3
|
+
import {jsx} from '@emotion/react';
|
|
4
|
+
|
|
5
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
6
|
+
import {PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
7
|
+
import {base} from '@workday/canvas-tokens-web';
|
|
8
|
+
import {createStyles, cssVar} from '@workday/canvas-kit-styling';
|
|
9
|
+
|
|
10
|
+
const backgroundColors = {
|
|
11
|
+
cssProp: cssVar(base.orange500),
|
|
12
|
+
styledComponent: cssVar(base.green500),
|
|
13
|
+
styleProps: cssVar(base.pink500),
|
|
14
|
+
createStyles: cssVar(base.purple500),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const StyledPrimaryButton = styled(PrimaryButton)({
|
|
18
|
+
backgroundColor: backgroundColors.styledComponent,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const styles = createStyles({
|
|
22
|
+
backgroundColor: backgroundColors.createStyles,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const CSSProp = () => (
|
|
26
|
+
<div
|
|
27
|
+
style={{
|
|
28
|
+
color: 'white',
|
|
29
|
+
padding: '0 4px',
|
|
30
|
+
height: 40,
|
|
31
|
+
width: 100,
|
|
32
|
+
backgroundColor: backgroundColors.cssProp,
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
CSS Prop
|
|
36
|
+
</div>
|
|
37
|
+
);
|
|
38
|
+
const StyledComponent = () => (
|
|
39
|
+
<div
|
|
40
|
+
style={{
|
|
41
|
+
color: 'white',
|
|
42
|
+
padding: '0 4px',
|
|
43
|
+
height: 40,
|
|
44
|
+
width: 100,
|
|
45
|
+
backgroundColor: backgroundColors.styledComponent,
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
Styled Component
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
const CreateStyles = () => (
|
|
52
|
+
<div
|
|
53
|
+
style={{
|
|
54
|
+
color: 'white',
|
|
55
|
+
padding: '0 4px',
|
|
56
|
+
height: 40,
|
|
57
|
+
width: 100,
|
|
58
|
+
backgroundColor: backgroundColors.createStyles,
|
|
59
|
+
}}
|
|
60
|
+
>
|
|
61
|
+
createStyles
|
|
62
|
+
</div>
|
|
63
|
+
);
|
|
64
|
+
const StyleProps = () => (
|
|
65
|
+
<div
|
|
66
|
+
style={{
|
|
67
|
+
color: 'white',
|
|
68
|
+
padding: '0 4px',
|
|
69
|
+
height: 40,
|
|
70
|
+
width: 100,
|
|
71
|
+
backgroundColor: backgroundColors.styleProps,
|
|
72
|
+
}}
|
|
73
|
+
>
|
|
74
|
+
Style Props
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// We use this object and cast to `{}` to keep TypeScript happy. Emotion extends the JSX interface
|
|
79
|
+
// to include the `css` prop, but the `jsx` function type doesn't accept the `css` prop. Casting to
|
|
80
|
+
// an empty object keeps TypeScript happy and the `css` prop is valid at runtime.
|
|
81
|
+
const cssProp = {css: {backgroundColor: backgroundColors.cssProp}} as {};
|
|
82
|
+
|
|
83
|
+
export default () => {
|
|
84
|
+
return (
|
|
85
|
+
<Flex flexDirection="column" minHeight="100vh" gap="s">
|
|
86
|
+
<Flex flexDirection="column" gap="s">
|
|
87
|
+
<h2>Buttons</h2>
|
|
88
|
+
<Flex flexDirection="row" gap="s">
|
|
89
|
+
<PrimaryButton cs={styles}>createStyles</PrimaryButton>
|
|
90
|
+
{jsx(PrimaryButton, {...cssProp}, 'CSS Prop')}
|
|
91
|
+
<StyledPrimaryButton>Styled Component</StyledPrimaryButton>
|
|
92
|
+
<PrimaryButton backgroundColor={backgroundColors.styleProps}>Style Props</PrimaryButton>
|
|
93
|
+
</Flex>
|
|
94
|
+
<div>
|
|
95
|
+
{jsx(
|
|
96
|
+
PrimaryButton,
|
|
97
|
+
{
|
|
98
|
+
...cssProp,
|
|
99
|
+
cs: styles,
|
|
100
|
+
},
|
|
101
|
+
'createStyles + CSS Prop'
|
|
102
|
+
)}
|
|
103
|
+
</div>
|
|
104
|
+
<div>
|
|
105
|
+
<StyledPrimaryButton cs={styles}>createStyles + Styled Component</StyledPrimaryButton>
|
|
106
|
+
</div>
|
|
107
|
+
<div>
|
|
108
|
+
<PrimaryButton cs={styles} backgroundColor={backgroundColors.styleProps}>
|
|
109
|
+
createStyles + Style Props
|
|
110
|
+
</PrimaryButton>
|
|
111
|
+
</div>
|
|
112
|
+
<div>
|
|
113
|
+
<StyledPrimaryButton backgroundColor={backgroundColors.styleProps} cs={styles}>
|
|
114
|
+
createStyles + Styled Component + Style Props
|
|
115
|
+
</StyledPrimaryButton>
|
|
116
|
+
</div>
|
|
117
|
+
<div>
|
|
118
|
+
{jsx(
|
|
119
|
+
StyledPrimaryButton,
|
|
120
|
+
{
|
|
121
|
+
...cssProp,
|
|
122
|
+
backgroundColor: backgroundColors.styleProps,
|
|
123
|
+
cs: styles,
|
|
124
|
+
},
|
|
125
|
+
'createStyles + CSS Prop + Styled Component + Style Props'
|
|
126
|
+
)}
|
|
127
|
+
</div>
|
|
128
|
+
<div>{jsx(StyledPrimaryButton, {...cssProp}, 'CSS Prop + Styled Component')}</div>
|
|
129
|
+
<div>
|
|
130
|
+
{jsx(
|
|
131
|
+
PrimaryButton,
|
|
132
|
+
{
|
|
133
|
+
...cssProp,
|
|
134
|
+
backgroundColor: backgroundColors.styleProps,
|
|
135
|
+
},
|
|
136
|
+
'CSS Prop + Style Props'
|
|
137
|
+
)}
|
|
138
|
+
</div>
|
|
139
|
+
<div>
|
|
140
|
+
<StyledPrimaryButton backgroundColor={backgroundColors.styleProps}>
|
|
141
|
+
Styled Component + Style Props
|
|
142
|
+
</StyledPrimaryButton>
|
|
143
|
+
</div>
|
|
144
|
+
</Flex>
|
|
145
|
+
<div>
|
|
146
|
+
<p>Legend:</p>
|
|
147
|
+
<CreateStyles />
|
|
148
|
+
<CSSProp />
|
|
149
|
+
<StyledComponent />
|
|
150
|
+
<StyleProps />
|
|
151
|
+
</div>
|
|
152
|
+
<p>
|
|
153
|
+
Style Precedence: <strong>createStyles</strong> > <strong>CSS Props</strong> >{' '}
|
|
154
|
+
<strong>Styled Component</strong> > <strong>Style Props</strong>
|
|
155
|
+
</p>
|
|
156
|
+
</Flex>
|
|
157
|
+
);
|
|
158
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "14.0.0-alpha.
|
|
3
|
+
"version": "14.0.0-alpha.1153-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.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-preview-react": "^14.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-react": "^14.0.0-alpha.
|
|
51
|
-
"@workday/canvas-kit-styling": "^14.0.0-alpha.
|
|
48
|
+
"@workday/canvas-kit-labs-react": "^14.0.0-alpha.1153-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^14.0.0-alpha.1153-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^14.0.0-alpha.1153-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^14.0.0-alpha.1153-next.0",
|
|
52
52
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
53
53
|
"@workday/canvas-tokens-web": "3.0.0-alpha.5",
|
|
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": "99af78970bf60236bf766f829a651499297a0b64"
|
|
65
65
|
}
|