@workday/canvas-kit-react 10.0.0-alpha.538-next.0 → 10.0.0-alpha.539-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/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/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/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/commonjs/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +1 -1
- 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/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/segmented-control/lib/SegmentedControlButton.d.ts.map +1 -1
- package/dist/es6/segmented-control/lib/SegmentedControlButton.js +3 -1
- package/dist/es6/tabs/lib/TabsItem.d.ts +1 -1
- package/layout/lib/Box.tsx +6 -4
- package/package.json +5 -3
- package/popup/lib/PopupCloseIcon.tsx +1 -1
- package/segmented-control/lib/SegmentedControlButton.tsx +3 -1
|
@@ -1,256 +1,191 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
focusRing,
|
|
4
|
-
useTheme,
|
|
5
|
-
Themeable,
|
|
6
|
-
EmotionCanvasTheme,
|
|
7
|
-
createComponent,
|
|
8
|
-
styled,
|
|
9
|
-
StyledType,
|
|
10
|
-
} from '@workday/canvas-kit-react/common';
|
|
11
|
-
import {borderRadius, colors, space} from '@workday/canvas-kit-react/tokens';
|
|
12
|
-
import {CanvasSystemIcon} from '@workday/design-assets-types';
|
|
13
|
-
import {ButtonColors, IconPositions, ButtonSizes} from './types';
|
|
14
|
-
import {BaseButton, BaseButtonProps} from './BaseButton';
|
|
15
2
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
iconPosition?: IconPositions;
|
|
31
|
-
/**
|
|
32
|
-
* The icon of the TertiaryButton.
|
|
33
|
-
*/
|
|
34
|
-
icon?: CanvasSystemIcon;
|
|
35
|
-
/**
|
|
36
|
-
* The capitalization of the text in the button.
|
|
37
|
-
*/
|
|
38
|
-
/**
|
|
39
|
-
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
40
|
-
*/
|
|
41
|
-
shouldMirrorIcon?: boolean;
|
|
42
|
-
/**
|
|
43
|
-
* If set to `true`, transform text to all letters uppercase
|
|
44
|
-
*/
|
|
45
|
-
allCaps?: boolean;
|
|
46
|
-
children?: React.ReactNode;
|
|
3
|
+
import {buttonVars, getIconPosition} from './BaseButton';
|
|
4
|
+
import {createComponent, focusRing} from '@workday/canvas-kit-react/common';
|
|
5
|
+
import {createStyles, cssVar, createModifiers} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {system, brand, base} from '@workday/canvas-tokens-web';
|
|
7
|
+
import {borderRadius, space} from '@workday/canvas-kit-react/tokens';
|
|
8
|
+
import {Button, ButtonProps} from './Button';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
12
|
+
* We omit `ref` since all of our buttons use `createComponent` and already give access to `ref`.
|
|
13
|
+
* Use this type to extend and customize any one off buttons that you want full control over styling.
|
|
14
|
+
*/
|
|
15
|
+
export interface TertiaryButtonProps extends ButtonProps {
|
|
47
16
|
/**
|
|
48
|
-
*
|
|
17
|
+
* Variant has an option for `inverse` which will inverse the styling
|
|
49
18
|
*/
|
|
19
|
+
variant?: 'inverse';
|
|
50
20
|
isThemeable?: boolean;
|
|
51
21
|
}
|
|
52
22
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
hasThemeStyles: boolean
|
|
57
|
-
): ButtonColors => {
|
|
58
|
-
const {
|
|
59
|
-
canvas: {
|
|
60
|
-
palette: {primary: themePrimary},
|
|
61
|
-
},
|
|
62
|
-
} = theme;
|
|
63
|
-
|
|
64
|
-
if (variant === 'inverse') {
|
|
65
|
-
return {
|
|
66
|
-
default: {
|
|
67
|
-
background: 'transparent',
|
|
68
|
-
icon: colors.frenchVanilla100,
|
|
69
|
-
label: colors.frenchVanilla100,
|
|
70
|
-
},
|
|
71
|
-
hover: {
|
|
72
|
-
background: colors.frenchVanilla100,
|
|
73
|
-
icon: colors.blackPepper400,
|
|
74
|
-
label: colors.blackPepper400,
|
|
75
|
-
},
|
|
76
|
-
active: {
|
|
77
|
-
background: colors.soap200,
|
|
78
|
-
icon: colors.blackPepper400,
|
|
79
|
-
label: colors.blackPepper400,
|
|
80
|
-
},
|
|
81
|
-
focus: {
|
|
82
|
-
background: colors.frenchVanilla100,
|
|
83
|
-
icon: colors.blackPepper400,
|
|
84
|
-
label: colors.blackPepper400,
|
|
85
|
-
focusRing: focusRing(
|
|
86
|
-
{
|
|
87
|
-
separation: 2,
|
|
88
|
-
inset: 'inner',
|
|
89
|
-
innerColor: 'currentColor',
|
|
90
|
-
outerColor: colors.frenchVanilla100,
|
|
91
|
-
},
|
|
92
|
-
theme
|
|
93
|
-
),
|
|
94
|
-
},
|
|
95
|
-
disabled: {
|
|
96
|
-
background: 'transparent',
|
|
97
|
-
icon: colors.frenchVanilla100,
|
|
98
|
-
label: colors.frenchVanilla100,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
} else {
|
|
102
|
-
return {
|
|
103
|
-
default: {
|
|
104
|
-
icon: hasThemeStyles ? themePrimary.main : colors.blackPepper400,
|
|
105
|
-
label: themePrimary.main,
|
|
106
|
-
},
|
|
107
|
-
hover: {
|
|
108
|
-
background: colors.soap200,
|
|
109
|
-
icon: hasThemeStyles ? themePrimary.dark : colors.blackPepper500,
|
|
110
|
-
label: themePrimary.dark,
|
|
111
|
-
},
|
|
112
|
-
active: {
|
|
113
|
-
background: colors.soap300,
|
|
114
|
-
icon: hasThemeStyles ? themePrimary.dark : colors.blackPepper500,
|
|
115
|
-
label: themePrimary.dark,
|
|
116
|
-
},
|
|
117
|
-
focus: {
|
|
118
|
-
icon: hasThemeStyles ? themePrimary.main : colors.blackPepper500,
|
|
119
|
-
label: themePrimary.main,
|
|
120
|
-
focusRing: focusRing({innerColor: colors.blueberry400}, theme),
|
|
121
|
-
},
|
|
122
|
-
disabled: {
|
|
123
|
-
background: 'transparent',
|
|
124
|
-
icon: hasThemeStyles ? themePrimary.main : colors.blackPepper400,
|
|
125
|
-
label: themePrimary.main,
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const StyledButtonLabel = styled(BaseButton.Label)({
|
|
23
|
+
const tertiaryStyles = createStyles({
|
|
24
|
+
paddingInline: cssVar(system.space.x2, space.xxs),
|
|
25
|
+
minWidth: 'auto',
|
|
132
26
|
textDecoration: 'underline',
|
|
133
|
-
|
|
27
|
+
border: 0,
|
|
28
|
+
// Default Styles
|
|
29
|
+
[buttonVars.default.background]: 'transparent',
|
|
30
|
+
[buttonVars.default.border]: 'transparent',
|
|
31
|
+
[buttonVars.default.borderRadius]: cssVar(system.shape.medium),
|
|
32
|
+
[buttonVars.default.label]: cssVar(brand.primary.base),
|
|
33
|
+
[buttonVars.default.icon]: cssVar(base.blackPepper400),
|
|
34
|
+
// Hover Styles
|
|
35
|
+
[buttonVars.hover.background]: cssVar(base.soap200),
|
|
36
|
+
[buttonVars.hover.border]: 'transparent',
|
|
37
|
+
[buttonVars.hover.label]: cssVar(brand.primary.dark),
|
|
38
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper500),
|
|
39
|
+
// Focus Styles
|
|
40
|
+
[buttonVars.focus.background]: 'transparent',
|
|
41
|
+
[buttonVars.focus.border]: 'transparent',
|
|
42
|
+
[buttonVars.focus.label]: cssVar(brand.primary.base),
|
|
43
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper500),
|
|
44
|
+
[buttonVars.focus.boxShadowInner]: cssVar(brand.common.focusOutline),
|
|
45
|
+
[buttonVars.focus.boxShadowOuter]: cssVar(brand.common.focusOutline),
|
|
46
|
+
// Active Styles
|
|
47
|
+
[buttonVars.active.background]: cssVar(base.soap300),
|
|
48
|
+
[buttonVars.active.border]: 'transparent',
|
|
49
|
+
[buttonVars.active.label]: cssVar(brand.primary.dark),
|
|
50
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper500),
|
|
51
|
+
// Disabled Styles
|
|
52
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
53
|
+
[buttonVars.disabled.border]: cssVar(base.frenchVanilla100),
|
|
54
|
+
[buttonVars.disabled.label]: cssVar(brand.primary.base),
|
|
55
|
+
[buttonVars.disabled.icon]: cssVar(base.blackPepper400),
|
|
56
|
+
[buttonVars.disabled.opacity]: '0.4',
|
|
134
57
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
58
|
+
'&:focus-visible, &.focus': {
|
|
59
|
+
...focusRing({
|
|
60
|
+
width: 2,
|
|
61
|
+
separation: 0,
|
|
62
|
+
innerColor: cssVar(base.frenchVanilla100, cssVar(buttonVars.focus.boxShadowInner)),
|
|
63
|
+
outerColor: cssVar(brand.common.focusOutline, cssVar(buttonVars.focus.boxShadowOuter)),
|
|
64
|
+
}),
|
|
140
65
|
},
|
|
141
|
-
|
|
142
|
-
textTransform: allCaps ? 'uppercase' : undefined,
|
|
143
|
-
})
|
|
144
|
-
);
|
|
66
|
+
});
|
|
145
67
|
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
68
|
+
export const tertiaryButtonModifiers = createModifiers({
|
|
69
|
+
isThemeable: {
|
|
70
|
+
true: createStyles({
|
|
71
|
+
[buttonVars.default.icon]: cssVar(brand.primary.base),
|
|
72
|
+
[buttonVars.hover.icon]: cssVar(brand.primary.dark),
|
|
73
|
+
[buttonVars.focus.icon]: cssVar(brand.primary.base),
|
|
74
|
+
[buttonVars.active.icon]: cssVar(brand.primary.dark),
|
|
75
|
+
[buttonVars.disabled.icon]: cssVar(brand.primary.base),
|
|
76
|
+
}),
|
|
77
|
+
},
|
|
78
|
+
variant: {
|
|
79
|
+
inverse: createStyles({
|
|
80
|
+
// Default Styles
|
|
81
|
+
[buttonVars.default.background]: 'transparent',
|
|
82
|
+
[buttonVars.default.border]: 'transparent',
|
|
83
|
+
[buttonVars.default.label]: cssVar(base.frenchVanilla100),
|
|
84
|
+
[buttonVars.default.icon]: cssVar(base.frenchVanilla100),
|
|
85
|
+
// Hover Styles
|
|
86
|
+
[buttonVars.hover.background]: cssVar(base.frenchVanilla100),
|
|
87
|
+
[buttonVars.hover.border]: 'transparent',
|
|
88
|
+
[buttonVars.hover.label]: cssVar(base.blackPepper400),
|
|
89
|
+
[buttonVars.hover.icon]: cssVar(base.blackPepper400),
|
|
90
|
+
// Focus Styles
|
|
91
|
+
[buttonVars.focus.background]: cssVar(base.frenchVanilla100),
|
|
92
|
+
[buttonVars.focus.border]: 'transparent',
|
|
93
|
+
[buttonVars.focus.label]: cssVar(base.blackPepper400),
|
|
94
|
+
[buttonVars.focus.icon]: cssVar(base.blackPepper400),
|
|
95
|
+
// Active Styles
|
|
96
|
+
[buttonVars.active.background]: cssVar(base.soap200),
|
|
97
|
+
[buttonVars.active.border]: 'transparent',
|
|
98
|
+
[buttonVars.active.label]: cssVar(base.blackPepper400),
|
|
99
|
+
[buttonVars.active.icon]: cssVar(base.blackPepper400),
|
|
100
|
+
// Disabled Styles
|
|
101
|
+
[buttonVars.disabled.background]: 'transparent',
|
|
102
|
+
[buttonVars.disabled.border]: cssVar(base.frenchVanilla100),
|
|
103
|
+
[buttonVars.disabled.label]: cssVar(base.frenchVanilla100),
|
|
104
|
+
[buttonVars.disabled.icon]: cssVar(base.frenchVanilla100),
|
|
173
105
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
106
|
+
'&:focus-visible, &.focus': {
|
|
107
|
+
...focusRing({
|
|
108
|
+
inset: 'inner',
|
|
109
|
+
width: 2,
|
|
110
|
+
separation: 2,
|
|
111
|
+
innerColor: cssVar(base.blackPepper400, cssVar(buttonVars.focus.boxShadowInner)),
|
|
112
|
+
outerColor: cssVar(base.frenchVanilla100, cssVar(buttonVars.focus.boxShadowOuter)),
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
}),
|
|
116
|
+
},
|
|
117
|
+
iconPosition: {
|
|
118
|
+
largeOnly: createStyles({
|
|
119
|
+
borderRadius: borderRadius.circle,
|
|
120
|
+
padding: '0',
|
|
121
|
+
minWidth: cssVar(system.space.x12),
|
|
122
|
+
}),
|
|
123
|
+
largeStart: createStyles({
|
|
124
|
+
paddingInlineStart: space.xxs,
|
|
125
|
+
paddingInlineEnd: space.xs,
|
|
126
|
+
}),
|
|
127
|
+
largeEnd: createStyles({paddingInlineStart: space.xs, paddingInlineEnd: space.xxs}),
|
|
128
|
+
mediumOnly: createStyles({padding: '0', minWidth: space.xl, borderRadius: borderRadius.circle}),
|
|
129
|
+
mediumStart: createStyles({paddingInlineStart: space.xxs, paddingInlineEnd: space.xs}),
|
|
130
|
+
mediumEnd: createStyles({paddingInlineStart: space.xs, paddingInlineEnd: space.xxs}),
|
|
131
|
+
smallOnly: createStyles({padding: '0', minWidth: space.l, borderRadius: borderRadius.circle}),
|
|
132
|
+
smallStart: createStyles({paddingInlineStart: space.xxs, paddingInlineEnd: space.xs}),
|
|
133
|
+
smallEnd: createStyles({paddingInlineStart: space.xs, paddingInlineEnd: space.xxs}),
|
|
134
|
+
extraSmallOnly: createStyles({
|
|
135
|
+
padding: '0',
|
|
136
|
+
minWidth: space.m,
|
|
137
|
+
borderRadius: borderRadius.circle,
|
|
138
|
+
}),
|
|
139
|
+
extraSmallStart: createStyles({paddingInlineStart: space.xxxs, paddingInlineEnd: space.xxs}),
|
|
140
|
+
extraSmallEnd: createStyles({paddingInlineStart: space.xxs, paddingInlineEnd: space.xxxs}),
|
|
141
|
+
},
|
|
142
|
+
});
|
|
195
143
|
|
|
196
|
-
/**
|
|
197
|
-
* Tertiary Buttons have the lowest emphasis. Use for less important actions that the user may not
|
|
198
|
-
* often be looking to do. Tertiary Buttons have lower prominence as its container is not visible
|
|
199
|
-
* until it is interacted with. Use Tertiary Buttons for supplemental actions such as “View More”,
|
|
200
|
-
* “Read More” or “Select a File”. Tertiary Buttons are frequently used on Cards.
|
|
201
|
-
*
|
|
202
|
-
* Tertiary Buttons have four sizes: `extraSmall`, `small`, `medium` and `large`. Icons are
|
|
203
|
-
* supported for every size and can be positioned at the `start` or `end` with the `iconPosition`
|
|
204
|
-
* prop.
|
|
205
|
-
*/
|
|
206
144
|
export const TertiaryButton = createComponent('button')({
|
|
207
145
|
displayName: 'TertiaryButton',
|
|
208
146
|
Component: (
|
|
209
147
|
{
|
|
210
|
-
size = 'medium',
|
|
211
|
-
iconPosition = 'start',
|
|
212
|
-
isThemeable = false,
|
|
213
|
-
variant,
|
|
214
148
|
children,
|
|
215
149
|
icon,
|
|
216
|
-
|
|
150
|
+
colors,
|
|
151
|
+
size = 'medium',
|
|
152
|
+
isThemeable,
|
|
153
|
+
variant,
|
|
154
|
+
iconPosition,
|
|
155
|
+
cs,
|
|
217
156
|
...elemProps
|
|
218
157
|
}: TertiaryButtonProps,
|
|
219
158
|
ref,
|
|
220
159
|
Element
|
|
221
160
|
) => {
|
|
222
|
-
const
|
|
223
|
-
|
|
161
|
+
const baseIconPosition = iconPosition
|
|
162
|
+
? iconPosition
|
|
163
|
+
: icon
|
|
164
|
+
? children
|
|
165
|
+
? 'start'
|
|
166
|
+
: 'only'
|
|
167
|
+
: undefined;
|
|
224
168
|
|
|
225
169
|
return (
|
|
226
|
-
<
|
|
227
|
-
ref={ref}
|
|
170
|
+
<Button
|
|
228
171
|
as={Element}
|
|
229
|
-
|
|
172
|
+
ref={ref}
|
|
173
|
+
icon={icon}
|
|
174
|
+
iconPosition={iconPosition}
|
|
230
175
|
size={size}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
176
|
+
cs={[
|
|
177
|
+
tertiaryStyles,
|
|
178
|
+
tertiaryButtonModifiers({
|
|
179
|
+
isThemeable: (isThemeable || baseIconPosition !== 'only') as any,
|
|
180
|
+
variant: variant,
|
|
181
|
+
iconPosition: getIconPosition(size, baseIconPosition),
|
|
182
|
+
}),
|
|
183
|
+
cs,
|
|
184
|
+
]}
|
|
234
185
|
{...elemProps}
|
|
235
186
|
>
|
|
236
|
-
{
|
|
237
|
-
|
|
238
|
-
size={size}
|
|
239
|
-
iconPosition={iconPosition}
|
|
240
|
-
icon={icon}
|
|
241
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
242
|
-
/>
|
|
243
|
-
)}
|
|
244
|
-
{children && <StyledButtonLabel>{children}</StyledButtonLabel>}
|
|
245
|
-
{icon && iconPosition === 'end' && (
|
|
246
|
-
<BaseButton.Icon
|
|
247
|
-
size={size}
|
|
248
|
-
iconPosition={iconPosition}
|
|
249
|
-
icon={icon}
|
|
250
|
-
shouldMirrorIcon={shouldMirrorIcon}
|
|
251
|
-
/>
|
|
252
|
-
)}
|
|
253
|
-
</StyledTertiaryButtonContainer>
|
|
187
|
+
{children}
|
|
188
|
+
</Button>
|
|
254
189
|
);
|
|
255
190
|
},
|
|
256
191
|
});
|
|
@@ -9,10 +9,12 @@ import {
|
|
|
9
9
|
styled,
|
|
10
10
|
StyledType,
|
|
11
11
|
} from '@workday/canvas-kit-react/common';
|
|
12
|
+
import {cssVar} from '@workday/canvas-kit-styling';
|
|
12
13
|
import {ButtonColors} from './types';
|
|
13
14
|
import {BaseButton} from './BaseButton';
|
|
14
15
|
import {chevronDownSmallIcon} from '@workday/canvas-system-icons-web';
|
|
15
16
|
import {ToolbarIconButtonProps} from './ToolbarIconButton';
|
|
17
|
+
import {brand} from '@workday/canvas-tokens-web';
|
|
16
18
|
|
|
17
19
|
export interface ToolbarDropdownButtonProps
|
|
18
20
|
extends Omit<ToolbarIconButtonProps, 'toggled' | 'onToggleChange'>,
|
|
@@ -24,9 +26,9 @@ const StyledToolbarDropdownButton = styled(BaseButton)<StyledType & ToolbarDropd
|
|
|
24
26
|
width: 'auto',
|
|
25
27
|
height: space.l,
|
|
26
28
|
borderRadius: borderRadius.m,
|
|
29
|
+
gap: space.zero,
|
|
27
30
|
'& .wd-icon': {
|
|
28
31
|
display: 'inline-block',
|
|
29
|
-
verticalAlign: 'middle',
|
|
30
32
|
width: 20,
|
|
31
33
|
height: 20,
|
|
32
34
|
},
|
|
@@ -38,6 +40,14 @@ const StyledToolbarDropdownButton = styled(BaseButton)<StyledType & ToolbarDropd
|
|
|
38
40
|
marginRight: 0,
|
|
39
41
|
width: 18, // decrease the space between a custom icon and the chevron per design
|
|
40
42
|
},
|
|
43
|
+
'&:focus-visible, &.focus': {
|
|
44
|
+
...focusRing({
|
|
45
|
+
width: 2,
|
|
46
|
+
separation: 0,
|
|
47
|
+
innerColor: 'transparent',
|
|
48
|
+
outerColor: cssVar(brand.common.focusOutline),
|
|
49
|
+
}),
|
|
50
|
+
},
|
|
41
51
|
});
|
|
42
52
|
|
|
43
53
|
export const ToolbarDropdownButton = createComponent('button')({
|
|
@@ -96,7 +106,6 @@ const getToolbarDropdownButtonColors = (theme: EmotionCanvasTheme): ButtonColors
|
|
|
96
106
|
},
|
|
97
107
|
focus: {
|
|
98
108
|
icon: colors.licorice200,
|
|
99
|
-
focusRing: focusRing({width: 2, separation: 0}, theme),
|
|
100
109
|
background: 'transparent',
|
|
101
110
|
},
|
|
102
111
|
disabled: {
|
|
@@ -9,9 +9,11 @@ import {
|
|
|
9
9
|
styled,
|
|
10
10
|
StyledType,
|
|
11
11
|
} from '@workday/canvas-kit-react/common';
|
|
12
|
+
import {cssVar} from '@workday/canvas-kit-styling';
|
|
12
13
|
import {ButtonColors} from './types';
|
|
13
14
|
import {BaseButton} from './BaseButton';
|
|
14
15
|
import {TertiaryButtonProps} from './TertiaryButton';
|
|
16
|
+
import {brand} from '@workday/canvas-tokens-web';
|
|
15
17
|
|
|
16
18
|
export interface ToolbarIconButtonProps
|
|
17
19
|
extends Omit<TertiaryButtonProps, 'size' | 'variant'>,
|
|
@@ -24,10 +26,17 @@ export interface ToolbarIconButtonProps
|
|
|
24
26
|
const StyledToolbarIconButton = styled(BaseButton)<StyledType & ToolbarIconButtonProps>({
|
|
25
27
|
['& .wd-icon']: {
|
|
26
28
|
display: 'inline-block',
|
|
27
|
-
verticalAlign: 'middle',
|
|
28
29
|
width: 20,
|
|
29
30
|
height: 20,
|
|
30
31
|
},
|
|
32
|
+
'&:focus-visible, &.focus': {
|
|
33
|
+
...focusRing({
|
|
34
|
+
width: 2,
|
|
35
|
+
separation: 0,
|
|
36
|
+
innerColor: 'transparent',
|
|
37
|
+
outerColor: cssVar(brand.common.focusOutline),
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
31
40
|
});
|
|
32
41
|
|
|
33
42
|
export const ToolbarIconButton = createComponent('button')({
|
|
@@ -102,7 +111,6 @@ const getToolbarIconButtonColors = (theme: EmotionCanvasTheme, toggled?: boolean
|
|
|
102
111
|
},
|
|
103
112
|
focus: {
|
|
104
113
|
icon: toggled ? themePrimary.main : colors.licorice200,
|
|
105
|
-
focusRing: focusRing({width: 2, separation: 0}, theme),
|
|
106
114
|
background: toggled ? themePrimary.lightest : 'transparent',
|
|
107
115
|
},
|
|
108
116
|
disabled: {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {ButtonSizes
|
|
2
|
+
import {ButtonSizes} from '../types';
|
|
3
3
|
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
4
4
|
import {SystemIcon, SystemIconProps} from '@workday/canvas-kit-react/icon';
|
|
5
5
|
|
|
@@ -10,12 +10,6 @@ export interface ButtonLabelIconProps extends Partial<SystemIconProps> {
|
|
|
10
10
|
* @default 'medium'
|
|
11
11
|
*/
|
|
12
12
|
size?: ButtonSizes;
|
|
13
|
-
/**
|
|
14
|
-
* Button icon positions can either be `left` or `right`.
|
|
15
|
-
* If no value is provided, it defaults to `left`.
|
|
16
|
-
* @default 'start'
|
|
17
|
-
*/
|
|
18
|
-
iconPosition?: IconPositions;
|
|
19
13
|
/**
|
|
20
14
|
* If set to `true`, transform the icon's x-axis to mirror the graphic
|
|
21
15
|
* @default false
|
package/button/lib/types.ts
CHANGED
|
@@ -12,13 +12,13 @@ export interface ButtonStateColors {
|
|
|
12
12
|
opacity?: string;
|
|
13
13
|
}
|
|
14
14
|
export interface ButtonColors {
|
|
15
|
-
default
|
|
16
|
-
hover
|
|
17
|
-
active
|
|
18
|
-
focus
|
|
15
|
+
default?: ButtonStateColors;
|
|
16
|
+
hover?: ButtonStateColors;
|
|
17
|
+
active?: ButtonStateColors;
|
|
18
|
+
focus?: ButtonStateColors & {
|
|
19
19
|
focusRing?: CSSObject;
|
|
20
20
|
};
|
|
21
|
-
disabled
|
|
21
|
+
disabled?: ButtonStateColors;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -28,6 +28,4 @@ export interface ButtonColors {
|
|
|
28
28
|
* @default 'medium'
|
|
29
29
|
*/
|
|
30
30
|
export type ButtonSizes = 'extraSmall' | 'small' | 'medium' | 'large';
|
|
31
|
-
|
|
32
|
-
export type TertiaryButtonSizes = 'extraSmall' | 'small' | 'medium';
|
|
33
|
-
export type IconPositions = 'start' | 'end';
|
|
31
|
+
export type IconPositions = 'start' | 'end' | 'only';
|
|
@@ -1,34 +1,60 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import {Theme, ThemeProvider} from '@emotion/react';
|
|
3
3
|
import {InputProvider} from './InputProvider';
|
|
4
|
-
import {defaultCanvasTheme, PartialEmotionCanvasTheme} from './theming';
|
|
4
|
+
import {defaultCanvasTheme, PartialEmotionCanvasTheme, useTheme} from './theming';
|
|
5
|
+
import {brand} from '@workday/canvas-tokens-web';
|
|
5
6
|
|
|
6
7
|
export interface CanvasProviderProps {
|
|
7
8
|
theme: PartialEmotionCanvasTheme;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const mappedKeys = {
|
|
12
|
+
lightest: 'lightest',
|
|
13
|
+
light: 'light',
|
|
14
|
+
main: 'base',
|
|
15
|
+
dark: 'dark',
|
|
16
|
+
darkest: 'darkest',
|
|
17
|
+
contrast: 'accent',
|
|
18
|
+
};
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
const useCanvasThemeToCssVars = (
|
|
21
|
+
theme: PartialEmotionCanvasTheme,
|
|
22
|
+
elemProps: React.HTMLAttributes<HTMLElement>
|
|
23
|
+
) => {
|
|
24
|
+
const filledTheme = useTheme(theme);
|
|
25
|
+
const {palette} = filledTheme.canvas;
|
|
26
|
+
const style = (['common', 'primary', 'error', 'alert', 'success', 'neutral'] as const).reduce(
|
|
27
|
+
(result, color) => {
|
|
28
|
+
if (color === 'common') {
|
|
29
|
+
// @ts-ignore
|
|
30
|
+
result[brand.common.focusOutline] = palette.common.focusOutline;
|
|
31
|
+
}
|
|
32
|
+
(['lightest', 'light', 'main', 'dark', 'darkest', 'contrast'] as const).forEach(key => {
|
|
33
|
+
// @ts-ignore
|
|
34
|
+
result[brand[color][mappedKeys[key]]] = palette[color][key];
|
|
35
|
+
});
|
|
36
|
+
return result;
|
|
37
|
+
},
|
|
38
|
+
elemProps.style || {}
|
|
39
|
+
);
|
|
40
|
+
return {...elemProps, style};
|
|
41
|
+
};
|
|
21
42
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
export const CanvasProvider = ({
|
|
44
|
+
children,
|
|
45
|
+
theme,
|
|
46
|
+
...props
|
|
47
|
+
}: CanvasProviderProps & React.HTMLAttributes<HTMLElement>) => {
|
|
48
|
+
const elemProps = useCanvasThemeToCssVars(theme, props);
|
|
49
|
+
return (
|
|
50
|
+
<ThemeProvider theme={theme as Theme}>
|
|
51
|
+
<InputProvider />
|
|
52
|
+
<div
|
|
53
|
+
dir={(theme.canvas && theme.canvas.direction) || defaultCanvasTheme.direction}
|
|
54
|
+
{...(elemProps as React.HTMLAttributes<HTMLDivElement>)}
|
|
55
|
+
>
|
|
56
|
+
{children}
|
|
57
|
+
</div>
|
|
58
|
+
</ThemeProvider>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
export { PrimaryButton, PrimaryButtonProps } from './lib/PrimaryButton';
|
|
2
|
-
export { SecondaryButton, SecondaryButtonProps } from './lib/SecondaryButton';
|
|
3
|
-
export { TertiaryButton, TertiaryButtonProps } from './lib/TertiaryButton';
|
|
4
|
-
export { DeleteButton, DeleteButtonProps } from './lib/DeleteButton';
|
|
5
1
|
export { DeprecatedButton as deprecated_Button, DeprecatedButtonProps, } from './lib/deprecated_Button';
|
|
6
2
|
export { ToolbarIconButton, ToolbarIconButtonProps } from './lib/ToolbarIconButton';
|
|
7
3
|
export { ToolbarDropdownButton, ToolbarDropdownButtonProps } from './lib/ToolbarDropdownButton';
|
|
8
4
|
export { Hyperlink, HyperlinkProps } from './lib/Hyperlink';
|
|
9
|
-
export { BaseButton, ButtonContainerProps, BaseButtonProps, getMinWidthStyles, getPaddingStyles, } from './lib/BaseButton';
|
|
10
5
|
export { ExternalHyperlink, ExternalHyperlinkProps } from './lib/ExternalHyperlink';
|
|
11
6
|
export * from './lib/types';
|
|
7
|
+
export * from './lib/PrimaryButton';
|
|
8
|
+
export * from './lib/SecondaryButton';
|
|
9
|
+
export * from './lib/TertiaryButton';
|
|
10
|
+
export * from './lib/DeleteButton';
|
|
11
|
+
export * from './lib/BaseButton';
|
|
12
|
+
export * from './lib/ToolbarDropdownButton';
|
|
13
|
+
export * from './lib/ToolbarIconButton';
|
|
14
|
+
export * from './lib/types';
|
|
12
15
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../button/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../button/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,IAAI,iBAAiB,EACrC,qBAAqB,GACtB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAClF,OAAO,EAAC,qBAAqB,EAAE,0BAA0B,EAAC,MAAM,6BAA6B,CAAC;AAC9F,OAAO,EAAC,SAAS,EAAE,cAAc,EAAC,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAC,iBAAiB,EAAE,sBAAsB,EAAC,MAAM,yBAAyB,CAAC;AAClF,cAAc,aAAa,CAAC;AAC5B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,aAAa,CAAC"}
|