@khanacademy/wonder-blocks-button 6.1.0 → 6.2.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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # @khanacademy/wonder-blocks-button
2
2
 
3
+ ## 6.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - a70a929b: Add `labelStyle` to override the styles of the internal label
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [7b24db93]
12
+ - @khanacademy/wonder-blocks-clickable@4.0.10
13
+
3
14
  ## 6.1.0
4
15
 
5
16
  ### Minor Changes
@@ -100,6 +100,10 @@ Partial<Omit<AriaProps, "aria-disabled">> & {
100
100
  * page reload.
101
101
  */
102
102
  skipClientNav?: boolean;
103
+ /**
104
+ * Optional custom styles for the inner label.
105
+ */
106
+ labelStyle?: StyleType;
103
107
  /**
104
108
  * Optional custom styles.
105
109
  */
package/dist/es/index.js CHANGED
@@ -235,7 +235,7 @@ function ButtonIcon({
235
235
  }
236
236
  }
237
237
 
238
- const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "light", "pressed", "size", "style", "testId", "type", "spinner", "startIcon", "endIcon", "id", "waiting"];
238
+ const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "labelStyle", "light", "pressed", "size", "style", "testId", "type", "spinner", "startIcon", "endIcon", "id", "waiting"];
239
239
  const StyledAnchor = addStyle("a");
240
240
  const StyledButton = addStyle("button");
241
241
  const StyledLink = addStyle(Link);
@@ -255,6 +255,7 @@ const ButtonCore = React.forwardRef(function ButtonCore(props, ref) {
255
255
  hovered,
256
256
  href = undefined,
257
257
  kind = "primary",
258
+ labelStyle,
258
259
  light = false,
259
260
  pressed,
260
261
  size = "medium",
@@ -278,7 +279,7 @@ const ButtonCore = React.forwardRef(function ButtonCore(props, ref) {
278
279
  }, restProps);
279
280
  const Label = size === "small" ? LabelSmall : LabelLarge;
280
281
  const label = React.createElement(Label, {
281
- style: [sharedStyles.text, size === "large" && sharedStyles.largeText, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? [buttonStyles.hover, buttonStyles.active] : hovered && buttonStyles.hover)],
282
+ style: [sharedStyles.text, size === "large" && sharedStyles.largeText, labelStyle, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? [buttonStyles.hover, buttonStyles.active] : hovered && buttonStyles.hover)],
282
283
  testId: testId ? `${testId}-inner-label` : undefined
283
284
  }, children);
284
285
  const sizeMapping = {
@@ -447,43 +448,37 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
447
448
  }
448
449
  };
449
450
  } else if (kind === "secondary") {
450
- const horizontalPadding = padding - (theme.border.width.focused - 1);
451
451
  const secondaryBorderColor = buttonColor === "destructive" ? theme.color.border.secondary.critical : theme.color.border.secondary.action;
452
452
  const secondaryActiveColor = buttonColor === "destructive" ? theme.color.bg.secondary.active.critical : theme.color.bg.secondary.active.action;
453
453
  newStyles = {
454
454
  default: {
455
455
  background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.default,
456
456
  color: light ? theme.color.text.inverse : color,
457
- borderColor: light ? theme.color.border.secondary.inverse : secondaryBorderColor,
458
- borderStyle: "solid",
459
- borderWidth: theme.border.width.secondary,
457
+ outlineColor: light ? theme.color.border.secondary.inverse : secondaryBorderColor,
458
+ outlineStyle: "solid",
459
+ outlineWidth: theme.border.width.secondary,
460
+ outlineOffset: 1,
460
461
  paddingLeft: padding,
461
462
  paddingRight: padding
462
463
  },
463
464
  focus: {
464
465
  background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.focus,
465
- borderColor: light ? theme.color.border.primary.inverse : color,
466
- borderWidth: theme.border.width.focused,
467
- paddingLeft: horizontalPadding,
468
- paddingRight: horizontalPadding
466
+ outlineColor: light ? theme.color.border.primary.inverse : color,
467
+ outlineWidth: theme.border.width.focused
469
468
  },
470
469
  active: {
471
470
  background: light ? activeColor : secondaryActiveColor,
472
471
  color: light ? fadedColor : activeColor,
473
- borderColor: light ? fadedColor : activeColor,
474
- borderWidth: theme.border.width.focused,
475
- paddingLeft: horizontalPadding,
476
- paddingRight: horizontalPadding
472
+ outlineColor: light ? fadedColor : activeColor,
473
+ outlineWidth: theme.border.width.focused
477
474
  },
478
475
  disabled: {
479
476
  color: light ? theme.color.text.secondary.inverse : theme.color.text.disabled,
480
- borderColor: light ? fadedColor : theme.color.border.disabled,
477
+ outlineColor: light ? fadedColor : theme.color.border.disabled,
481
478
  cursor: "default",
482
479
  ":focus": {
483
- borderColor: light ? theme.color.border.secondary.inverse : theme.color.border.disabled,
484
- borderWidth: theme.border.width.disabled,
485
- paddingLeft: padding - 1,
486
- paddingRight: padding - 1
480
+ outlineColor: light ? theme.color.border.secondary.inverse : theme.color.border.disabled,
481
+ outlineWidth: theme.border.width.disabled
487
482
  }
488
483
  }
489
484
  };
@@ -508,16 +503,10 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
508
503
  }
