@tstdl/base 0.71.18 → 0.71.21
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.
|
@@ -3,7 +3,6 @@ export declare type ThemeEntry<Name extends string = string> = string | {
|
|
|
3
3
|
color: string;
|
|
4
4
|
};
|
|
5
5
|
export declare type Theme<T extends Record<string, ThemeEntry> = Record<string, ThemeEntry>> = {
|
|
6
|
-
isDark?: boolean;
|
|
7
6
|
colors: T;
|
|
8
7
|
};
|
|
9
8
|
export declare function createTheme<T extends Theme>(theme: T): T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.model.js","sourceRoot":"","sources":["../../../source/css/theme/theme.model.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"theme.model.js","sourceRoot":"","sources":["../../../source/css/theme/theme.model.ts"],"names":[],"mappings":";;;AASA,SAAgB,WAAW,CAAkB,KAAQ;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AAFD,kCAEC"}
|
|
@@ -15,10 +15,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
15
15
|
exports.ThemeService = void 0;
|
|
16
16
|
const container_1 = require("../../container");
|
|
17
17
|
const tokens_1 = require("../../tokens");
|
|
18
|
-
const array_1 = require("../../utils/array/array");
|
|
19
18
|
const type_guards_1 = require("../../utils/type-guards");
|
|
20
19
|
const chroma = require("chroma-js");
|
|
21
|
-
const paletteNumbers = [50, ...(0, array_1.createArray)(9, (index) => (100 + (100 * index)))];
|
|
22
20
|
let ThemeService = class ThemeService {
|
|
23
21
|
constructor(document) {
|
|
24
22
|
this.styleElement = document.createElement('style');
|
|
@@ -59,20 +57,33 @@ ThemeService = __decorate([
|
|
|
59
57
|
], ThemeService);
|
|
60
58
|
exports.ThemeService = ThemeService;
|
|
61
59
|
function buildThemeRules(theme) {
|
|
62
|
-
var _a
|
|
60
|
+
var _a;
|
|
63
61
|
const rules = [];
|
|
64
62
|
for (const [colorName, value] of Object.entries(theme.colors)) {
|
|
65
63
|
const name = (0, type_guards_1.isString)(value) ? colorName : ((_a = value.name) !== null && _a !== void 0 ? _a : colorName);
|
|
66
64
|
const color = (0, type_guards_1.isString)(value) ? value : value.color;
|
|
67
|
-
const colorRules = generatePaletteVariableDeclarations(name,
|
|
65
|
+
const colorRules = generatePaletteVariableDeclarations(name, color);
|
|
68
66
|
rules.push(...colorRules);
|
|
69
67
|
}
|
|
70
68
|
return rules;
|
|
71
69
|
}
|
|
72
|
-
function generatePaletteVariableDeclarations(paletteName,
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
70
|
+
function generatePaletteVariableDeclarations(paletteName, color) {
|
|
71
|
+
const chromaColor = chroma(color);
|
|
72
|
+
const [hue, saturation, lightness] = chromaColor.hsl();
|
|
73
|
+
const colors = {
|
|
74
|
+
50: chroma.hsl(hue, saturation, lightness + 0.40).css(),
|
|
75
|
+
100: chroma.hsl(hue, saturation, lightness + 0.32).css(),
|
|
76
|
+
200: chroma.hsl(hue, saturation, lightness + 0.24).css(),
|
|
77
|
+
300: chroma.hsl(hue, saturation, lightness + 0.16).css(),
|
|
78
|
+
400: chroma.hsl(hue, saturation, lightness + 0.08).css(),
|
|
79
|
+
500: chromaColor.css(),
|
|
80
|
+
600: chroma.hsl(hue, saturation, lightness - 0.11).css(),
|
|
81
|
+
700: chroma.hsl(hue, saturation, lightness - 0.22).css(),
|
|
82
|
+
800: chroma.hsl(hue, saturation, lightness - 0.33).css(),
|
|
83
|
+
900: chroma.hsl(hue, saturation, lightness - 0.44).css()
|
|
84
|
+
};
|
|
85
|
+
const colorEntries = Object.entries(colors);
|
|
86
|
+
const variables = [[`--color-${paletteName}`, colors[500]], ...colorEntries.map(([number, numberColor]) => [`--color-${paletteName}-${number}`, numberColor])];
|
|
76
87
|
const variableDeclarations = variables.map(([name, value]) => `${name}: ${value};`);
|
|
77
88
|
return variableDeclarations;
|
|
78
89
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../../source/css/theme/theme.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAChD,yCAAoC;AACpC,
|
|
1
|
+
{"version":3,"file":"theme.service.js","sourceRoot":"","sources":["../../../source/css/theme/theme.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAgD;AAChD,yCAAoC;AACpC,yDAA0D;AAC1D,oCAAoC;AAIpC,IAAa,YAAY,GAAzB,MAAa,YAAY;IAGvB,YAA8B,QAAkB;QAC9C,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACpD,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC/C,CAAC;IAED,QAAQ,CAAC,KAAY,EAAE,SAAiB;QACtC,MAAM,UAAU,GAAG,eAAe,CAAC,KAAK,CAAC,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAA,uBAAS,EAAC,SAAS,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACzE,MAAM,gBAAgB,GAAG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/C,MAAM,eAAe,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,YAAY,CAAC,SAAS,GAAG;;;MAG5B,gBAAgB;;;;MAIhB,eAAe;;;;;;MAMf,eAAe;;;;MAIf,gBAAgB;;;CAGrB,CAAC;IACA,CAAC;CACF,CAAA;AApCY,YAAY;IADxB,IAAA,qBAAS,GAAE;IAIG,WAAA,IAAA,kBAAM,EAAC,iBAAQ,CAAC,CAAA;qCAAW,QAAQ;GAHrC,YAAY,CAoCxB;AApCY,oCAAY;AAsCzB,SAAS,eAAe,CAAC,KAAY;;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;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