@khanacademy/wonder-blocks-button 2.9.14 → 2.11.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/CHANGELOG.md +6 -0
- package/dist/es/index.js +53 -35
- package/dist/index.js +40 -22
- package/package.json +14 -15
- package/src/__tests__/__snapshots__/custom-snapshot.test.js.snap +155 -125
- package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +307 -72
- package/src/__tests__/generated-snapshot.test.js +74 -12
- package/src/components/__docs__/accessibility.stories.mdx +92 -0
- package/src/components/__docs__/best-practices.stories.mdx +107 -0
- package/src/components/__docs__/button.argtypes.js +231 -0
- package/src/components/__docs__/navigation-callbacks.stories.mdx +68 -0
- package/src/components/__tests__/button.test.js +63 -0
- package/src/components/button-core.js +29 -10
- package/src/components/button.js +20 -16
- package/src/components/button.md +134 -23
- package/src/components/button.stories.js +413 -104
- package/LICENSE +0 -21
package/CHANGELOG.md
ADDED
package/dist/es/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from '@babel/runtime/helpers/extends';
|
|
2
2
|
import _objectWithoutPropertiesLoose from '@babel/runtime/helpers/objectWithoutPropertiesLoose';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { __RouterContext } from 'react-router';
|
|
5
5
|
import { isClientSideUrl, getClickableBehavior } from '@khanacademy/wonder-blocks-clickable';
|
|
6
6
|
import { StyleSheet } from 'aphrodite';
|
|
7
7
|
import { Link } from 'react-router-dom';
|
|
@@ -12,12 +12,12 @@ import { CircularSpinner } from '@khanacademy/wonder-blocks-progress-spinner';
|
|
|
12
12
|
import Icon from '@khanacademy/wonder-blocks-icon';
|
|
13
13
|
import Spacing from '@khanacademy/wonder-blocks-spacing';
|
|
14
14
|
|
|
15
|
-
const _excluded = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "light", "pressed", "size", "style", "testId", "type", "spinner", "icon", "id", "waiting"];
|
|
15
|
+
const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "light", "pressed", "size", "style", "testId", "type", "spinner", "icon", "id", "waiting"];
|
|
16
16
|
const StyledAnchor = addStyle("a");
|
|
17
17
|
const StyledButton = addStyle("button");
|
|
18
18
|
const StyledLink = addStyle(Link);
|
|
19
|
-
class ButtonCore extends Component {
|
|
20
|
-
|
|
19
|
+
class ButtonCore extends React.Component {
|
|
20
|
+
renderInner(router) {
|
|
21
21
|
const _this$props = this.props,
|
|
22
22
|
{
|
|
23
23
|
children,
|
|
@@ -38,11 +38,8 @@ class ButtonCore extends Component {
|
|
|
38
38
|
icon,
|
|
39
39
|
id
|
|
40
40
|
} = _this$props,
|
|
41
|
-
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
41
|
+
restProps = _objectWithoutPropertiesLoose(_this$props, _excluded$1);
|
|
42
42
|
|
|
43
|
-
const {
|
|
44
|
-
router
|
|
45
|
-
} = this.context;
|
|
46
43
|
const buttonColor = color === "destructive" ? SemanticColor.controlDestructive : SemanticColor.controlDefault;
|
|
47
44
|
const iconWidth = icon ? (size === "small" ? 16 : 24) + 8 : 0;
|
|
48
45
|
|
|
@@ -60,16 +57,16 @@ class ButtonCore extends Component {
|
|
|
60
57
|
}, restProps);
|
|
61
58
|
|
|
62
59
|
const Label = size === "small" ? LabelSmall : LabelLarge;
|
|
63
|
-
const label = /*#__PURE__*/createElement(Label, {
|
|
60
|
+
const label = /*#__PURE__*/React.createElement(Label, {
|
|
64
61
|
style: [sharedStyles.text, size === "xlarge" && sharedStyles.xlargeText, icon && sharedStyles.textWithIcon, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, // apply focus effect on the label instead
|
|
65
62
|
kind === "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus)]
|
|
66
|
-
}, icon && /*#__PURE__*/createElement(Icon, {
|
|
63
|
+
}, icon && /*#__PURE__*/React.createElement(Icon, {
|
|
67
64
|
size: size,
|
|
68
65
|
color: "currentColor",
|
|
69
66
|
icon: icon,
|
|
70
67
|
style: sharedStyles.icon
|
|
71
68
|
}), children);
|
|
72
|
-
const contents = /*#__PURE__*/createElement(Fragment, null, label, spinner && /*#__PURE__*/createElement(CircularSpinner, {
|
|
69
|
+
const contents = /*#__PURE__*/React.createElement(React.Fragment, null, label, spinner && /*#__PURE__*/React.createElement(CircularSpinner, {
|
|
73
70
|
style: sharedStyles.spinner,
|
|
74
71
|
size: {
|
|
75
72
|
medium: "small",
|
|
@@ -80,24 +77,25 @@ class ButtonCore extends Component {
|
|
|
80
77
|
}));
|
|
81
78
|
|
|
82
79
|
if (href && !disabled) {
|
|
83
|
-
return router && !skipClientNav && isClientSideUrl(href) ? /*#__PURE__*/createElement(StyledLink, _extends({}, commonProps, {
|
|
80
|
+
return router && !skipClientNav && isClientSideUrl(href) ? /*#__PURE__*/React.createElement(StyledLink, _extends({}, commonProps, {
|
|
84
81
|
to: href
|
|
85
|
-
}), contents) : /*#__PURE__*/createElement(StyledAnchor, _extends({}, commonProps, {
|
|
82
|
+
}), contents) : /*#__PURE__*/React.createElement(StyledAnchor, _extends({}, commonProps, {
|
|
86
83
|
href: href
|
|
87
84
|
}), contents);
|
|
88
85
|
} else {
|
|
89
|
-
return /*#__PURE__*/createElement(StyledButton, _extends({
|
|
86
|
+
return /*#__PURE__*/React.createElement(StyledButton, _extends({
|
|
90
87
|
type: type || "button"
|
|
91
88
|
}, commonProps, {
|
|
92
|
-
disabled: disabled
|
|
89
|
+
"aria-disabled": disabled
|
|
93
90
|
}), contents);
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
93
|
|
|
94
|
+
render() {
|
|
95
|
+
return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderInner(router));
|
|
96
|
+
}
|
|
97
|
+
|
|
97
98
|
}
|
|
98
|
-
ButtonCore.contextTypes = {
|
|
99
|
-
router: any
|
|
100
|
-
};
|
|
101
99
|
const sharedStyles = StyleSheet.create({
|
|
102
100
|
shared: {
|
|
103
101
|
position: "relative",
|
|
@@ -215,7 +213,10 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
215
213
|
disabled: {
|
|
216
214
|
background: light ? fadedColor : offBlack32,
|
|
217
215
|
color: light ? color : white64,
|
|
218
|
-
cursor: "default"
|
|
216
|
+
cursor: "default",
|
|
217
|
+
":focus": {
|
|
218
|
+
boxShadow: `0 0 0 1px ${light ? offBlack32 : white}, 0 0 0 3px ${light ? fadedColor : offBlack32}`
|
|
219
|
+
}
|
|
219
220
|
}
|
|
220
221
|
};
|
|
221
222
|
} else if (kind === "secondary") {
|
|
@@ -243,6 +244,8 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
243
244
|
color: light ? fadedColor : activeColor,
|
|
244
245
|
borderColor: light ? fadedColor : activeColor,
|
|
245
246
|
borderWidth: 2,
|
|
247
|
+
// We need to reduce padding to offset the difference
|
|
248
|
+
// caused by the border becoming thicker on focus.
|
|
246
249
|
// The left padding for the button with icon should have 4px
|
|
247
250
|
// less padding
|
|
248
251
|
paddingLeft: iconWidth ? padding - 5 : padding - 1,
|
|
@@ -251,10 +254,21 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
251
254
|
disabled: {
|
|
252
255
|
color: light ? white50 : offBlack32,
|
|
253
256
|
borderColor: light ? fadedColor : offBlack32,
|
|
254
|
-
cursor: "default"
|
|
257
|
+
cursor: "default",
|
|
258
|
+
":focus": {
|
|
259
|
+
borderColor: light ? white50 : offBlack32,
|
|
260
|
+
borderWidth: 2,
|
|
261
|
+
// We need to reduce padding to offset the difference
|
|
262
|
+
// caused by the border becoming thicker on focus.
|
|
263
|
+
// The left padding for the button with icon should have 4px
|
|
264
|
+
// less padding
|
|
265
|
+
paddingLeft: iconWidth ? padding - 5 : padding - 1,
|
|
266
|
+
paddingRight: padding - 1
|
|
267
|
+
}
|
|
255
268
|
}
|
|
256
269
|
};
|
|
257
270
|
} else if (kind === "tertiary") {
|
|
271
|
+
// TODO(FEI-4229): Make tertiary buttons focusable
|
|
258
272
|
newStyles = {
|
|
259
273
|
default: {
|
|
260
274
|
background: "none",
|
|
@@ -300,7 +314,7 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
300
314
|
return styles[buttonType];
|
|
301
315
|
};
|
|
302
316
|
|
|
303
|
-
const _excluded
|
|
317
|
+
const _excluded = ["href", "type", "children", "skipClientNav", "spinner", "disabled", "onClick", "beforeNav", "safeWithNav", "tabIndex", "target", "rel"],
|
|
304
318
|
_excluded2 = ["tabIndex"];
|
|
305
319
|
|
|
306
320
|
/**
|
|
@@ -311,17 +325,20 @@ const _excluded$1 = ["href", "type", "children", "skipClientNav", "spinner", "di
|
|
|
311
325
|
* `ButtonCore` is a stateless component which displays the different states
|
|
312
326
|
* the `Button` can take.
|
|
313
327
|
*
|
|
314
|
-
*
|
|
328
|
+
* ### Usage
|
|
329
|
+
*
|
|
315
330
|
* ```jsx
|
|
331
|
+
* import Button from "@khanacademy/wonder-blocks-button";
|
|
332
|
+
*
|
|
316
333
|
* <Button
|
|
317
334
|
* onClick={(e) => console.log("Hello, world!")}
|
|
318
335
|
* >
|
|
319
|
-
*
|
|
336
|
+
* Hello, world!
|
|
320
337
|
* </Button>
|
|
321
338
|
* ```
|
|
322
339
|
*/
|
|
323
|
-
class Button extends Component {
|
|
324
|
-
|
|
340
|
+
class Button extends React.Component {
|
|
341
|
+
renderClickableBehavior(router) {
|
|
325
342
|
const _this$props = this.props,
|
|
326
343
|
{
|
|
327
344
|
href = undefined,
|
|
@@ -337,9 +354,9 @@ class Button extends Component {
|
|
|
337
354
|
target,
|
|
338
355
|
rel
|
|
339
356
|
} = _this$props,
|
|
340
|
-
sharedButtonCoreProps = _objectWithoutPropertiesLoose(_this$props, _excluded
|
|
357
|
+
sharedButtonCoreProps = _objectWithoutPropertiesLoose(_this$props, _excluded);
|
|
341
358
|
|
|
342
|
-
const ClickableBehavior = getClickableBehavior(href, skipClientNav,
|
|
359
|
+
const ClickableBehavior = getClickableBehavior(href, skipClientNav, router);
|
|
343
360
|
|
|
344
361
|
const renderProp = (state, _ref) => {
|
|
345
362
|
let {
|
|
@@ -347,7 +364,7 @@ class Button extends Component {
|
|
|
347
364
|
} = _ref,
|
|
348
365
|
restChildProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
|
|
349
366
|
|
|
350
|
-
return /*#__PURE__*/createElement(ButtonCore, _extends({}, sharedButtonCoreProps, state, restChildProps, {
|
|
367
|
+
return /*#__PURE__*/React.createElement(ButtonCore, _extends({}, sharedButtonCoreProps, state, restChildProps, {
|
|
351
368
|
disabled: disabled,
|
|
352
369
|
spinner: spinner || state.waiting,
|
|
353
370
|
skipClientNav: skipClientNav,
|
|
@@ -362,7 +379,7 @@ class Button extends Component {
|
|
|
362
379
|
};
|
|
363
380
|
|
|
364
381
|
if (beforeNav) {
|
|
365
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
382
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
366
383
|
disabled: spinner || disabled,
|
|
367
384
|
href: href,
|
|
368
385
|
role: "button",
|
|
@@ -373,7 +390,7 @@ class Button extends Component {
|
|
|
373
390
|
rel: rel
|
|
374
391
|
}, renderProp);
|
|
375
392
|
} else {
|
|
376
|
-
return /*#__PURE__*/createElement(ClickableBehavior, {
|
|
393
|
+
return /*#__PURE__*/React.createElement(ClickableBehavior, {
|
|
377
394
|
disabled: spinner || disabled,
|
|
378
395
|
href: href,
|
|
379
396
|
role: "button",
|
|
@@ -386,10 +403,11 @@ class Button extends Component {
|
|
|
386
403
|
}
|
|
387
404
|
}
|
|
388
405
|
|
|
406
|
+
render() {
|
|
407
|
+
return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
|
|
408
|
+
}
|
|
409
|
+
|
|
389
410
|
}
|
|
390
|
-
Button.contextTypes = {
|
|
391
|
-
router: any
|
|
392
|
-
};
|
|
393
411
|
Button.defaultProps = {
|
|
394
412
|
color: "default",
|
|
395
413
|
kind: "primary",
|
|
@@ -399,4 +417,4 @@ Button.defaultProps = {
|
|
|
399
417
|
spinner: false
|
|
400
418
|
};
|
|
401
419
|
|
|
402
|
-
export default
|
|
420
|
+
export { Button as default };
|
package/dist/index.js
CHANGED
|
@@ -101,7 +101,7 @@ module.exports = require("@khanacademy/wonder-blocks-color");
|
|
|
101
101
|
/* 2 */
|
|
102
102
|
/***/ (function(module, exports) {
|
|
103
103
|
|
|
104
|
-
module.exports = require("
|
|
104
|
+
module.exports = require("react-router");
|
|
105
105
|
|
|
106
106
|
/***/ }),
|
|
107
107
|
/* 3 */
|
|
@@ -141,8 +141,8 @@ module.exports = require("@khanacademy/wonder-blocks-typography");
|
|
|
141
141
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Button; });
|
|
142
142
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(0);
|
|
143
143
|
/* harmony import */ var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_0__);
|
|
144
|
-
/* harmony import */ var
|
|
145
|
-
/* harmony import */ var
|
|
144
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
|
|
145
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_1__);
|
|
146
146
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
|
|
147
147
|
/* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__);
|
|
148
148
|
/* harmony import */ var _button_core_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9);
|
|
@@ -161,17 +161,20 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
161
161
|
* `ButtonCore` is a stateless component which displays the different states
|
|
162
162
|
* the `Button` can take.
|
|
163
163
|
*
|
|
164
|
-
*
|
|
164
|
+
* ### Usage
|
|
165
|
+
*
|
|
165
166
|
* ```jsx
|
|
167
|
+
* import Button from "@khanacademy/wonder-blocks-button";
|
|
168
|
+
*
|
|
166
169
|
* <Button
|
|
167
170
|
* onClick={(e) => console.log("Hello, world!")}
|
|
168
171
|
* >
|
|
169
|
-
*
|
|
172
|
+
* Hello, world!
|
|
170
173
|
* </Button>
|
|
171
174
|
* ```
|
|
172
175
|
*/
|
|
173
176
|
class Button extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
174
|
-
|
|
177
|
+
renderClickableBehavior(router) {
|
|
175
178
|
const {
|
|
176
179
|
href = undefined,
|
|
177
180
|
type = undefined,
|
|
@@ -187,7 +190,7 @@ class Button extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
187
190
|
rel,
|
|
188
191
|
...sharedButtonCoreProps
|
|
189
192
|
} = this.props;
|
|
190
|
-
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__["getClickableBehavior"])(href, skipClientNav,
|
|
193
|
+
const ClickableBehavior = Object(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__["getClickableBehavior"])(href, skipClientNav, router);
|
|
191
194
|
|
|
192
195
|
const renderProp = (state, {
|
|
193
196
|
tabIndex: clickableTabIndex,
|
|
@@ -232,10 +235,11 @@ class Button extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
232
235
|
}
|
|
233
236
|
}
|
|
234
237
|
|
|
238
|
+
render() {
|
|
239
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_1__["__RouterContext"].Consumer, null, router => this.renderClickableBehavior(router));
|
|
240
|
+
}
|
|
241
|
+
|
|
235
242
|
}
|
|
236
|
-
Button.contextTypes = {
|
|
237
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_1__["any"]
|
|
238
|
-
};
|
|
239
243
|
Button.defaultProps = {
|
|
240
244
|
color: "default",
|
|
241
245
|
kind: "primary",
|
|
@@ -257,8 +261,8 @@ Button.defaultProps = {
|
|
|
257
261
|
/* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
|
|
258
262
|
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
|
|
259
263
|
/* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
|
|
260
|
-
/* harmony import */ var
|
|
261
|
-
/* harmony import */ var
|
|
264
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
|
|
265
|
+
/* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_3__);
|
|
262
266
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
|
|
263
267
|
/* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__);
|
|
264
268
|
/* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
|
|
@@ -290,7 +294,7 @@ const StyledAnchor = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MO
|
|
|
290
294
|
const StyledButton = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__["addStyle"])("button");
|
|
291
295
|
const StyledLink = Object(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__["addStyle"])(react_router_dom__WEBPACK_IMPORTED_MODULE_2__["Link"]);
|
|
292
296
|
class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
293
|
-
|
|
297
|
+
renderInner(router) {
|
|
294
298
|
const {
|
|
295
299
|
children,
|
|
296
300
|
skipClientNav,
|
|
@@ -312,9 +316,6 @@ class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
312
316
|
waiting: _,
|
|
313
317
|
...restProps
|
|
314
318
|
} = this.props;
|
|
315
|
-
const {
|
|
316
|
-
router
|
|
317
|
-
} = this.context;
|
|
318
319
|
const buttonColor = color === "destructive" ? _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__["SemanticColor"].controlDestructive : _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__["SemanticColor"].controlDefault;
|
|
319
320
|
const iconWidth = icon ? (size === "small" ? 16 : 24) + 8 : 0;
|
|
320
321
|
|
|
@@ -360,15 +361,16 @@ class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
|
|
|
360
361
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](StyledButton, _extends({
|
|
361
362
|
type: type || "button"
|
|
362
363
|
}, commonProps, {
|
|
363
|
-
disabled: disabled
|
|
364
|
+
"aria-disabled": disabled
|
|
364
365
|
}), contents);
|
|
365
366
|
}
|
|
366
367
|
}
|
|
367
368
|
|
|
369
|
+
render() {
|
|
370
|
+
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](react_router__WEBPACK_IMPORTED_MODULE_3__["__RouterContext"].Consumer, null, router => this.renderInner(router));
|
|
371
|
+
}
|
|
372
|
+
|
|
368
373
|
}
|
|
369
|
-
ButtonCore.contextTypes = {
|
|
370
|
-
router: prop_types__WEBPACK_IMPORTED_MODULE_3__["any"]
|
|
371
|
-
};
|
|
372
374
|
const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create({
|
|
373
375
|
shared: {
|
|
374
376
|
position: "relative",
|
|
@@ -486,7 +488,10 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
486
488
|
disabled: {
|
|
487
489
|
background: light ? fadedColor : offBlack32,
|
|
488
490
|
color: light ? color : white64,
|
|
489
|
-
cursor: "default"
|
|
491
|
+
cursor: "default",
|
|
492
|
+
":focus": {
|
|
493
|
+
boxShadow: `0 0 0 1px ${light ? offBlack32 : white}, 0 0 0 3px ${light ? fadedColor : offBlack32}`
|
|
494
|
+
}
|
|
490
495
|
}
|
|
491
496
|
};
|
|
492
497
|
} else if (kind === "secondary") {
|
|
@@ -514,6 +519,8 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
514
519
|
color: light ? fadedColor : activeColor,
|
|
515
520
|
borderColor: light ? fadedColor : activeColor,
|
|
516
521
|
borderWidth: 2,
|
|
522
|
+
// We need to reduce padding to offset the difference
|
|
523
|
+
// caused by the border becoming thicker on focus.
|
|
517
524
|
// The left padding for the button with icon should have 4px
|
|
518
525
|
// less padding
|
|
519
526
|
paddingLeft: iconWidth ? padding - 5 : padding - 1,
|
|
@@ -522,10 +529,21 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
|
|
|
522
529
|
disabled: {
|
|
523
530
|
color: light ? white50 : offBlack32,
|
|
524
531
|
borderColor: light ? fadedColor : offBlack32,
|
|
525
|
-
cursor: "default"
|
|
532
|
+
cursor: "default",
|
|
533
|
+
":focus": {
|
|
534
|
+
borderColor: light ? white50 : offBlack32,
|
|
535
|
+
borderWidth: 2,
|
|
536
|
+
// We need to reduce padding to offset the difference
|
|
537
|
+
// caused by the border becoming thicker on focus.
|
|
538
|
+
// The left padding for the button with icon should have 4px
|
|
539
|
+
// less padding
|
|
540
|
+
paddingLeft: iconWidth ? padding - 5 : padding - 1,
|
|
541
|
+
paddingRight: padding - 1
|
|
542
|
+
}
|
|
526
543
|
}
|
|
527
544
|
};
|
|
528
545
|
} else if (kind === "tertiary") {
|
|
546
|
+
// TODO(FEI-4229): Make tertiary buttons focusable
|
|
529
547
|
newStyles = {
|
|
530
548
|
default: {
|
|
531
549
|
background: "none",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@khanacademy/wonder-blocks-button",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"design": "v1",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,23 +15,22 @@
|
|
|
15
15
|
"author": "",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@babel/runtime": "^7.
|
|
19
|
-
"@khanacademy/wonder-blocks-clickable": "^2.1
|
|
20
|
-
"@khanacademy/wonder-blocks-color": "^1.1.
|
|
21
|
-
"@khanacademy/wonder-blocks-core": "^
|
|
22
|
-
"@khanacademy/wonder-blocks-icon": "^1.2.
|
|
23
|
-
"@khanacademy/wonder-blocks-progress-spinner": "^1.1.
|
|
24
|
-
"@khanacademy/wonder-blocks-spacing": "^3.0.
|
|
25
|
-
"@khanacademy/wonder-blocks-typography": "^1.1.
|
|
18
|
+
"@babel/runtime": "^7.16.3",
|
|
19
|
+
"@khanacademy/wonder-blocks-clickable": "^2.2.1",
|
|
20
|
+
"@khanacademy/wonder-blocks-color": "^1.1.20",
|
|
21
|
+
"@khanacademy/wonder-blocks-core": "^4.0.0",
|
|
22
|
+
"@khanacademy/wonder-blocks-icon": "^1.2.24",
|
|
23
|
+
"@khanacademy/wonder-blocks-progress-spinner": "^1.1.28",
|
|
24
|
+
"@khanacademy/wonder-blocks-spacing": "^3.0.5",
|
|
25
|
+
"@khanacademy/wonder-blocks-typography": "^1.1.28"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"aphrodite": "^1.2.5",
|
|
29
|
-
"
|
|
30
|
-
"react": "
|
|
31
|
-
"react-router-dom": "
|
|
29
|
+
"react": "16.14.0",
|
|
30
|
+
"react-router": "5.2.1",
|
|
31
|
+
"react-router-dom": "5.3.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"wb-dev-build-settings": "^0.
|
|
35
|
-
}
|
|
36
|
-
"gitHead": "9a9cc04bf2bbfb425f991a347b4f8b0d0d56e120"
|
|
34
|
+
"wb-dev-build-settings": "^0.2.0"
|
|
35
|
+
}
|
|
37
36
|
}
|