509
504
  },
510
505
  focus: {
511
- ":after": {
512
- content: "''",
513
- position: "absolute",
514
- width: `calc(100% + ${theme.border.width.focused * 2}px)`,
515
- height: `calc(100% - ${theme.border.width.focused * 2}px)`,
516
- borderStyle: "solid",
517
- borderColor: light ? theme.color.border.tertiary.inverse : color,
518
- borderWidth: theme.border.width.focused,
519
- borderRadius: theme.border.radius.default
520
- }
506
+ outlineStyle: "solid",
507
+ outlineColor: light ? theme.color.border.tertiary.inverse : color,
508
+ outlineWidth: theme.border.width.focused,
509
+ borderRadius: theme.border.radius.default
521
510
  },
522
511
  active: {
523
512
  color: light ? fadedColor : activeColor,
@@ -531,9 +520,7 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
531
520
  cursor: "default"
532
521
  },
533
522
  disabledFocus: {
534
- ":after": {
535
- borderColor: light ? theme.color.border.tertiary.inverse : theme.color.border.disabled
536
- }
523
+ outlineColor: light ? theme.color.border.tertiary.inverse : theme.color.border.disabled
537
524
  }
538
525
  };
539
526
  } else {
package/dist/index.js CHANGED
@@ -257,7 +257,7 @@ function ButtonIcon({
257
257
  }
258
258
  }
259
259
 
260
- const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "light", "pressed", "size", "style", "testId", "type", "spinner", "startIcon", "endIcon", "id", "waiting"];
260
+ const _excluded$1 = ["children", "skipClientNav", "color", "disabled", "focused", "hovered", "href", "kind", "labelStyle", "light", "pressed", "size", "style", "testId", "type", "spinner", "startIcon", "endIcon", "id", "waiting"];
261
261
  const StyledAnchor = wonderBlocksCore.addStyle("a");
262
262
  const StyledButton = wonderBlocksCore.addStyle("button");
263
263
  const StyledLink = wonderBlocksCore.addStyle(reactRouterDom.Link);
@@ -277,6 +277,7 @@ const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
277
277
  hovered,
278
278
  href = undefined,
279
279
  kind = "primary",
280
+ labelStyle,
280
281
  light = false,
281
282
  pressed,
282
283
  size = "medium",
@@ -300,7 +301,7 @@ const ButtonCore = React__namespace.forwardRef(function ButtonCore(props, ref) {
300
301
  }, restProps);
301
302
  const Label = size === "small" ? wonderBlocksTypography.LabelSmall : wonderBlocksTypography.LabelLarge;
302
303
  const label = React__namespace.createElement(Label, {
303
- style: [sharedStyles.text, size === "large" && sharedStyles.largeText, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? [buttonStyles.hover, buttonStyles.active] : hovered && buttonStyles.hover)],
304
+ style: [sharedStyles.text, size === "large" && sharedStyles.largeText, labelStyle, spinner && sharedStyles.hiddenText, kind === "tertiary" && sharedStyles.textWithFocus, kind === "tertiary" && !disabled && (pressed ? [buttonStyles.hover, buttonStyles.active] : hovered && buttonStyles.hover)],
304
305
  testId: testId ? `${testId}-inner-label` : undefined
305
306
  }, children);
306
307
  const sizeMapping = {
@@ -469,43 +470,37 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
469
470
  }
470
471
  };
