@spark-web/button 5.1.0 → 5.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # @spark-web/button
2
2
 
3
+ ## 5.2.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#574](https://github.com/brighte-labs/spark-web/pull/574)
8
+ [`e77b91f`](https://github.com/brighte-labs/spark-web/commit/e77b91fcd59e18795c49fcefec29259eb2aec0a6)
9
+ Thanks [@mkt-brighte](https://github.com/mkt-brighte)! - Move button
10
+ fontWeight to token
11
+
12
+ - Updated dependencies
13
+ [[`e77b91f`](https://github.com/brighte-labs/spark-web/commit/e77b91fcd59e18795c49fcefec29259eb2aec0a6)]:
14
+ - @spark-web/theme@5.7.2
15
+
16
+ ## 5.2.0
17
+
18
+ ### Minor Changes
19
+
20
+ - This release covers the following changes:
21
+
22
+ - Updates the primary color palette of the Brighte theme
23
+ - Add new Storybook story for the `rounded` prop for button components
24
+ - Tweak focus state styling of buttons at Pantheon theme
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies []:
29
+ - @spark-web/theme@5.6.0
30
+
3
31
  ## 5.1.0
4
32
 
5
33
  ### Minor Changes
@@ -5,5 +5,5 @@ export declare type ButtonLinkProps = LinkComponentProps & CommonButtonProps;
5
5
  /** The appearance of a `Button`, with the semantics of a link. */
6
6
  export declare const ButtonLink: <Comp extends import("react").ElementType<any, keyof import("react").JSX.IntrinsicElements> = "a">(props: {
7
7
  as?: Comp | undefined;
8
- ref?: import("react").Ref<Comp extends "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "clipPath" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "filter" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "marker" | "mask" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
8
+ ref?: import("react").Ref<Comp extends "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view" | keyof HTMLElementTagNameMap ? (HTMLElementTagNameMap & Pick<SVGElementTagNameMap, "symbol" | "clipPath" | "filter" | "mask" | "marker" | "svg" | "animate" | "animateMotion" | "animateTransform" | "circle" | "defs" | "desc" | "ellipse" | "feBlend" | "feColorMatrix" | "feComponentTransfer" | "feComposite" | "feConvolveMatrix" | "feDiffuseLighting" | "feDisplacementMap" | "feDistantLight" | "feDropShadow" | "feFlood" | "feFuncA" | "feFuncB" | "feFuncG" | "feFuncR" | "feGaussianBlur" | "feImage" | "feMerge" | "feMergeNode" | "feMorphology" | "feOffset" | "fePointLight" | "feSpecularLighting" | "feSpotLight" | "feTile" | "feTurbulence" | "foreignObject" | "g" | "image" | "line" | "linearGradient" | "metadata" | "mpath" | "path" | "pattern" | "polygon" | "polyline" | "radialGradient" | "rect" | "set" | "stop" | "switch" | "text" | "textPath" | "tspan" | "use" | "view">)[Comp] : Comp extends new (...args: any) => any ? InstanceType<Comp> : undefined> | undefined;
9
9
  } & Omit<import("react").PropsWithoutRef<import("react").ComponentProps<Comp>>, "as"> & ButtonLinkProps) => import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
@@ -52,7 +52,23 @@ export declare function useButtonStyles({ iconOnly, prominence, rounded, size, t
52
52
  } | {
53
53
  border?: string | undefined;
54
54
  outline?: string | undefined;
55
+ /**
56
+ * useButtonStyles
57
+ *
58
+ * Custom hook for styling buttons and certain links.
59
+ * Returns a tuple where the first item is an object of props to spread onto the
60
+ * underlying `Box` component, and the second item is a CSS object that can be
61
+ * passed to Emotion's `css` function.
62
+ */
55
63
  outlineOffset?: string | undefined;
64
+ /**
65
+ * useButtonStyles
66
+ *
67
+ * Custom hook for styling buttons and certain links.
68
+ * Returns a tuple where the first item is an object of props to spread onto the
69
+ * underlying `Box` component, and the second item is a CSS object that can be
70
+ * passed to Emotion's `css` function.
71
+ */
56
72
  boxShadow?: string | undefined;
57
73
  };
58
74
  };
@@ -76,6 +92,8 @@ export declare function useButtonStyles({ iconOnly, prominence, rounded, size, t
76
92
  readonly transitionProperty: string;
77
93
  readonly transitionTimingFunction: string;
78
94
  readonly transitionDuration: string;
95
+ }, {
96
+ readonly fontWeight: "medium" | "light" | "bold" | "thin" | "extralight" | "regular" | "semibold" | "extrabold" | "black" | undefined;
79
97
  }];
80
98
  export declare type UseButtonStylesProps = Omit<Required<ButtonStyleProps>, 'css' | 'rounded'> & Partial<Pick<ButtonStyleProps, 'rounded'>> & {
81
99
  /** Whether the children of the button is a single icon or not. */
@@ -235,7 +235,8 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
235
235
  isLoading = _ref.isLoading,
236
236
  prominence = _ref.prominence,
237
237
  size = _ref.size,
238
- tone = _ref.tone;
238
+ tone = _ref.tone,
239
+ weight = _ref.weight;
239
240
  var variant = variants[prominence][tone];
240
241
  return react.Children.map(children, function (child) {
241
242
  if (typeof child === 'string' || typeof child === 'number') {
@@ -245,7 +246,7 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
245
246
  as: "span",
246
247
  baseline: false,
247
248
  overflowStrategy: "nowrap",
248
- weight: "semibold",
249
+ weight: weight !== null && weight !== void 0 ? weight : 'semibold',
249
250
  size: mapTokens.fontSize[size],
250
251
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone,
251
252
  children: child
@@ -293,7 +294,7 @@ function HiddenWhenLoading(_ref2) {
293
294
  * passed to Emotion's `css` function.
294
295
  */
295
296
  function useButtonStyles(_ref) {
296
- var _theme$components$but, _theme$components;
297
+ var _theme$components$but, _theme$components, _theme$components2;
297
298
  var iconOnly = _ref.iconOnly,
298
299
  prominence = _ref.prominence,
299
300
  _ref$rounded = _ref.rounded,
@@ -364,7 +365,9 @@ function useButtonStyles(_ref) {
364
365
  },
365
366
  ':focus': disabledFocusRingStyles
366
367
  }
367
- })];
368
+ }), {
369
+ fontWeight: (_theme$components2 = theme$1.components) === null || _theme$components2 === void 0 || (_theme$components2 = _theme$components2.buttons) === null || _theme$components2 === void 0 ? void 0 : _theme$components2.fontWeight
370
+ }];
368
371
  }
369
372
 
370
373
  var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
@@ -402,9 +405,10 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
402
405
  tone: tone,
403
406
  prominence: prominence
404
407
  }),
