@flodesk/grain 5.5.3 → 5.6.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/es/components/button.js +11 -4
- package/package.json +1 -1
package/es/components/button.js
CHANGED
|
@@ -4,7 +4,7 @@ import "core-js/modules/es.object.define-properties.js";
|
|
|
4
4
|
import "core-js/modules/es.object.keys.js";
|
|
5
5
|
import "core-js/modules/es.array.index-of.js";
|
|
6
6
|
import "core-js/modules/es.symbol.js";
|
|
7
|
-
var _excluded = ["children", "variant", "isDisabled", "icon", "hasFullWidth", "hasSpinner"];
|
|
7
|
+
var _excluded = ["children", "variant", "isDisabled", "icon", "iconPosition", "hasFullWidth", "hasSpinner"];
|
|
8
8
|
|
|
9
9
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
10
10
|
|
|
@@ -31,11 +31,13 @@ var variants = {
|
|
|
31
31
|
primary: accentCss,
|
|
32
32
|
accent: accentCss
|
|
33
33
|
};
|
|
34
|
-
var Wrapper = styled.button(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n appearance: none;\n border: none;\n font-family: inherit;\n font-size: inherit;\n cursor: pointer;\n border-width: 1px;\n border-style: solid;\n font-weight: ", ";\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-paddingX-m);\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 12px;\n\n ", ";\n ", ";\n\n &:disabled {\n color: ", ";\n background-color: ", ";\n border-color: transparent;\n cursor: default;\n }\n"])), variables, transitions, getWeight('medium'), getRadius('s'), function (p) {
|
|
34
|
+
var Wrapper = styled.button(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", ";\n ", ";\n appearance: none;\n border: none;\n font-family: inherit;\n font-size: inherit;\n cursor: pointer;\n border-width: 1px;\n border-style: solid;\n font-weight: ", ";\n border-radius: ", ";\n height: var(--grn-textBoxHeight-m);\n padding: 0 var(--grn-paddingX-m);\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 12px;\n\n ", ";\n ", ";\n\n &:disabled {\n color: ", ";\n background-color: ", ";\n border-color: transparent;\n cursor: default;\n }\n\n .buttonIcon {\n ", ";\n }\n"])), variables, transitions, getWeight('medium'), getRadius('s'), function (p) {
|
|
35
35
|
return !p.isDisabled && variants[p.variant];
|
|
36
36
|
}, function (p) {
|
|
37
37
|
return p.hasFullWidth && "width: 100%";
|
|
38
|
-
}, getColor('contentDisabled'), getColor('backgroundDisabled'))
|
|
38
|
+
}, getColor('contentDisabled'), getColor('backgroundDisabled'), function (p) {
|
|
39
|
+
return p.iconPosition === 'right' && "order: 1";
|
|
40
|
+
});
|
|
39
41
|
|
|
40
42
|
var checkDeprecatedVariant = function checkDeprecatedVariant(variant) {
|
|
41
43
|
if (variant === 'primary') {
|
|
@@ -49,6 +51,8 @@ export var Button = function Button(_ref) {
|
|
|
49
51
|
variant = _ref$variant === void 0 ? 'neutral' : _ref$variant,
|
|
50
52
|
isDisabled = _ref.isDisabled,
|
|
51
53
|
icon = _ref.icon,
|
|
54
|
+
_ref$iconPosition = _ref.iconPosition,
|
|
55
|
+
iconPosition = _ref$iconPosition === void 0 ? 'left' : _ref$iconPosition,
|
|
52
56
|
hasFullWidth = _ref.hasFullWidth,
|
|
53
57
|
hasSpinner = _ref.hasSpinner,
|
|
54
58
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -58,18 +62,21 @@ export var Button = function Button(_ref) {
|
|
|
58
62
|
variant: variant,
|
|
59
63
|
disabled: isDisabled,
|
|
60
64
|
icon: icon,
|
|
65
|
+
iconPosition: iconPosition,
|
|
61
66
|
hasFullWidth: hasFullWidth,
|
|
62
67
|
hasSpinner: hasSpinner
|
|
63
68
|
}, props), hasSpinner && /*#__PURE__*/React.createElement(Spinner, {
|
|
64
69
|
color: "currentColor"
|
|
65
70
|
}), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
66
71
|
icon: icon,
|
|
67
|
-
color: "currentColor"
|
|
72
|
+
color: "currentColor",
|
|
73
|
+
className: "buttonIcon"
|
|
68
74
|
}), children);
|
|
69
75
|
};
|
|
70
76
|
Button.propTypes = {
|
|
71
77
|
children: PropTypes.node,
|
|
72
78
|
icon: PropTypes.node,
|
|
79
|
+
iconPosition: PropTypes.oneOf(['left', 'right']),
|
|
73
80
|
variant: PropTypes.oneOf(['neutral', 'accent']),
|
|
74
81
|
onClick: PropTypes.func,
|
|
75
82
|
isDisabled: PropTypes.bool,
|