@khanacademy/wonder-blocks-button 2.11.4 → 2.11.7

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,35 @@
1
1
  # @khanacademy/wonder-blocks-button
2
2
 
3
+ ## 2.11.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [83486dba]
8
+ - @khanacademy/wonder-blocks-icon@1.2.29
9
+ - @khanacademy/wonder-blocks-progress-spinner@1.1.33
10
+
11
+ ## 2.11.6
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies [5f4a4297]
16
+ - Updated dependencies [2b96fd59]
17
+ - @khanacademy/wonder-blocks-core@4.3.2
18
+ - @khanacademy/wonder-blocks-clickable@2.2.7
19
+ - @khanacademy/wonder-blocks-icon@1.2.28
20
+ - @khanacademy/wonder-blocks-progress-spinner@1.1.32
21
+ - @khanacademy/wonder-blocks-typography@1.1.32
22
+
23
+ ## 2.11.5
24
+
25
+ ### Patch Changes
26
+
27
+ - @khanacademy/wonder-blocks-clickable@2.2.6
28
+ - @khanacademy/wonder-blocks-core@4.3.1
29
+ - @khanacademy/wonder-blocks-icon@1.2.27
30
+ - @khanacademy/wonder-blocks-progress-spinner@1.1.31
31
+ - @khanacademy/wonder-blocks-typography@1.1.31
32
+
3
33
  ## 2.11.4
4
34
 
5
35
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -46,8 +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, // apply focus effect only to default and secondary buttons
50
- 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 === "xlarge" && sharedStyles.xlarge];
51
50
 
