@flodesk/grain 5.4.1 → 5.4.2
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 +15 -5
- package/es/types.js +2 -1
- package/package.json +1 -1
package/es/components/button.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "core-js/modules/es.array.slice.js";
|
|
2
2
|
import "core-js/modules/es.object.freeze.js";
|
|
3
3
|
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
4
5
|
import "core-js/modules/es.array.index-of.js";
|
|
5
6
|
import "core-js/modules/es.symbol.js";
|
|
6
7
|
var _excluded = ["children", "variant", "isDisabled", "icon", "hasFullWidth", "hasSpinner"];
|
|
@@ -8,7 +9,6 @@ var _excluded = ["children", "variant", "isDisabled", "icon", "hasFullWidth", "h
|
|
|
8
9
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
9
10
|
|
|
10
11
|
import "core-js/modules/es.object.assign.js";
|
|
11
|
-
import "core-js/modules/es.object.keys.js";
|
|
12
12
|
|
|
13
13
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
14
14
|
|
|
@@ -24,16 +24,25 @@ import PropTypes from 'prop-types';
|
|
|
24
24
|
import { css } from '@emotion/react';
|
|
25
25
|
import { transitions } from '../foundational';
|
|
26
26
|
import { Spinner } from './spinner';
|
|
27
|
-
var
|
|
27
|
+
var accentCss = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: white;\n background-color: ", ";\n border-color: transparent;\n\n &:hover {\n background-color: ", ";\n }\n &:active {\n background-color: ", ";\n }\n"])), getColor('accent'), getColor('grey7'), getColor('grey6'));
|
|
28
|
+
var variables = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n --grn-paddingX-m: 16px;\n --grn-borderColor: var(--grn-color-fade4);\n --grn-borderColor-hover: var(--grn-color-fade6);\n --grn-borderColor-active: var(--grn-color-grey8);\n"])));
|
|
28
29
|
var variants = {
|
|
29
|
-
neutral: css(
|
|
30
|
-
primary:
|
|
30
|
+
neutral: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: inherit;\n background-color: transparent;\n border-color: var(--grn-borderColor);\n\n &:hover {\n border-color: var(--grn-borderColor-hover);\n }\n &:active {\n border-color: var(--grn-borderColor-active);\n }\n "]))),
|
|
31
|
+
primary: accentCss,
|
|
32
|
+
accent: accentCss
|
|
31
33
|
};
|
|
32
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) {
|
|
33
35
|
return !p.isDisabled && variants[p.variant];
|
|
34
36
|
}, function (p) {
|
|
35
37
|
return p.hasFullWidth && "width: 100%";
|
|
36
38
|
}, getColor('disabledContent'), getColor('disabledBackground'));
|
|
39
|
+
|
|
40
|
+
var checkDeprecatedVariant = function checkDeprecatedVariant(variant) {
|
|
41
|
+
if (variant === 'primary') {
|
|
42
|
+
console.warn('Grain: The variant `primary` name has changed, use `accent` instead.');
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
37
46
|
export var Button = function Button(_ref) {
|
|
38
47
|
var children = _ref.children,
|
|
39
48
|
_ref$variant = _ref.variant,
|
|
@@ -44,6 +53,7 @@ export var Button = function Button(_ref) {
|
|
|
44
53
|
hasSpinner = _ref.hasSpinner,
|
|
45
54
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
46
55
|
|
|
56
|
+
checkDeprecatedVariant(variant);
|
|
47
57
|
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
48
58
|
variant: variant,
|
|
49
59
|
disabled: isDisabled,
|
|
@@ -60,7 +70,7 @@ export var Button = function Button(_ref) {
|
|
|
60
70
|
Button.propTypes = {
|
|
61
71
|
children: PropTypes.node,
|
|
62
72
|
icon: PropTypes.node,
|
|
63
|
-
variant: PropTypes.oneOf(
|
|
73
|
+
variant: PropTypes.oneOf(['neutral', 'accent']),
|
|
64
74
|
onClick: PropTypes.func,
|
|
65
75
|
isDisabled: PropTypes.bool,
|
|
66
76
|
hasFullWidth: PropTypes.bool,
|
package/es/types.js
CHANGED
|
@@ -24,5 +24,6 @@ export var types = {
|
|
|
24
24
|
autoFlow: PropTypes.oneOf(autoFlows),
|
|
25
25
|
gridItemsAlignment: PropTypes.oneOf(gridItemsAlignments),
|
|
26
26
|
gridContentPosition: PropTypes.oneOf(gridContentPositions),
|
|
27
|
-
icon: PropTypes.node
|
|
27
|
+
icon: PropTypes.node,
|
|
28
|
+
zIndex: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
|
|
28
29
|
};
|