@flodesk/grain 11.0.0-next.10 → 11.0.0-next.11
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/styles/utilities.js +17 -21
- package/es/styles/variables.js +1 -1
- package/es/utilities/style-config.js +0 -1
- package/package.json +1 -1
package/es/styles/utilities.js
CHANGED
|
@@ -12,9 +12,9 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
12
12
|
|
|
13
13
|
import "core-js/modules/es.object.to-string.js";
|
|
14
14
|
import "core-js/modules/web.dom-collections.for-each.js";
|
|
15
|
+
import "core-js/modules/es.array.concat.js";
|
|
15
16
|
import "core-js/modules/es.array.includes.js";
|
|
16
17
|
import "core-js/modules/es.string.includes.js";
|
|
17
|
-
import "core-js/modules/es.array.concat.js";
|
|
18
18
|
import "core-js/modules/es.object.entries.js";
|
|
19
19
|
import "core-js/modules/es.symbol.js";
|
|
20
20
|
import "core-js/modules/es.symbol.description.js";
|
|
@@ -30,50 +30,46 @@ import { propNameToShort } from '../utilities/style-config';
|
|
|
30
30
|
import { breakpoints, deviceShort } from '../variables';
|
|
31
31
|
|
|
32
32
|
var generateUtilityClassDeclarations = function generateUtilityClassDeclarations(propertySets) {
|
|
33
|
-
var
|
|
33
|
+
var cssParts = [];
|
|
34
34
|
propertySets.forEach(function (set) {
|
|
35
35
|
set.variables.forEach(function (variable) {
|
|
36
36
|
set.props.forEach(function (prop) {
|
|
37
|
-
var property = prop.property;
|
|
38
37
|
var cssValue = set.valueTransformer ? set.valueTransformer(variable) : variable;
|
|
39
|
-
var hasHover = prop.propName.includes('Hover');
|
|
40
38
|
var selector = ".".concat(propNameToShort(prop.propName), "-").concat(variable);
|
|
41
|
-
var declaration = "{".concat(property, ": ").concat(cssValue, "}");
|
|
42
|
-
|
|
43
|
-
|
|
39
|
+
var declaration = "{".concat(prop.property, ": ").concat(cssValue, "}");
|
|
40
|
+
var hoverSelector = "".concat(selector, ":hover");
|
|
41
|
+
cssParts.push(prop.propName.includes('Hover') ? "".concat(hoverSelector, " ").concat(declaration) : "".concat(selector, " ").concat(declaration));
|
|
44
42
|
});
|
|
45
43
|
});
|
|
46
44
|
});
|
|
47
|
-
return
|
|
45
|
+
return cssParts.join('');
|
|
48
46
|
};
|
|
49
47
|
|
|
50
48
|
var generateStyleClassDeclarations = function generateStyleClassDeclarations(propertySets) {
|
|
51
|
-
var
|
|
49
|
+
var cssParts = [];
|
|
52
50
|
propertySets.forEach(function (set) {
|
|
53
51
|
set.props.forEach(function (prop) {
|
|
54
|
-
var
|
|
55
|
-
var
|
|
56
|
-
var
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
if (!hasHover) css += "[style*=\"".concat(cssVar, ":\"] ").concat(declaration);
|
|
60
|
-
if (hasHover) css += "[style*=\"".concat(cssVar, ":\"]:hover ").concat(declaration);
|
|
52
|
+
var cssVar = "--".concat(propNameToShort(prop.propName));
|
|
53
|
+
var declaration = "{".concat(prop.property, ": var(").concat(cssVar, ")}");
|
|
54
|
+
var selector = "[style*=\"".concat(cssVar, ":\"]");
|
|
55
|
+
var hoverSelector = "".concat(selector, ":hover");
|
|
56
|
+
cssParts.push(prop.propName.includes('Hover') ? "".concat(hoverSelector, " ").concat(declaration) : "".concat(selector, " ").concat(declaration));
|
|
61
57
|
|
|
62
58
|
if (set.isResponsive) {
|
|
63
|
-
var
|
|
64
|
-
|
|
59
|
+
var deviceSelector = "[style*=\"".concat(cssVar, "-").concat(deviceShort.default, "\"]");
|
|
60
|
+
cssParts.push("".concat(deviceSelector, " ").concat(declaration));
|
|
65
61
|
Object.entries(breakpoints).forEach(function (_ref) {
|
|
66
62
|
var _ref2 = _slicedToArray(_ref, 2),
|
|
67
63
|
deviceName = _ref2[0],
|
|
68
64
|
screenSize = _ref2[1];
|
|
69
65
|
|
|
70
|
-
var
|
|
71
|
-
|
|
66
|
+
var deviceVar = "".concat(cssVar, "-").concat(deviceShort[deviceName]);
|
|
67
|
+
cssParts.push("@media (max-width: ".concat(screenSize, "px) { [style*=\"").concat(deviceVar, "\"] ").concat(declaration, " }"));
|
|
72
68
|
});
|
|
73
69
|
}
|
|
74
70
|
});
|
|
75
71
|
});
|
|
76
|
-
return
|
|
72
|
+
return cssParts.join('');
|
|
77
73
|
};
|
|
78
74
|
|
|
79
75
|
var spaceProps = styleConfig.spaceProps,
|
package/es/styles/variables.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var variables = "\n :root {\n --grn-unit: 8px;\n }\n\n :root {\n --grn-text-s: 12px;\n --grn-text-m:
|
|
1
|
+
var variables = "\n :root {\n --grn-unit: 8px;\n }\n\n :root {\n --grn-text-s: 12px;\n --grn-text-m: 14px;\n --grn-text-l: 18px;\n --grn-text-xl: 24px;\n --grn-text-xxl: 30px;\n }\n\n /* text size \u2715 ~1.2 */\n :root {\n --grn-icon-s: 14px;\n --grn-icon-m: 18px;\n --grn-icon-l: 22px;\n --grn-icon-xl: 28px;\n --grn-icon-xxl: 36px;\n }\n\n :root {\n --grn-weight-normal: 400;\n --grn-weight-medium: 500;\n }\n\n :root {\n --grn-space-xs: calc(var(--grn-unit) / 2);\n --grn-space-s: calc(var(--grn-unit) * 1);\n --grn-space-s2: calc(var(--grn-unit) * 1.5);\n --grn-space-m: calc(var(--grn-unit) * 2);\n --grn-space-l: calc(var(--grn-unit) * 3);\n --grn-space-l2: calc(var(--grn-unit) * 4);\n --grn-space-xl: calc(var(--grn-unit) * 5);\n --grn-space-xl2: calc(var(--grn-unit) * 6);\n --grn-space-xxl: calc(var(--grn-unit) * 7);\n }\n\n :root {\n --grn-radius-s: 3px;\n --grn-radius-m: 6px;\n --grn-radius-l: 10px;\n }\n\n :root {\n --grn-transition-slow: 400ms;\n --grn-transition-fast: 200ms;\n --grn-transition-xFast: 160ms;\n --grn-transition-xxFast: 80ms;\n }\n\n :root,\n [data-theme] {\n --grn-space-betweenFormTitleAndContent: var(--grn-space-l);\n --grn-space-betweenFormContents: var(--grn-space-m);\n --grn-space-betweenFormContentAndActions: var(--grn-space-xl);\n --grn-space-betweenFormControlAndLabel: var(--grn-space-s);\n --grn-space-fieldPaddingX: 12px;\n\n --grn-color-fieldBorder: var(--grn-color-fade3);\n --grn-color-fieldBorderHover: var(--grn-color-fade6);\n --grn-color-fieldBorderFocus: var(--grn-color-shade9);\n --grn-color-fieldBorderDisabled: var(--grn-color-shade5);\n --grn-color-fieldBackgroundDisabled: var(--grn-color-shade2);\n --grn-color-backdrop: hsl(var(--H) 15% 10% / 0.6);\n\n --grn-transition-leave: var(--grn-transition-slow);\n --grn-transition-hover: var(--grn-transition-fast);\n --grn-transition-active: var(--grn-transition-xxFast);\n }\n";
|
|
2
2
|
export default variables;
|
|
@@ -505,7 +505,6 @@ Object.values(styleConfig).forEach(function (config) {
|
|
|
505
505
|
propNameToShortMap[prop.propName] = prop.short;
|
|
506
506
|
});
|
|
507
507
|
});
|
|
508
|
-
console.log(propNameToShortMap);
|
|
509
508
|
export var propNameToShort = function propNameToShort(propName) {
|
|
510
509
|
return propNameToShortMap[propName] || null;
|
|
511
510
|
};
|