@hyphen/hyphen-components 2.16.3 → 2.18.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/dist/components/Button/Button.d.ts +5 -1
- package/dist/components/Button/Button.stories.d.ts +1 -0
- package/dist/css/utilities.css +19 -1
- package/dist/css/variables.css +5 -2
- package/dist/hyphen-components.cjs.development.js +10 -20
- package/dist/hyphen-components.cjs.development.js.map +1 -1
- package/dist/hyphen-components.cjs.production.min.js +1 -1
- package/dist/hyphen-components.cjs.production.min.js.map +1 -1
- package/dist/hyphen-components.esm.js +10 -20
- package/dist/hyphen-components.esm.js.map +1 -1
- package/dist/lib/tokens.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Button/Button.mdx +7 -0
- package/src/components/Button/Button.stories.tsx +19 -3
- package/src/components/Button/Button.test.tsx +241 -293
- package/src/components/Button/Button.tsx +13 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IconName, ResponsiveProp } from '../../types';
|
|
1
|
+
import { BoxShadowSize, IconName, ResponsiveProp } from '../../types';
|
|
2
2
|
import React, { AnchorHTMLAttributes, ButtonHTMLAttributes, FocusEvent, MouseEvent, ReactNode } from 'react';
|
|
3
3
|
export type ButtonVariant = 'primary' | 'secondary' | 'tertiary' | 'danger';
|
|
4
4
|
export type ButtonSize = 'sm' | 'md' | 'lg';
|
|
@@ -56,6 +56,10 @@ export interface BaseButtonProps {
|
|
|
56
56
|
* Callback when Button receives focus.
|
|
57
57
|
*/
|
|
58
58
|
onFocus?: (event: FocusEvent<HTMLButtonElement | HTMLAnchorElement>) => void;
|
|
59
|
+
/**
|
|
60
|
+
* The size of the drop shadow applied to the Box
|
|
61
|
+
*/
|
|
62
|
+
shadow?: BoxShadowSize | ResponsiveProp<BoxShadowSize>;
|
|
59
63
|
/**
|
|
60
64
|
* Specify the tabIndex of the button.
|
|
61
65
|
*/
|
|
@@ -11,4 +11,5 @@ export declare const Icons: () => React.JSX.Element;
|
|
|
11
11
|
export declare const IconButton: () => React.JSX.Element;
|
|
12
12
|
export declare const Loading: () => React.JSX.Element;
|
|
13
13
|
export declare const Disabled: () => React.JSX.Element;
|
|
14
|
+
export declare const Shadow: () => React.JSX.Element;
|
|
14
15
|
export declare const Anchor: () => React.JSX.Element;
|
package/dist/css/utilities.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
\***************************************************************************************************************************/
|
|
4
4
|
/**
|
|
5
5
|
* Do not edit directly
|
|
6
|
-
* Generated on
|
|
6
|
+
* Generated on Fri, 11 Oct 2024 15:47:07 GMT
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
.font-family-monospace { font-family: var(--assets-font-family-monospace); }
|
|
@@ -168,18 +168,36 @@
|
|
|
168
168
|
|
|
169
169
|
.focus\:background-color-brand-gradient:focus { background: var(--color-background-brand-gradient); }
|
|
170
170
|
|
|
171
|
+
.background-color-brand-gradient-reverse { background: var(--color-background-brand-gradient-reverse); }
|
|
172
|
+
|
|
173
|
+
.hover\:background-color-brand-gradient-reverse:hover { background: var(--color-background-brand-gradient-reverse); }
|
|
174
|
+
|
|
175
|
+
.focus\:background-color-brand-gradient-reverse:focus { background: var(--color-background-brand-gradient-reverse); }
|
|
176
|
+
|
|
171
177
|
.background-color-brand-gradient-purple { background: var(--color-background-brand-gradient-purple); }
|
|
172
178
|
|
|
173
179
|
.hover\:background-color-brand-gradient-purple:hover { background: var(--color-background-brand-gradient-purple); }
|
|
174
180
|
|
|
175
181
|
.focus\:background-color-brand-gradient-purple:focus { background: var(--color-background-brand-gradient-purple); }
|
|
176
182
|
|
|
183
|
+
.background-color-brand-gradient-purple-reverse { background: var(--color-background-brand-gradient-purple-reverse); }
|
|
184
|
+
|
|
185
|
+
.hover\:background-color-brand-gradient-purple-reverse:hover { background: var(--color-background-brand-gradient-purple-reverse); }
|
|
186
|
+
|
|
187
|
+
.focus\:background-color-brand-gradient-purple-reverse:focus { background: var(--color-background-brand-gradient-purple-reverse); }
|
|
188
|
+
|
|
177
189
|
.background-color-brand-gradient-cyan { background: var(--color-background-brand-gradient-cyan); }
|
|
178
190
|
|
|
179
191
|
.hover\:background-color-brand-gradient-cyan:hover { background: var(--color-background-brand-gradient-cyan); }
|
|
180
192
|
|
|
181
193
|
.focus\:background-color-brand-gradient-cyan:focus { background: var(--color-background-brand-gradient-cyan); }
|
|
182
194
|
|
|
195
|
+
.background-color-brand-gradient-cyan-reverse { background: var(--color-background-brand-gradient-cyan-reverse); }
|
|
196
|
+
|
|
197
|
+
.hover\:background-color-brand-gradient-cyan-reverse:hover { background: var(--color-background-brand-gradient-cyan-reverse); }
|
|
198
|
+
|
|
199
|
+
.focus\:background-color-brand-gradient-cyan-reverse:focus { background: var(--color-background-brand-gradient-cyan-reverse); }
|
|
200
|
+
|
|
183
201
|
.background-color-brand-yellow { background: var(--color-background-brand-yellow); }
|
|
184
202
|
|
|
185
203
|
.hover\:background-color-brand-yellow:hover { background: var(--color-background-brand-yellow); }
|
package/dist/css/variables.css
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
\*********************************************************************************************************************/
|
|
4
4
|
/**
|
|
5
5
|
* Do not edit directly
|
|
6
|
-
* Generated on
|
|
6
|
+
* Generated on Fri, 11 Oct 2024 15:47:07 GMT
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
:root {
|
|
@@ -36,8 +36,11 @@
|
|
|
36
36
|
--color-background-toast: #262626;
|
|
37
37
|
--color-background-toast-error: #ef4444;
|
|
38
38
|
--color-background-brand-gradient: linear-gradient(60deg, #eab308 0%, #fa0a64 100%);
|
|
39
|
+
--color-background-brand-gradient-reverse: linear-gradient(270deg, #eab308 0%, #fa0a64 100%);
|
|
39
40
|
--color-background-brand-gradient-purple: linear-gradient(60deg, #b47dff 0%, #4b32aa 100%);
|
|
41
|
+
--color-background-brand-gradient-purple-reverse: linear-gradient(270deg, #b47dff 0%, #4b32aa 100%);
|
|
40
42
|
--color-background-brand-gradient-cyan: linear-gradient(60deg, #00b4ff 0%, #dc50ff 100%);
|
|
43
|
+
--color-background-brand-gradient-cyan-reverse: linear-gradient(270deg, #00b4ff 0%, #dc50ff 100%);
|
|
41
44
|
--color-background-brand-yellow: #ffd200;
|
|
42
45
|
--color-background-brand-orange: #ff911e;
|
|
43
46
|
--color-background-brand-magenta: #ff3278;
|
|
@@ -308,7 +311,7 @@
|
|
|
308
311
|
\*******************************************************************************************************************************/
|
|
309
312
|
/**
|
|
310
313
|
* Do not edit directly
|
|
311
|
-
* Generated on
|
|
314
|
+
* Generated on Fri, 11 Oct 2024 15:47:07 GMT
|
|
312
315
|
*/
|
|
313
316
|
|
|
314
317
|
:root.dark {
|
|
@@ -754,9 +754,9 @@ var handleReactRouterClick = function handleReactRouterClick(event, onClick, tar
|
|
|
754
754
|
|
|
755
755
|
var styles$s = {"button":"Button-module_button__18Bed","size-sm":"Button-module_size-sm__6Xrjw","size-md":"Button-module_size-md__BkuGu","size-lg":"Button-module_size-lg__JVYWV","primary":"Button-module_primary__st6yY","secondary":"Button-module_secondary__j-3rj","tertiary":"Button-module_tertiary__Nd7xM","danger":"Button-module_danger__Hxs5n","size-sm-tablet":"Button-module_size-sm-tablet__9XaSx","size-md-tablet":"Button-module_size-md-tablet__YQxaI","size-lg-tablet":"Button-module_size-lg-tablet__h3l97","size-sm-desktop":"Button-module_size-sm-desktop__8tTsg","size-md-desktop":"Button-module_size-md-desktop__OCdDi","size-lg-desktop":"Button-module_size-lg-desktop__uFc4f","size-sm-hd":"Button-module_size-sm-hd__INFfD","size-md-hd":"Button-module_size-md-hd__8e2mW","size-lg-hd":"Button-module_size-lg-hd__DH60l","loading":"Button-module_loading__QfItr","label":"Button-module_label__1PsXG","full-width":"Button-module_full-width__qDri6","spinner-wrapper":"Button-module_spinner-wrapper__rALNw"};
|
|
756
756
|
|
|
757
|
-
var _excluded$F = ["children", "as", "className", "fullWidth", "id", "href", "iconPrefix", "iconSuffix", "isDisabled", "isLoading", "navigate", "onClick", "onFocus", "onBlur", "
|
|
757
|
+
var _excluded$F = ["children", "as", "className", "fullWidth", "id", "href", "iconPrefix", "iconSuffix", "isDisabled", "isLoading", "navigate", "onClick", "onFocus", "onBlur", "shadow", "size", "tabIndex", "target", "type", "variant"];
|
|
758
758
|
var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
759
|
-
var _classNames;
|
|
759
|
+
var _classNames, _extends2;
|
|
760
760
|
var _ref$children = _ref.children,
|
|
761
761
|
children = _ref$children === void 0 ? undefined : _ref$children,
|
|
762
762
|
_ref$as = _ref.as,
|
|
@@ -785,14 +785,16 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
785
785
|
onFocus = _ref$onFocus === void 0 ? undefined : _ref$onFocus,
|
|
786
786
|
_ref$onBlur = _ref.onBlur,
|
|
787
787
|
onBlur = _ref$onBlur === void 0 ? undefined : _ref$onBlur,
|
|
788
|
+
_ref$shadow = _ref.shadow,
|
|
789
|
+
shadow = _ref$shadow === void 0 ? undefined : _ref$shadow,
|
|
790
|
+
_ref$size = _ref.size,
|
|
791
|
+
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
788
792
|
_ref$tabIndex = _ref.tabIndex,
|
|
789
793
|
tabIndex = _ref$tabIndex === void 0 ? undefined : _ref$tabIndex,
|
|
790
794
|
_ref$target = _ref.target,
|
|
791
795
|
target = _ref$target === void 0 ? undefined : _ref$target,
|
|
792
796
|
_ref$type = _ref.type,
|
|
793
797
|
type = _ref$type === void 0 ? undefined : _ref$type,
|
|
794
|
-
_ref$size = _ref.size,
|
|
795
|
-
size = _ref$size === void 0 ? 'md' : _ref$size,
|
|
796
798
|
_ref$variant = _ref.variant,
|
|
797
799
|
variant = _ref$variant === void 0 ? 'primary' : _ref$variant,
|
|
798
800
|
restProps = _objectWithoutPropertiesLoose(_ref, _excluded$F);
|
|
@@ -800,7 +802,7 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
800
802
|
var responsiveClasses = generateResponsiveClasses('size', size).map(function (c) {
|
|
801
803
|
return styles$s[c];
|
|
802
804
|
});
|
|
803
|
-
var buttonClasses = classNames('hyphen-components__variables__form-control', styles$s.button, className, responsiveClasses, (_classNames = {}, _classNames[styles$s.loading] = isLoading, _classNames[styles$s[variant]] = variant, _classNames[styles$s['full-width']] = fullWidth, _classNames));
|
|
805
|
+
var buttonClasses = classNames('hyphen-components__variables__form-control', styles$s.button, className, responsiveClasses, generateResponsiveClasses('shadow', shadow), (_classNames = {}, _classNames[styles$s.loading] = isLoading, _classNames[styles$s[variant]] = variant, _classNames[styles$s['full-width']] = fullWidth, _classNames));
|
|
804
806
|
var handleClick = handleReactRouterClick;
|
|
805
807
|
var handleFocus = function handleFocus(event) {
|
|
806
808
|
if (onFocus) onFocus(event);
|
|
@@ -844,21 +846,9 @@ var Button = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
|
844
846
|
var buttonElement = getElementType(Button, {
|
|
845
847
|
as: as
|
|
846
848
|
});
|
|
847
|
-
return React.createElement(buttonElement, _extends({
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
className: buttonClasses,
|
|
851
|
-
disabled: disabled,
|
|
852
|
-
target: as === 'a' && href ? target : null,
|
|
853
|
-
onBlur: handleBlur,
|
|
854
|
-
onClick: function onClick(event) {
|
|
855
|
-
return handleClick(event, _onClick, target, navigate);
|
|
856
|
-
},
|
|
857
|
-
onFocus: handleFocus,
|
|
858
|
-
ref: ref,
|
|
859
|
-
type: type || (as !== 'a' && !href ? 'button' : undefined),
|
|
860
|
-
tabIndex: tabIndex
|
|
861
|
-
}, restProps), buttonContent);
|
|
849
|
+
return React.createElement(buttonElement, _extends((_extends2 = {}, _extends2['aria-disabled'] = disabled, _extends2.id = id, _extends2.href = href, _extends2.className = buttonClasses, _extends2.disabled = disabled, _extends2.target = as === 'a' && href ? target : null, _extends2.rel = as === 'a' && href && target === '_blank' ? 'noopener noreferrer' : null, _extends2.onBlur = handleBlur, _extends2.onClick = function onClick(event) {
|
|
850
|
+
return handleClick(event, _onClick, target, navigate);
|
|
851
|
+
}, _extends2.onFocus = handleFocus, _extends2.ref = ref, _extends2.type = type || (as !== 'a' && !href ? 'button' : undefined), _extends2.tabIndex = tabIndex, _extends2), restProps), buttonContent);
|
|
862
852
|
});
|
|
863
853
|
|
|
864
854
|
var _excluded$E = ["background", "borderColor", "borderWidth", "children", "display", "padding"];
|