@spark-web/button 5.3.3 → 5.5.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,30 @@
1
1
  # @spark-web/button
2
2
 
3
+ ## 5.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#659](https://github.com/brighte-labs/spark-web/pull/659)
8
+ [`6b8615a`](https://github.com/brighte-labs/spark-web/commit/6b8615a0e63d51a6757fd569bf21798a3bceaeea)
9
+ Thanks [@mkt-brighte](https://github.com/mkt-brighte)! - Added dark tone for
10
+ button component and add dark tokens
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+ [[`6b8615a`](https://github.com/brighte-labs/spark-web/commit/6b8615a0e63d51a6757fd569bf21798a3bceaeea)]:
16
+ - @spark-web/a11y@5.2.0
17
+ - @spark-web/theme@5.11.1
18
+
19
+ ## 5.4.0
20
+
21
+ ### Minor Changes
22
+
23
+ - [#647](https://github.com/brighte-labs/spark-web/pull/647)
24
+ [`b6825e0`](https://github.com/brighte-labs/spark-web/commit/b6825e0fdffb297cecb033fd70e15b13a65d27a7)
25
+ Thanks [@michtntbrighte](https://github.com/michtntbrighte)! - Improve low
26
+ prominence and support filled props for button
27
+
3
28
  ## 5.3.3
4
29
 
5
30
  ### Patch Changes
@@ -22,6 +22,8 @@ export declare type ButtonProps = CommonButtonProps & {
22
22
  size?: CommonButtonProps['size'];
23
23
  /** Provide an alternate type if the button is within a form. */
24
24
  type?: 'button' | 'submit' | 'reset';
25
+ /** When true, the button will be filled depending on the variant. */
26
+ filled?: boolean;
25
27
  };
26
28
  /**
27
29
  * Buttons are used to initialize an action, their label should express what
@@ -38,5 +38,7 @@ export declare type ButtonStyleProps = {
38
38
  size?: ButtonSize;
39
39
  /** Sets the tone of the button. */
40
40
  tone?: ButtonTone;
41
+ /** Sets the background color of the button. */
42
+ filled?: boolean;
41
43
  };
42
44
  export {};
@@ -7,7 +7,7 @@ import type { ButtonStyleProps } from "./types.js";
7
7
  * underlying `Box` component, and the second item is a CSS object that can be
8
8
  * passed to Emotion's `css` function.
9
9
  */
10
- export declare function useButtonStyles({ iconOnly, prominence, rounded, size, tone, }: UseButtonStylesProps): readonly [{
10
+ export declare function useButtonStyles({ iconOnly, prominence, rounded, size, tone, filled, }: UseButtonStylesProps): readonly [{
11
11
  readonly alignItems: "center";
12
12
  readonly background: string | number | undefined;
13
13
  readonly border: import("@spark-web/theme").ResponsiveProp<string> | undefined;
@@ -95,7 +95,7 @@ export declare function useButtonStyles({ iconOnly, prominence, rounded, size, t
95
95
  }, {
96
96
  readonly fontWeight: "bold" | "medium" | "light" | "thin" | "black" | "extralight" | "regular" | "semibold" | "extrabold" | undefined;
97
97
  }];
98
- export declare type UseButtonStylesProps = Omit<Required<ButtonStyleProps>, 'css' | 'rounded'> & Partial<Pick<ButtonStyleProps, 'rounded'>> & {
98
+ export declare type UseButtonStylesProps = Omit<Required<ButtonStyleProps>, 'css' | 'rounded' | 'filled'> & Partial<Pick<ButtonStyleProps, 'rounded' | 'filled'>> & {
99
99
  /** Whether the children of the button is a single icon or not. */
100
100
  iconOnly: boolean;
101
101
  };
@@ -4,6 +4,7 @@ import type { SparkTheme } from '@spark-web/theme';
4
4
  import type { ButtonProminence, ButtonTone } from "./types.js";
5
5
  declare type BaseButtonStyles = {
6
6
  background: BoxProps['background'];
7
+ backgroundFill?: BoxProps['background'];
7
8
  border?: BoxProps['border'];
8
9
  borderWidth?: BoxProps['borderWidth'];
9
10
  textTone?: ForegroundTone;
@@ -122,14 +122,20 @@ var variants = {
122
122
  background: 'primaryDark',
123
123
  backgroundHover: 'primaryHover',
124
124
  backgroundActive: 'primaryActive'
125
+ }, highDisabledStyles),
126
+ dark: _objectSpread({
127
+ background: 'dark',
128
+ backgroundHover: 'darkHover',
129
+ backgroundActive: 'darkActive'
125
130
  }, highDisabledStyles)
126
131
  },
127
132
  low: {
128
133
  primary: _objectSpread({
129
134
  background: 'surface',
135
+ backgroundFill: 'primarySoft',
130
136
  border: 'primary',
131
137
  borderWidth: 'large',
132
- textTone: 'primary',
138
+ textTone: 'neutral',
133
139
  backgroundHover: 'none',
134
140
  borderHover: 'primaryHover',
135
141
  textToneHover: 'primaryHover',
@@ -185,6 +191,16 @@ var variants = {
185
191
  backgroundActive: 'none',
186
192
  borderActive: 'primaryActive',
187
193
  textToneActive: 'primaryActive'
194
+ }, lowDisabledAltStyles),
195
+ dark: _objectSpread({
196
+ background: 'surface',
197
+ backgroundHover: 'none',
198
+ backgroundActive: 'none',
199
+ textTone: 'dark',
200
+ borderWidth: 'large',
201
+ border: 'dark',
202
+ borderHover: 'darkHover',
203
+ borderActive: 'darkActive'
188
204
  }, lowDisabledAltStyles)
189
205
  },
190
206
  none: {
@@ -235,6 +251,12 @@ var variants = {
235
251
  textTone: 'primaryActive',
236
252
  backgroundHover: 'primaryLowHover',
237
253
  backgroundActive: 'primaryLowActive'
254
+ }, noneDisabledStyles),
255
+ dark: _objectSpread({
256
+ background: 'surface',
257
+ textTone: 'dark',
258
+ backgroundHover: 'darkLowHover',
259
+ backgroundActive: 'darkLowActive'
238
260
  }, noneDisabledStyles)
239
261
  }
240
262
  };
@@ -317,13 +339,15 @@ function HiddenWhenLoading(_ref2) {
317
339
  * passed to Emotion's `css` function.
318
340
  */
319
341
  function useButtonStyles(_ref) {
320
- var _theme$components$but, _theme$components, _theme$components2;
342
+ var _variant$backgroundFi, _theme$components$but, _theme$components, _theme$components2;
321
343
  var iconOnly = _ref.iconOnly,
322
344
  prominence = _ref.prominence,
323
345
  _ref$rounded = _ref.rounded,
324
346
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
325
347
  size = _ref.size,
326
- tone = _ref.tone;
348
+ tone = _ref.tone,
349
+ _ref$filled = _ref.filled,
350
+ filled = _ref$filled === void 0 ? false : _ref$filled;
327
351
  var theme$1 = theme.useTheme();
328
352
  var focusRingStyles = a11y.useFocusRing({
329
353
  tone: tone,
@@ -341,7 +365,7 @@ function useButtonStyles(_ref) {
341
365
  };
342
366
  return [{
343
367
  alignItems: 'center',
344
- background: variant === null || variant === void 0 ? void 0 : variant.background,
368
+ background: filled ? (_variant$backgroundFi = variant === null || variant === void 0 ? void 0 : variant.backgroundFill) !== null && _variant$backgroundFi !== void 0 ? _variant$backgroundFi : variant === null || variant === void 0 ? void 0 : variant.background : variant === null || variant === void 0 ? void 0 : variant.background,
345
369
  border: variant === null || variant === void 0 ? void 0 : variant.border,
346
370
  borderWidth: variant === null || variant === void 0 ? void 0 : variant.borderWidth,
347
371
  borderRadius: rounded ? 'full' : isLarge ? 'medium' : 'small',
@@ -394,7 +418,7 @@ function useButtonStyles(_ref) {
394
418
  }];
395
419
  }
396
420
 
397
- var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
421
+ var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type", "filled"];
398
422
  /**
399
423
  * Buttons are used to initialize an action, their label should express what
400
424
  * action will occur when the user interacts with it.
@@ -420,6 +444,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
420
444
  _ref$tone = _ref.tone,
421
445
  tone = _ref$tone === void 0 ? 'primary' : _ref$tone,
422
446
  type = _ref.type,
447
+ _ref$filled = _ref.filled,
448
+ filled = _ref$filled === void 0 ? false : _ref$filled,
423
449
  props = _objectWithoutProperties(_ref, _excluded$1);
424
450
  var iconOnly = Boolean(props.label);
425
451
  var _useButtonStyles = useButtonStyles({
@@ -427,7 +453,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
427
453
  rounded: rounded,
428
454
  size: size,
429
455
  tone: tone,
430
- prominence: prominence
456
+ prominence: prominence,
457
+ filled: filled
431
458
  }),
432
459
  _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
433
460
  boxProps = _useButtonStyles2[0],
@@ -122,14 +122,20 @@ var variants = {
122
122
  background: 'primaryDark',
123
123
  backgroundHover: 'primaryHover',
124
124
  backgroundActive: 'primaryActive'
125
+ }, highDisabledStyles),
126
+ dark: _objectSpread({
127
+ background: 'dark',
128
+ backgroundHover: 'darkHover',
129
+ backgroundActive: 'darkActive'
125
130
  }, highDisabledStyles)
126
131
  },
127
132
  low: {
128
133
  primary: _objectSpread({
129
134
  background: 'surface',
135
+ backgroundFill: 'primarySoft',
130
136
  border: 'primary',
131
137
  borderWidth: 'large',
132
- textTone: 'primary',
138
+ textTone: 'neutral',
133
139
  backgroundHover: 'none',
134
140
  borderHover: 'primaryHover',
135
141
  textToneHover: 'primaryHover',
@@ -185,6 +191,16 @@ var variants = {
185
191
  backgroundActive: 'none',
186
192
  borderActive: 'primaryActive',
187
193
  textToneActive: 'primaryActive'
194
+ }, lowDisabledAltStyles),
195
+ dark: _objectSpread({
196
+ background: 'surface',
197
+ backgroundHover: 'none',
198
+ backgroundActive: 'none',
199
+ textTone: 'dark',
200
+ borderWidth: 'large',
201
+ border: 'dark',
202
+ borderHover: 'darkHover',
203
+ borderActive: 'darkActive'
188
204
  }, lowDisabledAltStyles)
189
205
  },
190
206
  none: {
@@ -235,6 +251,12 @@ var variants = {
235
251
  textTone: 'primaryActive',
236
252
  backgroundHover: 'primaryLowHover',
237
253
  backgroundActive: 'primaryLowActive'
254
+ }, noneDisabledStyles),
255
+ dark: _objectSpread({
256
+ background: 'surface',
257
+ textTone: 'dark',
258
+ backgroundHover: 'darkLowHover',
259
+ backgroundActive: 'darkLowActive'
238
260
  }, noneDisabledStyles)
239
261
  }
240
262
  };
@@ -317,13 +339,15 @@ function HiddenWhenLoading(_ref2) {
317
339
  * passed to Emotion's `css` function.
318
340
  */
319
341
  function useButtonStyles(_ref) {
320
- var _theme$components$but, _theme$components, _theme$components2;
342
+ var _variant$backgroundFi, _theme$components$but, _theme$components, _theme$components2;
321
343
  var iconOnly = _ref.iconOnly,
322
344
  prominence = _ref.prominence,
323
345
  _ref$rounded = _ref.rounded,
324
346
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
325
347
  size = _ref.size,
326
- tone = _ref.tone;
348
+ tone = _ref.tone,
349
+ _ref$filled = _ref.filled,
350
+ filled = _ref$filled === void 0 ? false : _ref$filled;
327
351
  var theme$1 = theme.useTheme();
328
352
  var focusRingStyles = a11y.useFocusRing({
329
353
  tone: tone,
@@ -341,7 +365,7 @@ function useButtonStyles(_ref) {
341
365
  };
342
366
  return [{
343
367
  alignItems: 'center',
344
- background: variant === null || variant === void 0 ? void 0 : variant.background,
368
+ background: filled ? (_variant$backgroundFi = variant === null || variant === void 0 ? void 0 : variant.backgroundFill) !== null && _variant$backgroundFi !== void 0 ? _variant$backgroundFi : variant === null || variant === void 0 ? void 0 : variant.background : variant === null || variant === void 0 ? void 0 : variant.background,
345
369
  border: variant === null || variant === void 0 ? void 0 : variant.border,
346
370
  borderWidth: variant === null || variant === void 0 ? void 0 : variant.borderWidth,
347
371
  borderRadius: rounded ? 'full' : isLarge ? 'medium' : 'small',
@@ -394,7 +418,7 @@ function useButtonStyles(_ref) {
394
418
  }];
395
419
  }
396
420
 
397
- var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
421
+ var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type", "filled"];
398
422
  /**
399
423
  * Buttons are used to initialize an action, their label should express what
400
424
  * action will occur when the user interacts with it.
@@ -420,6 +444,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
420
444
  _ref$tone = _ref.tone,
421
445
  tone = _ref$tone === void 0 ? 'primary' : _ref$tone,
422
446
  type = _ref.type,
447
+ _ref$filled = _ref.filled,
448
+ filled = _ref$filled === void 0 ? false : _ref$filled,
423
449
  props = _objectWithoutProperties(_ref, _excluded$1);
424
450
  var iconOnly = Boolean(props.label);
425
451
  var _useButtonStyles = useButtonStyles({
@@ -427,7 +453,8 @@ var Button = /*#__PURE__*/react.forwardRef(function (_ref, forwardedRef) {
427
453
  rounded: rounded,
428
454
  size: size,
429
455
  tone: tone,
430
- prominence: prominence
456
+ prominence: prominence,
457
+ filled: filled
431
458
  }),
432
459
  _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
433
460
  boxProps = _useButtonStyles2[0],
@@ -118,14 +118,20 @@ var variants = {
118
118
  background: 'primaryDark',
119
119
  backgroundHover: 'primaryHover',
120
120
  backgroundActive: 'primaryActive'
121
+ }, highDisabledStyles),
122
+ dark: _objectSpread({
123
+ background: 'dark',
124
+ backgroundHover: 'darkHover',
125
+ backgroundActive: 'darkActive'
121
126
  }, highDisabledStyles)
122
127
  },
123
128
  low: {
124
129
  primary: _objectSpread({
125
130
  background: 'surface',
131
+ backgroundFill: 'primarySoft',
126
132
  border: 'primary',
127
133
  borderWidth: 'large',
128
- textTone: 'primary',
134
+ textTone: 'neutral',
129
135
  backgroundHover: 'none',
130
136
  borderHover: 'primaryHover',
131
137
  textToneHover: 'primaryHover',
@@ -181,6 +187,16 @@ var variants = {
181
187
  backgroundActive: 'none',
182
188
  borderActive: 'primaryActive',
183
189
  textToneActive: 'primaryActive'
190
+ }, lowDisabledAltStyles),
191
+ dark: _objectSpread({
192
+ background: 'surface',
193
+ backgroundHover: 'none',
194
+ backgroundActive: 'none',
195
+ textTone: 'dark',
196
+ borderWidth: 'large',
197
+ border: 'dark',
198
+ borderHover: 'darkHover',
199
+ borderActive: 'darkActive'
184
200
  }, lowDisabledAltStyles)
185
201
  },
186
202
  none: {
@@ -231,6 +247,12 @@ var variants = {
231
247
  textTone: 'primaryActive',
232
248
  backgroundHover: 'primaryLowHover',
233
249
  backgroundActive: 'primaryLowActive'
250
+ }, noneDisabledStyles),
251
+ dark: _objectSpread({
252
+ background: 'surface',
253
+ textTone: 'dark',
254
+ backgroundHover: 'darkLowHover',
255
+ backgroundActive: 'darkLowActive'
234
256
  }, noneDisabledStyles)
235
257
  }
236
258
  };
@@ -313,13 +335,15 @@ function HiddenWhenLoading(_ref2) {
313
335
  * passed to Emotion's `css` function.
314
336
  */
315
337
  function useButtonStyles(_ref) {
316
- var _theme$components$but, _theme$components, _theme$components2;
338
+ var _variant$backgroundFi, _theme$components$but, _theme$components, _theme$components2;
317
339
  var iconOnly = _ref.iconOnly,
318
340
  prominence = _ref.prominence,
319
341
  _ref$rounded = _ref.rounded,
320
342
  rounded = _ref$rounded === void 0 ? false : _ref$rounded,
321
343
  size = _ref.size,
322
- tone = _ref.tone;
344
+ tone = _ref.tone,
345
+ _ref$filled = _ref.filled,
346
+ filled = _ref$filled === void 0 ? false : _ref$filled;
323
347
  var theme = useTheme();
324
348
  var focusRingStyles = useFocusRing({
325
349
  tone: tone,
@@ -337,7 +361,7 @@ function useButtonStyles(_ref) {
337
361
  };
338
362
  return [{
339
363
  alignItems: 'center',
340
- background: variant === null || variant === void 0 ? void 0 : variant.background,
364
+ background: filled ? (_variant$backgroundFi = variant === null || variant === void 0 ? void 0 : variant.backgroundFill) !== null && _variant$backgroundFi !== void 0 ? _variant$backgroundFi : variant === null || variant === void 0 ? void 0 : variant.background : variant === null || variant === void 0 ? void 0 : variant.background,
341
365
  border: variant === null || variant === void 0 ? void 0 : variant.border,
342
366
  borderWidth: variant === null || variant === void 0 ? void 0 : variant.borderWidth,
343
367
  borderRadius: rounded ? 'full' : isLarge ? 'medium' : 'small',
@@ -390,7 +414,7 @@ function useButtonStyles(_ref) {
390
414
  }];
391
415
  }
392
416
 
393
- var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type"];
417
+ var _excluded$1 = ["aria-controls", "aria-describedby", "aria-expanded", "aria-label", "data", "disabled", "id", "loading", "onClick", "css", "rounded", "prominence", "size", "tone", "type", "filled"];
394
418
  /**
395
419
  * Buttons are used to initialize an action, their label should express what
396
420
  * action will occur when the user interacts with it.
@@ -416,6 +440,8 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
416
440
  _ref$tone = _ref.tone,
417
441
  tone = _ref$tone === void 0 ? 'primary' : _ref$tone,
418
442
  type = _ref.type,
443
+ _ref$filled = _ref.filled,
444
+ filled = _ref$filled === void 0 ? false : _ref$filled,
419
445
  props = _objectWithoutProperties(_ref, _excluded$1);
420
446
  var iconOnly = Boolean(props.label);
421
447
  var _useButtonStyles = useButtonStyles({
@@ -423,7 +449,8 @@ var Button = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
423
449
  rounded: rounded,
424
450
  size: size,
425
451
  tone: tone,
426
- prominence: prominence
452
+ prominence: prominence,
453
+ filled: filled
427
454
  }),
428
455
  _useButtonStyles2 = _slicedToArray(_useButtonStyles, 3),
429
456
  boxProps = _useButtonStyles2[0],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spark-web/button",
3
- "version": "5.3.3",
3
+ "version": "5.5.0",
4
4
  "homepage": "https://github.com/brighte-labs/spark-web#readme",
5
5
  "repository": {
6
6
  "type": "git",
@@ -17,13 +17,13 @@
17
17
  "dependencies": {
18
18
  "@babel/runtime": "^7.25.0",
19
19
  "@emotion/react": "^11.14.0",
20
- "@spark-web/a11y": "^5.1.0",
20
+ "@spark-web/a11y": "^5.2.0",
21
21
  "@spark-web/box": "^5.0.0",
22
22
  "@spark-web/icon": "^5.0.0",
23
23
  "@spark-web/link": "^5.0.0",
24
24
  "@spark-web/spinner": "^5.0.1",
25
25
  "@spark-web/text": "^5.1.0",
26
- "@spark-web/theme": "^5.9.0",
26
+ "@spark-web/theme": "^5.11.1",
27
27
  "@spark-web/utils": "^5.0.0"
28
28
  },
29
29
  "devDependencies": {