405
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
408
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
406
409
  boxProps = _useButtonStyles2[0],
407
- buttonStyles = _useButtonStyles2[1];
410
+ buttonStyles = _useButtonStyles2[1],
411
+ fontWeight = _useButtonStyles2[2].fontWeight;
408
412
  var variant = variants[prominence][tone];
409
413
  return jsxRuntime.jsxs(BaseButton, _objectSpread(_objectSpread({}, boxProps), {}, {
410
414
  "aria-controls": ariaControls,
@@ -422,7 +426,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
422
426
  isLoading: loading,
423
427
  prominence: prominence,
424
428
  size: size,
425
- tone: tone
429
+ tone: tone,
430
+ weight: fontWeight
426
431
  })), loading && jsxRuntime.jsx(Loading, {
427
432
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone
428
433
  })]
@@ -476,9 +481,10 @@ var ButtonLink = ts.forwardRefWithAs(function (_ref, forwardedRef) {
476
481
  size: size,
477
482
  tone: tone
478
483
  }),
479
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
484
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
480
485
  boxProps = _useButtonStyles2[0],
481
- buttonStyles = _useButtonStyles2[1];
486
+ buttonStyles = _useButtonStyles2[1],
487
+ fontWeight = _useButtonStyles2[2].fontWeight;
482
488
  return jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), {}, {
483
489
  "aria-label": consumerProps.label,
484
490
  as: LinkComponent,
@@ -494,7 +500,8 @@ var ButtonLink = ts.forwardRefWithAs(function (_ref, forwardedRef) {
494
500
  isLoading: false,
495
501
  prominence: prominence,
496
502
  size: size,
497
- tone: tone
503
+ tone: tone,
504
+ weight: fontWeight
498
505
  }))
