@flodesk/grain 10.9.5 → 10.9.6
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/box2.js +40 -42
- package/es/utilities/attributes.js +27 -23
- package/package.json +1 -1
package/es/components/box2.js
CHANGED
|
@@ -30,22 +30,11 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
|
30
30
|
import React, { forwardRef } from 'react';
|
|
31
31
|
import { types } from '../types';
|
|
32
32
|
import PropTypes from 'prop-types';
|
|
33
|
-
import {
|
|
33
|
+
import { generateStyleAttributes, generateClassNameAttributes } from '../utilities';
|
|
34
34
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
|
35
|
-
var dimensionProps = styleConfig.dimensionProps,
|
|
36
|
-
colorProps = styleConfig.colorProps,
|
|
37
|
-
zIndexProps = styleConfig.zIndexProps,
|
|
38
|
-
aspectRatioProps = styleConfig.aspectRatioProps,
|
|
39
|
-
flexProps = styleConfig.flexProps,
|
|
40
|
-
spaceProps = styleConfig.spaceProps,
|
|
41
|
-
shadowProps = styleConfig.shadowProps,
|
|
42
|
-
radiusProps = styleConfig.radiusProps,
|
|
43
|
-
orderProps = styleConfig.orderProps,
|
|
44
|
-
positionProps = styleConfig.positionProps,
|
|
45
|
-
overflowProps = styleConfig.overflowProps,
|
|
46
|
-
transitionProps = styleConfig.transitionProps,
|
|
47
|
-
cursorProps = styleConfig.cursorProps;
|
|
48
35
|
export var Box2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
36
|
+
var _generateClassNameAtt;
|
|
37
|
+
|
|
49
38
|
var all = _ref.all,
|
|
50
39
|
color = _ref.color,
|
|
51
40
|
colorHover = _ref.colorHover,
|
|
@@ -101,21 +90,44 @@ export var Box2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
101
90
|
style = _ref.style,
|
|
102
91
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
|
103
92
|
|
|
104
|
-
var
|
|
105
|
-
all: all,
|
|
106
|
-
color: color,
|
|
107
|
-
colorHover: colorHover,
|
|
108
|
-
backgroundColor: backgroundColor,
|
|
109
|
-
backgroundColorHover: backgroundColorHover,
|
|
110
|
-
borderColorHover: borderColorHover,
|
|
111
|
-
borderSide: borderSide,
|
|
93
|
+
var styles = _objectSpread({}, generateStyleAttributes({
|
|
112
94
|
width: width,
|
|
113
95
|
minWidth: minWidth,
|
|
114
96
|
maxWidth: maxWidth,
|
|
115
97
|
height: height,
|
|
116
98
|
minHeight: minHeight,
|
|
117
99
|
maxHeight: maxHeight,
|
|
100
|
+
color: color,
|
|
101
|
+
colorHover: colorHover,
|
|
102
|
+
backgroundColor: backgroundColor,
|
|
103
|
+
backgroundColorHover: backgroundColorHover,
|
|
104
|
+
padding: padding,
|
|
105
|
+
paddingTop: paddingTop,
|
|
106
|
+
paddingBottom: paddingBottom,
|
|
107
|
+
paddingLeft: paddingLeft,
|
|
108
|
+
paddingRight: paddingRight,
|
|
109
|
+
paddingX: paddingX,
|
|
110
|
+
paddingY: paddingY,
|
|
111
|
+
margin: margin,
|
|
112
|
+
marginTop: marginTop,
|
|
113
|
+
marginBottom: marginBottom,
|
|
114
|
+
marginLeft: marginLeft,
|
|
115
|
+
marginRight: marginRight,
|
|
116
|
+
marginX: marginX,
|
|
117
|
+
marginY: marginY,
|
|
118
|
+
shadow: shadow,
|
|
119
|
+
shadowHover: shadowHover,
|
|
118
120
|
radius: radius,
|
|
121
|
+
order: order,
|
|
122
|
+
zIndex: zIndex,
|
|
123
|
+
transition: transition,
|
|
124
|
+
transitionHover: transitionHover,
|
|
125
|
+
aspectRatio: aspectRatio,
|
|
126
|
+
flex: flex
|
|
127
|
+
}));
|
|
128
|
+
|
|
129
|
+
var propClassName = className ? className : '';
|
|
130
|
+
var classNames = [generateClassNameAttributes((_generateClassNameAtt = {
|
|
119
131
|
padding: padding,
|
|
120
132
|
paddingTop: paddingTop,
|
|
121
133
|
paddingBottom: paddingBottom,
|
|
@@ -135,28 +147,14 @@ export var Box2 = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
135
147
|
bottom: bottom,
|
|
136
148
|
left: left,
|
|
137
149
|
right: right,
|
|
150
|
+
color: color,
|
|
151
|
+
colorHover: colorHover,
|
|
152
|
+
backgroundColor: backgroundColor,
|
|
153
|
+
backgroundColorHover: backgroundColorHover,
|
|
138
154
|
shadow: shadow,
|
|
139
155
|
shadowHover: shadowHover,
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
overflowY: overflowY,
|
|
143
|
-
aspectRatio: aspectRatio,
|
|
144
|
-
zIndex: zIndex,
|
|
145
|
-
tag: tag,
|
|
146
|
-
opacity: opacity,
|
|
147
|
-
opacityHover: opacityHover,
|
|
148
|
-
order: order,
|
|
149
|
-
alignSelf: alignSelf,
|
|
150
|
-
flex: flex,
|
|
151
|
-
transition: transition,
|
|
152
|
-
transitionHover: transitionHover,
|
|
153
|
-
cursor: cursor
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
var styles = _objectSpread({}, generateStyleAttributes([dimensionProps, colorProps, spaceProps, shadowProps, radiusProps, orderProps, zIndexProps, transitionProps, aspectRatioProps, flexProps], allProps));
|
|
157
|
-
|
|
158
|
-
var propClassName = className ? className : '';
|
|
159
|
-
var classNames = [generateClassNameAttributes([spaceProps, colorProps, shadowProps, radiusProps, positionProps, overflowProps, transitionProps, cursorProps], allProps), propClassName].join(' ').replace(/\s+/g, ' ').trim();
|
|
156
|
+
radius: radius
|
|
157
|
+
}, _defineProperty(_generateClassNameAtt, "position", position), _defineProperty(_generateClassNameAtt, "overflow", overflow), _defineProperty(_generateClassNameAtt, "transition", transition), _defineProperty(_generateClassNameAtt, "transitionHover", transitionHover), _defineProperty(_generateClassNameAtt, "cursor", cursor), _generateClassNameAtt)), propClassName].join(' ').replace(/\s+/g, ' ').trim();
|
|
160
158
|
var Tag = tag;
|
|
161
159
|
return ___EmotionJSX(Tag, _extends({
|
|
162
160
|
ref: ref,
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import "core-js/modules/es.object.values.js";
|
|
1
2
|
import "core-js/modules/es.object.to-string.js";
|
|
2
3
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
4
|
+
import "core-js/modules/es.object.keys.js";
|
|
3
5
|
import "core-js/modules/es.array.concat.js";
|
|
4
6
|
import { isObject } from './helpers';
|
|
5
|
-
import { propNameToShort } from './style-config';
|
|
6
|
-
export var generateStyleAttributes = function generateStyleAttributes(
|
|
7
|
+
import { propNameToShort, styleConfig } from './style-config';
|
|
8
|
+
export var generateStyleAttributes = function generateStyleAttributes(props) {
|
|
7
9
|
var styles = {};
|
|
8
|
-
|
|
10
|
+
var styleConfigValues = Object.values(styleConfig);
|
|
11
|
+
styleConfigValues.forEach(function (propsSet) {
|
|
9
12
|
propsSet.props.forEach(function (_ref) {
|
|
10
13
|
var propName = _ref.propName;
|
|
11
|
-
var value =
|
|
14
|
+
var value = props[propName];
|
|
12
15
|
var hasVariable = propsSet.variableChecker ? propsSet.variableChecker(value) : false;
|
|
13
16
|
var hasTransformer = propsSet.valueTransformer ? true : false;
|
|
14
17
|
if (hasVariable) return;
|
|
@@ -18,34 +21,35 @@ export var generateStyleAttributes = function generateStyleAttributes(propsSets,
|
|
|
18
21
|
|
|
19
22
|
if (!isObject(value)) {
|
|
20
23
|
styles["--".concat(propNameShort)] = cssValue;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (isObject(value)) {
|
|
24
|
+
} else {
|
|
24
25
|
var def = value.default,
|
|
25
26
|
mobile = value.mobile,
|
|
26
27
|
tablet = value.tablet;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
styles["--".concat(propNameShort, "-def")] = defaultValueCss;
|
|
31
|
-
styles["--".concat(propNameShort, "-mob")] = mobileValueCss;
|
|
32
|
-
styles["--".concat(propNameShort, "-tab")] = tabletValueCss;
|
|
28
|
+
styles["--".concat(propNameShort, "-def")] = hasTransformer ? propsSet.valueTransformer(def) : def;
|
|
29
|
+
styles["--".concat(propNameShort, "-mob")] = hasTransformer ? propsSet.valueTransformer(mobile) : mobile;
|
|
30
|
+
styles["--".concat(propNameShort, "-tab")] = hasTransformer ? propsSet.valueTransformer(tablet) : tablet;
|
|
33
31
|
}
|
|
34
32
|
});
|
|
35
33
|
});
|
|
36
34
|
return styles;
|
|
37
35
|
};
|
|
38
|
-
export var generateClassNameAttributes = function generateClassNameAttributes(
|
|
36
|
+
export var generateClassNameAttributes = function generateClassNameAttributes(props) {
|
|
39
37
|
var classNames = [];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
var propKeys = Object.keys(props);
|
|
39
|
+
var styleConfigValues = Object.values(styleConfig);
|
|
40
|
+
propKeys.forEach(function (prop) {
|
|
41
|
+
styleConfigValues.forEach(function (styleConfigItem) {
|
|
42
|
+
styleConfigItem.props.forEach(function (propItem) {
|
|
43
|
+
if (propItem.propName === prop) {
|
|
44
|
+
var propName = propItem.propName;
|
|
45
|
+
var value = props[propName];
|
|
46
|
+
var hasVariable = styleConfigItem.variableChecker ? styleConfigItem.variableChecker(value) : false;
|
|
47
|
+
if (!hasVariable) return;
|
|
48
|
+
if (!value) return;
|
|
49
|
+
var className = "".concat(propNameToShort(propName), "-").concat(value);
|
|
50
|
+
classNames.push(className);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
49
53
|
});
|
|
50
54
|
});
|
|
51
55
|
return classNames.join(' ');
|