@workday/canvas-kit-react 10.0.0-alpha.538-next.0 → 10.0.0-alpha.540-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/button/index.ts +8 -11
- package/button/lib/BaseButton.tsx +274 -256
- package/button/lib/Button.tsx +67 -0
- package/button/lib/DeleteButton.tsx +42 -58
- package/button/lib/PrimaryButton.tsx +82 -149
- package/button/lib/SecondaryButton.tsx +87 -173
- package/button/lib/TertiaryButton.tsx +158 -223
- package/button/lib/ToolbarDropdownButton.tsx +11 -2
- package/button/lib/ToolbarIconButton.tsx +10 -2
- package/button/lib/parts/ButtonLabelIcon.tsx +1 -7
- package/button/lib/types.ts +6 -8
- package/checkbox/lib/Checkbox.tsx +24 -33
- package/common/lib/CanvasProvider.tsx +50 -24
- package/dist/commonjs/button/index.d.ts +8 -5
- package/dist/commonjs/button/index.d.ts.map +1 -1
- package/dist/commonjs/button/index.js +9 -13
- package/dist/commonjs/button/lib/BaseButton.d.ts +69 -5
- package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/BaseButton.js +199 -192
- package/dist/commonjs/button/lib/Button.d.ts +17 -0
- package/dist/commonjs/button/lib/Button.d.ts.map +1 -0
- package/dist/commonjs/button/lib/Button.js +42 -0
- package/dist/commonjs/button/lib/DeleteButton.d.ts +7 -9
- package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/DeleteButton.js +29 -19
- package/dist/commonjs/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +67 -79
- package/dist/commonjs/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/SecondaryButton.js +71 -96
- package/dist/commonjs/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/TertiaryButton.js +136 -134
- package/dist/commonjs/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/commonjs/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/ToolbarIconButton.js +10 -2
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/commonjs/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/commonjs/button/lib/types.d.ts +6 -7
- package/dist/commonjs/button/lib/types.d.ts.map +1 -1
- package/dist/commonjs/card/lib/Card.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts +1 -1
- package/dist/commonjs/card/lib/CardBody.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/commonjs/checkbox/lib/Checkbox.js +13 -17
- package/dist/commonjs/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/commonjs/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +31 -13
- package/dist/commonjs/dialog/lib/Dialog.d.ts +1 -1
- package/dist/commonjs/layout/lib/Box.d.ts +3 -2
- package/dist/commonjs/layout/lib/Box.d.ts.map +1 -1
- package/dist/commonjs/layout/lib/Box.js +2 -1
- package/dist/commonjs/layout/lib/Flex.d.ts +1 -1
- package/dist/commonjs/layout/lib/Grid.d.ts +1 -1
- package/dist/commonjs/menu/lib/MenuItem.d.ts +1 -1
- package/dist/commonjs/popup/lib/Popup.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupBody.d.ts +1 -1
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/radio/lib/Radio.d.ts.map +1 -1
- package/dist/commonjs/radio/lib/Radio.js +17 -22
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/commonjs/table/lib/Table.d.ts +1 -2
- package/dist/commonjs/table/lib/Table.d.ts.map +1 -1
- package/dist/commonjs/table/lib/Table.js +1 -2
- package/dist/commonjs/table/lib/TableRow.d.ts +3 -6
- package/dist/commonjs/table/lib/TableRow.d.ts.map +1 -1
- package/dist/commonjs/table/lib/TableRow.js +3 -5
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/commonjs/text-area/lib/TextArea.d.ts.map +1 -1
- package/dist/commonjs/text-area/lib/TextArea.js +1 -1
- package/dist/commonjs/text-input/lib/TextInput.js +1 -1
- package/dist/commonjs/tokens/lib/space.d.ts +44 -31
- package/dist/commonjs/tokens/lib/space.d.ts.map +1 -1
- package/dist/commonjs/tokens/lib/space.js +22 -29
- package/dist/commonjs/tooltip/lib/TooltipContainer.js +2 -2
- package/dist/es6/button/index.d.ts +8 -5
- package/dist/es6/button/index.d.ts.map +1 -1
- package/dist/es6/button/index.js +8 -5
- package/dist/es6/button/lib/BaseButton.d.ts +69 -5
- package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/es6/button/lib/BaseButton.js +199 -192
- package/dist/es6/button/lib/Button.d.ts +17 -0
- package/dist/es6/button/lib/Button.d.ts.map +1 -0
- package/dist/es6/button/lib/Button.js +20 -0
- package/dist/es6/button/lib/DeleteButton.d.ts +7 -9
- package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/es6/button/lib/DeleteButton.js +31 -21
- package/dist/es6/button/lib/PrimaryButton.d.ts +15 -36
- package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +67 -79
- package/dist/es6/button/lib/SecondaryButton.d.ts +16 -43
- package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/SecondaryButton.js +71 -95
- package/dist/es6/button/lib/TertiaryButton.d.ts +35 -47
- package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/TertiaryButton.js +137 -135
- package/dist/es6/button/lib/ToolbarDropdownButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarDropdownButton.js +11 -2
- package/dist/es6/button/lib/ToolbarIconButton.d.ts.map +1 -1
- package/dist/es6/button/lib/ToolbarIconButton.js +10 -2
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts +1 -7
- package/dist/es6/button/lib/parts/ButtonLabelIcon.d.ts.map +1 -1
- package/dist/es6/button/lib/types.d.ts +6 -7
- package/dist/es6/button/lib/types.d.ts.map +1 -1
- package/dist/es6/card/lib/Card.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts +1 -1
- package/dist/es6/card/lib/CardBody.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.d.ts.map +1 -1
- package/dist/es6/checkbox/lib/Checkbox.js +14 -18
- package/dist/es6/common/lib/CanvasProvider.d.ts +1 -8
- package/dist/es6/common/lib/CanvasProvider.d.ts.map +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +31 -13
- package/dist/es6/dialog/lib/Dialog.d.ts +1 -1
- package/dist/es6/layout/lib/Box.d.ts +3 -2
- package/dist/es6/layout/lib/Box.d.ts.map +1 -1
- package/dist/es6/layout/lib/Box.js +2 -1
- package/dist/es6/layout/lib/Flex.d.ts +1 -1
- package/dist/es6/layout/lib/Grid.d.ts +1 -1
- package/dist/es6/menu/lib/MenuItem.d.ts +1 -1
- package/dist/es6/popup/lib/Popup.d.ts +1 -1
- package/dist/es6/popup/lib/PopupBody.d.ts +1 -1
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/radio/lib/Radio.d.ts.map +1 -1
- package/dist/es6/radio/lib/Radio.js +18 -23
- package/dist/es6/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/es6/table/lib/Table.d.ts +1 -2
- package/dist/es6/table/lib/Table.d.ts.map +1 -1
- package/dist/es6/table/lib/Table.js +1 -2
- package/dist/es6/table/lib/TableRow.d.ts +3 -6
- package/dist/es6/table/lib/TableRow.d.ts.map +1 -1
- package/dist/es6/table/lib/TableRow.js +4 -6
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/dist/es6/text-area/lib/TextArea.d.ts.map +1 -1
- package/dist/es6/text-area/lib/TextArea.js +2 -2
- package/dist/es6/text-input/lib/TextInput.js +2 -2
- package/dist/es6/tokens/lib/space.d.ts +44 -31
- package/dist/es6/tokens/lib/space.d.ts.map +1 -1
- package/dist/es6/tokens/lib/space.js +22 -29
- package/dist/es6/tooltip/lib/TooltipContainer.js +3 -3
- package/layout/lib/Box.tsx +6 -4
- package/package.json +5 -3
- package/popup/lib/PopupCloseIcon.tsx +1 -1
- package/radio/lib/Radio.tsx +18 -34
- package/segmented-control/lib/SegmentedControlButton.tsx +3 -1
- package/table/lib/Table.tsx +1 -2
- package/table/lib/TableRow.tsx +5 -8
- package/text-area/lib/TextArea.tsx +2 -8
- package/text-input/lib/TextInput.tsx +2 -2
- package/tokens/README.md +25 -28
- package/tokens/lib/space.ts +53 -40
- package/tooltip/lib/TooltipContainer.tsx +3 -3
|
@@ -1,43 +1,44 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {ButtonColors} from './types';
|
|
3
|
-
import {BaseButton, BaseButtonProps, getMinWidthStyles, getPaddingStyles} from './BaseButton';
|
|
4
|
-
import {
|
|
5
|
-
GrowthBehavior,
|
|
6
|
-
useTheme,
|
|
7
|
-
Themeable,
|
|
8
|
-
EmotionCanvasTheme,
|
|
9
|
-
createComponent,
|
|
10
|
-
} from '@workday/canvas-kit-react/common';
|
|
11
2
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
children?: React.ReactNode;
|
|
18
|
-
}
|
|
3
|
+
import {buttonVars} from './BaseButton';
|
|
4
|
+
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {createStyles, cssVar} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {base, brand, system} from '@workday/canvas-tokens-web';
|
|
7
|
+
import {Button, ButtonProps} from './Button';
|
|
19
8
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
11
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
12
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
13
|
+
*/
|
|
14
|
+
export interface DeleteButtonProps extends ButtonProps {}
|
|
15
|
+
|
|
16
|
+
const deleteStyles = createStyles({
|
|
17
|
+
[buttonVars.default.background]: cssVar(brand.error.base),
|
|
18
|
+
[buttonVars.default.border]: 'transparent',
|
|
19
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
20
|
+
[buttonVars.default.label]: cssVar(brand.error.accent),
|
|
21
|
+
'&:hover, &.hover': {
|
|
22
|
+
[buttonVars.hover.background]: cssVar(brand.error.dark),
|
|
23
|
+
[buttonVars.hover.border]: 'transparent',
|
|
24
|
+
[buttonVars.hover.label]: cssVar(brand.error.accent),
|
|
31
25
|
},
|
|
32
|
-
|
|
33
|
-
background:
|
|
26
|
+
'&:focus-visible, &.focus': {
|
|
27
|
+
[buttonVars.focus.background]: cssVar(brand.error.base),
|
|
28
|
+
[buttonVars.focus.border]: 'transparent',
|
|
29
|
+
[buttonVars.focus.label]: cssVar(brand.error.accent),
|
|
30
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
31
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
34
32
|
},
|
|
35
|
-
|
|
36
|
-
background:
|
|
33
|
+
'&:active, &.active': {
|
|
34
|
+
[buttonVars.active.background]: cssVar(brand.error.darkest),
|
|
35
|
+
[buttonVars.active.border]: 'transparent',
|
|
36
|
+
[buttonVars.active.label]: cssVar(brand.error.accent),
|
|
37
37
|
},
|
|
38
|
-
disabled: {
|
|
39
|
-
background:
|
|
40
|
-
|
|
38
|
+
'&:disabled, &:active:disabled, &:focus:disabled, &:hover:disabled': {
|
|
39
|
+
[buttonVars.disabled.background]: cssVar(brand.error.light),
|
|
40
|
+
[buttonVars.disabled.label]: cssVar(brand.error.accent),
|
|
41
|
+
opacity: 1,
|
|
41
42
|
},
|
|
42
43
|
});
|
|
43
44
|
|
|
@@ -48,28 +49,11 @@ const getDeleteButtonColors = ({
|
|
|
48
49
|
*/
|
|
49
50
|
export const DeleteButton = createComponent('button')({
|
|
50
51
|
displayName: 'DeleteButton',
|
|
51
|
-
Component: (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
...elemProps
|
|
59
|
-
}: DeleteButtonProps,
|
|
60
|
-
ref,
|
|
61
|
-
Element
|
|
62
|
-
) => (
|
|
63
|
-
<BaseButton
|
|
64
|
-
padding={getPaddingStyles(children, size, undefined, undefined)}
|
|
65
|
-
minWidth={getMinWidthStyles(children, size)}
|
|
66
|
-
ref={ref}
|
|
67
|
-
as={Element}
|
|
68
|
-
colors={getDeleteButtonColors(theme)}
|
|
69
|
-
size={size}
|
|
70
|
-
{...elemProps}
|
|
71
|
-
>
|
|
72
|
-
<BaseButton.Label>{children}</BaseButton.Label>
|
|
73
|
-
</BaseButton>
|
|
74
|
-
),
|
|
52
|
+
Component: ({children, cs, size, ...elemProps}: DeleteButtonProps, ref, Element) => {
|
|
53
|
+
return (
|
|
54
|
+
<Button as={Element} ref={ref} size={size} cs={[deleteStyles, cs]} {...elemProps}>
|
|
55
|
+
{children}
|
|
56
|
+
</Button>
|
|
57
|
+
);
|
|
58
|
+
},
|
|
75
59
|
});
|
|
@@ -1,171 +1,104 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
createComponent,
|
|
9
|
-
focusRing,
|
|
10
|
-
} from '@workday/canvas-kit-react/common';
|
|
11
|
-
import {colors} from '@workday/canvas-kit-react/tokens';
|
|
12
|
-
import {CanvasSystemIcon} from '@workday/design-assets-types';
|
|
13
|
-
import {ButtonSizes, IconPositions} from './types';
|
|
14
|
-
import {BaseButton, BaseButtonProps, getMinWidthStyles, getPaddingStyles} from './BaseButton';
|
|
3
|
+
import {buttonVars} from './BaseButton';
|
|
4
|
+
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {createStyles, cssVar, createModifiers} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {base, brand, system} from '@workday/canvas-tokens-web';
|
|
7
|
+
import {Button, ButtonProps} from './Button';
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
switch (variant) {
|
|
24
|
-
case undefined:
|
|
25
|
-
default:
|
|
26
|
-
return {
|
|
27
|
-
default: {
|
|
28
|
-
background: themePrimary.main,
|
|
29
|
-
icon: themePrimary.contrast,
|
|
30
|
-
label: themePrimary.contrast,
|
|
31
|
-
},
|
|
32
|
-
hover: {
|
|
33
|
-
background: themePrimary.dark,
|
|
34
|
-
},
|
|
35
|
-
active: {
|
|
36
|
-
background: themePrimary.darkest,
|
|
37
|
-
},
|
|
38
|
-
focus: {
|
|
39
|
-
background: themePrimary.main,
|
|
40
|
-
},
|
|
41
|
-
disabled: {
|
|
42
|
-
background: themePrimary.main,
|
|
43
|
-
},
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
case 'inverse':
|
|
47
|
-
return {
|
|
48
|
-
default: {
|
|
49
|
-
background: colors.frenchVanilla100,
|
|
50
|
-
icon: colors.blackPepper400,
|
|
51
|
-
label: colors.blackPepper400,
|
|
52
|
-
},
|
|
53
|
-
hover: {
|
|
54
|
-
background: colors.soap300,
|
|
55
|
-
icon: colors.blackPepper500,
|
|
56
|
-
label: colors.blackPepper500,
|
|
57
|
-
},
|
|
58
|
-
active: {
|
|
59
|
-
background: colors.soap400,
|
|
60
|
-
icon: colors.blackPepper500,
|
|
61
|
-
label: colors.blackPepper500,
|
|
62
|
-
},
|
|
63
|
-
focus: {
|
|
64
|
-
background: colors.frenchVanilla100,
|
|
65
|
-
border: colors.blackPepper400,
|
|
66
|
-
icon: colors.blackPepper400,
|
|
67
|
-
label: colors.blackPepper400,
|
|
68
|
-
|
|
69
|
-
focusRing: focusRing(
|
|
70
|
-
{
|
|
71
|
-
separation: 1,
|
|
72
|
-
innerColor: colors.blackPepper400,
|
|
73
|
-
outerColor: colors.frenchVanilla100,
|
|
74
|
-
},
|
|
75
|
-
theme
|
|
76
|
-
),
|
|
77
|
-
},
|
|
78
|
-
// Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
|
|
79
|
-
disabled: {
|
|
80
|
-
background: colors.frenchVanilla100,
|
|
81
|
-
icon: colors.blackPepper400,
|
|
82
|
-
label: colors.blackPepper400,
|
|
83
|
-
},
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export interface PrimaryButtonProps extends Themeable, GrowthBehavior, BaseButtonProps {
|
|
9
|
+
/**
|
|
10
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
11
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
12
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
13
|
+
*/
|
|
14
|
+
export interface PrimaryButtonProps extends ButtonProps {
|
|
89
15
|
/**
|
|
90
|
-
*
|
|
16
|
+
* Variant has an option for `inverse` which will inverse the styling
|
|
91
17
|
*/
|
|
92
18
|
variant?: 'inverse';
|
|
93
|
-
/**
|
|
94
|
-
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
95
|
-
* If no size is provided, it will default to `medium`.
|
|
96
|
-
*/
|
|
97
|
-
size?: ButtonSizes;
|
|
98
|
-
/**
|
|
99
|
-
* The icon of the Button.
|
|
100
|
-
* Note: not displayed at `small` size
|
|
101
|
-
*/
|
|
102
|
-
icon?: CanvasSystemIcon;
|
|
103
|
-
/**
|
|
104
|
-
* Button icon positions can either be `start` or `end`.
|
|
105
|
-
* If no value is provided, it defaults to `start`.
|
|
106
|
-
*/
|
|
107
|
-
iconPosition?: IconPositions;
|
|
108
|
-
/**
|
|
109
|
-
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
110
|
-
*/
|
|
111
|
-
shouldMirrorIcon?: boolean;
|
|
112
|
-
children?: React.ReactNode;
|
|
113
19
|
}
|
|
114
20
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
21
|
+
const primaryStyles = createStyles({
|
|
22
|
+
// Default Styles
|
|
23
|
+
[buttonVars.default.background]: cssVar(brand.primary.base, cssVar(base.blueberry400)),
|
|
24
|
+
[buttonVars.default.border]: 'transparent',
|
|
25
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
26
|
+
[buttonVars.default.label]: cssVar(brand.primary.accent),
|
|
27
|
+
[buttonVars.default.icon]: cssVar(brand.primary.accent),
|
|
28
|
+
// Hover Styles
|
|
29
|
+
[buttonVars.hover.background]: cssVar(brand.primary.dark),
|
|
30
|
+
[buttonVars.hover.border]: 'transparent',
|
|
31
|
+
[buttonVars.hover.label]: cssVar(brand.primary.accent),
|
|
32
|
+
[buttonVars.hover.icon]: cssVar(brand.primary.accent),
|
|
33
|
+
// Focus Styles
|
|
34
|
+
[buttonVars.focus.background]: cssVar(brand.primary.base),
|
|
35
|
+
[buttonVars.focus.border]: 'transparent',
|
|
36
|
+
[buttonVars.focus.label]: cssVar(brand.primary.accent),
|
|
37
|
+
[buttonVars.focus.icon]: cssVar(brand.primary.accent),
|
|
38
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
39
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
40
|
+
// Active Styles
|
|
41
|
+
[buttonVars.active.background]: cssVar(brand.primary.darkest),
|
|
42
|
+
[buttonVars.active.border]: 'transparent',
|
|
43
|
+
[buttonVars.active.label]: cssVar(brand.primary.accent),
|
|
44
|
+
[buttonVars.active.icon]: cssVar(brand.primary.accent),
|
|
45
|
+
// Disabled Styles
|
|
46
|
+
[buttonVars.disabled.background]: cssVar(brand.primary.base),
|
|
47
|
+
[buttonVars.disabled.border]: 'transparent',
|
|
48
|
+
[buttonVars.disabled.label]: cssVar(brand.primary.accent),
|
|
49
|
+
[buttonVars.disabled.opacity]: '0.4',
|
|
50
|
+
[buttonVars.disabled.icon]: cssVar(brand.primary.accent),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const primaryButtonModifiers = createModifiers({
|
|
54
|
+
variant: {
|
|
55
|
+
inverse: createStyles({
|
|
56
|
+
// Default Styles
|
|
57
|
+
[buttonVars.default.background]: cssVar(base.frenchVanilla100),
|
|
58
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
59
|
+
[buttonVars.default.label]: cssVar(base.blackPepper400),
|
|
60
|
+
[buttonVars.default.icon]: cssVar(base.blackPepper400),
|
|
61
|
+
// Hover Styles
|
|
62
|
+
[buttonVars.hover.background]: cssVar(base.soap300),
|
|
63
|
+
[buttonVars.hover.label]: cssVar(base.blackPepper500),
|
|
64
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper500),
|
|
65
|
+
// Focus Styles
|
|
66
|
+
[buttonVars.focus.background]: cssVar(base.frenchVanilla100),
|
|
67
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper400),
|
|
68
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper400),
|
|
69
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.blackPepper400),
|
|
70
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(base.frenchVanilla100),
|
|
71
|
+
// Active Styles
|
|
72
|
+
[buttonVars.active.background]: cssVar(base.soap400),
|
|
73
|
+
[buttonVars.active.label]: cssVar(base.blackPepper500),
|
|
74
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper500),
|
|
75
|
+
// Disabled Styles
|
|
76
|
+
[buttonVars.disabled.background]: cssVar(base.frenchVanilla100),
|
|
77
|
+
[buttonVars.disabled.label]: cssVar(base.blackPepper400),
|
|
78
|
+
[buttonVars.disabled.icon]: cssVar(base.blackPepper400),
|
|
79
|
+
}),
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
124
83
|
export const PrimaryButton = createComponent('button')({
|
|
125
84
|
displayName: 'PrimaryButton',
|
|
126
85
|
Component: (
|
|
127
|
-
{
|
|
128
|
-
size = 'medium',
|
|
129
|
-
iconPosition = 'start',
|
|
130
|
-
variant,
|
|
131
|
-
icon,
|
|
132
|
-
shouldMirrorIcon = false,
|
|
133
|
-
children,
|
|
134
|
-
...elemProps
|
|
135
|
-
}: PrimaryButtonProps,
|
|
86
|
+
{children, icon, cs, iconPosition, variant, size, ...elemProps}: PrimaryButtonProps,
|
|
136
87
|
ref,
|
|
137
88
|
Element
|
|
138
89
|
) => {
|
|
139
|
-
const theme = useTheme();
|
|
140
90
|
return (
|
|
141
|
-
<
|
|
91
|
+
<Button
|
|
92
|
+
as={Element}
|
|
142
93
|
ref={ref}
|
|
143
94
|
size={size}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
as={Element}
|
|
95
|
+
icon={icon}
|
|
96
|
+
iconPosition={iconPosition}
|
|
97
|
+
cs={[primaryStyles, primaryButtonModifiers({variant: variant}), cs]}
|
|
148
98
|
{...elemProps}
|
|
149
99
|
>
|
|
150
|
-
{
|
|
151
|
-
|
|
152
|
-
size={size}
|
|
153
|
-
iconPosition={iconPosition}
|
|
154
|
-
icon={icon}
|
|
155
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
156
|
-
/>
|
|
157
|
-
)}
|
|
158
|
-
{children && <BaseButton.Label>{children}</BaseButton.Label>}
|
|
159
|
-
|
|
160
|
-
{icon && iconPosition === 'end' && (
|
|
161
|
-
<BaseButton.Icon
|
|
162
|
-
size={size}
|
|
163
|
-
iconPosition={iconPosition}
|
|
164
|
-
icon={icon}
|
|
165
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
166
|
-
/>
|
|
167
|
-
)}
|
|
168
|
-
</BaseButton>
|
|
100
|
+
{children}
|
|
101
|
+
</Button>
|
|
169
102
|
);
|
|
170
103
|
},
|
|
171
104
|
});
|
|
@@ -1,193 +1,107 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
EmotionCanvasTheme,
|
|
9
|
-
createComponent,
|
|
10
|
-
focusRing,
|
|
11
|
-
} from '@workday/canvas-kit-react/common';
|
|
12
|
-
import {CanvasSystemIcon} from '@workday/design-assets-types';
|
|
13
|
-
import {ButtonColors, ButtonSizes, IconPositions} from './types';
|
|
14
|
-
import {BaseButton, BaseButtonProps, getMinWidthStyles, getPaddingStyles} from './BaseButton';
|
|
3
|
+
import {buttonVars} from './BaseButton';
|
|
4
|
+
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {createStyles, cssVar, createModifiers} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {base, brand, system} from '@workday/canvas-tokens-web';
|
|
7
|
+
import {Button, ButtonProps} from './Button';
|
|
15
8
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* There are four button sizes: `extraSmall`, `small`, `medium`, and `large`.
|
|
24
|
-
* If no size is provided, it will default to `medium`.
|
|
25
|
-
*
|
|
26
|
-
* @default 'medium'
|
|
27
|
-
*/
|
|
28
|
-
size?: ButtonSizes;
|
|
29
|
-
/**
|
|
30
|
-
* The icon of the Button.
|
|
31
|
-
* Note: not displayed at `small` size
|
|
32
|
-
*/
|
|
33
|
-
icon?: CanvasSystemIcon;
|
|
34
|
-
/**
|
|
35
|
-
* Button icon positions can either be `start` or `end`.
|
|
36
|
-
* If no value is provided, it defaults to `start`.
|
|
37
|
-
* @default 'start'
|
|
38
|
-
*/
|
|
39
|
-
iconPosition?: IconPositions;
|
|
9
|
+
/**
|
|
10
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
11
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
12
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
13
|
+
*/
|
|
14
|
+
export interface SecondaryButtonProps extends ButtonProps {
|
|
40
15
|
/**
|
|
41
|
-
*
|
|
42
|
-
* @default false
|
|
16
|
+
* Variant has an option for `inverse` which will inverse the styling
|
|
43
17
|
*/
|
|
44
|
-
|
|
45
|
-
children?: React.ReactNode;
|
|
18
|
+
variant?: 'inverse';
|
|
46
19
|
}
|
|
47
20
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
21
|
+
const secondaryStyles = createStyles({
|
|
22
|
+
// Default Styles
|
|
23
|
+
[buttonVars.default.background]: 'transparent',
|
|
24
|
+
[buttonVars.default.border]: cssVar(base.blackPepper400),
|
|
25
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.circle),
|
|
26
|
+
[buttonVars.default.label]: cssVar(base.blackPepper400),
|
|
27
|
+
[buttonVars.default.icon]: cssVar(base.blackPepper400),
|
|
28
|
+
// Hover Styles
|
|
29
|
+
[buttonVars.hover.background]: cssVar(base.blackPepper400),
|
|
30
|
+
[buttonVars.hover.border]: cssVar(base.blackPepper400),
|
|
31
|
+
[buttonVars.hover.label]: cssVar(brand.primary.accent),
|
|
32
|
+
[buttonVars.hover.icon]: cssVar(brand.primary.accent),
|
|
33
|
+
// Focus Styles
|
|
34
|
+
[buttonVars.focus.background]: 'transparent',
|
|
35
|
+
[buttonVars.focus.border]: cssVar(base.blackPepper400),
|
|
36
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper400),
|
|
37
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper400),
|
|
38
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.frenchVanilla100),
|
|
39
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
40
|
+
// Active Styles
|
|
41
|
+
[buttonVars.active.background]: cssVar(base.blackPepper500),
|
|
42
|
+
[buttonVars.active.border]: cssVar(base.blackPepper500),
|
|
43
|
+
[buttonVars.active.label]: cssVar(brand.primary.accent),
|
|
44
|
+
[buttonVars.active.icon]: cssVar(brand.primary.accent),
|
|
45
|
+
// Disabled Styles
|
|
46
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
47
|
+
[buttonVars.disabled.border]: cssVar(base.blackPepper400),
|
|
48
|
+
[buttonVars.disabled.label]: cssVar(base.blackPepper400),
|
|
49
|
+
[buttonVars.disabled.opacity]: '0.4',
|
|
50
|
+
[buttonVars.disabled.icon]: cssVar(base.blackPepper400),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const secondaryButtonModifiers = createModifiers({
|
|
54
|
+
variant: {
|
|
55
|
+
inverse: createStyles({
|
|
56
|
+
// Default Styles
|
|
57
|
+
[buttonVars.default.background]: 'transparent',
|
|
58
|
+
[buttonVars.default.border]: cssVar(base.frenchVanilla100),
|
|
59
|
+
[buttonVars.default.label]: cssVar(base.frenchVanilla100),
|
|
60
|
+
[buttonVars.default.icon]: cssVar(base.frenchVanilla100),
|
|
61
|
+
// Hover Styles
|
|
62
|
+
[buttonVars.hover.background]: cssVar(base.soap300),
|
|
63
|
+
[buttonVars.hover.border]: cssVar(base.soap300),
|
|
64
|
+
[buttonVars.hover.label]: cssVar(base.blackPepper500),
|
|
65
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper500),
|
|
66
|
+
// Focus Styles
|
|
67
|
+
[buttonVars.focus.background]: cssVar(base.frenchVanilla100),
|
|
68
|
+
[buttonVars.focus.border]: cssVar(base.frenchVanilla100),
|
|
69
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper500),
|
|
70
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper500),
|
|
71
|
+
[buttonVars.focus.boxShadowInner]: cssVar(base.blackPepper500),
|
|
72
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(base.frenchVanilla100),
|
|
73
|
+
// Active Styles
|
|
74
|
+
[buttonVars.active.background]: cssVar(base.soap400),
|
|
75
|
+
[buttonVars.active.border]: cssVar(base.soap400),
|
|
76
|
+
[buttonVars.active.label]: cssVar(base.blackPepper500),
|
|
77
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper500),
|
|
78
|
+
// Disabled Styles
|
|
79
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
80
|
+
[buttonVars.disabled.border]: cssVar(base.frenchVanilla100),
|
|
81
|
+
[buttonVars.disabled.label]: cssVar(base.frenchVanilla100),
|
|
82
|
+
[buttonVars.disabled.icon]: cssVar(base.frenchVanilla100),
|
|
83
|
+
}),
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
57
87
|
export const SecondaryButton = createComponent('button')({
|
|
58
88
|
displayName: 'SecondaryButton',
|
|
59
89
|
Component: (
|
|
60
|
-
{
|
|
61
|
-
size = 'medium',
|
|
62
|
-
iconPosition = 'start',
|
|
63
|
-
variant,
|
|
64
|
-
icon,
|
|
65
|
-
shouldMirrorIcon = false,
|
|
66
|
-
children,
|
|
67
|
-
...elemProps
|
|
68
|
-
}: SecondaryButtonProps,
|
|
90
|
+
{children, icon, cs, iconPosition, variant, ...elemProps}: SecondaryButtonProps,
|
|
69
91
|
ref,
|
|
70
92
|
Element
|
|
71
93
|
) => {
|
|
72
|
-
const theme = useTheme();
|
|
73
|
-
|
|
74
94
|
return (
|
|
75
|
-
<
|
|
76
|
-
ref={ref}
|
|
77
|
-
size={size}
|
|
78
|
-
colors={getSecondaryButtonColors(variant, theme)}
|
|
79
|
-
padding={getPaddingStyles(children, size, icon, iconPosition)}
|
|
80
|
-
minWidth={getMinWidthStyles(children, size)}
|
|
95
|
+
<Button
|
|
81
96
|
as={Element}
|
|
97
|
+
ref={ref}
|
|
98
|
+
icon={icon}
|
|
99
|
+
iconPosition={iconPosition}
|
|
100
|
+
cs={[secondaryStyles, secondaryButtonModifiers({variant: variant}), cs]}
|
|
82
101
|
{...elemProps}
|
|
83
102
|
>
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
size={size}
|
|
87
|
-
iconPosition={iconPosition}
|
|
88
|
-
icon={icon}
|
|
89
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
90
|
-
/>
|
|
91
|
-
)}
|
|
92
|
-
{children && <BaseButton.Label>{children}</BaseButton.Label>}
|
|
93
|
-
{icon && iconPosition === 'end' && (
|
|
94
|
-
<BaseButton.Icon
|
|
95
|
-
size={size}
|
|
96
|
-
iconPosition={iconPosition}
|
|
97
|
-
icon={icon}
|
|
98
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
99
|
-
/>
|
|
100
|
-
)}
|
|
101
|
-
</BaseButton>
|
|
103
|
+
{children}
|
|
104
|
+
</Button>
|
|
102
105
|
);
|
|
103
106
|
},
|
|
104
107
|
});
|
|
105
|
-
|
|
106
|
-
export const getSecondaryButtonColors = (
|
|
107
|
-
variant: 'inverse' | undefined,
|
|
108
|
-
theme: EmotionCanvasTheme
|
|
109
|
-
): ButtonColors => {
|
|
110
|
-
const {
|
|
111
|
-
canvas: {
|
|
112
|
-
palette: {primary: themePrimary},
|
|
113
|
-
},
|
|
114
|
-
} = theme;
|
|
115
|
-
|
|
116
|
-
switch (variant) {
|
|
117
|
-
case undefined:
|
|
118
|
-
default:
|
|
119
|
-
return {
|
|
120
|
-
default: {
|
|
121
|
-
background: 'transparent',
|
|
122
|
-
border: colors.blackPepper400,
|
|
123
|
-
icon: colors.blackPepper400,
|
|
124
|
-
label: colors.blackPepper400,
|
|
125
|
-
},
|
|
126
|
-
hover: {
|
|
127
|
-
background: colors.blackPepper400,
|
|
128
|
-
border: colors.blackPepper400,
|
|
129
|
-
icon: themePrimary.contrast,
|
|
130
|
-
label: themePrimary.contrast,
|
|
131
|
-
},
|
|
132
|
-
active: {
|
|
133
|
-
background: colors.blackPepper500,
|
|
134
|
-
border: colors.blackPepper500,
|
|
135
|
-
icon: themePrimary.contrast,
|
|
136
|
-
label: themePrimary.contrast,
|
|
137
|
-
},
|
|
138
|
-
focus: {
|
|
139
|
-
border: colors.blackPepper400,
|
|
140
|
-
icon: colors.blackPepper400,
|
|
141
|
-
label: colors.blackPepper400,
|
|
142
|
-
},
|
|
143
|
-
// Identical to 'default' styles. ButtonContainer will set opacity to 40%
|
|
144
|
-
disabled: {
|
|
145
|
-
background: 'transparent',
|
|
146
|
-
border: colors.blackPepper400,
|
|
147
|
-
icon: colors.blackPepper400,
|
|
148
|
-
label: colors.blackPepper400,
|
|
149
|
-
},
|
|
150
|
-
};
|
|
151
|
-
case 'inverse':
|
|
152
|
-
return {
|
|
153
|
-
default: {
|
|
154
|
-
background: 'transparent',
|
|
155
|
-
border: colors.frenchVanilla100,
|
|
156
|
-
icon: colors.frenchVanilla100,
|
|
157
|
-
label: colors.frenchVanilla100,
|
|
158
|
-
},
|
|
159
|
-
hover: {
|
|
160
|
-
background: colors.soap300,
|
|
161
|
-
border: colors.soap300,
|
|
162
|
-
icon: colors.blackPepper500,
|
|
163
|
-
label: colors.blackPepper500,
|
|
164
|
-
},
|
|
165
|
-
active: {
|
|
166
|
-
background: colors.soap400,
|
|
167
|
-
border: colors.soap400,
|
|
168
|
-
icon: colors.blackPepper500,
|
|
169
|
-
label: colors.blackPepper500,
|
|
170
|
-
},
|
|
171
|
-
focus: {
|
|
172
|
-
background: colors.frenchVanilla100,
|
|
173
|
-
icon: colors.blackPepper500,
|
|
174
|
-
label: colors.blackPepper500,
|
|
175
|
-
focusRing: focusRing(
|
|
176
|
-
{
|
|
177
|
-
separation: 2,
|
|
178
|
-
innerColor: 'currentColor',
|
|
179
|
-
outerColor: colors.frenchVanilla100,
|
|
180
|
-
},
|
|
181
|
-
theme
|
|
182
|
-
),
|
|
183
|
-
},
|
|
184
|
-
// Identical to inverse 'default' styles. ButtonContainer will set opacity to 40%
|
|
185
|
-
disabled: {
|
|
186
|
-
background: 'transparent',
|
|
187
|
-
border: colors.frenchVanilla100,
|
|
188
|
-
icon: colors.frenchVanilla100,
|
|
189
|
-
label: colors.frenchVanilla100,
|
|
190
|
-
},
|
|
191
|
-
};
|
|
192
|
-
}
|
|
193
|
-
};
|