@flodesk/grain 10.9.4 → 10.9.5

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.
@@ -1,7 +1,8 @@
1
1
  import "core-js/modules/es.object.to-string.js";
2
2
  import "core-js/modules/web.dom-collections.for-each.js";
3
3
  import "core-js/modules/es.array.concat.js";
4
- import { propertyToShorthand, propNameToShorthand, styleConfig } from '../utilities';
4
+ import { styleConfig } from '../utilities';
5
+ import { propNameToShort } from '../utilities/style-config';
5
6
 
6
7
  var generateUtilityClasses = function generateUtilityClasses(propertySets) {
7
8
  var css = '';
@@ -13,11 +14,11 @@ var generateUtilityClasses = function generateUtilityClasses(propertySets) {
13
14
  var hasHover = prop.modifier === 'hover';
14
15
 
15
16
  if (!hasHover) {
16
- css += "\n .".concat(propNameToShorthand(prop.propName), "-").concat(variable, " {\n ").concat(property, ": ").concat(cssValue, "\n }");
17
+ css += "\n .".concat(propNameToShort(prop.propName), "-").concat(variable, " {\n ").concat(property, ": ").concat(cssValue, "\n }");
17
18
  }
18
19
 
19
20
  if (hasHover) {
20
- css += "\n .".concat(propNameToShorthand(prop.propName), "-").concat(variable, ":hover {\n ").concat(property, ": ").concat(cssValue, "\n }");
21
+ css += "\n .".concat(propNameToShort(prop.propName), "-").concat(variable, ":hover {\n ").concat(property, ": ").concat(cssValue, "\n }");
21
22
  }
22
23
  });
23
24
  });