499
506
  }));
500
507
  });
@@ -235,7 +235,8 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
235
235
  isLoading = _ref.isLoading,
236
236
  prominence = _ref.prominence,
237
237
  size = _ref.size,
238
- tone = _ref.tone;
238
+ tone = _ref.tone,
239
+ weight = _ref.weight;
239
240
  var variant = variants[prominence][tone];
240
241
  return react.Children.map(children, function (child) {
241
242
  if (typeof child === 'string' || typeof child === 'number') {
@@ -245,7 +246,7 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
245
246
  as: "span",
246
247
  baseline: false,
247
248
  overflowStrategy: "nowrap",
248
- weight: "semibold",
249
+ weight: weight !== null && weight !== void 0 ? weight : 'semibold',
249
250
  size: mapTokens.fontSize[size],
250
251
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone,
251
252
  children: child
@@ -293,7 +294,7 @@ function HiddenWhenLoading(_ref2) {
293
294
  * passed to Emotion's `css` function.
294
295
  */
295
296
  function useButtonStyles(_ref) {
296
- var _theme$components$but, _theme$components;
297
+ var _theme$components$but, _theme$components, _theme$components2;
297
298
  var iconOnly = _ref.iconOnly,
298
299
  prominence = _ref.prominence,
299
300
  _ref$rounded = _ref.rounded,
@@ -364,7 +365,9 @@ function useButtonStyles(_ref) {
364
365
  },
365
366
  ':focus': disabledFocusRingStyles
366
367
  }
367
- })];
368
+ }), {
369
+ fontWeight: (_theme$components2 = theme$1.components) === null || _theme$components2 === void 0 || (_theme$components2 = _theme$components2.buttons) === null || _theme$components2 === void 0 ? void 0 : _theme$components2.fontWeight
370
+ }];
368
371
  }
369
372
 
370
373
  var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
@@ -402,9 +405,10 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
402
405
  tone: tone,
403
406
  prominence: prominence
404
407
  }),
405
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
408
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
406
409
  boxProps = _useButtonStyles2[0],
407
- buttonStyles = _useButtonStyles2[1];
410
+ buttonStyles = _useButtonStyles2[1],
411
+ fontWeight = _useButtonStyles2[2].fontWeight;
408
412
  var variant = variants[prominence][tone];
409
413
  return jsxRuntime.jsxs(BaseButton, _objectSpread(_objectSpread({}, boxProps), {}, {
410
414
  "aria-controls": ariaControls,
@@ -422,7 +426,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
422
426
  isLoading: loading,
423
427
  prominence: prominence,
424
428
  size: size,
425
- tone: tone
429
+ tone: tone,
430
+ weight: fontWeight
426
431
  })), loading && jsxRuntime.jsx(Loading, {
427
432
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone
428
433
  })]
@@ -476,9 +481,10 @@ var ButtonLink = ts.forwardRefWithAs(function (_ref, forwardedRef) {
476
481
  size: size,
477
482
  tone: tone
478
483
  }),
479
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
484
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
480
485
  boxProps = _useButtonStyles2[0],
481
- buttonStyles = _useButtonStyles2[1];
486
+ buttonStyles = _useButtonStyles2[1],
487
+ fontWeight = _useButtonStyles2[2].fontWeight;
482
488
  return jsxRuntime.jsx(box.Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), {}, {
483
489
  "aria-label": consumerProps.label,
484
490
  as: LinkComponent,
@@ -494,7 +500,8 @@ var ButtonLink = ts.forwardRefWithAs(function (_ref, forwardedRef) {
494
500
  isLoading: false,
495
501
  prominence: prominence,
496
502
  size: size,
497
- tone: tone
503
+ tone: tone,
504
+ weight: fontWeight
498
505
  }))
499
506
  }));
500
507
  });
@@ -231,7 +231,8 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
231
231
  isLoading = _ref.isLoading,
232
232
  prominence = _ref.prominence,
233
233
  size = _ref.size,
234
- tone = _ref.tone;
234
+ tone = _ref.tone,
235
+ weight = _ref.weight;
235
236
  var variant = variants[prominence][tone];
