@evlop/commons 1.0.111 → 1.0.112
Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"themeHelpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"themeHelpers.d.ts","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":"AA+BA,eAAO,MAAM,iBAAiB,aAAa,MAAM,YAAY;IAAC,KAAK,EAAC,MAAM,CAAC;IAAC,MAAK,MAAM,CAAA;CAAC,EAAE,OAGpF,CAAC;AAGP,eAAO,MAAM,cAAc;;;GAgB1B,CAAA;AAED,eAAO,MAAM,iBAAiB,iBAAkB,MAAM,OAAoD,CAAC;AAG3G,eAAO,MAAM,kBAAkB;;;GAAwD,CAAC;AACxF,eAAO,MAAM,mBAAmB,iBAAkB,MAAM,OAAwD,CAAC;AAGjH,eAAO,MAAM,iBAAiB;;;GAmB7B,CAAA;AAED,eAAO,MAAM,oBAAoB,gBAAiB,MAAM,OAAsD,CAAC;AAqC/G,wBAAgB,gBAAgB,CAAC,MAAM,EAAE;IAAC,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC;;EAuCrE"}
|
@@ -3,6 +3,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getColorVariants = exports.generateSpacingSizes = exports.spacingVariations = exports.generateLineHeights = exports.lineHeightVariants = exports.generateFontSizes = exports.fontVariations = exports.generateSizeScale = void 0;
|
4
4
|
const lodash_1 = require("lodash");
|
5
5
|
const polished_1 = require("polished");
|
6
|
+
function lightenRgb(hex, intensity) {
|
7
|
+
const color = polished_1.parseToRgb(hex);
|
8
|
+
if (!color) {
|
9
|
+
return "";
|
10
|
+
}
|
11
|
+
const r = Math.round(color.red + (255 - color.red) * intensity);
|
12
|
+
const g = Math.round(color.green + (255 - color.green) * intensity);
|
13
|
+
const b = Math.round(color.blue + (255 - color.blue) * intensity);
|
14
|
+
return polished_1.rgb(r, g, b);
|
15
|
+
}
|
16
|
+
function darkenRgb(hex, intensity) {
|
17
|
+
const color = polished_1.parseToRgb(hex);
|
18
|
+
if (!color) {
|
19
|
+
return "";
|
20
|
+
}
|
21
|
+
const r = Math.round(color.red * (1 - intensity));
|
22
|
+
const g = Math.round(color.green * (1 - intensity));
|
23
|
+
const b = Math.round(color.blue * (1 - intensity));
|
24
|
+
return polished_1.rgb(r, g, b);
|
25
|
+
}
|
6
26
|
const generateSizeScale = (baseSize, variants) => variants.reduce((sizes, { name, scale }) => {
|
7
27
|
sizes[name] = baseSize * scale;
|
8
28
|
return sizes;
|
@@ -55,6 +75,38 @@ exports.spacingVariations = [
|
|
55
75
|
];
|
56
76
|
const generateSpacingSizes = (baseSpacing) => exports.generateSizeScale(baseSpacing, exports.spacingVariations);
|
57
77
|
exports.generateSpacingSizes = generateSpacingSizes;
|
78
|
+
const colorShades = {
|
79
|
+
// whiten
|
80
|
+
0: 0,
|
81
|
+
50: 0.95,
|
82
|
+
100: 0.9,
|
83
|
+
200: 0.75,
|
84
|
+
300: 0.6,
|
85
|
+
400: 0.3,
|
86
|
+
// darken
|
87
|
+
500: 0,
|
88
|
+
600: 0.1,
|
89
|
+
700: 0.25,
|
90
|
+
800: 0.4,
|
91
|
+
900: 0.51
|
92
|
+
};
|
93
|
+
function interpolateShadeAndGetColor(color, shade) {
|
94
|
+
let _shade = Math.max(Math.min(900, shade), 0);
|
95
|
+
if (lodash_1.hasIn(colorShades, _shade))
|
96
|
+
return getColorShade(color, _shade);
|
97
|
+
const firstShade = Math.floor(_shade / 100);
|
98
|
+
const secondShade = Math.ceil(_shade / 100);
|
99
|
+
const weight = (_shade % 100) / 100;
|
100
|
+
return polished_1.mix(weight, getColorShade(color, firstShade), getColorShade(color, secondShade));
|
101
|
+
}
|
102
|
+
function getColorShade(color, shade) {
|
103
|
+
if (shade < 500) {
|
104
|
+
return lightenRgb(color, colorShades[shade]);
|
105
|
+
}
|
106
|
+
else {
|
107
|
+
return darkenRgb(color, colorShades[shade]);
|
108
|
+
}
|
109
|
+
}
|
58
110
|
// colors
|
59
111
|
function getColorVariants(colors) {
|
60
112
|
return new Proxy(colors, {
|
@@ -84,6 +136,9 @@ function getColorVariants(colors) {
|
|
84
136
|
case 'grayscale':
|
85
137
|
resultColor = polished_1.grayscale(resultColor);
|
86
138
|
break;
|
139
|
+
case 'shade':
|
140
|
+
const shadeLevel = colorParams.shift();
|
141
|
+
resultColor = interpolateShadeAndGetColor(resultColor, +shadeLevel);
|
87
142
|
default:
|
88
143
|
}
|
89
144
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"themeHelpers.js","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":";;;AAAA,
|
1
|
+
{"version":3,"file":"themeHelpers.js","sourceRoot":"","sources":["../../../src/helpers/themeHelpers.tsx"],"names":[],"mappings":";;;AAAA,mCAA+C;AAC/C,uCAAiH;AAEjH,SAAS,UAAU,CAAC,GAAG,EAAE,SAAS;IAC9B,MAAM,KAAK,GAAG,qBAAU,CAAC,GAAG,CAAC,CAAC;IAE9B,IAAI,CAAC,KAAK,EAAE;QACV,OAAO,EAAE,CAAC;KACX;IAED,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,SAAS,CAAC,CAAC;IAChE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC;IACpE,MAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,GAAG,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC;IAElE,OAAO,cAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAA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