@@ -30,7 +31,8 @@ var generateStyleClasses = function generateStyleClasses(propertySets) {
30
31
  propertySets.forEach(function (set) {
31
32
  set.props.forEach(function (prop) {
32
33
  var property = prop.property;
33
- var cssVar = "--".concat(propertyToShorthand(property));
34
+ var propName = prop.propName;
35
+ var cssVar = "--".concat(propNameToShort(propName));
34
36
  var hasHover = prop.modifier === 'hover';
35
37
 
36
38
  if (!hasHover) {
@@ -38,7 +40,7 @@ var generateStyleClasses = function generateStyleClasses(propertySets) {
38
40
  }
39
41
 
40
42
  if (hasHover) {
41
- css += "\n [style*=\"".concat(cssVar, "-hover\"]:hover {\n ").concat(property, ": var(").concat(cssVar, "-hover)\n }");
43
+ css += "\n [style*=\"".concat(cssVar, "\"]:hover {\n ").concat(property, ": var(").concat(cssVar, ")\n }");
42
44
  }
43
45
 
44
46
  if (set.isResponsive) {
@@ -1,7 +1,8 @@
1
1
  import "core-js/modules/es.object.to-string.js";
2
2
  import "core-js/modules/web.dom-collections.for-each.js";
3
3
  import "core-js/modules/es.array.concat.js";
4
- import { isObject, propNameToShorthand } from './helpers';
4
+ import { isObject } from './helpers';
5
+ import { propNameToShort } from './style-config';
5
6
  export var generateStyleAttributes = function generateStyleAttributes(propsSets, allProps) {
6
7
  var styles = {};
7
8
  propsSets.forEach(function (propsSet) {
@@ -13,7 +14,7 @@ export var generateStyleAttributes = function generateStyleAttributes(propsSets,
13
14
  if (hasVariable) return;
14
15
  if (!value) return;
15
16
  var cssValue = hasTransformer ? propsSet.valueTransformer(value) : value;
16
- var propNameShort = propNameToShorthand(propName);
17
+ var propNameShort = propNameToShort(propName);
17
18
 
18
19
  if (!isObject(value)) {
19
20
  styles["--".concat(propNameShort)] = cssValue;
@@ -43,7 +44,7 @@ export var generateClassNameAttributes = function generateClassNameAttributes(pr
43
44
  var hasVariable = propsSet.variableChecker ? propsSet.variableChecker(value) : false;
44
45
  if (!hasVariable) return;
45
46
  if (!value) return;
46
- var className = "".concat(propNameToShorthand(propName), "-").concat(value);
47
+ var className = "".concat(propNameToShort(propName), "-").concat(value);
47
48
  classNames.push(className);
48
49
  });
49
50
  });
@@ -3,7 +3,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" =
3
3
  import "core-js/modules/es.array.concat.js";
4
4
  import "core-js/modules/es.object.to-string.js";
5
5
  import "core-js/modules/web.dom-collections.for-each.js";
6
- import "core-js/modules/es.array.find.js";
7
6
  import "core-js/modules/es.symbol.js";
8
7
  import "core-js/modules/es.symbol.description.js";
9
8
  import "core-js/modules/es.symbol.iterator.js";
@@ -45,189 +44,4 @@ export var mergeRefs = function mergeRefs(refs) {
45
44
  }
46
45
  });
47
46
  };
48
- };
49
- var shortHandProps = [{
50
- propName: 'padding',
51
- property: 'padding',
52
- value: 'p'
53
- }, {
54
- propName: 'paddingTop',
55
- property: 'padding-top',
56
- value: 'pt'
57
- }, {
58
- propName: 'paddingBottom',
59
- property: 'padding-bottom',
60
- value: 'pb'
61
- }, {
62
- propName: 'paddingLeft',
63
- property: 'padding-left',
64
- value: 'pl'
65
- }, {
66
- propName: 'paddingRight',
67
- property: 'padding-right',
68
- value: 'pr'
69
- }, {
70
- propName: 'paddingX',
71
- property: 'padding-inline',
72
- value: 'px'
73
- }, {
74
- propName: 'paddingY',
75
- property: 'padding-block',
76
- value: 'py'
77
- }, {
78
- propName: 'margin',
79
- property: 'margin',
80
- value: 'm'
81
- }, {
82
- propName: 'marginTop',
83
- property: 'margin-top',
84
- value: 'mt'
85
- }, {
86
- propName: 'marginBottom',
87
- property: 'margin-bottom',
88
- value: 'mb'
89
- }, {
90
- propName: 'marginLeft',
91
- property: 'margin-left',
92
- value: 'ml'
93
- }, {
94
- propName: 'marginRight',
95
- property: 'margin-right',
96
- value: 'mr'
97
- }, {
98
- propName: 'marginX',
99
- property: 'margin-inline',
100
- value: 'mx'
101
- }, {
102
- propName: 'marginY',
103
- property: 'margin-block',
104
- value: 'my'
105
- }, {
106
- propName: 'top',
107
- property: 'top',
108
- value: 't'
109
- }, {
110
- propName: 'bottom',
111
- property: 'bottom',
112
- value: 'b'
113
- }, {
114
- propName: 'left',
115
- property: 'left',
116
- value: 'l'
117
- }, {
118
- propName: 'right',
119
- property: 'right',
120
- value: 'r'
121
- }, {
122
- propName: 'width',
123
- property: 'width',
124
- value: 'w'
125
- }, {
126
- propName: 'height',
127
- property: 'height',
128
- value: 'h'
129
- }, {
130
- propName: 'minWidth',
131
- property: 'min-width',
132
- value: 'min-w'
133
- }, {
134
- propName: 'maxWidth',
135
- property: 'max-width',
136
- value: 'max-w'
137
- }, {
138
- propName: 'minHeight',
139
- property: 'min-height',
140
- value: 'min-h'
141
- }, {
142
- propName: 'maxHeight',
143
- property: 'max-height',
144
- value: 'max-h'
145
- }, {
146
- propName: 'color',
147
- property: 'color',
148
- value: 'c'
149
- }, {
150
- propName: 'colorHover',
151
- property: 'color',
152
- value: 'c-hover'
153
- }, {
154
- propName: 'backgroundColor',
155
- property: 'background-color',
156
- value: 'bgc'
157
- }, {
158
- propName: 'backgroundColorHover',
159
- property: 'background-color',
160
- value: 'bgc-hover'
161
- }, {
162
- propName: 'shadow',
163
- property: 'box-shadow',
164
- value: 'sh'
165
- }, {
166
- propName: 'shadowHover',
167
- property: 'box-shadow',
168
- value: 'sh-hover'
169
- }, {
170
- propName: 'radius',
171
- property: 'border-radius',
172
- value: 'rad'
173
- }, {
174
- propName: 'order',
175
- property: 'order',
176
- value: 'ord'
177
- }, {
178
- propName: 'position',
179
- property: 'position',
180
- value: 'pos'
181
- }, {
182
- propName: 'overflow',
183
- property: 'overflow',
184
- value: 'ovf'
185
- }, {
186
- propName: 'overflowX',
187
- property: 'overflow-x',
188
- value: 'ovf-x'
189
- }, {
190
- propName: 'overflowY',
191
- property: 'overflow-y',
192
- value: 'ovf-y'
193
- }, {
194
- propName: 'zIndex',
195
- property: 'z-index',
196
- value: 'z'
197
- }, {
198
- propName: 'transition',
199
- property: 'transition',
200
- value: 'tr'
201
- }, {
202
- propName: 'transitionHover',
203
- property: 'transition',
204
- value: 'tr-hover'
205
- }, {
206
- propName: 'cursor',
207
- property: 'cursor',
208
- value: 'cur'
209
- }, {
210
- propName: 'aspectRatio',
211
- property: 'aspect-ratio',
212
- value: 'ar'
213
- }, {
214
- propName: 'flex',
215
- property: 'flex',
216
- value: 'flex'
217
- }];
218
- export var propertyToShorthand = function propertyToShorthand(property) {
219
- var _shortHandProps$find;
220
-
221
- return (_shortHandProps$find = shortHandProps.find(function (_ref) {
222
- var prop = _ref.property;
223
- return prop === property;
224
- })) === null || _shortHandProps$find === void 0 ? void 0 : _shortHandProps$find.value;
225
- };
226
- export var propNameToShorthand = function propNameToShorthand(propName) {
227
- var _shortHandProps$find2;
228
-
229
- return (_shortHandProps$find2 = shortHandProps.find(function (_ref2) {
230
- var prop = _ref2.propName;
231
- return prop === propName;
232
- })) === null || _shortHandProps$find2 === void 0 ? void 0 : _shortHandProps$find2.value;
233
47
  };
@@ -2,9 +2,11 @@ import "core-js/modules/es.array.concat.js";
2
2
  import "core-js/modules/es.object.keys.js";
3
3
  import "core-js/modules/es.array.includes.js";
4
4
  import "core-js/modules/es.string.includes.js";
5
+ import "core-js/modules/es.array.find.js";
6
+ import "core-js/modules/es.object.to-string.js";
7
+ import "core-js/modules/es.object.values.js";
5
8
  import "core-js/modules/es.symbol.js";
6
9
  import "core-js/modules/es.symbol.description.js";
7
- import "core-js/modules/es.object.to-string.js";
8
10
  import "core-js/modules/es.symbol.iterator.js";
9
11
  import "core-js/modules/es.array.iterator.js";
10
12
  import "core-js/modules/es.string.iterator.js";
@@ -38,58 +40,76 @@ export var styleConfig = {
38
40
  spaceProps: {
39
41
  props: [{
40
42
  propName: 'padding',
41
- property: 'padding'
43
+ property: 'padding',
44
+ short: 'p'
42
45
  }, {
43
46
  propName: 'paddingTop',
44
- property: 'padding-top'
47
+ property: 'padding-top',
48
+ short: 'pt'
45
49
  }, {
46
50
  propName: 'paddingBottom',
47
- property: 'padding-bottom'
51
+ property: 'padding-bottom',
52
+ short: 'pb'
48
53
  }, {
49
54
  propName: 'paddingLeft',
50
- property: 'padding-left'
55
+ property: 'padding-left',
56
+ short: 'pl'
51
57
  }, {
52
58
  propName: 'paddingRight',
53
- property: 'padding-right'
59
+ property: 'padding-right',
60
+ short: 'pr'
54
61
  }, {
55
62
  propName: 'paddingX',
56
- property: 'padding-inline'
63
+ property: 'padding-inline',
64
+ short: 'px'
57
65
  }, {
58
66
  propName: 'paddingY',
59
- property: 'padding-block'
67
+ property: 'padding-block',
68
+ short: 'py'
60
69
  }, {
61
70
  propName: 'margin',
62
- property: 'margin'
71
+ property: 'margin',
72
+ short: 'm'
63
73
  }, {
64
74
  propName: 'marginTop',
65
- property: 'margin-top'
75
+ property: 'margin-top',
76
+ short: 'mt'
66
77
  }, {
67
78
  propName: 'marginBottom',
68
- property: 'margin-bottom'
79
+ property: 'margin-bottom',
80
+ short: 'mb'
69
81
  }, {
70
82
  propName: 'marginLeft',
71
- property: 'margin-left'
83
+ property: 'margin-left',
84
+ short: 'ml'
72
85
  }, {
73
86
  propName: 'marginRight',
74
- property: 'margin-right'
87
+ property: 'margin-right',
88
+ short: 'mr'
75
89
  }, {
76
90
  propName: 'marginX',
77
- property: 'margin-inline'
91
+ property: 'margin-inline',
92
+ short: 'mx'
78
93
  }, {
79
94
  propName: 'marginY',
80
- property: 'margin-block'
95
+ property: 'margin-block',
96
+ short: 'my'
81
97
  }, {
82
98
  propName: 'top',
83
- property: 'top'
99
+ property: 'top',
100
+ short: 't'
84
101
  }, {
85
102
  propName: 'bottom',
86
- property: 'bottom'
103
+ property: 'bottom',
104
+ short: 'b'
87
105
  }, {
88
106
  propName: 'left',
89
- property: 'left'
107
+ property: 'left',
108
+ short: 'l'
90
109
  }, {
91
110
  propName: 'right',
92
- property: 'right'
111
+ property: 'right',
112
+ short: 'r'
93
113
  }],
94
114
  valueTransformer: getSpace,
95
115
  variableChecker: isSpaceVar,
@@ -99,22 +119,28 @@ export var styleConfig = {
99
119
  dimensionProps: {
100
120
  props: [{
101
121
  propName: 'width',
102
- property: 'width'
122
+ property: 'width',
123
+ short: 'w'
103
124
  }, {
104
125
  propName: 'minWidth',
105
- property: 'height'
126
+ property: 'height',
127
+ short: 'min-w'
106
128
  }, {
107
129
  propName: 'maxWidth',
108
- property: 'min-width'
130
+ property: 'min-width',
131
+ short: 'max-w'
109
132
  }, {
110
133
  propName: 'height',
111
- property: 'max-width'
134
+ property: 'max-width',
135
+ short: 'h'
112
136
  }, {
113
137
  propName: 'minHeight',
114
- property: 'min-height'
138
+ property: 'min-height',
139
+ short: 'min-h'
115
140
  }, {
116
141
  propName: 'maxHeight',
117
- property: 'max-height'
142
+ property: 'max-height',
143
+ short: 'max-h'
118
144
  }],
119
145
  valueTransformer: getDimension,
120
146
  isResponsive: true
@@ -122,18 +148,22 @@ export var styleConfig = {
122
148
  colorProps: {
123
149
  props: [{
124
150
  propName: 'color',
125
- property: 'color'
151
+ property: 'color',
152
+ short: 'c'
126
153
  }, {
127
154
  propName: 'colorHover',
128
155
  property: 'color',
129
- modifier: 'hover'
156
+ modifier: 'hover',
157
+ short: 'c-hover'
130
158
  }, {
131
159
  propName: 'backgroundColor',
132
- property: 'background-color'
160
+ property: 'background-color',
161
+ short: 'bgc'
133
162
  }, {
134
163
  propName: 'backgroundColorHover',
135
164
  property: 'background-color',
136
- modifier: 'hover'
165
+ modifier: 'hover',
166
+ short: 'bgc-hover'
137
167
  }],
138
168
  valueTransformer: getColor,
139
169
  variableChecker: isColorVar,
@@ -142,11 +172,13 @@ export var styleConfig = {
142
172
  shadowProps: {
143
173
  props: [{
144
174
  propName: 'shadow',
145
- property: 'box-shadow'
175
+ property: 'box-shadow',
176
+ short: 'sh'
146
177
  }, {
147
178
  propName: 'shadowHover',
148
179
  property: 'box-shadow',
149
- modifier: 'hover'
180
+ modifier: 'hover',
181
+ short: 'sh-hover'
150
182
  }],
151
183
  valueTransformer: getShadow,
152
184
  variableChecker: isShadowVar,
@@ -155,7 +187,8 @@ export var styleConfig = {
155
187
  radiusProps: {
156
188
  props: [{
157
189
  propName: 'radius',
158
- property: 'border-radius'
190
+ property: 'border-radius',
191
+ short: 'rad'
159
192
  }],
160
193
  valueTransformer: getRadius,
161
194
  variableChecker: isRadiusVar,
@@ -164,26 +197,30 @@ export var styleConfig = {
164
197
  orderProps: {
165
198
  props: [{
166
199
  propName: 'order',
167
- property: 'order'
200
+ property: 'order',
201
+ short: 'ord'
168
202
  }]
169
203
  },
170
204
  flexProps: {
171
205
  props: [{
172
206
  propName: 'flex',
173
- property: 'flex'
207
+ property: 'flex',
208
+ short: 'flex'
174
209
  }],
175
210
  isResponsive: true
176
211
  },
177
212
  zIndexProps: {
178
213
  props: [{
179
214
  propName: 'zIndex',
180
- property: 'z-index'
215
+ property: 'z-index',
216
+ short: 'z'
181
217
  }]
182
218
  },
183
219
  positionProps: {
184
220
  props: [{
185
221
  propName: 'position',
186
- property: 'position'
222
+ property: 'position',
223
+ short: 'pos'
187
224
  }],
188
225
  variableChecker: function variableChecker(value) {
189
226
  return positions.includes(value);
@@ -193,13 +230,16 @@ export var styleConfig = {
193
230
  overflowProps: {
194
231
  props: [{
195
232
  propName: 'overflow',
196
- property: 'overflow'
233
+ property: 'overflow',
234
+ short: 'ovf'
197
235
  }, {
198
236
  propName: 'overflowX',
199
- property: 'overflow-x'
237
+ property: 'overflow-x',
238
+ short: 'ovf-x'
200
239
  }, {
201
240
  propName: 'overflowY',
202
- property: 'overflow-y'
241
+ property: 'overflow-y',
242
+ short: 'ovf-y'
203
243
  }],
204
244
  variableChecker: function variableChecker(value) {
205
245
  return overflows.includes(value);
@@ -209,11 +249,13 @@ export var styleConfig = {
209
249
  transitionProps: {
210
250
  props: [{
211
251
  propName: 'transition',
212
- property: 'transition'
252
+ property: 'transition',
253
+ short: 'tr'
213
254
  }, {
214
255
  propName: 'transitionHover',
215
256
  property: 'transition',
216
- modifier: 'hover'
257
+ modifier: 'hover',
258
+ short: 'tr-hover'
217
259
  }],
218
260
  valueTransformer: getTransition,
219
261
  variableChecker: isTrasitionVar,
@@ -222,7 +264,8 @@ export var styleConfig = {
222
264
  cursorProps: {
223
265
  props: [{
224
266
  propName: 'cursor',
225
- property: 'cursor'
267
+ property: 'cursor',
268
+ short: 'cur'
226
269
  }],
227
270
  variableChecker: function variableChecker(value) {
228
271
  return cursors.includes(value);
@@ -232,7 +275,23 @@ export var styleConfig = {
232
275
  aspectRatioProps: {
233
276
  props: [{
234
277
  propName: 'aspectRatio',
235
- property: 'aspect-ratio'
278
+ property: 'aspect-ratio',
279
+ short: 'ar'
236
280
  }]
237
281
  }
282
+ };
283
+ export var propNameToShort = function propNameToShort(propName) {
284
+ var _prop$props$find;
285
+
286
+ var prop = Object.values(styleConfig).find(function (_ref) {
287
+ var props = _ref.props;
288
+ return props.find(function (_ref2) {
289
+ var prop = _ref2.propName;
290
+ return prop === propName;
291
+ });
292
+ });
293
+ return prop === null || prop === void 0 ? void 0 : (_prop$props$find = prop.props.find(function (_ref3) {
294
+ var prop = _ref3.propName;
295
+ return prop === propName;
296
+ })) === null || _prop$props$find === void 0 ? void 0 : _prop$props$find.short;
238
297
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flodesk/grain",
3
- "version": "10.9.4",
3
+ "version": "10.9.5",
4
4
  "description": "Flodesk design system",
5
5
  "module": "es/index.js",
6
6
  "author": "Flodesk",