@tstdl/base 0.81.23 → 0.81.24
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/package.json +3 -3
- package/theme/theme-service.js +14 -57
- package/theme/theme-service.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.81.
|
|
3
|
+
"version": "0.81.24",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"pub": "npm run build:prod && rm -vf dist/test* && npm publish dist/"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"luxon": "^3.
|
|
18
|
+
"luxon": "^3.2",
|
|
19
19
|
"reflect-metadata": "^0.1",
|
|
20
20
|
"rxjs": "^7.8",
|
|
21
21
|
"type-fest": "^2.19"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@types/chroma-js": "2.1",
|
|
25
25
|
"@types/koa__router": "12.0",
|
|
26
|
-
"@types/luxon": "3.
|
|
26
|
+
"@types/luxon": "3.2",
|
|
27
27
|
"@types/minio": "7.0",
|
|
28
28
|
"@types/mjml": "4.7",
|
|
29
29
|
"@types/node": "18",
|
package/theme/theme-service.js
CHANGED
|
@@ -76,7 +76,7 @@ function calculateTheme(theme) {
|
|
|
76
76
|
return calculatedTheme;
|
|
77
77
|
}
|
|
78
78
|
function generateColorTones(base) {
|
|
79
|
-
const colors = generateColors(
|
|
79
|
+
const colors = generateColors(base, 10);
|
|
80
80
|
return {
|
|
81
81
|
base: (0, type_guards_1.isString)(base) ? base : base.hex(),
|
|
82
82
|
50: colors[0],
|
|
@@ -106,63 +106,20 @@ function generateContrastColorTones(base, tones) {
|
|
|
106
106
|
900: getContrastColor(tones[900])
|
|
107
107
|
};
|
|
108
108
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const diverging = (0, type_guards_1.isDefined)(divergingColors) && (divergingColors.length > 0);
|
|
114
|
-
const even = (colorCount % 2) == 0;
|
|
115
|
-
const numColorsLeft = diverging ? Math.ceil(colorCount / 2) + (even ? 1 : 0) : colorCount;
|
|
116
|
-
const numColorsRight = diverging ? Math.ceil(colorCount / 2) + (even ? 1 : 0) : 0;
|
|
117
|
-
const genColors = (baseColors.length > 0)
|
|
118
|
-
? (baseColors.length > 1)
|
|
119
|
-
? baseColors
|
|
120
|
-
: autoColors(baseColors[0], numColorsLeft, diverging)
|
|
121
|
-
: [];
|
|
122
|
-
const genColors2 = diverging
|
|
123
|
-
? (divergingColors.length > 1)
|
|
124
|
-
? divergingColors
|
|
125
|
-
: autoColors(divergingColors[0], numColorsRight, diverging, true)
|
|
126
|
-
: [];
|
|
127
|
-
const stepsLeft = (baseColors.length > 0)
|
|
128
|
-
? (bezier ? chroma.bezier(genColors).scale() : chroma.scale(genColors))
|
|
129
|
-
.correctLightness(correctLightness)
|
|
130
|
-
.colors(numColorsLeft)
|
|
131
|
-
: [];
|
|
132
|
-
const stepsRight = diverging
|
|
133
|
-
? ((bezier && (divergingColors.length > 1)) ? chroma.bezier(genColors2).scale() : chroma.scale(genColors2))
|
|
134
|
-
.correctLightness(correctLightness)
|
|
135
|
-
.colors(numColorsRight)
|
|
136
|
-
: [];
|
|
137
|
-
const steps = (even && diverging ? stepsLeft.slice(0, stepsLeft.length - 1) : stepsLeft).concat(stepsRight.slice(1));
|
|
138
|
-
return steps;
|
|
139
|
-
}
|
|
140
|
-
function autoColors(color, numColors, diverging, reverse = false) {
|
|
141
|
-
if (diverging) {
|
|
142
|
-
const colors = autoGradient(color, 3, diverging).concat(chroma('#f5f5f5'));
|
|
143
|
-
if (reverse) {
|
|
144
|
-
return colors.reverse();
|
|
145
|
-
}
|
|
146
|
-
return colors;
|
|
109
|
+
function generateColors(baseColor, colorCount, { bezier = true, correctLightness = true } = {}) {
|
|
110
|
+
const generatedColors = autoGradient(baseColor, colorCount);
|
|
111
|
+
if (!bezier && !correctLightness) {
|
|
112
|
+
return generatedColors.map((color) => color.hex());
|
|
147
113
|
}
|
|
148
|
-
|
|
114
|
+
const scale = (bezier ? chroma.bezier(generatedColors).scale() : chroma.scale(generatedColors));
|
|
115
|
+
const colors = scale
|
|
116
|
+
.correctLightness(correctLightness)
|
|
117
|
+
.colors(colorCount);
|
|
118
|
+
return colors;
|
|
149
119
|
}
|
|
150
|
-
function autoGradient(color, numColors
|
|
151
|
-
const
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
const lStart = (100 - lRange) * 0.5;
|
|
155
|
-
const range = (0, array_1.createArray)(numColors, (i) => lStart + (i * lStep));
|
|
156
|
-
let offset = 0;
|
|
157
|
-
if (!diverging) {
|
|
158
|
-
offset = 9999;
|
|
159
|
-
for (let i = 0; i < numColors; i++) {
|
|
160
|
-
const diff = lab[0] - range[i];
|
|
161
|
-
if (Math.abs(diff) < Math.abs(offset)) {
|
|
162
|
-
offset = diff;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return range.map((l) => chroma.lab(l + offset, lab[1], lab[2]));
|
|
120
|
+
function autoGradient(color, numColors) {
|
|
121
|
+
const [, a, b] = chroma(color).lab();
|
|
122
|
+
const step = 100 / (numColors + 1);
|
|
123
|
+
return (0, array_1.createArray)(numColors, (i) => chroma.lab(100 - ((i + 1) * step), a, b));
|
|
167
124
|
}
|
|
168
125
|
//# sourceMappingURL=theme-service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme-service.js","sourceRoot":"","sources":["../../source/theme/theme-service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwC;AAExC,gDAAkD;AAClD,mDAAkE;AAClE,
|
|
1
|
+
{"version":3,"file":"theme-service.js","sourceRoot":"","sources":["../../source/theme/theme-service.ts"],"names":[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