@skbkontur/colors 2.0.0-alpha.3 → 2.0.0-alpha.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.
- package/README.md +3 -3
- package/colors.d.ts +319 -0
- package/colors.js +319 -0
- package/colors.less +319 -0
- package/colors.scss +319 -0
- package/lib/consts/default-swatch.d.ts +108 -0
- package/lib/consts/default-swatch.js +108 -0
- package/{dist/esm/consts/default-swatch.js → lib/consts/default-swatch.ts} +11 -7
- package/lib/consts/params/abney-correction.js +1102 -0
- package/{dist/esm/consts/params/abney-correction.js → lib/consts/params/abney-correction.ts} +3 -1
- package/lib/consts/params/chroma-params.js +102 -0
- package/{dist/esm/consts/params/chroma-params.js → lib/consts/params/chroma-params.ts} +3 -1
- package/lib/consts/params/interactions.ts +9 -0
- package/lib/consts/params/logo-lightness.ts +1 -0
- package/{dist/esm → lib}/consts/params/promo-hue-shift.d.ts +1 -1
- package/lib/consts/params/promo-hue-shift.js +11 -0
- package/{dist/esm/consts/params/promo-hue-shift.js → lib/consts/params/promo-hue-shift.ts} +1 -1
- package/{dist/esm → lib}/consts/params/warning-hue-patch.d.ts +1 -1
- package/lib/consts/params/warning-hue-patch.js +22 -0
- package/{dist/esm/consts/params/warning-hue-patch.js → lib/consts/params/warning-hue-patch.ts} +1 -1
- package/lib/get-colors-base.d.ts +11 -0
- package/lib/get-colors-base.js +78 -0
- package/{dist/esm/get-colors-base.js → lib/get-colors-base.ts} +44 -26
- package/lib/get-colors-default-tokens.d.ts +645 -0
- package/lib/get-colors-default-tokens.js +647 -0
- package/lib/get-colors-default-tokens.ts +646 -0
- package/lib/get-colors.d.ts +39 -0
- package/lib/get-colors.js +24 -0
- package/lib/get-colors.ts +59 -0
- package/{dist/esm → lib}/helpers/get-interactions.d.ts +2 -2
- package/lib/helpers/get-interactions.js +35 -0
- package/lib/helpers/get-interactions.ts +64 -0
- package/{dist/esm → lib}/helpers/get-logo.d.ts +2 -2
- package/lib/helpers/get-logo.js +25 -0
- package/lib/helpers/get-logo.ts +40 -0
- package/lib/helpers/get-palette.d.ts +51 -0
- package/lib/helpers/get-palette.js +204 -0
- package/lib/helpers/get-palette.ts +261 -0
- package/lib/helpers/get-promo.d.ts +6 -0
- package/lib/helpers/get-promo.js +47 -0
- package/lib/helpers/get-promo.ts +55 -0
- package/lib/types/tokens-base-generator.d.ts +43 -0
- package/{dist/esm/types/tokens-base-generator.d.ts → lib/types/tokens-base-generator.ts} +10 -15
- package/lib/types/tokens-base.d.ts +55 -0
- package/{dist/esm/types/tokens-base.d.ts → lib/types/tokens-base.ts} +7 -2
- package/lib/types/tokens.d.ts +12 -0
- package/{dist/esm/types/tokens.d.ts → lib/types/tokens.ts} +6 -0
- package/lib/utils/convert-color.js +144 -0
- package/lib/utils/convert-color.ts +163 -0
- package/lib/utils/format-variable.js +6 -0
- package/lib/utils/format-variable.ts +7 -0
- package/package.json +66 -7
- package/{dist/tokens → tokens}/brand-blue-deep_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-blue-deep_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-blue_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-blue_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-green_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-green_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-mint_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-mint_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-orange_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-purple_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-purple_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-red_accent-gray.css +2 -2
- package/{dist/tokens → tokens}/brand-violet_accent-brand.css +2 -2
- package/{dist/tokens → tokens}/brand-violet_accent-gray.css +2 -2
- package/{dist/tokens-mobile → tokens-mobile}/brand-blue-deep_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-blue-deep_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-blue_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-blue_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-green_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-green_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-mint_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-mint_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-orange_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-purple_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-purple_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-red_accent-gray.json +135 -135
- package/{dist/tokens-mobile → tokens-mobile}/brand-violet_accent-brand.json +117 -117
- package/{dist/tokens-mobile → tokens-mobile}/brand-violet_accent-gray.json +135 -135
- package/CHANGELOG.md +0 -84
- package/dist/colors.default-dark.js +0 -332
- package/dist/colors.default-light.js +0 -336
- package/dist/colors.less +0 -319
- package/dist/colors.scss +0 -319
- package/dist/esm/consts/default-swatch.d.ts +0 -109
- package/dist/esm/get-colors-base.d.ts +0 -12
- package/dist/esm/get-colors-default-tokens.d.ts +0 -645
- package/dist/esm/get-colors-default-tokens.js +0 -992
- package/dist/esm/get-colors.d.ts +0 -13
- package/dist/esm/get-colors.js +0 -14
- package/dist/esm/get-default-tokens.d.ts +0 -645
- package/dist/esm/get-default-tokens.js +0 -992
- package/dist/esm/helpers/get-interactions.js +0 -49
- package/dist/esm/helpers/get-logo.js +0 -28
- package/dist/esm/helpers/get-palette.d.ts +0 -76
- package/dist/esm/helpers/get-palette.js +0 -232
- package/dist/esm/helpers/get-promo.d.ts +0 -12
- package/dist/esm/helpers/get-promo.js +0 -51
- package/dist/esm/utils/convert-color.js +0 -133
- package/dist/esm/utils/format-variable.js +0 -10
- package/dist/tokens-js/brand-blue-deep_accent-brand.js +0 -644
- package/dist/tokens-js/brand-blue-deep_accent-gray.js +0 -644
- package/dist/tokens-js/brand-blue_accent-brand.js +0 -644
- package/dist/tokens-js/brand-blue_accent-gray.js +0 -644
- package/dist/tokens-js/brand-green_accent-brand.js +0 -644
- package/dist/tokens-js/brand-green_accent-gray.js +0 -644
- package/dist/tokens-js/brand-mint_accent-brand.js +0 -644
- package/dist/tokens-js/brand-mint_accent-gray.js +0 -644
- package/dist/tokens-js/brand-orange_accent-gray.js +0 -644
- package/dist/tokens-js/brand-purple_accent-brand.js +0 -644
- package/dist/tokens-js/brand-purple_accent-gray.js +0 -644
- package/dist/tokens-js/brand-red_accent-gray.js +0 -644
- package/dist/tokens-js/brand-violet_accent-brand.js +0 -644
- package/dist/tokens-js/brand-violet_accent-gray.js +0 -644
- package/scripts/babel-register.js +0 -4
- package/scripts/tokens-base.json +0 -3499
- package/scripts/tokens.json +0 -710
- /package/{dist/colors.js → colors.ts} +0 -0
- /package/{dist/esm → lib}/consts/params/abney-correction.d.ts +0 -0
- /package/{dist/esm → lib}/consts/params/chroma-params.d.ts +0 -0
- /package/{dist/esm → lib}/consts/params/interactions.d.ts +0 -0
- /package/{dist/esm → lib}/consts/params/interactions.js +0 -0
- /package/{dist/esm → lib}/consts/params/logo-lightness.d.ts +0 -0
- /package/{dist/esm → lib}/consts/params/logo-lightness.js +0 -0
- /package/{dist/esm → lib}/types/tokens-base-generator.js +0 -0
- /package/{dist/esm → lib}/types/tokens-base.js +0 -0
- /package/{dist/esm → lib}/types/tokens.js +0 -0
- /package/{dist/esm → lib}/utils/convert-color.d.ts +0 -0
- /package/{dist/esm → lib}/utils/format-variable.d.ts +0 -0
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
export var CHROMA_PARAMS = {
|
|
2
|
+
20: {
|
|
3
|
+
vivid: { rel: 100, max: 12 },
|
|
4
|
+
normal: { rel: 66, min: 4.4, max: 8 },
|
|
5
|
+
dim: { rel: 46, min: 2, max: 4.4 },
|
|
6
|
+
},
|
|
7
|
+
24: {
|
|
8
|
+
vivid: { rel: 100, max: 14.2 },
|
|
9
|
+
normal: { rel: 68, min: 5.7, max: 10 },
|
|
10
|
+
dim: { rel: 48, min: 2.8, max: 5.7 },
|
|
11
|
+
},
|
|
12
|
+
28: {
|
|
13
|
+
vivid: { rel: 100, max: 15.8 },
|
|
14
|
+
normal: { rel: 70, min: 7, max: 11.8 },
|
|
15
|
+
dim: { rel: 50, min: 3.6, max: 7 },
|
|
16
|
+
},
|
|
17
|
+
32: {
|
|
18
|
+
vivid: { rel: 100, max: 17.1 },
|
|
19
|
+
normal: { rel: 72, min: 8.2, max: 13.2 },
|
|
20
|
+
dim: { rel: 52, min: 4.4, max: 8.2 },
|
|
21
|
+
},
|
|
22
|
+
36: {
|
|
23
|
+
vivid: { rel: 100, max: 18 },
|
|
24
|
+
normal: { rel: 74, min: 9.4, max: 14.4 },
|
|
25
|
+
dim: { rel: 54, min: 5.2, max: 9.4 },
|
|
26
|
+
},
|
|
27
|
+
40: {
|
|
28
|
+
vivid: { rel: 100, max: 18.8 },
|
|
29
|
+
normal: { rel: 76, min: 10.6, max: 15.6 },
|
|
30
|
+
dim: { rel: 56, min: 6, max: 10.6 },
|
|
31
|
+
},
|
|
32
|
+
44: {
|
|
33
|
+
vivid: { rel: 100, max: 19.6 },
|
|
34
|
+
normal: { rel: 78, min: 11.7, max: 16.6 },
|
|
35
|
+
dim: { rel: 58, min: 6.8, max: 11.7 },
|
|
36
|
+
},
|
|
37
|
+
48: {
|
|
38
|
+
vivid: { rel: 100, max: 20.3 },
|
|
39
|
+
normal: { rel: 80, min: 12.8, max: 17.5 },
|
|
40
|
+
dim: { rel: 60, min: 7.6, max: 12.8 },
|
|
41
|
+
},
|
|
42
|
+
52: {
|
|
43
|
+
vivid: { rel: 100, max: 21 },
|
|
44
|
+
normal: { rel: 82, min: 13.9, max: 18.4 },
|
|
45
|
+
dim: { rel: 62, min: 8.4, max: 13.9 },
|
|
46
|
+
},
|
|
47
|
+
56: {
|
|
48
|
+
vivid: { rel: 100, max: 21.6 },
|
|
49
|
+
normal: { rel: 84, min: 15, max: 19.2 },
|
|
50
|
+
dim: { rel: 64, min: 9.2, max: 15 },
|
|
51
|
+
},
|
|
52
|
+
60: {
|
|
53
|
+
vivid: { rel: 100, max: 22 },
|
|
54
|
+
normal: { rel: 86, min: 15.9, max: 19.9 },
|
|
55
|
+
dim: { rel: 66, min: 9.9, max: 15.9 },
|
|
56
|
+
},
|
|
57
|
+
64: {
|
|
58
|
+
vivid: { rel: 100, max: 22.2 },
|
|
59
|
+
normal: { rel: 88, min: 16.2, max: 20.2 },
|
|
60
|
+
dim: { rel: 68, min: 10.2, max: 16.2 },
|
|
61
|
+
},
|
|
62
|
+
68: {
|
|
63
|
+
vivid: { rel: 100, max: 21.9 },
|
|
64
|
+
normal: { rel: 90, min: 15.8, max: 19.8 },
|
|
65
|
+
dim: { rel: 70, min: 9.6, max: 15.8 },
|
|
66
|
+
},
|
|
67
|
+
72: {
|
|
68
|
+
vivid: { rel: 100, max: 21.2 },
|
|
69
|
+
normal: { rel: 92, min: 14.8, max: 18.8 },
|
|
70
|
+
dim: { rel: 72, min: 8.4, max: 14.8 },
|
|
71
|
+
},
|
|
72
|
+
76: {
|
|
73
|
+
vivid: { rel: 100, max: 20.3 },
|
|
74
|
+
normal: { rel: 90, min: 13.1, max: 17.5 },
|
|
75
|
+
dim: { rel: 70, min: 7, max: 13.1 },
|
|
76
|
+
},
|
|
77
|
+
80: {
|
|
78
|
+
vivid: { rel: 100, max: 19 },
|
|
79
|
+
normal: { rel: 88, min: 11.2, max: 15.6 },
|
|
80
|
+
dim: { rel: 68, min: 5.6, max: 11.2 },
|
|
81
|
+
},
|
|
82
|
+
84: {
|
|
83
|
+
vivid: { rel: 100, max: 17.1 },
|
|
84
|
+
normal: { rel: 86, min: 9, max: 13.4 },
|
|
85
|
+
dim: { rel: 66, min: 4.4, max: 9 },
|
|
86
|
+
},
|
|
87
|
+
88: {
|
|
88
|
+
vivid: { rel: 100, max: 14.2 },
|
|
89
|
+
normal: { rel: 84, min: 6.7, max: 10.4 },
|
|
90
|
+
dim: { rel: 64, min: 3.2, max: 6.7 },
|
|
91
|
+
},
|
|
92
|
+
92: {
|
|
93
|
+
vivid: { rel: 100, max: 11 },
|
|
94
|
+
normal: { rel: 82, min: 4.4, max: 7.4 },
|
|
95
|
+
dim: { rel: 62, min: 2.2, max: 4.4 },
|
|
96
|
+
},
|
|
97
|
+
96: {
|
|
98
|
+
vivid: { rel: 100, max: 7 },
|
|
99
|
+
normal: { rel: 80, min: 2.6, max: 4.4 },
|
|
100
|
+
dim: { rel: 60, min: 1.5, max: 2.6 },
|
|
101
|
+
},
|
|
102
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import type { GeneratorColorChromaParamsGroup } from '../../types/tokens-base-generator.js';
|
|
2
|
+
|
|
3
|
+
export const CHROMA_PARAMS: GeneratorColorChromaParamsGroup = {
|
|
2
4
|
20: {
|
|
3
5
|
vivid: { rel: 100, max: 12 },
|
|
4
6
|
normal: { rel: 66, min: 4.4, max: 8 },
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const HOVER_LIGHT_L = -4;
|
|
2
|
+
export const HOVER_LIGHT_C = 0;
|
|
3
|
+
export const HOVER_DARK_L = +4;
|
|
4
|
+
export const HOVER_DARK_C = 0;
|
|
5
|
+
|
|
6
|
+
export const PRESSED_LIGHT_L = -8;
|
|
7
|
+
export const PRESSED_LIGHT_C = -0.03;
|
|
8
|
+
export const PRESSED_DARK_L = -4;
|
|
9
|
+
export const PRESSED_DARK_C = -0.03;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const LOGO_LIGHTNESS_MIN = 64;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export var WARNING_HUE_PATCH = {
|
|
2
|
+
96: 0,
|
|
3
|
+
92: 0,
|
|
4
|
+
88: 0,
|
|
5
|
+
84: 0,
|
|
6
|
+
80: 0,
|
|
7
|
+
76: 0,
|
|
8
|
+
72: -4,
|
|
9
|
+
68: -8,
|
|
10
|
+
64: -12,
|
|
11
|
+
60: -8,
|
|
12
|
+
56: -4,
|
|
13
|
+
52: -2,
|
|
14
|
+
48: 0,
|
|
15
|
+
44: 0,
|
|
16
|
+
40: 0,
|
|
17
|
+
36: 0,
|
|
18
|
+
32: 0,
|
|
19
|
+
28: 0,
|
|
20
|
+
24: 0,
|
|
21
|
+
20: 0,
|
|
22
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ColorFormat } from './utils/convert-color.js';
|
|
2
|
+
import * as DEFAULT_SWATCH from './consts/default-swatch.js';
|
|
3
|
+
import type { TokensBase } from './types/tokens-base.js';
|
|
4
|
+
export type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
|
|
5
|
+
export interface ConfigOptions {
|
|
6
|
+
brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
|
|
7
|
+
accent: PresetOrCustom<'brand' | 'gray'>;
|
|
8
|
+
system?: typeof DEFAULT_SWATCH.system;
|
|
9
|
+
format?: ColorFormat;
|
|
10
|
+
}
|
|
11
|
+
export declare function getColorsBase({ brand, accent, system, format, }: ConfigOptions): TokensBase;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { calcOnBrand, getPalette } from './helpers/get-palette.js';
|
|
2
|
+
import { getHover, getPressed } from './helpers/get-interactions.js';
|
|
3
|
+
import { getLogo } from './helpers/get-logo.js';
|
|
4
|
+
import { getPromo } from './helpers/get-promo.js';
|
|
5
|
+
import { convertColorFormat } from './utils/convert-color.js';
|
|
6
|
+
import * as DEFAULT_SWATCH from './consts/default-swatch.js';
|
|
7
|
+
export function getColorsBase(_a) {
|
|
8
|
+
var brand = _a.brand, accent = _a.accent, _b = _a.system, system = _b === void 0 ? DEFAULT_SWATCH.system : _b, _c = _a.format, format = _c === void 0 ? 'hex/rgba' : _c;
|
|
9
|
+
var isPresetColor = brand in DEFAULT_SWATCH.brand;
|
|
10
|
+
var brandColor;
|
|
11
|
+
if (isPresetColor) {
|
|
12
|
+
brandColor = DEFAULT_SWATCH.brand[brand];
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
brandColor = brand;
|
|
16
|
+
}
|
|
17
|
+
var accentColor;
|
|
18
|
+
if (accent === 'brand') {
|
|
19
|
+
accentColor = brandColor;
|
|
20
|
+
}
|
|
21
|
+
else if (accent !== 'gray') {
|
|
22
|
+
accentColor = accent;
|
|
23
|
+
}
|
|
24
|
+
var brandPalette = getPalette({ color: brandColor });
|
|
25
|
+
var accentPalette;
|
|
26
|
+
if (accent === 'brand') {
|
|
27
|
+
accentPalette = brandPalette;
|
|
28
|
+
}
|
|
29
|
+
else if (accent !== 'gray' && accentColor) {
|
|
30
|
+
accentPalette = getPalette({ color: accentColor });
|
|
31
|
+
}
|
|
32
|
+
var customizablePalettes = {};
|
|
33
|
+
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
34
|
+
var key = colorKey;
|
|
35
|
+
if (key === brand && isPresetColor) {
|
|
36
|
+
customizablePalettes[key] = brandPalette;
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
customizablePalettes[key] = getPalette({
|
|
40
|
+
color: DEFAULT_SWATCH.customizable[key],
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
var result = {
|
|
44
|
+
brand: {
|
|
45
|
+
logo: getLogo(brandColor),
|
|
46
|
+
promo: getPromo(brandColor),
|
|
47
|
+
original: brandColor,
|
|
48
|
+
interactions: {
|
|
49
|
+
hover: getHover(brandColor),
|
|
50
|
+
pressed: getPressed(brandColor),
|
|
51
|
+
},
|
|
52
|
+
palette: brandPalette,
|
|
53
|
+
},
|
|
54
|
+
accent: accentColor
|
|
55
|
+
? {
|
|
56
|
+
original: {
|
|
57
|
+
light: accentColor,
|
|
58
|
+
dark: accentColor,
|
|
59
|
+
},
|
|
60
|
+
interactions: {
|
|
61
|
+
hover: getHover(accentColor),
|
|
62
|
+
pressed: getPressed(accentColor),
|
|
63
|
+
},
|
|
64
|
+
palette: accentPalette,
|
|
65
|
+
}
|
|
66
|
+
: undefined,
|
|
67
|
+
warning: getPalette({ color: system.warning }),
|
|
68
|
+
error: getPalette({ color: system.error }),
|
|
69
|
+
success: getPalette({ color: system.success }),
|
|
70
|
+
gray: DEFAULT_SWATCH.gray,
|
|
71
|
+
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
72
|
+
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
73
|
+
onBrand: calcOnBrand(brandColor),
|
|
74
|
+
onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
|
|
75
|
+
customizable: customizablePalettes,
|
|
76
|
+
};
|
|
77
|
+
return convertColorFormat(result, format);
|
|
78
|
+
}
|
|
@@ -2,48 +2,65 @@ import { calcOnBrand, getPalette } from './helpers/get-palette.js';
|
|
|
2
2
|
import { getHover, getPressed } from './helpers/get-interactions.js';
|
|
3
3
|
import { getLogo } from './helpers/get-logo.js';
|
|
4
4
|
import { getPromo } from './helpers/get-promo.js';
|
|
5
|
-
import { convertColorFormat } from './utils/convert-color.js';
|
|
5
|
+
import { type ColorFormat, convertColorFormat } from './utils/convert-color.js';
|
|
6
|
+
import { type ColorStructure } from './types/tokens.js';
|
|
6
7
|
import * as DEFAULT_SWATCH from './consts/default-swatch.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
8
|
+
import type { TokensBase, ColorPalette } from './types/tokens-base.js';
|
|
9
|
+
|
|
10
|
+
export type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
|
|
11
|
+
|
|
12
|
+
export interface ConfigOptions {
|
|
13
|
+
brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
|
|
14
|
+
accent: PresetOrCustom<'brand' | 'gray'>;
|
|
15
|
+
system?: typeof DEFAULT_SWATCH.system;
|
|
16
|
+
format?: ColorFormat;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function getColorsBase({
|
|
20
|
+
brand,
|
|
21
|
+
accent,
|
|
22
|
+
system = DEFAULT_SWATCH.system,
|
|
23
|
+
format = 'hex/rgba',
|
|
24
|
+
}: ConfigOptions): TokensBase {
|
|
25
|
+
const isPresetColor = brand in DEFAULT_SWATCH.brand;
|
|
26
|
+
let brandColor;
|
|
17
27
|
if (isPresetColor) {
|
|
18
|
-
brandColor = DEFAULT_SWATCH.brand[brand];
|
|
28
|
+
brandColor = DEFAULT_SWATCH.brand[brand as keyof typeof DEFAULT_SWATCH.brand];
|
|
19
29
|
} else {
|
|
20
30
|
brandColor = brand;
|
|
21
31
|
}
|
|
22
|
-
|
|
32
|
+
|
|
33
|
+
let accentColor;
|
|
23
34
|
if (accent === 'brand') {
|
|
24
35
|
accentColor = brandColor;
|
|
25
36
|
} else if (accent !== 'gray') {
|
|
26
37
|
accentColor = accent;
|
|
27
38
|
}
|
|
28
|
-
|
|
29
|
-
|
|
39
|
+
|
|
40
|
+
const brandPalette = getPalette({ color: brandColor }) as ColorPalette;
|
|
41
|
+
let accentPalette;
|
|
30
42
|
if (accent === 'brand') {
|
|
31
43
|
accentPalette = brandPalette;
|
|
32
44
|
} else if (accent !== 'gray' && accentColor) {
|
|
33
|
-
accentPalette = getPalette({ color: accentColor });
|
|
45
|
+
accentPalette = getPalette({ color: accentColor }) as ColorPalette;
|
|
34
46
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
|
|
48
|
+
const customizablePalettes: TokensBase['customizable'] = {} as TokensBase['customizable'];
|
|
49
|
+
|
|
50
|
+
for (const colorKey in DEFAULT_SWATCH.customizable) {
|
|
51
|
+
const key = colorKey as keyof TokensBase['customizable'];
|
|
52
|
+
|
|
38
53
|
if (key === brand && isPresetColor) {
|
|
39
54
|
customizablePalettes[key] = brandPalette;
|
|
40
55
|
continue;
|
|
41
56
|
}
|
|
57
|
+
|
|
42
58
|
customizablePalettes[key] = getPalette({
|
|
43
59
|
color: DEFAULT_SWATCH.customizable[key],
|
|
44
|
-
});
|
|
60
|
+
}) as ColorPalette;
|
|
45
61
|
}
|
|
46
|
-
|
|
62
|
+
|
|
63
|
+
const result = {
|
|
47
64
|
brand: {
|
|
48
65
|
logo: getLogo(brandColor),
|
|
49
66
|
promo: getPromo(brandColor),
|
|
@@ -67,15 +84,16 @@ export function getColorsBase(_a) {
|
|
|
67
84
|
palette: accentPalette,
|
|
68
85
|
}
|
|
69
86
|
: undefined,
|
|
70
|
-
warning: getPalette({ color: system.warning }),
|
|
71
|
-
error: getPalette({ color: system.error }),
|
|
72
|
-
success: getPalette({ color: system.success }),
|
|
87
|
+
warning: getPalette({ color: system.warning }) as ColorPalette,
|
|
88
|
+
error: getPalette({ color: system.error }) as ColorPalette,
|
|
89
|
+
success: getPalette({ color: system.success }) as ColorPalette,
|
|
73
90
|
gray: DEFAULT_SWATCH.gray,
|
|
74
91
|
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
75
92
|
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
76
93
|
onBrand: calcOnBrand(brandColor),
|
|
77
94
|
onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
|
|
78
95
|
customizable: customizablePalettes,
|
|
79
|
-
};
|
|
80
|
-
|
|
96
|
+
} as unknown as ColorStructure;
|
|
97
|
+
|
|
98
|
+
return convertColorFormat(result, format) as unknown as TokensBase;
|
|
81
99
|
}
|