236
237
  return Children.map(children, function (child) {
237
238
  if (typeof child === 'string' || typeof child === 'number') {
@@ -241,7 +242,7 @@ var resolveButtonChildren = function resolveButtonChildren(_ref) {
241
242
  as: "span",
242
243
  baseline: false,
243
244
  overflowStrategy: "nowrap",
244
- weight: "semibold",
245
+ weight: weight !== null && weight !== void 0 ? weight : 'semibold',
245
246
  size: mapTokens.fontSize[size],
246
247
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone,
247
248
  children: child
@@ -289,7 +290,7 @@ function HiddenWhenLoading(_ref2) {
289
290
  * passed to Emotion's `css` function.
290
291
  */
291
292
  function useButtonStyles(_ref) {
292
- var _theme$components$but, _theme$components;
293
+ var _theme$components$but, _theme$components, _theme$components2;
293
294
  var iconOnly = _ref.iconOnly,
294
295
  prominence = _ref.prominence,
295
296
  _ref$rounded = _ref.rounded,
@@ -360,7 +361,9 @@ function useButtonStyles(_ref) {
360
361
  },
361
362
  ':focus': disabledFocusRingStyles
362
363
  }
363
- })];
364
+ }), {
365
+ fontWeight: (_theme$components2 = theme.components) === null || _theme$components2 === void 0 || (_theme$components2 = _theme$components2.buttons) === null || _theme$components2 === void 0 ? void 0 : _theme$components2.fontWeight
366
+ }];
364
367
  }
365
368
 
366
369
  var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
@@ -398,9 +401,10 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
398
401
  tone: tone,
399
402
  prominence: prominence
400
403
  }),
401
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
404
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
402
405
  boxProps = _useButtonStyles2[0],
403
- buttonStyles = _useButtonStyles2[1];
406
+ buttonStyles = _useButtonStyles2[1],
407
+ fontWeight = _useButtonStyles2[2].fontWeight;
404
408
  var variant = variants[prominence][tone];
405
409
  return jsxs(BaseButton, _objectSpread(_objectSpread({}, boxProps), {}, {
406
410
  "aria-controls": ariaControls,
@@ -418,7 +422,8 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
418
422
  isLoading: loading,
419
423
  prominence: prominence,
420
424
  size: size,
421
- tone: tone
425
+ tone: tone,
426
+ weight: fontWeight
422
427
  })), loading && jsx(Loading, {
423
428
  tone: variant === null || variant === void 0 ? void 0 : variant.textTone
424
429
  })]
@@ -472,9 +477,10 @@ var ButtonLink = forwardRefWithAs(function (_ref, forwardedRef) {
472
477
  size: size,
473
478
  tone: tone
474
479
  }),
475
- _useButtonStyles2 = _slicedToArray(_useButtonStyles, 2),
480
+ _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
476
481
  boxProps = _useButtonStyles2[0],
477
- buttonStyles = _useButtonStyles2[1];
482
+ buttonStyles = _useButtonStyles2[1],
483
+ fontWeight = _useButtonStyles2[2].fontWeight;
478
484
  return jsx(Box, _objectSpread(_objectSpread(_objectSpread({}, boxProps), {}, {
479
485
  "aria-label": consumerProps.label,
480
486
  as: LinkComponent,
@@ -490,7 +496,8 @@ var ButtonLink = forwardRefWithAs(function (_ref, forwardedRef) {
490
496
  isLoading: false,
491
497
  prominence: prominence,
492
498
  size: size,
493
- tone: tone
499
+ tone: tone,
500
+ weight: fontWeight
494
501
  }))
495
502
  }));
496
503
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/button",
3
- "version": "5.1.0",
3
+ "version": "5.2.1",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -23,7 +23,7 @@
23
23
  "@spark-web/link": "^5.0.0",
24
24
  "@spark-web/spinner": "^5.0.0",
25
25
  "@spark-web/text": "^5.1.0",
26
- "@spark-web/theme": "^5.5.0",
26
+ "@spark-web/theme": "^5.7.2",
27
27
  "@spark-web/utils": "^5.0.0"
28
28
  },
29
29
  "devDependencies": {