@skbkontur/colors 1.1.2-d1791.0 → 2.0.0-alpha.0
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/dist/cjs/constants/abney-correction.js +1102 -1102
- package/dist/cjs/constants/chroma-settings.js +102 -102
- package/dist/cjs/constants/default-swatch.d.ts +97 -95
- package/dist/cjs/constants/default-swatch.js +99 -97
- package/dist/cjs/constants/interaction-settings.d.ts +8 -0
- package/dist/cjs/constants/interaction-settings.js +19 -0
- package/dist/cjs/constants/logo-lightness.js +2 -2
- package/dist/cjs/constants/promo-hue-shift.d.ts +1 -1
- package/dist/cjs/constants/promo-hue-shift.js +11 -11
- package/dist/cjs/constants/warning-hue-patch.d.ts +1 -1
- package/dist/cjs/constants/warning-hue-patch.js +22 -22
- package/dist/cjs/get-base-tokens.d.ts +11 -9
- package/dist/cjs/get-base-tokens.js +178 -202
- package/dist/cjs/get-colors.d.ts +19 -0
- package/dist/cjs/get-colors.js +16 -0
- package/dist/cjs/get-default-tokens.d.ts +642 -1275
- package/dist/cjs/get-default-tokens.js +993 -1280
- package/dist/cjs/helpers/get-interactions.d.ts +7 -0
- package/dist/cjs/helpers/get-interactions.js +61 -0
- package/dist/cjs/helpers/get-logo.d.ts +2 -2
- package/dist/cjs/helpers/get-logo.js +28 -25
- package/dist/cjs/helpers/get-palette.d.ts +69 -42
- package/dist/cjs/helpers/get-palette.js +249 -204
- package/dist/cjs/helpers/get-promo.d.ts +10 -4
- package/dist/cjs/helpers/get-promo.js +48 -50
- package/dist/cjs/types/base-tokens.d.ts +115 -43
- package/dist/cjs/types/base-tokens.js +2 -2
- package/dist/cjs/types/generator-tokens.d.ts +30 -30
- package/dist/cjs/types/generator-tokens.js +2 -2
- package/dist/cjs/utils/format-variable.d.ts +2 -0
- package/dist/cjs/utils/format-variable.js +15 -0
- package/dist/colors.default-dark.js +325 -0
- package/dist/colors.default-light.js +326 -0
- package/dist/colors.js +319 -0
- package/dist/colors.less +319 -0
- package/dist/colors.scss +319 -0
- package/dist/esm/constants/abney-correction.js +1100 -1100
- package/dist/esm/constants/chroma-settings.js +100 -100
- package/dist/esm/constants/default-swatch.d.ts +97 -95
- package/dist/esm/constants/default-swatch.js +97 -95
- package/dist/esm/constants/interaction-settings.d.ts +8 -0
- package/dist/esm/constants/interaction-settings.js +8 -0
- package/dist/esm/constants/promo-hue-shift.d.ts +1 -1
- package/dist/esm/constants/promo-hue-shift.js +9 -9
- package/dist/esm/constants/warning-hue-patch.d.ts +1 -1
- package/dist/esm/constants/warning-hue-patch.js +20 -20
- package/dist/esm/get-base-tokens.d.ts +11 -9
- package/dist/esm/get-base-tokens.js +130 -172
- package/dist/esm/get-colors.d.ts +19 -0
- package/dist/esm/get-colors.js +12 -0
- package/dist/esm/get-default-tokens.d.ts +642 -1275
- package/dist/esm/get-default-tokens.js +991 -1278
- package/dist/esm/helpers/get-interactions.d.ts +7 -0
- package/dist/esm/helpers/get-interactions.js +49 -0
- package/dist/esm/helpers/get-logo.d.ts +2 -2
- package/dist/esm/helpers/get-logo.js +24 -21
- package/dist/esm/helpers/get-palette.d.ts +69 -42
- package/dist/esm/helpers/get-palette.js +197 -175
- package/dist/esm/helpers/get-promo.d.ts +10 -4
- package/dist/esm/helpers/get-promo.js +44 -46
- package/dist/esm/types/base-tokens.d.ts +115 -43
- package/dist/esm/types/generator-tokens.d.ts +30 -30
- package/dist/esm/utils/format-variable.d.ts +2 -0
- package/dist/esm/utils/format-variable.js +10 -0
- package/dist/tokens/brand-blue-deep_accent-brand.css +643 -0
- package/dist/tokens/brand-blue-deep_accent-gray.css +643 -0
- package/dist/tokens/brand-blue_accent-brand.css +643 -0
- package/dist/tokens/brand-blue_accent-gray.css +643 -0
- package/dist/tokens/brand-green_accent-brand.css +643 -0
- package/dist/tokens/brand-green_accent-gray.css +643 -0
- package/dist/tokens/brand-mint_accent-brand.css +643 -0
- package/dist/tokens/brand-mint_accent-gray.css +643 -0
- package/dist/tokens/brand-orange_accent-gray.css +643 -0
- package/dist/tokens/brand-purple_accent-brand.css +643 -0
- package/dist/tokens/brand-purple_accent-gray.css +643 -0
- package/dist/tokens/brand-red_accent-gray.css +643 -0
- package/dist/tokens/brand-violet_accent-brand.css +643 -0
- package/dist/tokens/brand-violet_accent-gray.css +643 -0
- package/dist/tokens-js/brand-blue-deep_accent-brand.js +644 -0
- package/dist/tokens-js/brand-blue-deep_accent-gray.js +644 -0
- package/dist/tokens-js/brand-blue_accent-brand.js +644 -0
- package/dist/tokens-js/brand-blue_accent-gray.js +644 -0
- package/dist/tokens-js/brand-green_accent-brand.js +644 -0
- package/dist/tokens-js/brand-green_accent-gray.js +644 -0
- package/dist/tokens-js/brand-mint_accent-brand.js +644 -0
- package/dist/tokens-js/brand-mint_accent-gray.js +644 -0
- package/dist/tokens-js/brand-orange_accent-gray.js +644 -0
- package/dist/tokens-js/brand-purple_accent-brand.js +644 -0
- package/dist/tokens-js/brand-purple_accent-gray.js +644 -0
- package/dist/tokens-js/brand-red_accent-gray.js +644 -0
- package/dist/tokens-js/brand-violet_accent-brand.js +644 -0
- package/dist/tokens-js/brand-violet_accent-gray.js +644 -0
- package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-blue_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-blue_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-green_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-green_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-mint_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-mint_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-orange_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-purple_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-purple_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-red_accent-gray.json +718 -0
- package/dist/tokens-mobile/brand-violet_accent-brand.json +718 -0
- package/dist/tokens-mobile/brand-violet_accent-gray.json +718 -0
- package/package.json +7 -6
- package/dist/cjs/get-tokens.d.ts +0 -15
- package/dist/cjs/get-tokens.js +0 -13
- package/dist/esm/get-tokens.d.ts +0 -15
- package/dist/esm/get-tokens.js +0 -9
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
export declare function getPromo(
|
|
1
|
+
export declare function getPromo(
|
|
2
|
+
color: string,
|
|
3
|
+
hueShifts?: {
|
|
2
4
|
[hueRange: number]: number;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
+
}
|
|
6
|
+
): string;
|
|
7
|
+
export declare function getPromoHueShift(
|
|
8
|
+
currentHue: number,
|
|
9
|
+
promoHueShifts: {
|
|
5
10
|
[hueRange: number]: number;
|
|
6
|
-
}
|
|
11
|
+
}
|
|
12
|
+
): number;
|
|
@@ -1,53 +1,51 @@
|
|
|
1
1
|
import { clampChroma, converter, formatHex } from 'culori';
|
|
2
2
|
import { PROMO_HUE_SHIFTS } from '../constants/promo-hue-shift';
|
|
3
3
|
export function getPromo(color, hueShifts) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
catch (error) {
|
|
31
|
-
console.error('Error generating promo palette:', error);
|
|
32
|
-
return '';
|
|
33
|
-
}
|
|
4
|
+
if (hueShifts === void 0) {
|
|
5
|
+
hueShifts = PROMO_HUE_SHIFTS;
|
|
6
|
+
}
|
|
7
|
+
var toOklch = converter('oklch');
|
|
8
|
+
var oklchColor = toOklch(color);
|
|
9
|
+
if (!oklchColor) {
|
|
10
|
+
throw new Error('Invalid color string: '.concat(color));
|
|
11
|
+
}
|
|
12
|
+
var currentHue = oklchColor.h;
|
|
13
|
+
var promoHueShift = getPromoHueShift(currentHue, hueShifts);
|
|
14
|
+
var correctedHue = (currentHue + promoHueShift + 360) % 360;
|
|
15
|
+
var promoLightness = oklchColor.l * 100;
|
|
16
|
+
if (promoLightness >= 50) {
|
|
17
|
+
promoLightness = promoLightness - 32;
|
|
18
|
+
}
|
|
19
|
+
promoLightness = Math.min(Math.max(promoLightness, 30), 34);
|
|
20
|
+
var promoChroma = 0.1;
|
|
21
|
+
var finalLightness = Math.round(promoLightness) / 100;
|
|
22
|
+
var finalChroma = Math.round(promoChroma * 100) / 100;
|
|
23
|
+
var promoOklch = {
|
|
24
|
+
mode: 'oklch',
|
|
25
|
+
l: finalLightness,
|
|
26
|
+
c: finalChroma,
|
|
27
|
+
h: correctedHue,
|
|
28
|
+
};
|
|
29
|
+
return formatHex(clampChroma(promoOklch, 'oklch'));
|
|
34
30
|
}
|
|
35
31
|
export function getPromoHueShift(currentHue, promoHueShifts) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
32
|
+
var hueRanges = Object.keys(promoHueShifts)
|
|
33
|
+
.map(Number)
|
|
34
|
+
.sort(function (a, b) {
|
|
35
|
+
return a - b;
|
|
36
|
+
});
|
|
37
|
+
var selectedHueRange = hueRanges[0];
|
|
38
|
+
for (var i = 0; i < hueRanges.length; i++) {
|
|
39
|
+
var startRange = hueRanges[i];
|
|
40
|
+
var endRange = hueRanges[i + 1] !== undefined ? hueRanges[i + 1] : 360;
|
|
41
|
+
if (currentHue >= startRange && currentHue < endRange) {
|
|
42
|
+
selectedHueRange = startRange;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
if (i === hueRanges.length - 1 && (currentHue >= startRange || currentHue < hueRanges[0])) {
|
|
46
|
+
selectedHueRange = startRange;
|
|
47
|
+
break;
|
|
51
48
|
}
|
|
52
|
-
|
|
49
|
+
}
|
|
50
|
+
return promoHueShifts[selectedHueRange] !== undefined ? promoHueShifts[selectedHueRange] : 0;
|
|
53
51
|
}
|
|
@@ -1,53 +1,125 @@
|
|
|
1
1
|
export interface BaseTokens {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
};
|
|
10
|
-
palette: ColorPalette;
|
|
2
|
+
brand: {
|
|
3
|
+
logo: ThemedValue;
|
|
4
|
+
original: string;
|
|
5
|
+
promo: string;
|
|
6
|
+
interactions: {
|
|
7
|
+
hover: ThemedValue;
|
|
8
|
+
pressed: ThemedValue;
|
|
11
9
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
};
|
|
20
|
-
warning: ColorPalette;
|
|
21
|
-
error: ColorPalette;
|
|
22
|
-
success: ColorPalette;
|
|
23
|
-
gray: ColorWithScale<GrayScale>;
|
|
24
|
-
whiteAlpha: ColorWithScale<AlphaScale>;
|
|
25
|
-
blackAlpha: ColorWithScale<AlphaScale>;
|
|
26
|
-
onBrand: ColorWithScale<AlphaScale>;
|
|
27
|
-
customizable: {
|
|
28
|
-
red: ColorPalette;
|
|
29
|
-
orange: ColorPalette;
|
|
30
|
-
green: ColorPalette;
|
|
31
|
-
mint: ColorPalette;
|
|
32
|
-
blue: ColorPalette;
|
|
33
|
-
blueDeep: ColorPalette;
|
|
34
|
-
violet: ColorPalette;
|
|
35
|
-
purple: ColorPalette;
|
|
10
|
+
palette: ColorPalette;
|
|
11
|
+
};
|
|
12
|
+
accent?: {
|
|
13
|
+
original: ThemedValue;
|
|
14
|
+
interactions: {
|
|
15
|
+
hover: ThemedValue;
|
|
16
|
+
pressed: ThemedValue;
|
|
36
17
|
};
|
|
18
|
+
palette?: ColorPalette;
|
|
19
|
+
};
|
|
20
|
+
warning: ColorPalette;
|
|
21
|
+
error: ColorPalette;
|
|
22
|
+
success: ColorPalette;
|
|
23
|
+
gray: ColorWithScale<GrayScale>;
|
|
24
|
+
whiteAlpha: ColorWithScale<AlphaScale>;
|
|
25
|
+
blackAlpha: ColorWithScale<AlphaScale>;
|
|
26
|
+
onBrand: ColorWithScale<AlphaScale>;
|
|
27
|
+
onAccent?: ColorWithScale<AlphaScale>;
|
|
28
|
+
customizable: {
|
|
29
|
+
red: ColorPalette;
|
|
30
|
+
orange: ColorPalette;
|
|
31
|
+
green: ColorPalette;
|
|
32
|
+
mint: ColorPalette;
|
|
33
|
+
blue: ColorPalette;
|
|
34
|
+
blueDeep: ColorPalette;
|
|
35
|
+
violet: ColorPalette;
|
|
36
|
+
purple: ColorPalette;
|
|
37
|
+
yellow: ColorPalette;
|
|
38
|
+
};
|
|
37
39
|
}
|
|
38
40
|
export interface ColorPalette {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
vivid: ColorWithScale<ChromaScale>;
|
|
42
|
+
normal: ColorWithScale<ChromaScale>;
|
|
43
|
+
dim: ColorWithScale<ChromaScale>;
|
|
42
44
|
}
|
|
43
|
-
type ChromaScale =
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
export type ChromaScale =
|
|
46
|
+
| 20
|
|
47
|
+
| 24
|
|
48
|
+
| 28
|
|
49
|
+
| 32
|
|
50
|
+
| 36
|
|
51
|
+
| 40
|
|
52
|
+
| 44
|
|
53
|
+
| 48
|
|
54
|
+
| 52
|
|
55
|
+
| 56
|
|
56
|
+
| 60
|
|
57
|
+
| 64
|
|
58
|
+
| 68
|
|
59
|
+
| 72
|
|
60
|
+
| 76
|
|
61
|
+
| 80
|
|
62
|
+
| 84
|
|
63
|
+
| 88
|
|
64
|
+
| 92
|
|
65
|
+
| 96;
|
|
66
|
+
type AlphaScale =
|
|
67
|
+
| 4
|
|
68
|
+
| 6
|
|
69
|
+
| 8
|
|
70
|
+
| 12
|
|
71
|
+
| 16
|
|
72
|
+
| 20
|
|
73
|
+
| 24
|
|
74
|
+
| 28
|
|
75
|
+
| 32
|
|
76
|
+
| 36
|
|
77
|
+
| 40
|
|
78
|
+
| 44
|
|
79
|
+
| 48
|
|
80
|
+
| 52
|
|
81
|
+
| 56
|
|
82
|
+
| 60
|
|
83
|
+
| 64
|
|
84
|
+
| 68
|
|
85
|
+
| 72
|
|
86
|
+
| 76
|
|
87
|
+
| 80
|
|
88
|
+
| 84
|
|
89
|
+
| 88
|
|
90
|
+
| 92
|
|
91
|
+
| 96
|
|
92
|
+
| 100;
|
|
93
|
+
export type GrayScale =
|
|
94
|
+
| 0
|
|
95
|
+
| 16
|
|
96
|
+
| 20
|
|
97
|
+
| 24
|
|
98
|
+
| 28
|
|
99
|
+
| 32
|
|
100
|
+
| 36
|
|
101
|
+
| 40
|
|
102
|
+
| 44
|
|
103
|
+
| 48
|
|
104
|
+
| 52
|
|
105
|
+
| 56
|
|
106
|
+
| 60
|
|
107
|
+
| 64
|
|
108
|
+
| 68
|
|
109
|
+
| 72
|
|
110
|
+
| 76
|
|
111
|
+
| 80
|
|
112
|
+
| 84
|
|
113
|
+
| 88
|
|
114
|
+
| 92
|
|
115
|
+
| 96
|
|
116
|
+
| 98
|
|
117
|
+
| 100;
|
|
46
118
|
type ColorWithScale<T extends string | number> = {
|
|
47
|
-
|
|
119
|
+
[K in T]: string;
|
|
48
120
|
};
|
|
49
|
-
interface ThemedValue {
|
|
50
|
-
|
|
51
|
-
|
|
121
|
+
export interface ThemedValue {
|
|
122
|
+
light: string;
|
|
123
|
+
dark: string;
|
|
52
124
|
}
|
|
53
125
|
export {};
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
export interface GeneratorColorChromaSettingsGroup {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
[key: number]: {
|
|
3
|
+
vivid: GeneratorColorChromaSettings;
|
|
4
|
+
normal: GeneratorColorChromaSettings;
|
|
5
|
+
dim: GeneratorColorChromaSettings;
|
|
6
|
+
};
|
|
7
7
|
}
|
|
8
8
|
export interface GeneratorColorChromaSettings {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
rel: number;
|
|
10
|
+
min?: number;
|
|
11
|
+
max?: number;
|
|
12
12
|
}
|
|
13
13
|
export interface GeneratorColorPalette {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
vivid: {
|
|
15
|
+
[key: number]: string;
|
|
16
|
+
};
|
|
17
|
+
normal: {
|
|
18
|
+
[key: number]: string;
|
|
19
|
+
};
|
|
20
|
+
dim: {
|
|
21
|
+
[key: number]: string;
|
|
22
|
+
};
|
|
23
23
|
}
|
|
24
24
|
export interface GeneratorColorAbneyCorrection {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
[lightness: number]: {
|
|
26
|
+
[hueShiftRange: number]: number;
|
|
27
|
+
};
|
|
28
28
|
}
|
|
29
29
|
export interface GeneratorColorWarningHuePatch {
|
|
30
|
-
|
|
30
|
+
[lightness: number]: number;
|
|
31
31
|
}
|
|
32
32
|
export interface GeneratorPaletteParams {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
};
|
|
41
|
-
warningHuePatch?: GeneratorColorWarningHuePatch;
|
|
33
|
+
color: string;
|
|
34
|
+
type?: 'default' | 'warning' | 'promo';
|
|
35
|
+
settings?: {
|
|
36
|
+
chromaSettings?: GeneratorColorChromaSettingsGroup;
|
|
37
|
+
abneyCorrection?: GeneratorColorAbneyCorrection;
|
|
38
|
+
promoHueShifts?: {
|
|
39
|
+
[hueRange: number]: number;
|
|
42
40
|
};
|
|
41
|
+
warningHuePatch?: GeneratorColorWarningHuePatch;
|
|
42
|
+
};
|
|
43
43
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var camelCaseToKebabCase = function (str) {
|
|
2
|
+
return str.replace(/[A-Z]/g, function (match) {
|
|
3
|
+
return '-'.concat(match.toLowerCase());
|
|
4
|
+
});
|
|
5
|
+
};
|
|
6
|
+
export var kebabCaseToCamelCase = function (str) {
|
|
7
|
+
return str.replace(/-(\w)/g, function (_, c) {
|
|
8
|
+
return c.toUpperCase();
|
|
9
|
+
});
|
|
10
|
+
};
|