@workday/canvas-kit-docs 14.0.0-alpha.1148-next.0 → 14.0.0-alpha.1151-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 +0 -550
- 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 +19 -2
- package/dist/mdx/react/card/card.mdx +4 -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
- package/dist/mdx/preview-react/menu/Menu.mdx +0 -105
- package/dist/mdx/preview-react/menu/examples/Basic.tsx +0 -74
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +0 -67
- package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +0 -15
- package/dist/mdx/preview-react/menu/examples/Headers.tsx +0 -32
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +0 -26
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +0 -15
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from '@emotion/styled';
|
|
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 StyledButton = styled('button')<ButtonProps>(
|
|
12
|
+
{
|
|
13
|
+
// base styles
|
|
14
|
+
fontSize: '1rem',
|
|
15
|
+
display: 'flex',
|
|
16
|
+
borderRadius: '1rem',
|
|
17
|
+
},
|
|
18
|
+
// variant styles
|
|
19
|
+
({variant, backgroundColor}) => {
|
|
20
|
+
switch (variant) {
|
|
21
|
+
case 'primary':
|
|
22
|
+
return {
|
|
23
|
+
background: backgroundColor || 'blue',
|
|
24
|
+
color: 'white',
|
|
25
|
+
};
|
|
26
|
+
case 'secondary':
|
|
27
|
+
return {
|
|
28
|
+
background: backgroundColor || 'gray',
|
|
29
|
+
};
|
|
30
|
+
case 'danger':
|
|
31
|
+
return {
|
|
32
|
+
background: backgroundColor || 'red',
|
|
33
|
+
};
|
|
34
|
+
default:
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// size styles
|
|
39
|
+
({size}) => {
|
|
40
|
+
switch (size) {
|
|
41
|
+
case 'large':
|
|
42
|
+
return {
|
|
43
|
+
fontSize: '1.4rem',
|
|
44
|
+
height: '2rem',
|
|
45
|
+
};
|
|
46
|
+
case 'medium':
|
|
47
|
+
return {
|
|
48
|
+
fontSize: '1rem',
|
|
49
|
+
height: '1.5rem',
|
|
50
|
+
};
|
|
51
|
+
case 'small':
|
|
52
|
+
return {
|
|
53
|
+
fontSize: '0.8rem',
|
|
54
|
+
height: '1.2rem',
|
|
55
|
+
};
|
|
56
|
+
default:
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
export default () => {
|
|
63
|
+
return (
|
|
64
|
+
<div style={{display: 'flex', flexDirection: 'column', gap: '1rem'}}>
|
|
65
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
66
|
+
<StyledButton variant="primary" size="large">
|
|
67
|
+
Primary Large
|
|
68
|
+
</StyledButton>
|
|
69
|
+
<StyledButton variant="primary" size="medium">
|
|
70
|
+
Primary Medium
|
|
71
|
+
</StyledButton>
|
|
72
|
+
<StyledButton variant="primary" size="small">
|
|
73
|
+
Primary Small
|
|
74
|
+
</StyledButton>
|
|
75
|
+
</div>
|
|
76
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
77
|
+
<StyledButton variant="secondary" size="large">
|
|
78
|
+
Secondary Large
|
|
79
|
+
</StyledButton>
|
|
80
|
+
<StyledButton variant="secondary" size="medium">
|
|
81
|
+
Secondary Medium
|
|
82
|
+
</StyledButton>
|
|
83
|
+
<StyledButton variant="secondary" size="small">
|
|
84
|
+
Secondary Small
|
|
85
|
+
</StyledButton>
|
|
86
|
+
</div>
|
|
87
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
88
|
+
<StyledButton variant="danger" size="large">
|
|
89
|
+
Danger Large
|
|
90
|
+
</StyledButton>
|
|
91
|
+
<StyledButton variant="danger" size="medium">
|
|
92
|
+
Danger Medium
|
|
93
|
+
</StyledButton>
|
|
94
|
+
<StyledButton variant="danger" size="small">
|
|
95
|
+
Danger Small
|
|
96
|
+
</StyledButton>
|
|
97
|
+
</div>
|
|
98
|
+
<div style={{display: 'flex', gap: '1rem'}}>
|
|
99
|
+
<StyledButton variant="danger" size="large" backgroundColor="orange">
|
|
100
|
+
Custom Large
|
|
101
|
+
</StyledButton>
|
|
102
|
+
<StyledButton variant="danger" size="medium" backgroundColor="orange">
|
|
103
|
+
Custom Medium
|
|
104
|
+
</StyledButton>
|
|
105
|
+
<StyledButton variant="danger" size="small" backgroundColor="orange">
|
|
106
|
+
Custom Small
|
|
107
|
+
</StyledButton>
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {createStyles} 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 baseStyles = createStyles({
|
|
12
|
+
fontSize: '1rem',
|
|
13
|
+
display: 'flex',
|
|
14
|
+
borderRadius: '1rem',
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const modifierStyles = {
|
|
18
|
+
variant: {
|
|
19
|
+
primary: createStyles({
|
|
20
|
+
background: `var(--button-background-color, blue)`,
|
|
21
|
+
color: 'white',
|
|
22
|
+
}),
|
|
23
|
+
secondary: createStyles({
|
|
24
|
+
background: `var(--button-background-color, gray)`,
|
|
25
|
+
}),
|
|
26
|
+
danger: createStyles({
|
|
27
|
+
background: `var(--button-background-color, red)`,
|
|
28
|
+
}),
|
|
29
|
+
},
|
|
30
|
+
size: {
|
|
31
|
+
large: createStyles({
|
|
32
|
+
fontSize: '1.4rem',
|
|
33
|
+
height: '2rem',
|
|
34
|
+
}),
|
|
35
|
+
medium: createStyles({
|
|
36
|
+
fontSize: '1rem',
|
|
37
|
+
height: '1.5rem',
|
|
38
|
+
}),
|
|
39
|
+
small: createStyles({
|
|
40
|
+
fontSize: '0.8rem',
|
|
41
|
+
height: '1.2rem',
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const Button = ({variant, size, backgroundColor, children}: ButtonProps) => {
|
|
47
|
+
const className = [baseStyles, modifierStyles.variant[variant], modifierStyles.size[size]].join(
|
|
48
|
+
' '
|
|
49
|
+
);
|
|
50
|
+
const style = {'--button-background-color': backgroundColor} as React.CSSProperties;
|
|
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,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {system} from '@workday/canvas-tokens-web';
|
|
4
|
+
import {caretDownIcon} from '@workday/canvas-system-icons-web';
|
|
5
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {buttonStencil, PrimaryButton} from '@workday/canvas-kit-react/button';
|
|
7
|
+
import {systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
8
|
+
|
|
9
|
+
const varStyles = createStyles({
|
|
10
|
+
[buttonStencil.vars.background]: system.color.static.gray.soft,
|
|
11
|
+
[buttonStencil.vars.label]: system.color.static.blue.strong,
|
|
12
|
+
// Because PrimaryButton uses SystemIcon under the hood,
|
|
13
|
+
// we also can change system icon variable for color
|
|
14
|
+
[systemIconStencil.vars.color]: system.color.static.blue.strong,
|
|
15
|
+
'&:hover': {
|
|
16
|
+
[buttonStencil.vars.background]: system.color.static.amber.default,
|
|
17
|
+
[buttonStencil.vars.label]: system.color.static.white,
|
|
18
|
+
[systemIconStencil.vars.color]: system.color.static.white,
|
|
19
|
+
},
|
|
20
|
+
'&:focus-visible': {
|
|
21
|
+
[buttonStencil.vars.background]: system.color.static.green.default,
|
|
22
|
+
[buttonStencil.vars.boxShadowOuter]: system.color.static.green.strong,
|
|
23
|
+
[buttonStencil.vars.boxShadowInner]: system.color.static.white,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export default () => (
|
|
28
|
+
<PrimaryButton cs={varStyles} icon={caretDownIcon} iconPosition="end">
|
|
29
|
+
Overwrite styles by setting variables
|
|
30
|
+
</PrimaryButton>
|
|
31
|
+
);
|
|
@@ -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.1151-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.1151-next.0",
|
|
49
|
+
"@workday/canvas-kit-preview-react": "^14.0.0-alpha.1151-next.0",
|
|
50
|
+
"@workday/canvas-kit-react": "^14.0.0-alpha.1151-next.0",
|
|
51
|
+
"@workday/canvas-kit-styling": "^14.0.0-alpha.1151-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": "891b0d79a8054c5cd3799eb8dd2e0c3b0f15a47b"
|
|
65
65
|
}
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
|
-
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
3
|
-
import Basic from './examples/Basic';
|
|
4
|
-
import ContextMenu from './examples/ContextMenu';
|
|
5
|
-
import CustomMenuItem from './examples/CustomMenuItem';
|
|
6
|
-
import Icons from './examples/Icons';
|
|
7
|
-
import Headers from './examples/Headers';
|
|
8
|
-
import ManyItems from './examples/ManyItems';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
# Canvas Kit Menu
|
|
12
|
-
|
|
13
|
-
<StatusIndicator variant="red">
|
|
14
|
-
<StatusIndicator.Label>Deprecated</StatusIndicator.Label>
|
|
15
|
-
</StatusIndicator>
|
|
16
|
-
|
|
17
|
-
`Menu` in Preview been deprecated and will be removed in a future major version. Please use
|
|
18
|
-
[Menu in Main](https://workday.github.io/canvas-kit/?path=/docs/components-popups-menu--basic)
|
|
19
|
-
instead.
|
|
20
|
-
|
|
21
|
-
`DeprecatedMenu` displays a list of options when triggered by an action or UI element like an icon
|
|
22
|
-
or button.
|
|
23
|
-
|
|
24
|
-
[> Workday Design Reference](https://design.workday.com/components/popups/menus)
|
|
25
|
-
|
|
26
|
-
## Installation
|
|
27
|
-
|
|
28
|
-
```sh
|
|
29
|
-
yarn add @workday/canvas-kit-preview-react
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## Usage
|
|
33
|
-
|
|
34
|
-
### Basic Example
|
|
35
|
-
|
|
36
|
-
`DeprecatedMenu` is typically triggered by an action such as pressing a button. Here's an example of
|
|
37
|
-
how you might implement that behavior using a [`Popup`](/components/popups/popup/).
|
|
38
|
-
|
|
39
|
-
<ExampleCodeBlock code={Basic} />
|
|
40
|
-
|
|
41
|
-
`DeprecatedMenu` will automatically assign focus to itself when it appears provided you set the
|
|
42
|
-
`isOpen` prop correctly, so you do **not** need to use the `useInitialFocus` `Popup` hook. You
|
|
43
|
-
**will**, however, need to use `useReturnFocus` to return focus back to the triggering button after
|
|
44
|
-
closing the `DeprecatedMenu`.
|
|
45
|
-
|
|
46
|
-
`DeprecatedMenu` follows the
|
|
47
|
-
[Actions Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions-active-descendant.html)
|
|
48
|
-
using `aria-activedescendant`. Below is table of supported keyboard shortcuts and associated
|
|
49
|
-
actions.
|
|
50
|
-
|
|
51
|
-
| Key | Action |
|
|
52
|
-
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
53
|
-
| `Enter` or `Space` | Activates the menu item and then closes the menu |
|
|
54
|
-
| `Escape` | Closes the menu |
|
|
55
|
-
| `Up Arrow` | Moves focus to the previous menu item – if focus is on first menu item, it moves focus to the last menu item |
|
|
56
|
-
| `Down Arrow` | Moves focus to the next menu item – if focus is on last menu item, it moves focus to the first menu item |
|
|
57
|
-
| `Home` | Moves focus to the first menu item |
|
|
58
|
-
| `End` | Moves focus to the last menu item |
|
|
59
|
-
| `A-Z / a-z` | Moves focus to the next menu item with a label that starts with the typed character if such an menu item exists – otherwise, focus does not move |
|
|
60
|
-
|
|
61
|
-
Note that although `DeprecatedMenu` includes support for keyboard shortcuts for the menu itself,
|
|
62
|
-
you'll need to add your own keyboard handling and aria attributes to the triggering button.
|
|
63
|
-
|
|
64
|
-
### Context Menu
|
|
65
|
-
|
|
66
|
-
<ExampleCodeBlock code={ContextMenu} />
|
|
67
|
-
|
|
68
|
-
### Custom Menu Item
|
|
69
|
-
|
|
70
|
-
`DeprecatedMenu` renders a styled `<ul>` element with a role of `menu`, and `DeprecatedMenuItem`s
|
|
71
|
-
are `<li>` elements with the correct attributes to ensure they are accessible. If you choose to
|
|
72
|
-
implement your own custom menu items, be sure to use semantic `<li>` elements with the following
|
|
73
|
-
attributes:
|
|
74
|
-
|
|
75
|
-
- `role="menuitem"`
|
|
76
|
-
- `tabindex={-1}`
|
|
77
|
-
|
|
78
|
-
Below is an example:
|
|
79
|
-
|
|
80
|
-
<ExampleCodeBlock code={CustomMenuItem} />
|
|
81
|
-
|
|
82
|
-
### Icons
|
|
83
|
-
|
|
84
|
-
<ExampleCodeBlock code={Icons} />
|
|
85
|
-
|
|
86
|
-
### Headers
|
|
87
|
-
|
|
88
|
-
You can group menu items logically by adding a `isHeader` attribute on your `<MenuItems>`. To make
|
|
89
|
-
your new items screen reader friendly add an `aria-label` around each grouped item.
|
|
90
|
-
|
|
91
|
-
<ExampleCodeBlock code={Headers} />
|
|
92
|
-
|
|
93
|
-
### Many Items
|
|
94
|
-
|
|
95
|
-
<ExampleCodeBlock code={ManyItems} />
|
|
96
|
-
|
|
97
|
-
## Component API
|
|
98
|
-
|
|
99
|
-
### DeprecatedMenu
|
|
100
|
-
|
|
101
|
-
<SymbolDoc name="DeprecatedMenu" fileName="/preview-react/" />
|
|
102
|
-
|
|
103
|
-
### DeprecatedMenuItem
|
|
104
|
-
|
|
105
|
-
<SymbolDoc name="DeprecatedMenuItem" fileName="/preview-react/" />
|