@khanacademy/wonder-blocks-button 2.11.6 → 3.0.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @khanacademy/wonder-blocks-button
2
2
 
3
+ ## 3.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [ee6fc773]
8
+ - @khanacademy/wonder-blocks-clickable@2.3.0
9
+
10
+ ## 3.0.0
11
+
12
+ ### Major Changes
13
+
14
+ - 85c31780: Changed size prop value: From `xlarge` to `large`
15
+
16
+ ## 2.11.7
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies [83486dba]
21
+ - @khanacademy/wonder-blocks-icon@1.2.29
22
+ - @khanacademy/wonder-blocks-progress-spinner@1.1.33
23
+
3
24
  ## 2.11.6
4
25
 
5
26
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -46,7 +46,7 @@ class ButtonCore extends React.Component {
46
46
  const buttonStyles = _generateStyles(buttonColor, kind, light, iconWidth, size);
47
47
 
48
48
  const disabled = spinner || disabledProp;
49
- 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), size === "small" && sharedStyles.small, size === "xlarge" && sharedStyles.xlarge];
49
+ 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), size === "small" && sharedStyles.small, size === "large" && sharedStyles.large];
50
50
 
51
51
  const commonProps = _extends({
52
52
  "data-test-id": testId,
@@ -56,10 +56,11 @@ class ButtonCore extends React.Component {
56
56
  }, restProps);
57
57
 
58
58
  const Label = size === "small" ? LabelSmall : LabelLarge;
59
+ const iconSize = size === "small" ? "small" : "medium";
59
60
  const label = React.createElement(Label, {
60
- style: [sharedStyles.text, size === "xlarge" && sharedStyles.xlargeText, icon && sharedStyles.textWithIcon, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus)]
61
+ style: [sharedStyles.text, size === "large" && sharedStyles.largeText, icon && sharedStyles.textWithIcon, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus)]
61
62
  }, icon && React.createElement(Icon, {
62
- size: size,
63
+ size: iconSize,
63
64
  color: "currentColor",
64
65
  icon: icon,
65
66
  style: sharedStyles.icon
@@ -69,9 +70,10 @@ class ButtonCore extends React.Component {
69
70
  size: {
70
71
  medium: "small",
71
72
  small: "xsmall",
72
- xlarge: "medium"
73
+ large: "medium"
73
74
  }[size],
74
- light: kind === "primary"
75
+ light: kind === "primary",
76
+ testId: `${testId || "button"}-spinner`
75
77
  }));
76
78
 