471
472
  } else if (kind === "secondary") {
472
- const horizontalPadding = padding - (theme.border.width.focused - 1);
473
473
  const secondaryBorderColor = buttonColor === "destructive" ? theme.color.border.secondary.critical : theme.color.border.secondary.action;
474
474
  const secondaryActiveColor = buttonColor === "destructive" ? theme.color.bg.secondary.active.critical : theme.color.bg.secondary.active.action;
475
475
  newStyles = {
476
476
  default: {
477
477
  background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.default,
478
478
  color: light ? theme.color.text.inverse : color,
479
- borderColor: light ? theme.color.border.secondary.inverse : secondaryBorderColor,
480
- borderStyle: "solid",
481
- borderWidth: theme.border.width.secondary,
479
+ outlineColor: light ? theme.color.border.secondary.inverse : secondaryBorderColor,
480
+ outlineStyle: "solid",
481
+ outlineWidth: theme.border.width.secondary,
482
+ outlineOffset: 1,
482
483
  paddingLeft: padding,
483
484
  paddingRight: padding
484
485
  },
485
486
  focus: {
486
487
  background: light ? theme.color.bg.secondary.inverse : theme.color.bg.secondary.focus,
487
- borderColor: light ? theme.color.border.primary.inverse : color,
488
- borderWidth: theme.border.width.focused,
489
- paddingLeft: horizontalPadding,
490
- paddingRight: horizontalPadding
488
+ outlineColor: light ? theme.color.border.primary.inverse : color,
489
+ outlineWidth: theme.border.width.focused
491
490
  },
492
491
  active: {
493
492
  background: light ? activeColor : secondaryActiveColor,
494
493
  color: light ? fadedColor : activeColor,
495
- borderColor: light ? fadedColor : activeColor,
496
- borderWidth: theme.border.width.focused,
497
- paddingLeft: horizontalPadding,
498
- paddingRight: horizontalPadding
494
+ outlineColor: light ? fadedColor : activeColor,
495
+ outlineWidth: theme.border.width.focused
499
496
  },
500
497
  disabled: {
501
498
  color: light ? theme.color.text.secondary.inverse : theme.color.text.disabled,
502
- borderColor: light ? fadedColor : theme.color.border.disabled,
499
+ outlineColor: light ? fadedColor : theme.color.border.disabled,
503
500
  cursor: "default",
504
501
  ":focus": {
505
- borderColor: light ? theme.color.border.secondary.inverse : theme.color.border.disabled,
506
- borderWidth: theme.border.width.disabled,
507
- paddingLeft: padding - 1,
508
- paddingRight: padding - 1
502
+ outlineColor: light ? theme.color.border.secondary.inverse : theme.color.border.disabled,
503
+ outlineWidth: theme.border.width.disabled
509
504
  }
510
505
  }
511
506
  };
@@ -530,16 +525,10 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
530
525
  }
531
526
  },
532
527
  focus: {
533
- ":after": {
534
- content: "''",
535
- position: "absolute",
536
- width: `calc(100% + ${theme.border.width.focused * 2}px)`,
537
- height: `calc(100% - ${theme.border.width.focused * 2}px)`,
538
- borderStyle: "solid",
539
- borderColor: light ? theme.color.border.tertiary.inverse : color,
540
- borderWidth: theme.border.width.focused,
541
- borderRadius: theme.border.radius.default
542
- }
528
+ outlineStyle: "solid",
529
+ outlineColor: light ? theme.color.border.tertiary.inverse : color,
530
+ outlineWidth: theme.border.width.focused,
531
+ borderRadius: theme.border.radius.default
543
532
  },
544
533
  active: {
545
534
  color: light ? fadedColor : activeColor,
@@ -553,9 +542,7 @@ const _generateStyles = (buttonColor = "default", kind, light, size, theme, them
553
542
  cursor: "default"
554
543
  },
555
544
  disabledFocus: {
556
- ":after": {
557
- borderColor: light ? theme.color.border.tertiary.inverse : theme.color.border.disabled
558
- }
545
+ outlineColor: light ? theme.color.border.tertiary.inverse : theme.color.border.disabled
559
546
  }
560
547
  };
561
548
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-button",
3
- "version": "6.1.0",
3
+ "version": "6.2.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -16,7 +16,7 @@
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.18.6",
19
- "@khanacademy/wonder-blocks-clickable": "^4.0.9",
19
+ "@khanacademy/wonder-blocks-clickable": "^4.0.10",
20
20
  "@khanacademy/wonder-blocks-color": "^3.0.0",
21
21
  "@khanacademy/wonder-blocks-core": "^6.3.0",
22
22
  "@khanacademy/wonder-blocks-icon": "^2.2.1",