@workday/canvas-kit-react 11.0.0-alpha.767-next.0 → 11.0.0-alpha.770-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/lib/BaseButton.tsx +260 -204
- package/button/lib/Button.tsx +1 -4
- package/button/lib/DeleteButton.tsx +42 -38
- package/button/lib/PrimaryButton.tsx +74 -71
- package/button/lib/SecondaryButton.tsx +85 -87
- package/button/lib/TertiaryButton.tsx +214 -132
- package/dist/commonjs/button/lib/BaseButton.d.ts +70 -29
- package/dist/commonjs/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/BaseButton.js +98 -55
- package/dist/commonjs/button/lib/Button.d.ts.map +1 -1
- package/dist/commonjs/button/lib/Button.js +1 -2
- package/dist/commonjs/button/lib/DeleteButton.d.ts +1 -1
- package/dist/commonjs/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/DeleteButton.js +9 -6
- package/dist/commonjs/button/lib/PrimaryButton.d.ts +0 -5
- package/dist/commonjs/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +14 -10
- package/dist/commonjs/button/lib/SecondaryButton.d.ts +0 -5
- package/dist/commonjs/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/SecondaryButton.js +13 -10
- package/dist/commonjs/button/lib/TertiaryButton.d.ts +0 -22
- package/dist/commonjs/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/commonjs/button/lib/TertiaryButton.js +80 -35
- package/dist/es6/button/lib/BaseButton.d.ts +70 -29
- package/dist/es6/button/lib/BaseButton.d.ts.map +1 -1
- package/dist/es6/button/lib/BaseButton.js +99 -54
- package/dist/es6/button/lib/Button.d.ts.map +1 -1
- package/dist/es6/button/lib/Button.js +1 -2
- package/dist/es6/button/lib/DeleteButton.d.ts +1 -1
- package/dist/es6/button/lib/DeleteButton.d.ts.map +1 -1
- package/dist/es6/button/lib/DeleteButton.js +12 -9
- package/dist/es6/button/lib/PrimaryButton.d.ts +0 -5
- package/dist/es6/button/lib/PrimaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +15 -11
- package/dist/es6/button/lib/SecondaryButton.d.ts +0 -5
- package/dist/es6/button/lib/SecondaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/SecondaryButton.js +15 -12
- package/dist/es6/button/lib/TertiaryButton.d.ts +0 -22
- package/dist/es6/button/lib/TertiaryButton.d.ts.map +1 -1
- package/dist/es6/button/lib/TertiaryButton.js +82 -37
- package/package.json +4 -4
|
@@ -4,12 +4,12 @@ import {ButtonLabelIcon} from '../lib/parts/ButtonLabelIcon';
|
|
|
4
4
|
import {ButtonLabel} from '../lib/parts/ButtonLabel';
|
|
5
5
|
|
|
6
6
|
import {createComponent, GrowthBehavior, focusRing} from '@workday/canvas-kit-react/common';
|
|
7
|
-
import {
|
|
8
|
-
import {createStyles, createVars, cssVar, createModifiers} from '@workday/canvas-kit-styling';
|
|
7
|
+
import {cssVar, createStencil, px2rem, createVars, calc} from '@workday/canvas-kit-styling';
|
|
9
8
|
import {SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
10
|
-
import {
|
|
9
|
+
import {brand, system} from '@workday/canvas-tokens-web';
|
|
11
10
|
import {ButtonColors, ButtonSizes, IconPositions} from './types';
|
|
12
11
|
import {CanvasSystemIcon} from '@workday/design-assets-types';
|
|
12
|
+
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
13
13
|
|
|
14
14
|
export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBehavior {
|
|
15
15
|
/**
|
|
@@ -25,7 +25,7 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
|
|
|
25
25
|
size?: ButtonSizes;
|
|
26
26
|
/**
|
|
27
27
|
* The icon of the Button.
|
|
28
|
-
* Note:
|
|
28
|
+
* Note: Not displayed at `small` size
|
|
29
29
|
*/
|
|
30
30
|
icon?: CanvasSystemIcon;
|
|
31
31
|
/**
|
|
@@ -56,9 +56,9 @@ export interface ButtonContainerProps extends Partial<SystemIconProps>, GrowthBe
|
|
|
56
56
|
export interface BaseButtonProps extends Omit<ButtonContainerProps, 'ref'> {}
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* The purpose of this object is for the `colors` prop - to provide backwards compatibility with how we allowed color overrides in Emotion.
|
|
60
60
|
*/
|
|
61
|
-
export const
|
|
61
|
+
export const buttonColorPropVars = {
|
|
62
62
|
default: createVars(
|
|
63
63
|
'background',
|
|
64
64
|
'border',
|
|
@@ -69,7 +69,7 @@ export const buttonVars = {
|
|
|
69
69
|
'opacity',
|
|
70
70
|
'borderRadius'
|
|
71
71
|
),
|
|
72
|
-
|
|
72
|
+
focus: createVars(
|
|
73
73
|
'background',
|
|
74
74
|
'border',
|
|
75
75
|
'boxShadowInner',
|
|
@@ -79,7 +79,7 @@ export const buttonVars = {
|
|
|
79
79
|
'opacity',
|
|
80
80
|
'borderRadius'
|
|
81
81
|
),
|
|
82
|
-
|
|
82
|
+
hover: createVars(
|
|
83
83
|
'background',
|
|
84
84
|
'border',
|
|
85
85
|
'boxShadowInner',
|
|
@@ -89,7 +89,7 @@ export const buttonVars = {
|
|
|
89
89
|
'opacity',
|
|
90
90
|
'borderRadius'
|
|
91
91
|
),
|
|
92
|
-
|
|
92
|
+
active: createVars(
|
|
93
93
|
'background',
|
|
94
94
|
'border',
|
|
95
95
|
'boxShadowInner',
|
|
@@ -114,200 +114,260 @@ export const buttonVars = {
|
|
|
114
114
|
/**
|
|
115
115
|
* Base styles for Buttons.
|
|
116
116
|
*/
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
borderStyle: 'solid',
|
|
127
|
-
gap: system.space.x2,
|
|
128
|
-
borderColor: cssVar(buttonVars.default.border, 'transparent'),
|
|
129
|
-
cursor: 'pointer',
|
|
130
|
-
display: 'inline-flex',
|
|
131
|
-
boxShadow: 'none',
|
|
132
|
-
alignItems: 'center',
|
|
133
|
-
justifyContent: 'center',
|
|
134
|
-
boxSizing: 'border-box',
|
|
135
|
-
outline: '2px transparent',
|
|
136
|
-
whiteSpace: 'nowrap',
|
|
137
|
-
WebkitFontSmoothing: 'antialiased',
|
|
138
|
-
MozOsxFontSmoothing: 'grayscale',
|
|
139
|
-
borderRadius: cssVar(buttonVars.default.borderRadius, system.shape.round),
|
|
140
|
-
position: 'relative',
|
|
141
|
-
verticalAlign: 'middle',
|
|
142
|
-
overflow: 'hidden',
|
|
143
|
-
[systemIconStencil.vars.color]: cssVar(buttonVars.default.icon, base.blackPepper400),
|
|
144
|
-
transition:
|
|
145
|
-
'box-shadow 120ms linear, border 120ms linear, background-color 120ms linear, color 120ms linear',
|
|
146
|
-
'&:disabled, &:disabled:active, &.disabled': {
|
|
147
|
-
cursor: 'default',
|
|
148
|
-
boxShadow: 'none',
|
|
149
|
-
opacity: cssVar(buttonVars.disabled.opacity, '1'),
|
|
150
|
-
},
|
|
151
|
-
/*
|
|
152
|
-
'& span .wd-icon-fill, & span .wd-icon-accent, & span .wd-icon-accent2': {
|
|
153
|
-
transitionDuration: '40ms',
|
|
154
|
-
fill: cssVar(buttonVars.default.icon, base.blackPepper400),
|
|
117
|
+
export const buttonStencil = createStencil({
|
|
118
|
+
vars: {
|
|
119
|
+
background: '',
|
|
120
|
+
border: '',
|
|
121
|
+
boxShadowInner: '',
|
|
122
|
+
boxShadowOuter: '',
|
|
123
|
+
label: '',
|
|
124
|
+
opacity: '',
|
|
125
|
+
borderRadius: '',
|
|
155
126
|
},
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
127
|
+
base: ({background, border, boxShadowInner, boxShadowOuter, label, opacity, borderRadius}) => ({
|
|
128
|
+
// Default Styles
|
|
129
|
+
fontFamily: '"Roboto", "Helvetica Neue", "Helvetica", Arial, sans-serif',
|
|
130
|
+
fontSize: '0.875rem',
|
|
131
|
+
lineHeight: 'normal',
|
|
132
|
+
letterSpacing: '0.015rem',
|
|
133
|
+
fontWeight: system.fontWeight.bold,
|
|
134
|
+
backgroundColor: cssVar(
|
|
135
|
+
buttonColorPropVars.default.background,
|
|
136
|
+
cssVar(background, 'transparent')
|
|
137
|
+
),
|
|
138
|
+
color: cssVar(buttonColorPropVars.default.label, cssVar(label, system.color.fg.strong)),
|
|
139
|
+
borderWidth: px2rem(1),
|
|
140
|
+
borderStyle: 'solid',
|
|
141
|
+
gap: system.space.x2,
|
|
142
|
+
borderColor: cssVar(buttonColorPropVars.default.border, cssVar(border, 'transparent')),
|
|
143
|
+
cursor: 'pointer',
|
|
144
|
+
display: 'inline-flex',
|
|
145
|
+
boxShadow: 'none',
|
|
146
|
+
alignItems: 'center',
|
|
147
|
+
justifyContent: 'center',
|
|
148
|
+
boxSizing: 'border-box',
|
|
149
|
+
outline: `${px2rem(2)} transparent`,
|
|
150
|
+
whiteSpace: 'nowrap',
|
|
151
|
+
WebkitFontSmoothing: 'antialiased',
|
|
152
|
+
MozOsxFontSmoothing: 'grayscale',
|
|
153
|
+
borderRadius: cssVar(
|
|
154
|
+
buttonColorPropVars.default.borderRadius,
|
|
155
|
+
cssVar(borderRadius, system.shape.round)
|
|
156
|
+
),
|
|
157
|
+
position: 'relative',
|
|
158
|
+
verticalAlign: 'middle',
|
|
159
|
+
overflow: 'hidden',
|
|
160
|
+
[systemIconStencil.vars.color]: cssVar(
|
|
161
|
+
buttonColorPropVars.default.icon,
|
|
162
|
+
system.color.fg.strong
|
|
163
|
+
),
|
|
164
|
+
transition:
|
|
165
|
+
'box-shadow 120ms linear, border 120ms linear, background-color 120ms linear, color 120ms linear',
|
|
166
|
+
'&:disabled, &:disabled:active, &.disabled': {
|
|
167
|
+
cursor: 'default',
|
|
168
|
+
boxShadow: 'none',
|
|
169
|
+
opacity: cssVar(buttonColorPropVars.default.opacity, cssVar(opacity, system.opacity.full)),
|
|
168
170
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
171
|
+
// Focus Styles
|
|
172
|
+
'&:focus-visible, &.focus': {
|
|
173
|
+
backgroundColor: cssVar(
|
|
174
|
+
buttonColorPropVars.focus.background,
|
|
175
|
+
cssVar(background, 'transparent')
|
|
176
|
+
),
|
|
177
|
+
borderColor: cssVar(buttonColorPropVars.focus.border, cssVar(border, 'transparent')),
|
|
178
|
+
color: cssVar(buttonColorPropVars.focus.label, cssVar(label, system.color.fg.strong)),
|
|
179
|
+
[systemIconStencil.vars.color]: cssVar(
|
|
180
|
+
buttonColorPropVars.focus.icon,
|
|
181
|
+
system.color.fg.strong
|
|
182
|
+
),
|
|
183
|
+
...focusRing({
|
|
184
|
+
width: 2,
|
|
185
|
+
separation: 2,
|
|
186
|
+
innerColor: cssVar(
|
|
187
|
+
buttonColorPropVars.focus.boxShadowInner,
|
|
188
|
+
cssVar(boxShadowInner, system.color.fg.inverse)
|
|
189
|
+
),
|
|
190
|
+
outerColor: cssVar(
|
|
191
|
+
buttonColorPropVars.focus.boxShadowOuter,
|
|
192
|
+
cssVar(boxShadowOuter, brand.primary.base)
|
|
193
|
+
),
|
|
194
|
+
}),
|
|
185
195
|
},
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
196
|
+
// Hover Styles
|
|
197
|
+
'&:hover, &.hover': {
|
|
198
|
+
backgroundColor: cssVar(
|
|
199
|
+
buttonColorPropVars.hover.background,
|
|
200
|
+
cssVar(background, system.color.bg.contrast.strong)
|
|
201
|
+
),
|
|
202
|
+
borderColor: cssVar(buttonColorPropVars.hover.border, cssVar(border, 'transparent')),
|
|
203
|
+
color: cssVar(buttonColorPropVars.hover.label, cssVar(label, system.color.fg.stronger)),
|
|
204
|
+
[systemIconStencil.vars.color]: cssVar(
|
|
205
|
+
buttonColorPropVars.hover.icon,
|
|
206
|
+
system.color.fg.stronger
|
|
207
|
+
),
|
|
197
208
|
},
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
209
|
+
'&:hover:active': {transitionDuration: '40ms'},
|
|
210
|
+
// Active Styles
|
|
211
|
+
'&:active, &.active': {
|
|
212
|
+
backgroundColor: cssVar(
|
|
213
|
+
buttonColorPropVars.active.background,
|
|
214
|
+
cssVar(background, 'transparent')
|
|
215
|
+
),
|
|
216
|
+
borderColor: cssVar(buttonColorPropVars.active.border, cssVar(border, 'transparent')),
|
|
217
|
+
color: cssVar(buttonColorPropVars.active.label, cssVar(label, system.color.fg.strong)),
|
|
218
|
+
[systemIconStencil.vars.color]: cssVar(
|
|
219
|
+
buttonColorPropVars.active.icon,
|
|
220
|
+
system.color.fg.strong
|
|
221
|
+
),
|
|
222
|
+
},
|
|
223
|
+
// Disabled Styles
|
|
224
|
+
'&:disabled, &.disabled': {
|
|
225
|
+
backgroundColor: cssVar(
|
|
226
|
+
buttonColorPropVars.disabled.background,
|
|
227
|
+
cssVar(background, 'transparent')
|
|
228
|
+
),
|
|
229
|
+
borderColor: cssVar(buttonColorPropVars.disabled.border, cssVar(border, 'transparent')),
|
|
230
|
+
color: cssVar(buttonColorPropVars.disabled.label, cssVar(label, system.color.fg.strong)),
|
|
231
|
+
[systemIconStencil.vars.color]: cssVar(
|
|
232
|
+
buttonColorPropVars.disabled.icon,
|
|
233
|
+
system.color.fg.strong
|
|
234
|
+
),
|
|
235
|
+
},
|
|
236
|
+
}),
|
|
237
|
+
modifiers: {
|
|
238
|
+
/**
|
|
239
|
+
* Button modifiers that will overwrite the base styles of Buttons.
|
|
240
|
+
* - `Size`: These modifiers will dictate a size of a Button and has a set of styles to associated with it.
|
|
241
|
+
* - `iconPosition`: These modifiers will override the existing `Size` styles. These are specific to icon locations
|
|
242
|
+
* within a button or if there is only an icon and no text.
|
|
243
|
+
*/
|
|
244
|
+
size: {
|
|
245
|
+
large: {
|
|
246
|
+
...system.type.body.small,
|
|
247
|
+
fontWeight: system.fontWeight.bold,
|
|
248
|
+
height: px2rem(48),
|
|
249
|
+
paddingInline: system.space.x8,
|
|
250
|
+
minWidth: px2rem(112),
|
|
251
|
+
},
|
|
252
|
+
medium: {
|
|
253
|
+
...system.type.subtext.large,
|
|
254
|
+
fontWeight: system.fontWeight.bold,
|
|
255
|
+
minWidth: px2rem(96),
|
|
256
|
+
paddingInline: system.space.x6,
|
|
257
|
+
height: system.space.x10,
|
|
258
|
+
},
|
|
259
|
+
small: {
|
|
260
|
+
...system.type.subtext.large,
|
|
261
|
+
fontWeight: system.fontWeight.bold,
|
|
262
|
+
height: system.space.x8,
|
|
263
|
+
minWidth: system.space.x20,
|
|
264
|
+
paddingInline: system.space.x4,
|
|
265
|
+
gap: system.space.x1,
|
|
266
|
+
},
|
|
267
|
+
extraSmall: {
|
|
268
|
+
...system.type.subtext.medium,
|
|
269
|
+
fontWeight: system.fontWeight.bold,
|
|
270
|
+
height: system.space.x6,
|
|
271
|
+
minWidth: 'auto',
|
|
272
|
+
paddingInline: system.space.x3,
|
|
273
|
+
gap: system.space.x1,
|
|
274
|
+
},
|
|
275
|
+
},
|
|
276
|
+
// IconPosition Styles
|
|
277
|
+
iconPosition: {
|
|
278
|
+
only: {padding: system.space.zero},
|
|
279
|
+
start: {},
|
|
280
|
+
end: {},
|
|
208
281
|
},
|
|
209
|
-
*/
|
|
210
|
-
},
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Button modifiers that will overwrite the base styles of Buttons.
|
|
215
|
-
* - `Size`: These modifiers will dictate a size of a Button and has a set of styles to associated with it.
|
|
216
|
-
* - `iconPosition`: These modifiers will override the existing `Size` styles. These are specific to icon locations
|
|
217
|
-
* within a button or if there is only an icon and no text.
|
|
218
|
-
*/
|
|
219
|
-
export const buttonModifiers = createModifiers({
|
|
220
|
-
size: {
|
|
221
|
-
large: createStyles({
|
|
222
|
-
fontSize: system.space.x4,
|
|
223
|
-
lineHeight: system.space.x6,
|
|
224
|
-
letterSpacing: '0.01rem',
|
|
225
|
-
height: '48px',
|
|
226
|
-
paddingInline: system.space.x8,
|
|
227
|
-
minWidth: '112px',
|
|
228
|
-
}),
|
|
229
|
-
medium: createStyles({
|
|
230
|
-
fontSize: '0.875rem',
|
|
231
|
-
letterSpacing: '0.015rem',
|
|
232
|
-
minWidth: '96px',
|
|
233
|
-
paddingInline: system.space.x6,
|
|
234
|
-
height: system.space.x10,
|
|
235
|
-
}),
|
|
236
|
-
small: createStyles({
|
|
237
|
-
fontSize: '0.875rem',
|
|
238
|
-
letterSpacing: '0.015rem',
|
|
239
|
-
height: system.space.x8,
|
|
240
|
-
minWidth: system.space.x20,
|
|
241
|
-
paddingInline: system.space.x4,
|
|
242
|
-
gap: system.space.x1,
|
|
243
|
-
}),
|
|
244
|
-
extraSmall: createStyles({
|
|
245
|
-
fontSize: '0.75rem',
|
|
246
|
-
lineHeight: system.space.x4,
|
|
247
|
-
letterSpacing: '0.02rem',
|
|
248
|
-
height: system.space.x6,
|
|
249
|
-
minWidth: 'auto',
|
|
250
|
-
paddingInline: system.space.x3,
|
|
251
|
-
gap: system.space.x1,
|
|
252
|
-
}),
|
|
253
|
-
},
|
|
254
|
-
iconPosition: {
|
|
255
|
-
largeOnly: createStyles({
|
|
256
|
-
padding: '0',
|
|
257
|
-
minWidth: `calc(${system.space.x4} * 3)`,
|
|
258
|
-
}),
|
|
259
|
-
largeStart: createStyles({
|
|
260
|
-
paddingInlineStart: system.space.x6,
|
|
261
|
-
paddingInlineEnd: system.space.x8,
|
|
262
|
-
}),
|
|
263
|
-
largeEnd: createStyles({
|
|
264
|
-
paddingInlineStart: system.space.x8,
|
|
265
|
-
paddingInlineEnd: system.space.x6,
|
|
266
|
-
}),
|
|
267
|
-
mediumOnly: createStyles({padding: '0', minWidth: system.space.x10}),
|
|
268
|
-
mediumStart: createStyles({
|
|
269
|
-
paddingInlineStart: `calc(${system.space.x1} * 5)`,
|
|
270
|
-
paddingInlineEnd: system.space.x6,
|
|
271
|
-
}),
|
|
272
|
-
mediumEnd: createStyles({
|
|
273
|
-
paddingInlineStart: system.space.x6,
|
|
274
|
-
paddingInlineEnd: `calc(${system.space.x1} * 5)`,
|
|
275
|
-
}),
|
|
276
|
-
smallOnly: createStyles({padding: '0', minWidth: system.space.x8}),
|
|
277
|
-
smallStart: createStyles({
|
|
278
|
-
paddingInlineStart: system.space.x3,
|
|
279
|
-
paddingInlineEnd: system.space.x4,
|
|
280
|
-
}),
|
|
281
|
-
smallEnd: createStyles({
|
|
282
|
-
paddingInlineStart: system.space.x4,
|
|
283
|
-
paddingInlineEnd: system.space.x3,
|
|
284
|
-
}),
|
|
285
|
-
extraSmallOnly: createStyles({padding: '0', minWidth: system.space.x6}),
|
|
286
|
-
extraSmallStart: createStyles({
|
|
287
|
-
paddingInlineStart: system.space.x2,
|
|
288
|
-
paddingInlineEnd: system.space.x3,
|
|
289
|
-
}),
|
|
290
|
-
extraSmallEnd: createStyles({
|
|
291
|
-
paddingInlineStart: system.space.x3,
|
|
292
|
-
paddingInlineEnd: system.space.x2,
|
|
293
|
-
}),
|
|
294
282
|
},
|
|
283
|
+
// Compound Modifier Styles
|
|
284
|
+
compound: [
|
|
285
|
+
{
|
|
286
|
+
modifiers: {size: 'large', iconPosition: 'only'},
|
|
287
|
+
styles: {
|
|
288
|
+
minWidth: calc.multiply(system.space.x4, 3),
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
{
|
|
292
|
+
modifiers: {size: 'large', iconPosition: 'start'},
|
|
293
|
+
styles: {
|
|
294
|
+
paddingInlineStart: system.space.x6,
|
|
295
|
+
paddingInlineEnd: system.space.x8,
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
modifiers: {size: 'large', iconPosition: 'end'},
|
|
300
|
+
styles: {
|
|
301
|
+
paddingInlineStart: system.space.x8,
|
|
302
|
+
paddingInlineEnd: system.space.x6,
|
|
303
|
+
},
|
|
304
|
+
},
|
|
305
|
+
{
|
|
306
|
+
modifiers: {size: 'medium', iconPosition: 'only'},
|
|
307
|
+
styles: {
|
|
308
|
+
minWidth: system.space.x10,
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
modifiers: {size: 'medium', iconPosition: 'start'},
|
|
313
|
+
styles: {
|
|
314
|
+
paddingInlineStart: calc.multiply(system.space.x1, 5),
|
|
315
|
+
paddingInlineEnd: system.space.x6,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
modifiers: {size: 'medium', iconPosition: 'end'},
|
|
320
|
+
styles: {
|
|
321
|
+
paddingInlineStart: system.space.x6,
|
|
322
|
+
paddingInlineEnd: calc.multiply(system.space.x1, 5),
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
modifiers: {size: 'small', iconPosition: 'only'},
|
|
327
|
+
styles: {
|
|
328
|
+
minWidth: system.space.x8,
|
|
329
|
+
},
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
modifiers: {size: 'small', iconPosition: 'start'},
|
|
333
|
+
styles: {
|
|
334
|
+
paddingInlineStart: system.space.x3,
|
|
335
|
+
paddingInlineEnd: system.space.x4,
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
modifiers: {size: 'small', iconPosition: 'end'},
|
|
340
|
+
styles: {
|
|
341
|
+
paddingInlineStart: system.space.x4,
|
|
342
|
+
paddingInlineEnd: system.space.x3,
|
|
343
|
+
},
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
modifiers: {size: 'extraSmall', iconPosition: 'only'},
|
|
347
|
+
styles: {
|
|
348
|
+
minWidth: system.space.x6,
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
modifiers: {size: 'extraSmall', iconPosition: 'start'},
|
|
353
|
+
styles: {
|
|
354
|
+
paddingInlineStart: system.space.x2,
|
|
355
|
+
paddingInlineEnd: system.space.x3,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
modifiers: {size: 'extraSmall', iconPosition: 'end'},
|
|
360
|
+
styles: {
|
|
361
|
+
paddingInlineStart: system.space.x3,
|
|
362
|
+
paddingInlineEnd: system.space.x2,
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
],
|
|
295
366
|
});
|
|
296
367
|
|
|
297
|
-
export function capitalize(string: string = '') {
|
|
298
|
-
return string.charAt(0).toUpperCase() + string.substring(1);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export function getIconPosition(
|
|
302
|
-
size?: keyof typeof buttonModifiers.size,
|
|
303
|
-
iconPosition?: IconPositions,
|
|
304
|
-
children?: React.ReactNode
|
|
305
|
-
): keyof typeof buttonModifiers.iconPosition {
|
|
306
|
-
return `${size}${capitalize(iconPosition)}` as keyof typeof buttonModifiers.iconPosition;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
368
|
/**
|
|
310
|
-
* The base button which all
|
|
369
|
+
* The base button which which is the foundation of all Button variants (`PrimaryButton`,
|
|
370
|
+
* `SecondaryButton`, `TertiaryButton`, `DeleteButton`, `ToolbarIconButton` and `ToolbarDropdownButton`).
|
|
311
371
|
*/
|
|
312
372
|
export const BaseButton = createComponent('button')({
|
|
313
373
|
displayName: 'BaseButton',
|
|
@@ -330,16 +390,12 @@ export const BaseButton = createComponent('button')({
|
|
|
330
390
|
ref={ref}
|
|
331
391
|
type="button"
|
|
332
392
|
{...mergeStyles(elemProps, [
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
}),
|
|
338
|
-
|
|
339
|
-
buttonVars.focus(colors?.focus || {}),
|
|
340
|
-
buttonVars.hover(colors?.hover || {}),
|
|
341
|
-
buttonVars.active(colors?.active || {}),
|
|
342
|
-
buttonVars.disabled(colors?.disabled || {}),
|
|
393
|
+
buttonStencil({size, iconPosition}),
|
|
394
|
+
buttonColorPropVars.default(colors?.default || {}),
|
|
395
|
+
buttonColorPropVars.focus(colors?.focus || {}),
|
|
396
|
+
buttonColorPropVars.hover(colors?.hover || {}),
|
|
397
|
+
buttonColorPropVars.active(colors?.active || {}),
|
|
398
|
+
buttonColorPropVars.disabled(colors?.disabled || {}),
|
|
343
399
|
])}
|
|
344
400
|
>
|
|
345
401
|
{children}
|
package/button/lib/Button.tsx
CHANGED
|
@@ -56,10 +56,7 @@ export const Button = createComponent('button')({
|
|
|
56
56
|
)}
|
|
57
57
|
{children && <BaseButton.Label>{children}</BaseButton.Label>}
|
|
58
58
|
|
|
59
|
-
{icon && baseIconPosition
|
|
60
|
-
<BaseButton.Icon size={size} icon={icon} shouldMirrorIcon={shouldMirrorIcon} />
|
|
61
|
-
)}
|
|
62
|
-
{icon && baseIconPosition === 'end' && (
|
|
59
|
+
{icon && baseIconPosition && ['only', 'end'].includes(baseIconPosition) && (
|
|
63
60
|
<BaseButton.Icon size={size} icon={icon} shouldMirrorIcon={shouldMirrorIcon} />
|
|
64
61
|
)}
|
|
65
62
|
</BaseButton>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {buttonStencil} from './BaseButton';
|
|
4
4
|
import {createComponent} from '@workday/canvas-kit-react/common';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {base, brand, system} from '@workday/canvas-tokens-web';
|
|
5
|
+
import {createStencil} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {brand, system} from '@workday/canvas-tokens-web';
|
|
8
7
|
import {Button, ButtonProps} from './Button';
|
|
9
|
-
import {systemIconStencil} from '
|
|
8
|
+
import {systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
9
|
+
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Extends all the style properties from Box to our buttons as well as props from ButtonProps.
|
|
@@ -15,50 +15,54 @@ import {systemIconStencil} from '../../icon';
|
|
|
15
15
|
*/
|
|
16
16
|
export interface DeleteButtonProps extends ButtonProps {}
|
|
17
17
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
[buttonVars.focus.background]: brand.error.base,
|
|
26
|
-
[buttonVars.focus.border]: 'transparent',
|
|
27
|
-
[buttonVars.focus.label]: brand.error.accent,
|
|
28
|
-
[systemIconStencil.vars.color]: brand.error.accent,
|
|
29
|
-
[buttonVars.focus.boxShadowInner]: base.frenchVanilla100,
|
|
30
|
-
[buttonVars.focus.boxShadowOuter]: brand.common.focusOutline,
|
|
31
|
-
},
|
|
32
|
-
'&:hover, &.hover': {
|
|
33
|
-
[buttonVars.hover.background]: brand.error.dark,
|
|
34
|
-
[buttonVars.hover.border]: 'transparent',
|
|
35
|
-
[buttonVars.hover.label]: brand.error.accent,
|
|
36
|
-
[systemIconStencil.vars.color]: brand.error.accent,
|
|
37
|
-
},
|
|
38
|
-
'&:active, &.active': {
|
|
39
|
-
[buttonVars.active.background]: brand.error.darkest,
|
|
40
|
-
[buttonVars.active.border]: 'transparent',
|
|
41
|
-
[buttonVars.active.label]: brand.error.accent,
|
|
42
|
-
[systemIconStencil.vars.color]: brand.error.accent,
|
|
43
|
-
},
|
|
44
|
-
'&:disabled, &.disabled': {
|
|
45
|
-
[buttonVars.disabled.background]: brand.error.base,
|
|
46
|
-
[buttonVars.disabled.label]: brand.error.accent,
|
|
18
|
+
const deleteButtonStencil = createStencil({
|
|
19
|
+
extends: buttonStencil,
|
|
20
|
+
base: {
|
|
21
|
+
// Base Styles
|
|
22
|
+
[buttonStencil.vars.background]: brand.error.base,
|
|
23
|
+
[buttonStencil.vars.borderRadius]: system.shape.round,
|
|
24
|
+
[buttonStencil.vars.label]: brand.error.accent,
|
|
47
25
|
[systemIconStencil.vars.color]: brand.error.accent,
|
|
48
|
-
|
|
26
|
+
// Focus Styles
|
|
27
|
+
'&:focus-visible, &.focus': {
|
|
28
|
+
[buttonStencil.vars.background]: brand.error.base,
|
|
29
|
+
[buttonStencil.vars.label]: brand.error.accent,
|
|
30
|
+
[systemIconStencil.vars.color]: brand.error.accent,
|
|
31
|
+
[buttonStencil.vars.boxShadowInner]: system.color.fg.inverse,
|
|
32
|
+
[buttonStencil.vars.boxShadowOuter]: brand.common.focusOutline,
|
|
33
|
+
},
|
|
34
|
+
// Hover Styles
|
|
35
|
+
'&:hover, &.hover': {
|
|
36
|
+
[buttonStencil.vars.background]: brand.error.dark,
|
|
37
|
+
[buttonStencil.vars.label]: brand.error.accent,
|
|
38
|
+
[systemIconStencil.vars.color]: brand.error.accent,
|
|
39
|
+
},
|
|
40
|
+
// Active Styles
|
|
41
|
+
'&:active, &.active': {
|
|
42
|
+
[buttonStencil.vars.background]: brand.error.darkest,
|
|
43
|
+
[buttonStencil.vars.label]: brand.error.accent,
|
|
44
|
+
[systemIconStencil.vars.color]: brand.error.accent,
|
|
45
|
+
},
|
|
46
|
+
// Disabled Styles
|
|
47
|
+
'&:disabled, &.disabled': {
|
|
48
|
+
[buttonStencil.vars.background]: brand.error.base,
|
|
49
|
+
[buttonStencil.vars.label]: brand.error.accent,
|
|
50
|
+
[systemIconStencil.vars.color]: brand.error.accent,
|
|
51
|
+
[buttonStencil.vars.opacity]: system.opacity.disabled,
|
|
52
|
+
},
|
|
49
53
|
},
|
|
50
54
|
});
|
|
51
55
|
|
|
52
56
|
/**
|
|
53
57
|
* Use sparingly for destructive actions that will result in data loss, can’t be undone, or will
|
|
54
58
|
* have significant consequences. They commonly appear in confirmation dialogs as the final
|
|
55
|
-
* confirmation before
|
|
59
|
+
* confirmation before being deleted.
|
|
56
60
|
*/
|
|
57
61
|
export const DeleteButton = createComponent('button')({
|
|
58
62
|
displayName: 'DeleteButton',
|
|
59
|
-
Component: ({children,
|
|
63
|
+
Component: ({children, ...elemProps}: DeleteButtonProps, ref, Element) => {
|
|
60
64
|
return (
|
|
61
|
-
<Button as={Element} ref={ref}
|
|
65
|
+
<Button as={Element} ref={ref} {...mergeStyles(elemProps, deleteButtonStencil())}>
|
|
62
66
|
{children}
|
|
63
67
|
</Button>
|
|
64
68
|
);
|