77
79
  if (href && !disabled) {
@@ -126,8 +128,9 @@ const sharedStyles = StyleSheet.create({
126
128
  small: {
127
129
  height: 32
128
130
  },
129
- xlarge: {
130
- height: 60
131
+ large: {
132
+ borderRadius: Spacing.xxSmall_6,
133
+ height: 56
131
134
  },
132
135
  text: {
133
136
  alignItems: "center",
@@ -138,7 +141,7 @@ const sharedStyles = StyleSheet.create({
138
141
  display: "inline-block",
139
142
  pointerEvents: "none"
140
143
  },
141
- xlargeText: {
144
+ largeText: {
142
145
  fontSize: 18,
143
146
  lineHeight: "20px"
144
147
  },
@@ -177,7 +180,7 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
177
180
  } = Color;
178
181
  const fadedColor = mix(fade(color, 0.32), white);
179
182
  const activeColor = mix(offBlack32, color);
180
- const padding = size === "xlarge" ? Spacing.xLarge_32 : Spacing.medium_16;
183
+ const padding = size === "large" ? Spacing.xLarge_32 : Spacing.medium_16;
181
184
  let newStyles = {};
182
185
 
183
186
  if (kind === "primary") {
package/dist/index.js CHANGED
@@ -101,25 +101,25 @@ module.exports = require("@khanacademy/wonder-blocks-color");
101
101
  /* 2 */
102
102
  /***/ (function(module, exports) {
103
103
 
104
- module.exports = require("react-router");
104
+ module.exports = require("@khanacademy/wonder-blocks-spacing");
105
105
 
106
106
  /***/ }),
107
107
  /* 3 */
108
108
  /***/ (function(module, exports) {
109
109
 
110
- module.exports = require("@khanacademy/wonder-blocks-clickable");
110
+ module.exports = require("react-router");
111
111
 
112
112
  /***/ }),
113
113
  /* 4 */
114
114
  /***/ (function(module, exports) {
115
115
 
116
- module.exports = require("@khanacademy/wonder-blocks-core");
116
+ module.exports = require("@khanacademy/wonder-blocks-clickable");
117
117
 
118
118
  /***/ }),
119
119
  /* 5 */
120
120
  /***/ (function(module, exports) {
121
121
 
122
- module.exports = require("@khanacademy/wonder-blocks-spacing");
122
+ module.exports = require("@khanacademy/wonder-blocks-core");
123
123
 
124
124
  /***/ }),
125
125
  /* 6 */
@@ -141,9 +141,9 @@ 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 react_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2);
144
+ /* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3);
145
145
  /* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_1__);
146
- /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3);
146
+ /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(4);
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);
149
149
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -261,21 +261,21 @@ Button.defaultProps = {
261
261
  /* harmony import */ var aphrodite__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(aphrodite__WEBPACK_IMPORTED_MODULE_1__);
262
262
  /* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(10);
263
263
  /* harmony import */ var react_router_dom__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(react_router_dom__WEBPACK_IMPORTED_MODULE_2__);
264
- /* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2);
264
+ /* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3);
265
265
  /* harmony import */ var react_router__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(react_router__WEBPACK_IMPORTED_MODULE_3__);
266
266
  /* harmony import */ var _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7);
267
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__);
268
268
  /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(1);
269
269
  /* harmony import */ var _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__);
270
- /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4);
270
+ /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5);
271
271
  /* harmony import */ var _khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_core__WEBPACK_IMPORTED_MODULE_6__);
272
272
  /* harmony import */ var _khanacademy_wonder_blocks_progress_spinner__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(11);
273
273
  /* harmony import */ var _khanacademy_wonder_blocks_progress_spinner__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_progress_spinner__WEBPACK_IMPORTED_MODULE_7__);
274
274
  /* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(12);
275
275
  /* harmony import */ var _khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_8__);
276
- /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5);
276
+ /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(2);
277
277
  /* harmony import */ var _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9__);
278
- /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(3);
278
+ /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(4);
279
279
  /* harmony import */ var _khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_khanacademy_wonder_blocks_clickable__WEBPACK_IMPORTED_MODULE_10__);
280
280
  function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
281
281
 
@@ -323,7 +323,7 @@ class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
323
323
 
324
324
  const disabled = spinner || disabledProp;
