@flodesk/grain 2.20.0 → 2.20.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/es/components/arrange.js +33 -260
- package/es/components/box.js +62 -995
- package/es/components/button.js +36 -100
- package/es/components/icon-button.js +30 -93
- package/es/components/icon-toggle.js +39 -94
- package/es/components/icon.js +30 -126
- package/es/components/index.js +11 -107
- package/es/components/stack.js +26 -81
- package/es/components/text-button.js +28 -66
- package/es/components/text-input.js +76 -138
- package/es/components/text-toggle.js +32 -78
- package/es/components/text.js +33 -159
- package/es/foundational/index.js +9 -23
- package/es/hooks/index.js +1 -15
- package/es/hooks/useMedia.js +21 -17
- package/es/icons/icon-align-center.js +5 -43
- package/es/icons/icon-align-left.js +6 -44
- package/es/icons/icon-align-right.js +6 -44
- package/es/icons/icon-arrow-down.js +5 -43
- package/es/icons/icon-arrow-left.js +5 -43
- package/es/icons/icon-arrow-right.js +5 -43
- package/es/icons/icon-arrow-up.js +5 -43
- package/es/icons/icon-browser.js +9 -47
- package/es/icons/icon-chart.js +5 -43
- package/es/icons/icon-check.js +7 -45
- package/es/icons/icon-chevron-down.js +5 -43
- package/es/icons/icon-chevron-horizontal.js +5 -43
- package/es/icons/icon-chevron-left.js +5 -43
- package/es/icons/icon-chevron-right.js +10 -48
- package/es/icons/icon-chevron-up.js +10 -48
- package/es/icons/icon-chevron-vertical.js +13 -51
- package/es/icons/icon-clip.js +5 -43
- package/es/icons/icon-clock.js +6 -44
- package/es/icons/icon-crop.js +5 -43
- package/es/icons/icon-cross.js +5 -43
- package/es/icons/icon-download.js +8 -46
- package/es/icons/icon-duplicate.js +6 -44
- package/es/icons/icon-ellipsis.js +7 -45
- package/es/icons/icon-file.js +5 -43
- package/es/icons/icon-folder-add.js +5 -43
- package/es/icons/icon-folder.js +5 -43
- package/es/icons/icon-gear.js +6 -44
- package/es/icons/icon-globe.js +5 -43
- package/es/icons/icon-heart.js +5 -43
- package/es/icons/icon-image.js +5 -43
- package/es/icons/icon-link.js +6 -44
- package/es/icons/icon-mail.js +5 -43
- package/es/icons/icon-minus.js +5 -43
- package/es/icons/icon-monitor.js +5 -43
- package/es/icons/icon-pencil.js +5 -43
- package/es/icons/icon-phone.js +5 -43
- package/es/icons/icon-plus.js +5 -43
- package/es/icons/icon-redo.js +5 -43
- package/es/icons/icon-search.js +6 -44
- package/es/icons/icon-send.js +5 -43
- package/es/icons/icon-share.js +5 -43
- package/es/icons/icon-smile.js +8 -46
- package/es/icons/icon-switch.js +5 -43
- package/es/icons/icon-tablet.js +5 -43
- package/es/icons/icon-text-align-center.js +5 -43
- package/es/icons/icon-text-align-left.js +5 -43
- package/es/icons/icon-text-align-right.js +5 -43
- package/es/icons/icon-trash.js +5 -43
- package/es/icons/icon-type.js +5 -43
- package/es/icons/icon-undo.js +5 -43
- package/es/icons/icon-upload.js +8 -46
- package/es/icons/index.js +51 -417
- package/es/index.js +3 -52
- package/es/types.js +23 -38
- package/es/utilities/helpers.js +22 -50
- package/es/utilities/index.js +22 -145
- package/es/utilities/responsive.js +59 -79
- package/es/utilities/styles.js +45 -89
- package/es/variables.js +14 -26
- package/package.json +2 -2
package/es/components/button.js
CHANGED
|
@@ -1,126 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.Button = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _utilities = require("../utilities");
|
|
19
|
-
|
|
20
|
-
var _components = require("../components");
|
|
21
|
-
|
|
22
|
-
var _react = _interopRequireDefault(require("react"));
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.array.index-of.js";
|
|
5
|
+
import "core-js/modules/es.symbol.js";
|
|
6
|
+
var _excluded = ["children", "variant", "isDisabled", "icon", "hasFullWidth"];
|
|
23
7
|
|
|
24
|
-
var
|
|
8
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
25
9
|
|
|
26
|
-
|
|
10
|
+
import "core-js/modules/es.object.assign.js";
|
|
11
|
+
import "core-js/modules/es.object.keys.js";
|
|
27
12
|
|
|
28
|
-
var
|
|
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; }
|
|
29
14
|
|
|
30
|
-
var
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
16
|
|
|
32
|
-
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
33
18
|
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
import { getColor, getRadius, getWeight } from '../utilities';
|
|
20
|
+
import { Icon } from '../components';
|
|
21
|
+
import React from "react";
|
|
22
|
+
import styled from "@emotion/styled";
|
|
23
|
+
import PropTypes from "prop-types";
|
|
24
|
+
import { css } from '@emotion/react';
|
|
25
|
+
import { transitions } from '../foundational';
|
|
26
|
+
var variables = css(_templateObject || (_templateObject = _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"])));
|
|
36
27
|
var variants = {
|
|
37
|
-
neutral:
|
|
38
|
-
primary:
|
|
28
|
+
neutral: css(_templateObject2 || (_templateObject2 = _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 "]))),
|
|
29
|
+
primary: css(_templateObject3 || (_templateObject3 = _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'))
|
|
39
30
|
};
|
|
40
|
-
|
|
41
|
-
var Wrapper = _styled.default.button(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\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, _foundational.transitions, (0, _utilities.getWeight)('medium'), (0, _utilities.getRadius)('s'), function (p) {
|
|
31
|
+
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) {
|
|
42
32
|
return !p.isDisabled && variants[p.variant];
|
|
43
33
|
}, function (p) {
|
|
44
34
|
return p.hasFullWidth && "width: 100%";
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
var Button = function Button(_ref) {
|
|
35
|
+
}, getColor('disabledContent'), getColor('disabledBackground'));
|
|
36
|
+
export var Button = function Button(_ref) {
|
|
48
37
|
var children = _ref.children,
|
|
49
38
|
_ref$variant = _ref.variant,
|
|
50
39
|
variant = _ref$variant === void 0 ? 'neutral' : _ref$variant,
|
|
51
40
|
isDisabled = _ref.isDisabled,
|
|
52
41
|
icon = _ref.icon,
|
|
53
42
|
hasFullWidth = _ref.hasFullWidth,
|
|
54
|
-
props = (
|
|
55
|
-
|
|
43
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
|
+
|
|
45
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
56
46
|
variant: variant,
|
|
57
47
|
disabled: isDisabled,
|
|
58
48
|
icon: icon,
|
|
59
49
|
hasFullWidth: hasFullWidth
|
|
60
|
-
}, props), icon &&
|
|
50
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
61
51
|
icon: icon,
|
|
62
52
|
color: "currentColor"
|
|
63
53
|
}), children);
|
|
64
54
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
"variant": {
|
|
73
|
-
"defaultValue": {
|
|
74
|
-
"value": "'neutral'",
|
|
75
|
-
"computed": false
|
|
76
|
-
},
|
|
77
|
-
"type": {
|
|
78
|
-
"name": "enum",
|
|
79
|
-
"value": [{
|
|
80
|
-
"value": "\"neutral\"",
|
|
81
|
-
"computed": false
|
|
82
|
-
}, {
|
|
83
|
-
"value": "\"primary\"",
|
|
84
|
-
"computed": false
|
|
85
|
-
}]
|
|
86
|
-
},
|
|
87
|
-
"required": false,
|
|
88
|
-
"description": ""
|
|
89
|
-
},
|
|
90
|
-
"children": {
|
|
91
|
-
"type": {
|
|
92
|
-
"name": "node"
|
|
93
|
-
},
|
|
94
|
-
"required": false,
|
|
95
|
-
"description": ""
|
|
96
|
-
},
|
|
97
|
-
"icon": {
|
|
98
|
-
"type": {
|
|
99
|
-
"name": "node"
|
|
100
|
-
},
|
|
101
|
-
"required": false,
|
|
102
|
-
"description": ""
|
|
103
|
-
},
|
|
104
|
-
"onClick": {
|
|
105
|
-
"type": {
|
|
106
|
-
"name": "func"
|
|
107
|
-
},
|
|
108
|
-
"required": false,
|
|
109
|
-
"description": ""
|
|
110
|
-
},
|
|
111
|
-
"isDisabled": {
|
|
112
|
-
"type": {
|
|
113
|
-
"name": "bool"
|
|
114
|
-
},
|
|
115
|
-
"required": false,
|
|
116
|
-
"description": ""
|
|
117
|
-
},
|
|
118
|
-
"hasFullWidth": {
|
|
119
|
-
"type": {
|
|
120
|
-
"name": "bool"
|
|
121
|
-
},
|
|
122
|
-
"required": false,
|
|
123
|
-
"description": ""
|
|
124
|
-
}
|
|
125
|
-
}
|
|
55
|
+
Button.propTypes = {
|
|
56
|
+
children: PropTypes.node,
|
|
57
|
+
icon: PropTypes.node,
|
|
58
|
+
variant: PropTypes.oneOf(Object.keys(variants)),
|
|
59
|
+
onClick: PropTypes.func,
|
|
60
|
+
isDisabled: PropTypes.bool,
|
|
61
|
+
hasFullWidth: PropTypes.bool
|
|
126
62
|
};
|
|
@@ -1,111 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.IconButton = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _components = require("../components");
|
|
19
|
-
|
|
20
|
-
var _react = _interopRequireDefault(require("react"));
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
var _excluded = ["children", "isDisabled", "icon", "color"];
|
|
21
8
|
|
|
22
|
-
var
|
|
9
|
+
var _templateObject;
|
|
23
10
|
|
|
24
|
-
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
25
12
|
|
|
26
|
-
var
|
|
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; }
|
|
27
14
|
|
|
28
|
-
var
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
31
18
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
import { Icon } from '../components';
|
|
20
|
+
import React from "react";
|
|
21
|
+
import styled from "@emotion/styled";
|
|
22
|
+
import PropTypes from "prop-types";
|
|
23
|
+
import { types } from '../types';
|
|
24
|
+
import { ClearButtonBox } from '../foundational';
|
|
25
|
+
var Wrapper = styled(ClearButtonBox)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: var(--grn-clearButtonHeight-m);\n"])));
|
|
26
|
+
export var IconButton = function IconButton(_ref) {
|
|
36
27
|
var children = _ref.children,
|
|
37
28
|
isDisabled = _ref.isDisabled,
|
|
38
29
|
icon = _ref.icon,
|
|
39
30
|
color = _ref.color,
|
|
40
|
-
props = (
|
|
41
|
-
|
|
31
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
|
+
|
|
33
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
42
34
|
disabled: isDisabled,
|
|
43
35
|
icon: icon,
|
|
44
36
|
color: color
|
|
45
|
-
}, props), icon &&
|
|
37
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
46
38
|
icon: icon,
|
|
47
39
|
color: isDisabled ? 'currentColor' : color
|
|
48
40
|
}), children && children);
|
|
49
41
|
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"props": {
|
|
57
|
-
"children": {
|
|
58
|
-
"type": {
|
|
59
|
-
"name": "node"
|
|
60
|
-
},
|
|
61
|
-
"required": false,
|
|
62
|
-
"description": ""
|
|
63
|
-
},
|
|
64
|
-
"icon": {
|
|
65
|
-
"type": {
|
|
66
|
-
"name": "node"
|
|
67
|
-
},
|
|
68
|
-
"required": false,
|
|
69
|
-
"description": ""
|
|
70
|
-
},
|
|
71
|
-
"onClick": {
|
|
72
|
-
"type": {
|
|
73
|
-
"name": "func"
|
|
74
|
-
},
|
|
75
|
-
"required": false,
|
|
76
|
-
"description": ""
|
|
77
|
-
},
|
|
78
|
-
"isDisabled": {
|
|
79
|
-
"type": {
|
|
80
|
-
"name": "bool"
|
|
81
|
-
},
|
|
82
|
-
"required": false,
|
|
83
|
-
"description": ""
|
|
84
|
-
},
|
|
85
|
-
"color": {
|
|
86
|
-
"type": {
|
|
87
|
-
"name": "union",
|
|
88
|
-
"value": [{
|
|
89
|
-
"name": "enum",
|
|
90
|
-
"value": [{
|
|
91
|
-
"value": "\"greys\"",
|
|
92
|
-
"computed": false
|
|
93
|
-
}, {
|
|
94
|
-
"value": "\"fades\"",
|
|
95
|
-
"computed": false
|
|
96
|
-
}, {
|
|
97
|
-
"value": "\"baseColors\"",
|
|
98
|
-
"computed": false
|
|
99
|
-
}, {
|
|
100
|
-
"value": "\"semanticColors\"",
|
|
101
|
-
"computed": false
|
|
102
|
-
}]
|
|
103
|
-
}, {
|
|
104
|
-
"name": "string"
|
|
105
|
-
}]
|
|
106
|
-
},
|
|
107
|
-
"required": false,
|
|
108
|
-
"description": ""
|
|
109
|
-
}
|
|
110
|
-
}
|
|
42
|
+
IconButton.propTypes = {
|
|
43
|
+
children: PropTypes.node,
|
|
44
|
+
icon: PropTypes.node,
|
|
45
|
+
onClick: PropTypes.func,
|
|
46
|
+
isDisabled: PropTypes.bool,
|
|
47
|
+
color: types.color
|
|
111
48
|
};
|
|
@@ -1,119 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.IconToggleGroup = exports.IconToggle = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _utilities = require("../utilities");
|
|
19
|
-
|
|
20
|
-
var _ = require(".");
|
|
21
|
-
|
|
22
|
-
var _react = _interopRequireDefault(require("react"));
|
|
23
|
-
|
|
24
|
-
var _styled = _interopRequireDefault(require("@emotion/styled"));
|
|
25
|
-
|
|
26
|
-
var _react2 = require("@emotion/react");
|
|
27
|
-
|
|
28
|
-
var _types = require("../types");
|
|
29
|
-
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
30
7
|
var _excluded = ["children", "icon", "isActive", "onClick"],
|
|
31
8
|
_excluded2 = ["children"];
|
|
32
9
|
|
|
33
10
|
var _templateObject, _templateObject2, _templateObject3;
|
|
34
11
|
|
|
35
|
-
|
|
36
|
-
var variables = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n --grn-borderColor-hover: var(--grn-color-fade4);\n --grn-borderColor-active: var(--grn-color-grey8);\n --grn-width: calc(var(--grn-textBoxHeight-m) + 2px);\n"])));
|
|
12
|
+
import "core-js/modules/es.object.assign.js";
|
|
37
13
|
|
|
38
|
-
var
|
|
14
|
+
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; }
|
|
39
15
|
|
|
40
|
-
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
|
|
18
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
19
|
+
|
|
20
|
+
import { getTransition, getWeight } from "../utilities";
|
|
21
|
+
import { Icon } from ".";
|
|
22
|
+
import React from "react";
|
|
23
|
+
import styled from "@emotion/styled";
|
|
24
|
+
import PropTypes from "prop-types";
|
|
25
|
+
import { css } from "@emotion/react";
|
|
26
|
+
import { types } from "../types";
|
|
27
|
+
var variables = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n --grn-borderColor-hover: var(--grn-color-fade4);\n --grn-borderColor-active: var(--grn-color-grey8);\n --grn-width: calc(var(--grn-textBoxHeight-m) + 2px);\n"])));
|
|
28
|
+
var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n border: 1px solid var(--grn-color-border);\n border-radius: var(--grn-radius-s);\n width: fit-content;\n"])));
|
|
29
|
+
var ItemWrapper = styled.button(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", ";\n appearance: none;\n border: none;\n border-left: 1px solid transparent;\n padding: 0;\n font-family: inherit;\n font-size: inherit;\n font-weight: ", ";\n cursor: pointer;\n min-width: var(--grn-width);\n height: calc(var(--grn-textBoxHeight-m) - 2px);\n background-color: transparent;\n display: flex;\n align-items: center;\n justify-content: center;\n position: relative;\n color: var(--grn-color-bodyDimmed);\n transition: color ", ";\n\n ", ";\n \n & + .IconToggle {\n border-color: var(--grn-color-border);\n }\n \n &:after {\n content: \"\";\n pointer-events: none;\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n transition: ", ";\n ", ";\n }\n\n &:first-of-type {\n min-width: calc(var(--grn-width) - 1px);\n }\n \n &:first-of-type:after {\n width: calc(100% + 1px);\n left: -1px;\n border-radius: var(--grn-radius-s) 0 0 var(--grn-radius-s);\n }\n \n &:last-child:after {\n border-radius: 0 var(--grn-radius-s) var(--grn-radius-s) 0;\n }\n\n &:hover {\n color: var(--grn-color-body);\n }\n"])), variables, getWeight("medium"), getTransition('fast'), function (p) {
|
|
41
30
|
return p.isActive && "\n color: var(--grn-color-body);\n ";
|
|
42
|
-
},
|
|
31
|
+
}, getTransition('xFast'), function (p) {
|
|
43
32
|
return p.isActive && "box-shadow: 0 0 0 1px var(--grn-color-grey6)";
|
|
44
33
|
});
|
|
45
|
-
|
|
46
|
-
var IconToggle = function IconToggle(_ref) {
|
|
34
|
+
export var IconToggle = function IconToggle(_ref) {
|
|
47
35
|
var children = _ref.children,
|
|
48
36
|
icon = _ref.icon,
|
|
49
37
|
isActive = _ref.isActive,
|
|
50
38
|
onClick = _ref.onClick,
|
|
51
|
-
props = (
|
|
52
|
-
|
|
39
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
40
|
+
|
|
41
|
+
return /*#__PURE__*/React.createElement(ItemWrapper, Object.assign({
|
|
53
42
|
className: "IconToggle",
|
|
54
43
|
isActive: isActive,
|
|
55
44
|
onClick: onClick
|
|
56
|
-
}, props), icon &&
|
|
45
|
+
}, props), icon && /*#__PURE__*/React.createElement(Icon, {
|
|
57
46
|
icon: icon,
|
|
58
47
|
color: "currentColor"
|
|
59
48
|
}), children && children);
|
|
60
49
|
};
|
|
61
|
-
|
|
62
|
-
exports.IconToggle = IconToggle;
|
|
63
|
-
|
|
64
|
-
var IconToggleGroup = function IconToggleGroup(_ref2) {
|
|
50
|
+
export var IconToggleGroup = function IconToggleGroup(_ref2) {
|
|
65
51
|
var children = _ref2.children,
|
|
66
|
-
props = (
|
|
67
|
-
return __jsx(Wrapper, props, children);
|
|
68
|
-
};
|
|
52
|
+
props = _objectWithoutProperties(_ref2, _excluded2);
|
|
69
53
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"displayName": "IconToggle",
|
|
75
|
-
"props": {
|
|
76
|
-
"children": {
|
|
77
|
-
"type": {
|
|
78
|
-
"name": "node"
|
|
79
|
-
},
|
|
80
|
-
"required": false,
|
|
81
|
-
"description": ""
|
|
82
|
-
},
|
|
83
|
-
"icon": {
|
|
84
|
-
"type": {
|
|
85
|
-
"name": "node"
|
|
86
|
-
},
|
|
87
|
-
"required": false,
|
|
88
|
-
"description": ""
|
|
89
|
-
},
|
|
90
|
-
"isActive": {
|
|
91
|
-
"type": {
|
|
92
|
-
"name": "bool"
|
|
93
|
-
},
|
|
94
|
-
"required": false,
|
|
95
|
-
"description": ""
|
|
96
|
-
},
|
|
97
|
-
"onClick": {
|
|
98
|
-
"type": {
|
|
99
|
-
"name": "func"
|
|
100
|
-
},
|
|
101
|
-
"required": false,
|
|
102
|
-
"description": ""
|
|
103
|
-
}
|
|
104
|
-
}
|
|
54
|
+
return /*#__PURE__*/React.createElement(Wrapper, props, children);
|
|
55
|
+
};
|
|
56
|
+
IconToggleGroup.propTypes = {
|
|
57
|
+
children: PropTypes.node
|
|
105
58
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
"children": {
|
|
112
|
-
"type": {
|
|
113
|
-
"name": "node"
|
|
114
|
-
},
|
|
115
|
-
"required": false,
|
|
116
|
-
"description": ""
|
|
117
|
-
}
|
|
118
|
-
}
|
|
59
|
+
IconToggle.propTypes = {
|
|
60
|
+
children: PropTypes.node,
|
|
61
|
+
icon: types.icon,
|
|
62
|
+
isActive: PropTypes.bool,
|
|
63
|
+
onClick: PropTypes.func
|
|
119
64
|
};
|
package/es/components/icon.js
CHANGED
|
@@ -1,150 +1,54 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
exports.Icon = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
15
|
-
|
|
16
|
-
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
17
|
-
|
|
18
|
-
var _utilities = require("../utilities");
|
|
19
|
-
|
|
20
|
-
var _propTypes = require("prop-types");
|
|
21
|
-
|
|
22
|
-
var _react = _interopRequireDefault(require("react"));
|
|
1
|
+
import "core-js/modules/es.array.slice.js";
|
|
2
|
+
import "core-js/modules/es.object.freeze.js";
|
|
3
|
+
import "core-js/modules/es.object.define-properties.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
5
|
+
import "core-js/modules/es.array.index-of.js";
|
|
6
|
+
import "core-js/modules/es.symbol.js";
|
|
7
|
+
var _excluded = ["icon", "size", "color", "hasEvenBoundary"];
|
|
23
8
|
|
|
24
|
-
var
|
|
9
|
+
var _templateObject;
|
|
25
10
|
|
|
26
|
-
|
|
11
|
+
import "core-js/modules/es.object.assign.js";
|
|
27
12
|
|
|
28
|
-
var
|
|
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; }
|
|
29
14
|
|
|
30
|
-
var
|
|
15
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
31
16
|
|
|
32
|
-
|
|
17
|
+
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
33
18
|
|
|
34
|
-
|
|
35
|
-
|
|
19
|
+
import { getColor, getIconSize } from '../utilities';
|
|
20
|
+
import { PropTypes } from 'prop-types';
|
|
21
|
+
import React from "react";
|
|
22
|
+
import styled from "@emotion/styled";
|
|
23
|
+
import { types } from '../types';
|
|
24
|
+
var Wrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: block;\n width: ", ";\n color: ", ";\n \n svg {\n display: block;\n height: ", ";\n ", "\n"])), function (p) {
|
|
25
|
+
return getColor(p.color);
|
|
36
26
|
}, function (p) {
|
|
37
|
-
return
|
|
27
|
+
return getColor(p.color);
|
|
38
28
|
}, function (p) {
|
|
39
|
-
return
|
|
29
|
+
return getIconSize(p.size);
|
|
40
30
|
}, function (p) {
|
|
41
|
-
return p.hasEvenBoundary && "width: ".concat(
|
|
31
|
+
return p.hasEvenBoundary && "width: ".concat(getIconSize(p.size), "}");
|
|
42
32
|
});
|
|
43
|
-
|
|
44
|
-
var Icon = /*#__PURE__*/_react.default.forwardRef(function (_ref, ref) {
|
|
33
|
+
export var Icon = /*#__PURE__*/React.forwardRef(function (_ref, ref) {
|
|
45
34
|
var icon = _ref.icon,
|
|
46
35
|
_ref$size = _ref.size,
|
|
47
36
|
size = _ref$size === void 0 ? 'm' : _ref$size,
|
|
48
37
|
_ref$color = _ref.color,
|
|
49
38
|
color = _ref$color === void 0 ? 'body' : _ref$color,
|
|
50
39
|
hasEvenBoundary = _ref.hasEvenBoundary,
|
|
51
|
-
props = (
|
|
52
|
-
|
|
40
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
+
|
|
42
|
+
return /*#__PURE__*/React.createElement(Wrapper, Object.assign({
|
|
53
43
|
size: size,
|
|
54
44
|
color: color,
|
|
55
45
|
hasEvenBoundary: hasEvenBoundary,
|
|
56
46
|
ref: ref
|
|
57
47
|
}, props), icon && icon);
|
|
58
48
|
});
|
|
59
|
-
|
|
60
|
-
exports.Icon = Icon;
|
|
61
49
|
Icon.propTypes = {
|
|
62
|
-
icon:
|
|
63
|
-
hasEvenBoundary:
|
|
64
|
-
size:
|
|
65
|
-
color:
|
|
66
|
-
};
|
|
67
|
-
Icon.__docgenInfo = {
|
|
68
|
-
"description": "",
|
|
69
|
-
"methods": [],
|
|
70
|
-
"displayName": "Icon",
|
|
71
|
-
"props": {
|
|
72
|
-
"size": {
|
|
73
|
-
"defaultValue": {
|
|
74
|
-
"value": "'m'",
|
|
75
|
-
"computed": false
|
|
76
|
-
},
|
|
77
|
-
"type": {
|
|
78
|
-
"name": "union",
|
|
79
|
-
"value": [{
|
|
80
|
-
"name": "enum",
|
|
81
|
-
"value": [{
|
|
82
|
-
"value": "\"s\"",
|
|
83
|
-
"computed": false
|
|
84
|
-
}, {
|
|
85
|
-
"value": "\"m\"",
|
|
86
|
-
"computed": false
|
|
87
|
-
}, {
|
|
88
|
-
"value": "\"l\"",
|
|
89
|
-
"computed": false
|
|
90
|
-
}, {
|
|
91
|
-
"value": "\"xl\"",
|
|
92
|
-
"computed": false
|
|
93
|
-
}, {
|
|
94
|
-
"value": "\"xxl\"",
|
|
95
|
-
"computed": false
|
|
96
|
-
}]
|
|
97
|
-
}, {
|
|
98
|
-
"name": "number"
|
|
99
|
-
}, {
|
|
100
|
-
"name": "string"
|
|
101
|
-
}]
|
|
102
|
-
},
|
|
103
|
-
"required": false,
|
|
104
|
-
"description": ""
|
|
105
|
-
},
|
|
106
|
-
"color": {
|
|
107
|
-
"defaultValue": {
|
|
108
|
-
"value": "'body'",
|
|
109
|
-
"computed": false
|
|
110
|
-
},
|
|
111
|
-
"type": {
|
|
112
|
-
"name": "union",
|
|
113
|
-
"value": [{
|
|
114
|
-
"name": "enum",
|
|
115
|
-
"value": [{
|
|
116
|
-
"value": "\"greys\"",
|
|
117
|
-
"computed": false
|
|
118
|
-
}, {
|
|
119
|
-
"value": "\"fades\"",
|
|
120
|
-
"computed": false
|
|
121
|
-
}, {
|
|
122
|
-
"value": "\"baseColors\"",
|
|
123
|
-
"computed": false
|
|
124
|
-
}, {
|
|
125
|
-
"value": "\"semanticColors\"",
|
|
126
|
-
"computed": false
|
|
127
|
-
}]
|
|
128
|
-
}, {
|
|
129
|
-
"name": "string"
|
|
130
|
-
}]
|
|
131
|
-
},
|
|
132
|
-
"required": false,
|
|
133
|
-
"description": ""
|
|
134
|
-
},
|
|
135
|
-
"icon": {
|
|
136
|
-
"type": {
|
|
137
|
-
"name": "node"
|
|
138
|
-
},
|
|
139
|
-
"required": false,
|
|
140
|
-
"description": ""
|
|
141
|
-
},
|
|
142
|
-
"hasEvenBoundary": {
|
|
143
|
-
"type": {
|
|
144
|
-
"name": "bool"
|
|
145
|
-
},
|
|
146
|
-
"required": false,
|
|
147
|
-
"description": ""
|
|
148
|
-
}
|
|
149
|
-
}
|
|
50
|
+
icon: PropTypes.node,
|
|
51
|
+
hasEvenBoundary: PropTypes.bool,
|
|
52
|
+
size: types.iconSize,
|
|
53
|
+
color: types.color
|
|
150
54
|
};
|