@khanacademy/wonder-blocks-button 4.1.9 → 4.2.1
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/CHANGELOG.md +14 -0
- package/dist/es/index.js +217 -67
- package/dist/index.js +217 -69
- package/dist/themes/default.d.ts +118 -0
- package/dist/themes/khanmigo.d.ts +103 -0
- package/dist/themes/themed-button.d.ts +114 -0
- package/package.json +1 -1
- package/src/__tests__/__snapshots__/custom-snapshot.test.tsx.snap +264 -264
- package/src/components/button-core.tsx +129 -72
- package/src/components/button.tsx +6 -3
- package/src/themes/default.ts +139 -0
- package/src/themes/khanmigo.ts +43 -0
- package/src/themes/themed-button.tsx +42 -0
- package/tsconfig-build.json +1 -0
- package/tsconfig-build.tsbuildinfo +1 -1
package/dist/index.js
CHANGED
|
@@ -6,11 +6,10 @@ var wonderBlocksClickable = require('@khanacademy/wonder-blocks-clickable');
|
|
|
6
6
|
var aphrodite = require('aphrodite');
|
|
7
7
|
var reactRouterDom = require('react-router-dom');
|
|
8
8
|
var wonderBlocksTypography = require('@khanacademy/wonder-blocks-typography');
|
|
9
|
-
var Color = require('@khanacademy/wonder-blocks-color');
|
|
10
9
|
var wonderBlocksCore = require('@khanacademy/wonder-blocks-core');
|
|
11
10
|
var wonderBlocksProgressSpinner = require('@khanacademy/wonder-blocks-progress-spinner');
|
|
12
11
|
var Icon = require('@khanacademy/wonder-blocks-icon');
|
|
13
|
-
var
|
|
12
|
+
var wonderBlocksTheming = require('@khanacademy/wonder-blocks-theming');
|
|
14
13
|
|
|
15
14
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
16
15
|
|
|
@@ -33,9 +32,7 @@ function _interopNamespace(e) {
|
|
|
33
32
|
}
|
|
34
33
|
|
|
35
34
|
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
36
|
-
var Color__default = /*#__PURE__*/_interopDefaultLegacy(Color);
|
|
37
35
|
var Icon__default = /*#__PURE__*/_interopDefaultLegacy(Icon);
|
|
38
|
-
var Spacing__default = /*#__PURE__*/_interopDefaultLegacy(Spacing);
|
|
39
36
|
|
|
40
37
|
function _extends() {
|
|
41
38
|
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
@@ -65,11 +62,165 @@ function _objectWithoutPropertiesLoose(source, excluded) {
|
|
|
65
62
|
return target;
|
|
66
63
|
}
|
|
67
64
|
|
|
65
|
+
const theme$1 = {
|
|
66
|
+
color: {
|
|
67
|
+
bg: {
|
|
68
|
+
action: {
|
|
69
|
+
default: wonderBlocksTheming.tokens.color.blue,
|
|
70
|
+
active: wonderBlocksTheming.tokens.color.activeBlue,
|
|
71
|
+
inverse: wonderBlocksTheming.tokens.color.fadedBlue
|
|
72
|
+
},
|
|
73
|
+
critical: {
|
|
74
|
+
default: wonderBlocksTheming.tokens.color.red,
|
|
75
|
+
active: wonderBlocksTheming.tokens.color.activeRed,
|
|
76
|
+
inverse: wonderBlocksTheming.tokens.color.fadedRed
|
|
77
|
+
},
|
|
78
|
+
primary: {
|
|
79
|
+
default: wonderBlocksTheming.tokens.color.white,
|
|
80
|
+
disabled: wonderBlocksTheming.tokens.color.offBlack32,
|
|
81
|
+
inverse: wonderBlocksTheming.tokens.color.darkBlue
|
|
82
|
+
},
|
|
83
|
+
secondary: {
|
|
84
|
+
default: "none",
|
|
85
|
+
inverse: "none",
|
|
86
|
+
focus: wonderBlocksTheming.tokens.color.white,
|
|
87
|
+
active: {
|
|
88
|
+
action: wonderBlocksTheming.tokens.color.fadedBlue,
|
|
89
|
+
critical: wonderBlocksTheming.tokens.color.fadedRed
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
tertiary: {
|
|
93
|
+
hover: wonderBlocksTheming.tokens.color.white
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
text: {
|
|
97
|
+
disabled: wonderBlocksTheming.tokens.color.offBlack32,
|
|
98
|
+
inverse: wonderBlocksTheming.tokens.color.white,
|
|
99
|
+
primary: {
|
|
100
|
+
disabled: wonderBlocksTheming.tokens.color.white64
|
|
101
|
+
},
|
|
102
|
+
secondary: {
|
|
103
|
+
inverse: wonderBlocksTheming.tokens.color.white50
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
border: {
|
|
107
|
+
disabled: wonderBlocksTheming.tokens.color.offBlack32,
|
|
108
|
+
primary: {
|
|
109
|
+
inverse: wonderBlocksTheming.tokens.color.white
|
|
110
|
+
},
|
|
111
|
+
secondary: {
|
|
112
|
+
action: wonderBlocksTheming.tokens.color.offBlack50,
|
|
113
|
+
critical: wonderBlocksTheming.tokens.color.offBlack50,
|
|
114
|
+
inverse: wonderBlocksTheming.tokens.color.white50
|
|
115
|
+
},
|
|
116
|
+
tertiary: {
|
|
117
|
+
inverse: wonderBlocksTheming.tokens.color.white
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
border: {
|
|
122
|
+
width: {
|
|
123
|
+
secondary: wonderBlocksTheming.tokens.border.width.hairline,
|
|
124
|
+
focused: wonderBlocksTheming.tokens.border.width.thin,
|
|
125
|
+
disabled: wonderBlocksTheming.tokens.border.width.thin
|
|
126
|
+
},
|
|
127
|
+
radius: {
|
|
128
|
+
default: wonderBlocksTheming.tokens.border.radius.medium_4,
|
|
129
|
+
tertiary: wonderBlocksTheming.tokens.border.radius.xSmall_2,
|
|
130
|
+
small: wonderBlocksTheming.tokens.border.radius.small_3,
|
|
131
|
+
large: wonderBlocksTheming.tokens.border.radius.large_6
|
|
132
|
+
}
|
|
133
|
+
},
|
|
134
|
+
size: {
|
|
135
|
+
width: {
|
|
136
|
+
medium: wonderBlocksTheming.tokens.spacing.large_24,
|
|
137
|
+
large: wonderBlocksTheming.tokens.spacing.xLarge_32
|
|
138
|
+
},
|
|
139
|
+
height: {
|
|
140
|
+
tertiaryHover: wonderBlocksTheming.tokens.spacing.xxxxSmall_2,
|
|
141
|
+
small: wonderBlocksTheming.tokens.spacing.xLarge_32,
|
|
142
|
+
medium: 40,
|
|
143
|
+
large: 56
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
padding: {
|
|
147
|
+
small: wonderBlocksTheming.tokens.spacing.xSmall_8,
|
|
148
|
+
medium: wonderBlocksTheming.tokens.spacing.small_12,
|
|
149
|
+
large: wonderBlocksTheming.tokens.spacing.medium_16,
|
|
150
|
+
xLarge: wonderBlocksTheming.tokens.spacing.xLarge_32
|
|
151
|
+
},
|
|
152
|
+
font: {
|
|
153
|
+
size: {
|
|
154
|
+
large: 18
|
|
155
|
+
},
|
|
156
|
+
lineHeight: {
|
|
157
|
+
large: wonderBlocksTheming.tokens.font.lineHeight.medium
|
|
158
|
+
},
|
|
159
|
+
weight: {
|
|
160
|
+
default: wonderBlocksTheming.tokens.font.weight.bold
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
const theme = wonderBlocksTheming.mergeTheme(theme$1, {
|
|
166
|
+
color: {
|
|
167
|
+
bg: {
|
|
168
|
+
secondary: {
|
|
169
|
+
default: wonderBlocksTheming.tokens.color.offWhite,
|
|
170
|
+
active: {
|
|
171
|
+
action: wonderBlocksTheming.tokens.color.fadedBlue8,
|
|
172
|
+
critical: wonderBlocksTheming.tokens.color.fadedRed8
|
|
173
|
+
},
|
|
174
|
+
focus: wonderBlocksTheming.tokens.color.offWhite
|
|
175
|
+
}
|
|
176
|
+
},
|
|
177
|
+
border: {
|
|
178
|
+
secondary: {
|
|
179
|
+
action: wonderBlocksTheming.tokens.color.fadedBlue,
|
|
180
|
+
critical: wonderBlocksTheming.tokens.color.fadedRed
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
border: {
|
|
185
|
+
radius: {
|
|
186
|
+
default: wonderBlocksTheming.tokens.border.radius.xLarge_12,
|
|
187
|
+
small: wonderBlocksTheming.tokens.border.radius.large_6,
|
|
188
|
+
large: wonderBlocksTheming.tokens.border.radius.xLarge_12
|
|
189
|
+
},
|
|
190
|
+
width: {
|
|
191
|
+
focused: wonderBlocksTheming.tokens.border.width.hairline
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
font: {
|
|
195
|
+
weight: {
|
|
196
|
+
default: wonderBlocksTheming.tokens.font.weight.regular
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
const themes = {
|
|
202
|
+
default: theme$1,
|
|
203
|
+
khanmigo: theme
|
|
204
|
+
};
|
|
205
|
+
const ButtonThemeContext = wonderBlocksTheming.createThemeContext(theme$1);
|
|
206
|
+
function ThemedButton(props) {
|
|
207
|
+
const currentTheme = React__namespace.useContext(wonderBlocksTheming.ThemeSwitcherContext);
|
|
208
|
+
const theme = themes[currentTheme] || theme$1;
|
|
209
|
+
return React__namespace.createElement(ButtonThemeContext.Provider, {
|
|
210
|
+
value: theme
|
|
211
|
+
}, props.children);
|
|
212
|
+
}
|
|
213
|
+
|
|
68
214
|
const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "light", "pressed", "size", "style", "testId", "type", "spinner", "icon", "id", "waiting"];
|
|
69
215
|
const StyledAnchor = wonderBlocksCore.addStyle("a");
|
|
70
216
|
const StyledButton = wonderBlocksCore.addStyle("button");
|
|
71
217
|
const StyledLink = wonderBlocksCore.addStyle(reactRouterDom.Link);
|
|
72
218
|
const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
|
|
219
|
+
const {
|
|
220
|
+
theme,
|
|
221
|
+
themeName
|
|
222
|
+
} = wonderBlocksTheming.useScopedTheme(ButtonThemeContext);
|
|
223
|
+
const sharedStyles = wonderBlocksTheming.useStyles(themedSharedStyles, theme);
|
|
73
224
|
const renderInner = router => {
|
|
74
225
|
const {
|
|
75
226
|
children,
|
|
@@ -91,9 +242,8 @@ const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
|
|
|
91
242
|
id
|
|
92
243
|
} = props,
|
|
93
244
|
restProps = _objectWithoutPropertiesLoose(props, _excluded$1);
|
|
94
|
-
const
|
|
95
|
-
const
|
|
96
|
-
const buttonStyles = _generateStyles(buttonColor, kind, light, iconWidth, size);
|
|
245
|
+
const iconWidth = icon ? size === "small" ? theme.size.width.medium : theme.size.width.large : 0;
|
|
246
|
+
const buttonStyles = _generateStyles(color, kind, light, iconWidth, size, theme, themeName);
|
|
97
247
|
const disabled = spinner || disabledProp;
|
|
98
248
|
const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, icon && sharedStyles.withIcon, buttonStyles.default, disabled && buttonStyles.disabled, kind !== "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus), kind === "tertiary" && !pressed && focused && [buttonStyles.focus, disabled && buttonStyles.disabledFocus], size === "small" && sharedStyles.small, size === "large" && sharedStyles.large];
|
|
99
249
|
const commonProps = _extends({
|
|
@@ -145,19 +295,19 @@ const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
|
|
|
145
295
|
};
|
|
146
296
|
return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderInner(router));
|
|
147
297
|
});
|
|
148
|
-
const
|
|
298
|
+
const themedSharedStyles = theme => ({
|
|
149
299
|
shared: {
|
|
150
300
|
position: "relative",
|
|
151
301
|
display: "inline-flex",
|
|
152
302
|
alignItems: "center",
|
|
153
303
|
justifyContent: "center",
|
|
154
|
-
height:
|
|
304
|
+
height: theme.size.height.medium,
|
|
155
305
|
paddingTop: 0,
|
|
156
306
|
paddingBottom: 0,
|
|
157
|
-
paddingLeft:
|
|
158
|
-
paddingRight:
|
|
307
|
+
paddingLeft: theme.padding.large,
|
|
308
|
+
paddingRight: theme.padding.large,
|
|
159
309
|
border: "none",
|
|
160
|
-
borderRadius:
|
|
310
|
+
borderRadius: theme.border.radius.default,
|
|
161
311
|
cursor: "pointer",
|
|
162
312
|
outline: "none",
|
|
163
313
|
textDecoration: "none",
|
|
@@ -169,21 +319,22 @@ const sharedStyles = aphrodite.StyleSheet.create({
|
|
|
169
319
|
}
|
|
170
320
|
},
|
|
171
321
|
withIcon: {
|
|
172
|
-
paddingLeft:
|
|
322
|
+
paddingLeft: theme.padding.medium
|
|
173
323
|
},
|
|
174
324
|
disabled: {
|
|
175
325
|
cursor: "auto"
|
|
176
326
|
},
|
|
177
327
|
small: {
|
|
178
|
-
|
|
328
|
+
borderRadius: theme.border.radius.small,
|
|
329
|
+
height: theme.size.height.small
|
|
179
330
|
},
|
|
180
331
|
large: {
|
|
181
|
-
borderRadius:
|
|
182
|
-
height:
|
|
332
|
+
borderRadius: theme.border.radius.large,
|
|
333
|
+
height: theme.size.height.large
|
|
183
334
|
},
|
|
184
335
|
text: {
|
|
185
336
|
alignItems: "center",
|
|
186
|
-
fontWeight:
|
|
337
|
+
fontWeight: theme.font.weight.default,
|
|
187
338
|
whiteSpace: "nowrap",
|
|
188
339
|
overflow: "hidden",
|
|
189
340
|
textOverflow: "ellipsis",
|
|
@@ -191,8 +342,8 @@ const sharedStyles = aphrodite.StyleSheet.create({
|
|
|
191
342
|
pointerEvents: "none"
|
|
192
343
|
},
|
|
193
344
|
largeText: {
|
|
194
|
-
fontSize:
|
|
195
|
-
lineHeight:
|
|
345
|
+
fontSize: theme.font.size.large,
|
|
346
|
+
lineHeight: theme.font.lineHeight.large
|
|
196
347
|
},
|
|
197
348
|
textWithFocus: {
|
|
198
349
|
position: "relative"
|
|
@@ -204,85 +355,82 @@ const sharedStyles = aphrodite.StyleSheet.create({
|
|
|
204
355
|
position: "absolute"
|
|
205
356
|
},
|
|
206
357
|
icon: {
|
|
207
|
-
paddingRight:
|
|
358
|
+
paddingRight: theme.padding.small
|
|
208
359
|
}
|
|
209
360
|
});
|
|
210
361
|
const styles = {};
|
|
211
|
-
const _generateStyles = (
|
|
212
|
-
const
|
|
362
|
+
const _generateStyles = (buttonColor = "default", kind, light, iconWidth, size, theme, themeName) => {
|
|
363
|
+
const color = buttonColor === "destructive" ? theme.color.bg.critical.default : theme.color.bg.action.default;
|
|
364
|
+
const buttonType = `${color}-${kind}-${light}-${iconWidth}-${size}-${themeName}`;
|
|
213
365
|
if (styles[buttonType]) {
|
|
214
366
|
return styles[buttonType];
|
|
215
367
|
}
|
|
216
|
-
const
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
white64,
|
|
220
|
-
offBlack32,
|
|
221
|
-
offBlack50,
|
|
222
|
-
darkBlue
|
|
223
|
-
} = Color__default["default"];
|
|
224
|
-
const fadedColor = Color.mix(Color.fade(color, 0.32), white);
|
|
225
|
-
const activeColor = Color.mix(offBlack32, color);
|
|
226
|
-
const padding = size === "large" ? Spacing__default["default"].xLarge_32 : Spacing__default["default"].medium_16;
|
|
368
|
+
const fadedColor = buttonColor === "destructive" ? theme.color.bg.critical.inverse : theme.color.bg.action.inverse;
|
|
369
|
+
const activeColor = buttonColor === "destructive" ? theme.color.bg.critical.active : theme.color.bg.action.active;
|
|
370
|
+
const padding = size === "large" ? theme.padding.xLarge : theme.padding.large;
|
|
227
371
|
let newStyles = {};
|
|
228
372
|
if (kind === "primary") {
|
|
373
|
+
const boxShadowInnerColor = light ? theme.color.bg.primary.inverse : theme.color.bg.primary.default;
|
|
229
374
|
newStyles = {
|
|
230
375
|
default: {
|
|
231
|
-
background: light ?
|
|
232
|
-
color: light ? color :
|
|
376
|
+
background: light ? theme.color.bg.primary.default : color,
|
|
377
|
+
color: light ? color : theme.color.text.inverse,
|
|
233
378
|
paddingLeft: padding,
|
|
234
379
|
paddingRight: padding
|
|
235
380
|
},
|
|
236
381
|
focus: {
|
|
237
|
-
boxShadow: `0 0 0 1px ${
|
|
382
|
+
boxShadow: `0 0 0 1px ${boxShadowInnerColor}, 0 0 0 3px ${light ? theme.color.bg.primary.default : color}`
|
|
238
383
|
},
|
|
239
384
|
active: {
|
|
240
|
-
boxShadow: `0 0 0 1px ${
|
|
385
|
+
boxShadow: `0 0 0 1px ${boxShadowInnerColor}, 0 0 0 3px ${light ? fadedColor : activeColor}`,
|
|
241
386
|
background: light ? fadedColor : activeColor,
|
|
242
387
|
color: light ? activeColor : fadedColor
|
|
243
388
|
},
|
|
244
389
|
disabled: {
|
|
245
|
-
background: light ? fadedColor :
|
|
246
|
-
color: light ? color :
|
|
390
|
+
background: light ? fadedColor : theme.color.bg.primary.disabled,
|
|
391
|
+
color: light ? color : theme.color.text.primary.disabled,
|
|
247
392
|
cursor: "default",
|
|
248
393
|
":focus": {
|
|
249
|
-
boxShadow: `0 0 0 1px ${light ?
|
|
394
|
+
boxShadow: `0 0 0 1px ${light ? theme.color.bg.primary.disabled : theme.color.bg.primary.default}, 0 0 0 3px ${light ? fadedColor : theme.color.bg.primary.disabled}`
|
|
250
395
|
}
|
|
251
396
|
}
|
|
252
397
|
};
|
|
253
398
|
} else if (kind === "secondary") {
|
|
399
|
+
const horizontalPadding = padding - (theme.border.width.focused - 1);
|
|
400
|
+
const secondaryBorderColor = buttonColor === "destructive" ? theme.color.border.secondary.critical : theme.color.border.secondary.action;
|
|
401
|
+
const secondaryActiveColor = buttonColor === "destructive" ? theme.color.bg.secondary.active.critical : theme.color.bg.secondary.active.action;
|
|
254
402
|
newStyles = {
|
|
255
403
|
default: {
|
|
256
|
-
background:
|
|
257
|
-
color: light ?
|
|
258
|
-
borderColor: light ?
|
|
404
|
+
background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.default,
|
|
405
|
+
color: light ? theme.color.text.inverse : color,
|
|
406
|
+
borderColor: light ? theme.color.border.secondary.inverse : secondaryBorderColor,
|
|
259
407
|
borderStyle: "solid",
|
|
260
|
-
borderWidth:
|
|
408
|
+
borderWidth: theme.border.width.secondary,
|
|
261
409
|
paddingLeft: padding,
|
|
262
410
|
paddingRight: padding
|
|
263
411
|
},
|
|
264
412
|
focus: {
|
|
265
|
-
background: light ?
|
|
266
|
-
borderColor: light ?
|
|
267
|
-
borderWidth:
|
|
268
|
-
paddingLeft:
|
|
269
|
-
paddingRight:
|
|
413
|
+
background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.focus,
|
|
414
|
+
borderColor: light ? theme.color.border.primary.inverse : color,
|
|
415
|
+
borderWidth: theme.border.width.focused,
|
|
416
|
+
paddingLeft: horizontalPadding,
|
|
417
|
+
paddingRight: horizontalPadding
|
|
270
418
|
},
|
|
271
419
|
active: {
|
|
272
|
-
background: light ? activeColor :
|
|
420
|
+
background: light ? activeColor : secondaryActiveColor,
|
|
273
421
|
color: light ? fadedColor : activeColor,
|
|
274
422
|
borderColor: light ? fadedColor : activeColor,
|
|
275
|
-
borderWidth:
|
|
276
|
-
paddingLeft:
|
|
277
|
-
paddingRight:
|
|
423
|
+
borderWidth: theme.border.width.focused,
|
|
424
|
+
paddingLeft: horizontalPadding,
|
|
425
|
+
paddingRight: horizontalPadding
|
|
278
426
|
},
|
|
279
427
|
disabled: {
|
|
280
|
-
color: light ?
|
|
281
|
-
borderColor: light ? fadedColor :
|
|
428
|
+
color: light ? theme.color.text.secondary.inverse : theme.color.text.disabled,
|
|
429
|
+
borderColor: light ? fadedColor : theme.color.border.disabled,
|
|
282
430
|
cursor: "default",
|
|
283
431
|
":focus": {
|
|
284
|
-
borderColor: light ?
|
|
285
|
-
borderWidth:
|
|
432
|
+
borderColor: light ? theme.color.border.secondary.inverse : theme.color.border.disabled,
|
|
433
|
+
borderWidth: theme.border.width.disabled,
|
|
286
434
|
paddingLeft: padding - 1,
|
|
287
435
|
paddingRight: padding - 1
|
|
288
436
|
}
|
|
@@ -292,7 +440,7 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
292
440
|
newStyles = {
|
|
293
441
|
default: {
|
|
294
442
|
background: "none",
|
|
295
|
-
color: light ?
|
|
443
|
+
color: light ? theme.color.text.inverse : color,
|
|
296
444
|
paddingLeft: 0,
|
|
297
445
|
paddingRight: 0
|
|
298
446
|
},
|
|
@@ -300,24 +448,24 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
300
448
|
":after": {
|
|
301
449
|
content: "''",
|
|
302
450
|
position: "absolute",
|
|
303
|
-
height:
|
|
451
|
+
height: theme.size.height.tertiaryHover,
|
|
304
452
|
width: "100%",
|
|
305
453
|
right: 0,
|
|
306
454
|
bottom: 0,
|
|
307
|
-
background: light ?
|
|
308
|
-
borderRadius:
|
|
455
|
+
background: light ? theme.color.bg.tertiary.hover : color,
|
|
456
|
+
borderRadius: theme.border.radius.tertiary
|
|
309
457
|
}
|
|
310
458
|
},
|
|
311
459
|
focus: {
|
|
312
460
|
":after": {
|
|
313
461
|
content: "''",
|
|
314
462
|
position: "absolute",
|
|
315
|
-
width: `calc(100% + ${
|
|
316
|
-
height: `calc(100% - ${
|
|
463
|
+
width: `calc(100% + ${theme.border.width.focused * 2}px)`,
|
|
464
|
+
height: `calc(100% - ${theme.border.width.focused * 2}px)`,
|
|
317
465
|
borderStyle: "solid",
|
|
318
|
-
borderColor: light ?
|
|
319
|
-
borderWidth:
|
|
320
|
-
borderRadius:
|
|
466
|
+
borderColor: light ? theme.color.border.tertiary.inverse : color,
|
|
467
|
+
borderWidth: theme.border.width.focused,
|
|
468
|
+
borderRadius: theme.border.radius.default
|
|
321
469
|
}
|
|
322
470
|
},
|
|
323
471
|
active: {
|
|
@@ -328,12 +476,12 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
328
476
|
}
|
|
329
477
|
},
|
|
330
478
|
disabled: {
|
|
331
|
-
color: light ? fadedColor :
|
|
479
|
+
color: light ? fadedColor : theme.color.text.disabled,
|
|
332
480
|
cursor: "default"
|
|
333
481
|
},
|
|
334
482
|
disabledFocus: {
|
|
335
483
|
":after": {
|
|
336
|
-
borderColor: light ?
|
|
484
|
+
borderColor: light ? theme.color.border.tertiary.inverse : theme.color.border.disabled
|
|
337
485
|
}
|
|
338
486
|
}
|
|
339
487
|
};
|
|
@@ -407,7 +555,7 @@ const Button = React__namespace.forwardRef(function Button(props, ref) {
|
|
|
407
555
|
}, renderProp);
|
|
408
556
|
}
|
|
409
557
|
};
|
|
410
|
-
return React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderClickableBehavior(router));
|
|
558
|
+
return React__namespace.createElement(ThemedButton, null, React__namespace.createElement(reactRouter.__RouterContext.Consumer, null, router => renderClickableBehavior(router)));
|
|
411
559
|
});
|
|
412
560
|
|
|
413
561
|
module.exports = Button;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
declare const theme: {
|
|
2
|
+
color: {
|
|
3
|
+
bg: {
|
|
4
|
+
/**
|
|
5
|
+
* Color
|
|
6
|
+
*/
|
|
7
|
+
action: {
|
|
8
|
+
default: string;
|
|
9
|
+
active: string;
|
|
10
|
+
inverse: string;
|
|
11
|
+
};
|
|
12
|
+
critical: {
|
|
13
|
+
default: string;
|
|
14
|
+
active: string;
|
|
15
|
+
inverse: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Kind
|
|
19
|
+
*/
|
|
20
|
+
primary: {
|
|
21
|
+
default: string;
|
|
22
|
+
disabled: string;
|
|
23
|
+
inverse: string;
|
|
24
|
+
};
|
|
25
|
+
secondary: {
|
|
26
|
+
default: string;
|
|
27
|
+
inverse: string;
|
|
28
|
+
focus: string;
|
|
29
|
+
active: {
|
|
30
|
+
action: string;
|
|
31
|
+
critical: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
tertiary: {
|
|
35
|
+
hover: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
text: {
|
|
39
|
+
/**
|
|
40
|
+
* Default
|
|
41
|
+
*/
|
|
42
|
+
disabled: string;
|
|
43
|
+
inverse: string;
|
|
44
|
+
/**
|
|
45
|
+
* Kind
|
|
46
|
+
*/
|
|
47
|
+
primary: {
|
|
48
|
+
disabled: string;
|
|
49
|
+
};
|
|
50
|
+
secondary: {
|
|
51
|
+
inverse: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
border: {
|
|
55
|
+
/**
|
|
56
|
+
* Default
|
|
57
|
+
*/
|
|
58
|
+
disabled: string;
|
|
59
|
+
/**
|
|
60
|
+
* Kind
|
|
61
|
+
*/
|
|
62
|
+
primary: {
|
|
63
|
+
inverse: string;
|
|
64
|
+
};
|
|
65
|
+
secondary: {
|
|
66
|
+
action: string;
|
|
67
|
+
critical: string;
|
|
68
|
+
inverse: string;
|
|
69
|
+
};
|
|
70
|
+
tertiary: {
|
|
71
|
+
inverse: string;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
border: {
|
|
76
|
+
width: {
|
|
77
|
+
secondary: number;
|
|
78
|
+
focused: number;
|
|
79
|
+
disabled: number;
|
|
80
|
+
};
|
|
81
|
+
radius: {
|
|
82
|
+
default: number;
|
|
83
|
+
tertiary: number;
|
|
84
|
+
small: number;
|
|
85
|
+
large: number;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
size: {
|
|
89
|
+
width: {
|
|
90
|
+
medium: 24;
|
|
91
|
+
large: 32;
|
|
92
|
+
};
|
|
93
|
+
height: {
|
|
94
|
+
tertiaryHover: 2;
|
|
95
|
+
small: 32;
|
|
96
|
+
medium: number;
|
|
97
|
+
large: number;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
padding: {
|
|
101
|
+
small: 8;
|
|
102
|
+
medium: 12;
|
|
103
|
+
large: 16;
|
|
104
|
+
xLarge: 32;
|
|
105
|
+
};
|
|
106
|
+
font: {
|
|
107
|
+
size: {
|
|
108
|
+
large: number;
|
|
109
|
+
};
|
|
110
|
+
lineHeight: {
|
|
111
|
+
large: number;
|
|
112
|
+
};
|
|
113
|
+
weight: {
|
|
114
|
+
default: number;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
export default theme;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The overrides for the Khanmigo theme.
|
|
3
|
+
*/
|
|
4
|
+
declare const theme: {
|
|
5
|
+
color: {
|
|
6
|
+
bg: {
|
|
7
|
+
action: {
|
|
8
|
+
default: string;
|
|
9
|
+
active: string;
|
|
10
|
+
inverse: string;
|
|
11
|
+
};
|
|
12
|
+
critical: {
|
|
13
|
+
default: string;
|
|
14
|
+
active: string;
|
|
15
|
+
inverse: string;
|
|
16
|
+
};
|
|
17
|
+
primary: {
|
|
18
|
+
default: string;
|
|
19
|
+
disabled: string;
|
|
20
|
+
inverse: string;
|
|
21
|
+
};
|
|
22
|
+
secondary: {
|
|
23
|
+
default: string;
|
|
24
|
+
inverse: string;
|
|
25
|
+
focus: string;
|
|
26
|
+
active: {
|
|
27
|
+
action: string;
|
|
28
|
+
critical: string;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
tertiary: {
|
|
32
|
+
hover: string;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
text: {
|
|
36
|
+
disabled: string;
|
|
37
|
+
inverse: string;
|
|
38
|
+
primary: {
|
|
39
|
+
disabled: string;
|
|
40
|
+
};
|
|
41
|
+
secondary: {
|
|
42
|
+
inverse: string;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
border: {
|
|
46
|
+
disabled: string;
|
|
47
|
+
primary: {
|
|
48
|
+
inverse: string;
|
|
49
|
+
};
|
|
50
|
+
secondary: {
|
|
51
|
+
action: string;
|
|
52
|
+
critical: string;
|
|
53
|
+
inverse: string;
|
|
54
|
+
};
|
|
55
|
+
tertiary: {
|
|
56
|
+
inverse: string;
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
border: {
|
|
61
|
+
width: {
|
|
62
|
+
secondary: number;
|
|
63
|
+
focused: number;
|
|
64
|
+
disabled: number;
|
|
65
|
+
};
|
|
66
|
+
radius: {
|
|
67
|
+
default: number;
|
|
68
|
+
tertiary: number;
|
|
69
|
+
small: number;
|
|
70
|
+
large: number;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
size: {
|
|
74
|
+
width: {
|
|
75
|
+
medium: 24;
|
|
76
|
+
large: 32;
|
|
77
|
+
};
|
|
78
|
+
height: {
|
|
79
|
+
tertiaryHover: 2;
|
|
80
|
+
small: 32;
|
|
81
|
+
medium: number;
|
|
82
|
+
large: number;
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
padding: {
|
|
86
|
+
small: 8;
|
|
87
|
+
medium: 12;
|
|
88
|
+
large: 16;
|
|
89
|
+
xLarge: 32;
|
|
90
|
+
};
|
|
91
|
+
font: {
|
|
92
|
+
size: {
|
|
93
|
+
large: number;
|
|
94
|
+
};
|
|
95
|
+
lineHeight: {
|
|
96
|
+
large: number;
|
|
97
|
+
};
|
|
98
|
+
weight: {
|
|
99
|
+
default: number;
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export default theme;
|