325
325
  const defaultStyle = [sharedStyles.shared, disabled && sharedStyles.disabled, icon && sharedStyles.withIcon, buttonStyles.default, disabled && buttonStyles.disabled, // apply focus effect only to default and secondary buttons
326
- kind !== "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus), size === "small" && sharedStyles.small, size === "xlarge" && sharedStyles.xlarge];
326
+ kind !== "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus), size === "small" && sharedStyles.small, size === "large" && sharedStyles.large];
327
327
  const commonProps = {
328
328
  "data-test-id": testId,
329
329
  id: id,
@@ -331,12 +331,15 @@ class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
331
331
  style: [defaultStyle, style],
332
332
  ...restProps
333
333
  };
334
- const Label = size === "small" ? _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"] : _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelLarge"];
334
+ const Label = size === "small" ? _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelSmall"] : _khanacademy_wonder_blocks_typography__WEBPACK_IMPORTED_MODULE_4__["LabelLarge"]; // We have to use `medium` for both md and lg buttons so we can fit the
335
+ // icons in large buttons.
336
+
337
+ const iconSize = size === "small" ? "small" : "medium";
335
338
  const label = /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](Label, {
336
- style: [sharedStyles.text, size === "xlarge" && sharedStyles.xlargeText, icon && sharedStyles.textWithIcon, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, // apply focus effect on the label instead
339
+ style: [sharedStyles.text, size === "large" && sharedStyles.largeText, icon && sharedStyles.textWithIcon, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, // apply focus effect on the label instead
337
340
  kind === "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus)]
338
341
  }, icon && /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0__["createElement"](_khanacademy_wonder_blocks_icon__WEBPACK_IMPORTED_MODULE_8___default.a, {
339
- size: size,
342
+ size: iconSize,
340
343
  color: "currentColor",
341
344
  icon: icon,
342
345
  style: sharedStyles.icon
@@ -346,9 +349,10 @@ class ButtonCore extends react__WEBPACK_IMPORTED_MODULE_0__["Component"] {
346
349
  size: {
347
350
  medium: "small",
348
351
  small: "xsmall",
349
- xlarge: "medium"
352
+ large: "medium"
350
353
  }[size],
351
- light: kind === "primary"
354
+ light: kind === "primary",
355
+ testId: `${testId || "button"}-spinner`
352
356
  }));
353
357
 
354
358
  if (href && !disabled) {
@@ -407,8 +411,9 @@ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create
407
411
  small: {
408
412
  height: 32
409
413
  },
410
- xlarge: {
411
- height: 60
414
+ large: {
415
+ borderRadius: _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default.a.xxSmall_6,
416
+ height: 56
412
417
  },
413
418
  text: {
414
419
  alignItems: "center",
@@ -421,7 +426,7 @@ const sharedStyles = aphrodite__WEBPACK_IMPORTED_MODULE_1__["StyleSheet"].create
421
426
  pointerEvents: "none" // fix Safari bug where the browser was eating mouse events
422
427
 
423
428
  },
424
- xlargeText: {
429
+ largeText: {
425
430
  fontSize: 18,
426
431
  lineHeight: "20px"
427
432
  },
@@ -462,7 +467,7 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
462
467
  } = _khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5___default.a;
463
468
  const fadedColor = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__["mix"])(Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__["fade"])(color, 0.32), white);
464
469
  const activeColor = Object(_khanacademy_wonder_blocks_color__WEBPACK_IMPORTED_MODULE_5__["mix"])(offBlack32, color);
465
- const padding = size === "xlarge" ? _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default.a.xLarge_32 : _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default.a.medium_16;
470
+ const padding = size === "large" ? _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default.a.xLarge_32 : _khanacademy_wonder_blocks_spacing__WEBPACK_IMPORTED_MODULE_9___default.a.medium_16;
466
471
  let newStyles = {};
467
472
 
468
473
  if (kind === "primary") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-button",
3
- "version": "2.11.6",
3
+ "version": "3.0.1",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -15,12 +15,12 @@
15
15
  "author": "",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "@babel/runtime": "^7.16.3",
19
- "@khanacademy/wonder-blocks-clickable": "^2.2.7",
18
+ "@babel/runtime": "^7.18.6",
19
+ "@khanacademy/wonder-blocks-clickable": "^2.3.0",
20
20
  "@khanacademy/wonder-blocks-color": "^1.1.20",
21
21
  "@khanacademy/wonder-blocks-core": "^4.3.2",
22
- "@khanacademy/wonder-blocks-icon": "^1.2.28",
23
- "@khanacademy/wonder-blocks-progress-spinner": "^1.1.32",
22
+ "@khanacademy/wonder-blocks-icon": "^1.2.29",
23
+ "@khanacademy/wonder-blocks-progress-spinner": "^1.1.33",
24
24
  "@khanacademy/wonder-blocks-spacing": "^3.0.5",
25
25
  "@khanacademy/wonder-blocks-typography": "^1.1.32"
26
26
  },