52
51
  const commonProps = _extends({
53
52
  "data-test-id": testId,
@@ -57,16 +56,15 @@ class ButtonCore extends React.Component {
57
56
  }, restProps);
58
57
 
59
58
  const Label = size === "small" ? LabelSmall : LabelLarge;
60
- const label = /*#__PURE__*/React.createElement(Label, {
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
62
- kind === "tertiary" && !disabled && (pressed ? buttonStyles.active : (hovered || focused) && buttonStyles.focus)]
63
- }, icon && /*#__PURE__*/React.createElement(Icon, {
59
+ 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
+ }, icon && React.createElement(Icon, {
64
62
  size: size,
65
63
  color: "currentColor",
66
64
  icon: icon,
67
65
  style: sharedStyles.icon
68
66
  }), children);
69
- const contents = /*#__PURE__*/React.createElement(React.Fragment, null, label, spinner && /*#__PURE__*/React.createElement(CircularSpinner, {
67
+ const contents = React.createElement(React.Fragment, null, label, spinner && React.createElement(CircularSpinner, {
70
68
  style: sharedStyles.spinner,
71
69
  size: {
72
70
  medium: "small",
@@ -77,13 +75,13 @@ class ButtonCore extends React.Component {
77
75
  }));
78
76
 
79
77
  if (href && !disabled) {
80
- return router && !skipClientNav && isClientSideUrl(href) ? /*#__PURE__*/React.createElement(StyledLink, _extends({}, commonProps, {
78
+ return router && !skipClientNav && isClientSideUrl(href) ? React.createElement(StyledLink, _extends({}, commonProps, {
81
79
  to: href
82
- }), contents) : /*#__PURE__*/React.createElement(StyledAnchor, _extends({}, commonProps, {
80
+ }), contents) : React.createElement(StyledAnchor, _extends({}, commonProps, {
83
81
  href: href
84
82
  }), contents);
85
83
  } else {
86
- return /*#__PURE__*/React.createElement(StyledButton, _extends({
84
+ return React.createElement(StyledButton, _extends({
87
85
  type: type || "button"
88
86
  }, commonProps, {
89
87
  "aria-disabled": disabled
@@ -92,7 +90,7 @@ class ButtonCore extends React.Component {
92
90
  }
93
91
 
94
92
  render() {
95
- return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderInner(router));
93
+ return React.createElement(__RouterContext.Consumer, null, router => this.renderInner(router));
96
94
  }
97
95
 
98
96
  }
@@ -113,17 +111,13 @@ const sharedStyles = StyleSheet.create({
113
111
  outline: "none",
114
112
  textDecoration: "none",
115
113
  boxSizing: "border-box",
116
- // This removes the 300ms click delay on mobile browsers by indicating that
117
- // "double-tap to zoom" shouldn't be used on this element.
118
114
  touchAction: "manipulation",
119
115
  userSelect: "none",
120
116
  ":focus": {
121
- // Mobile: Removes a blue highlight style shown when the user clicks a button
122
117
  WebkitTapHighlightColor: "rgba(0,0,0,0)"
123
118
  }
124
119
  },
125
120
  withIcon: {
126
- // The left padding for the button with icon should have 4px less padding
127
121
  paddingLeft: 12
128
122
  },
129
123
  disabled: {
@@ -142,21 +136,17 @@ const sharedStyles = StyleSheet.create({
142
136
  overflow: "hidden",
143
137
  textOverflow: "ellipsis",
144
138
  display: "inline-block",
145
- // allows the button text to truncate
146
- pointerEvents: "none" // fix Safari bug where the browser was eating mouse events
147
-
139
+ pointerEvents: "none"
148
140
  },
149
141
  xlargeText: {
150
142
  fontSize: 18,
151
143
  lineHeight: "20px"
152
144
  },
153
145
  textWithIcon: {
154
- display: "flex" // allows the text and icon to sit nicely together
155
-
146
+ display: "flex"
156
147
  },
157
148
  textWithFocus: {
158
- position: "relative" // allows the tertiary button border to use the label width
159
-
149
+ position: "relative"
160
150
  },
161
151
  hiddenText: {
162
152
  visibility: "hidden"
@@ -199,10 +189,6 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
199
189
  paddingRight: padding
200
190
  },
201
191
  focus: {
202
- // This assumes a background of white for the regular button and
203
- // a background of darkBlue for the light version. The inner
204
- // box shadow/ring is also small enough for a slight variation
205
- // in the background color not to matter too much.
206
192
  boxShadow: `0 0 0 1px ${light ? darkBlue : white}, 0 0 0 3px ${light ? white : color}`
207
193
  },
208
194
  active: {
@@ -234,8 +220,6 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
234
220
  background: light ? "transparent" : white,
235
221
  borderColor: light ? white : color,
236
222
  borderWidth: 2,
237
- // The left padding for the button with icon should have 4px
238
- // less padding
239
223
  paddingLeft: iconWidth ? padding - 5 : padding - 1,
240
224
  paddingRight: padding - 1
241
225
  },
@@ -244,10 +228,6 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
244
228
  color: light ? fadedColor : activeColor,
245
229
  borderColor: light ? fadedColor : activeColor,
246
230
  borderWidth: 2,
247
- // We need to reduce padding to offset the difference
248
- // caused by the border becoming thicker on focus.
249
- // The left padding for the button with icon should have 4px
250
- // less padding
251
231
  paddingLeft: iconWidth ? padding - 5 : padding - 1,
252
232
  paddingRight: padding - 1
253
233
  },
@@ -258,17 +238,12 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
258
238
  ":focus": {
259
239
  borderColor: light ? white50 : offBlack32,
260
240
  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
241
  paddingLeft: iconWidth ? padding - 5 : padding - 1,
266
242
  paddingRight: padding - 1
267
243
  }
268
244
  }
269
245
  };
270
246
  } else if (kind === "tertiary") {
271
- // TODO(FEI-4229): Make tertiary buttons focusable
272
247
  newStyles = {
273
248
  default: {
274
249
  background: "none",
@@ -316,27 +291,6 @@ const _generateStyles = (color, kind, light, iconWidth, size) => {
316
291
 
317
292
  const _excluded = ["href", "type", "children", "skipClientNav", "spinner", "disabled", "onClick", "beforeNav", "safeWithNav", "tabIndex", "target", "rel"],
318
293
  _excluded2 = ["tabIndex"];
319
-
320
- /**
321
- * Reusable button component.
322
- *
323
- * Consisting of a [`ClickableBehavior`](#clickablebehavior) surrounding a
324
- * `ButtonCore`. `ClickableBehavior` handles interactions and state changes.
325
- * `ButtonCore` is a stateless component which displays the different states
326
- * the `Button` can take.
327
- *
328
- * ### Usage
329
- *
330
- * ```jsx
331
- * import Button from "@khanacademy/wonder-blocks-button";
332
- *
333
- * <Button
334
- * onClick={(e) => console.log("Hello, world!")}
335
- * >
336
- * Hello, world!
337
- * </Button>
338
- * ```
339
- */
340
294
  class Button extends React.Component {
341
295
  renderClickableBehavior(router) {
342
296
  const _this$props = this.props,
@@ -364,22 +318,19 @@ class Button extends React.Component {
364
318
  } = _ref,
365
319
  restChildProps = _objectWithoutPropertiesLoose(_ref, _excluded2);
366
320
 
367
- return /*#__PURE__*/React.createElement(ButtonCore, _extends({}, sharedButtonCoreProps, state, restChildProps, {
321
+ return React.createElement(ButtonCore, _extends({}, sharedButtonCoreProps, state, restChildProps, {
368
322
  disabled: disabled,
369
323
  spinner: spinner || state.waiting,
370
324
  skipClientNav: skipClientNav,
371
325
  href: href,
372
326
  target: target,
373
- type: type // If tabIndex is provide to the component we allow
374
- // it to override the tabIndex provide to use by
375
- // ClickableBehavior.
376
- ,
327
+ type: type,
377
328
  tabIndex: tabIndex || clickableTabIndex
378
329
  }), children);
379
330
  };
380
331
 
381
332
  if (beforeNav) {
382
- return /*#__PURE__*/React.createElement(ClickableBehavior, {
333
+ return React.createElement(ClickableBehavior, {
383
334
  disabled: spinner || disabled,
384
335
  href: href,
385
336
  role: "button",
@@ -390,7 +341,7 @@ class Button extends React.Component {
390
341
  rel: rel
391
342
  }, renderProp);
392
343
  } else {
393
- return /*#__PURE__*/React.createElement(ClickableBehavior, {
344
+ return React.createElement(ClickableBehavior, {
394
345
  disabled: spinner || disabled,
395
346
  href: href,
396
347
  role: "button",
@@ -404,7 +355,7 @@ class Button extends React.Component {
404
355
  }
405
356
 
406
357
  render() {
407
- return /*#__PURE__*/React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
358
+ return React.createElement(__RouterContext.Consumer, null, router => this.renderClickableBehavior(router));
408
359
  }
409
360
 
410
361
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-button",
3
- "version": "2.11.4",
3
+ "version": "2.11.7",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,13 +16,13 @@
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.16.3",
19
- "@khanacademy/wonder-blocks-clickable": "^2.2.5",
19
+ "@khanacademy/wonder-blocks-clickable": "^2.2.7",
20
20
  "@khanacademy/wonder-blocks-color": "^1.1.20",
21
- "@khanacademy/wonder-blocks-core": "^4.3.0",
22
- "@khanacademy/wonder-blocks-icon": "^1.2.26",
23
- "@khanacademy/wonder-blocks-progress-spinner": "^1.1.30",
21
+ "@khanacademy/wonder-blocks-core": "^4.3.2",
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
- "@khanacademy/wonder-blocks-typography": "^1.1.30"
25
+ "@khanacademy/wonder-blocks-typography": "^1.1.32"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "aphrodite": "^1.2.5",
@@ -31,6 +31,6 @@
31
31
  "react-router-dom": "5.3.0"
32
32
  },
33
33
  "devDependencies": {
34
- "wb-dev-build-settings": "^0.3.0"
34
+ "wb-dev-build-settings": "^0.4.0"
35
35
  }
36
36
  }
@@ -90,6 +90,8 @@ export type SharedProps = {|
90
90
  /**
91
91
  * A target destination window for a link to open in. Should only be used
92
92
  * when `href` is specified.
93
+ *
94
+ * TODO(WB-1262): only allow this prop when `href` is also set.t
93
95
  */
94
96
  target?: "_blank",
95
97