@skbkontur/colors 1.1.2-75bba.0 → 1.1.2-b2742.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/default-swatch.d.ts +5 -3
- package/dist/cjs/constants/default-swatch.js +5 -3
- package/dist/cjs/constants/interaction-settings.d.ts +8 -0
- package/dist/cjs/constants/interaction-settings.js +11 -0
- package/dist/cjs/get-base-tokens.js +15 -37
- package/dist/cjs/get-colors.d.ts +17 -0
- package/dist/cjs/get-colors.js +16 -0
- package/dist/cjs/get-default-tokens.d.ts +600 -1271
- package/dist/cjs/get-default-tokens.js +601 -1272
- package/dist/cjs/helpers/get-interactions.d.ts +7 -0
- package/dist/cjs/helpers/get-interactions.js +40 -0
- package/dist/cjs/helpers/get-palette.d.ts +2 -0
- package/dist/cjs/types/base-tokens.d.ts +6 -5
- package/dist/esm/constants/default-swatch.d.ts +5 -3
- package/dist/esm/constants/default-swatch.js +5 -3
- package/dist/esm/constants/interaction-settings.d.ts +8 -0
- package/dist/esm/constants/interaction-settings.js +8 -0
- package/dist/esm/get-base-tokens.js +15 -37
- package/dist/esm/get-colors.d.ts +17 -0
- package/dist/esm/get-colors.js +12 -0
- package/dist/esm/get-default-tokens.d.ts +600 -1271
- package/dist/esm/get-default-tokens.js +601 -1272
- package/dist/esm/helpers/get-interactions.d.ts +7 -0
- package/dist/esm/helpers/get-interactions.js +35 -0
- package/dist/esm/helpers/get-palette.d.ts +2 -0
- package/dist/esm/types/base-tokens.d.ts +6 -5
- package/package.json +5 -4
- 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
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPressed = exports.getHover = void 0;
|
|
4
|
+
var culori_1 = require("culori");
|
|
5
|
+
var interaction_settings_1 = require("../constants/interaction-settings");
|
|
6
|
+
function applyOklchDelta(oklchColor, dL, dC) {
|
|
7
|
+
var _a = oklchColor.l, l = _a === void 0 ? 0 : _a, _b = oklchColor.c, c = _b === void 0 ? 0 : _b, _c = oklchColor.h, h = _c === void 0 ? 0 : _c;
|
|
8
|
+
var safeH = h === undefined || isNaN(h) ? 0 : h;
|
|
9
|
+
var newL = Math.max(0, Math.min(1, l + dL / 100));
|
|
10
|
+
var newC = Math.max(0, c + dC);
|
|
11
|
+
return "oklch(".concat(newL.toFixed(3), " ").concat(newC.toFixed(3), " ").concat(safeH.toFixed(0), ")");
|
|
12
|
+
}
|
|
13
|
+
function getHover(hex) {
|
|
14
|
+
var toOklch = (0, culori_1.converter)('oklch');
|
|
15
|
+
var oklchColor = toOklch(hex);
|
|
16
|
+
if (!oklchColor) {
|
|
17
|
+
return { light: hex, dark: hex };
|
|
18
|
+
}
|
|
19
|
+
var lightHoverColor = applyOklchDelta(oklchColor, interaction_settings_1.HOVER_LIGHT_L, interaction_settings_1.HOVER_LIGHT_C);
|
|
20
|
+
var darkHoverColor = applyOklchDelta(oklchColor, interaction_settings_1.HOVER_DARK_L, interaction_settings_1.HOVER_DARK_C);
|
|
21
|
+
return {
|
|
22
|
+
light: lightHoverColor,
|
|
23
|
+
dark: darkHoverColor,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
exports.getHover = getHover;
|
|
27
|
+
function getPressed(hex) {
|
|
28
|
+
var toOklch = (0, culori_1.converter)('oklch');
|
|
29
|
+
var oklchColor = toOklch(hex);
|
|
30
|
+
if (!oklchColor) {
|
|
31
|
+
return { light: hex, dark: hex };
|
|
32
|
+
}
|
|
33
|
+
var lightPressedColor = applyOklchDelta(oklchColor, interaction_settings_1.PRESSED_LIGHT_L, interaction_settings_1.PRESSED_LIGHT_C);
|
|
34
|
+
var darkPressedColor = applyOklchDelta(oklchColor, interaction_settings_1.PRESSED_DARK_L, interaction_settings_1.PRESSED_DARK_C);
|
|
35
|
+
return {
|
|
36
|
+
light: lightPressedColor,
|
|
37
|
+
dark: darkPressedColor,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
exports.getPressed = getPressed;
|
|
@@ -22,6 +22,7 @@ export declare function calculateBaseHueAndCorrectionRange(inputColorString: str
|
|
|
22
22
|
} | null;
|
|
23
23
|
export declare function calcOnBrand(hex: string): {
|
|
24
24
|
4: string;
|
|
25
|
+
6: string;
|
|
25
26
|
8: string;
|
|
26
27
|
12: string;
|
|
27
28
|
16: string;
|
|
@@ -45,5 +46,6 @@ export declare function calcOnBrand(hex: string): {
|
|
|
45
46
|
88: string;
|
|
46
47
|
92: string;
|
|
47
48
|
96: string;
|
|
49
|
+
100: string;
|
|
48
50
|
};
|
|
49
51
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export interface BaseTokens {
|
|
2
|
-
brandLogo: ThemedValue;
|
|
3
|
-
brandPromo: ThemedValue;
|
|
4
2
|
brand: {
|
|
5
|
-
|
|
3
|
+
logo: ThemedValue;
|
|
4
|
+
original: string;
|
|
5
|
+
promo: string;
|
|
6
6
|
interactions: {
|
|
7
7
|
hover: ThemedValue;
|
|
8
8
|
pressed: ThemedValue;
|
|
@@ -33,6 +33,7 @@ export interface BaseTokens {
|
|
|
33
33
|
blueDeep: ColorPalette;
|
|
34
34
|
violet: ColorPalette;
|
|
35
35
|
purple: ColorPalette;
|
|
36
|
+
yellow: ColorPalette;
|
|
36
37
|
};
|
|
37
38
|
}
|
|
38
39
|
export interface ColorPalette {
|
|
@@ -41,8 +42,8 @@ export interface ColorPalette {
|
|
|
41
42
|
dim: ColorWithScale<ChromaScale>;
|
|
42
43
|
}
|
|
43
44
|
type ChromaScale = 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
|
|
44
|
-
type AlphaScale = 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96;
|
|
45
|
-
type GrayScale = 0 |
|
|
45
|
+
type AlphaScale = 4 | 6 | 8 | 12 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 100;
|
|
46
|
+
type GrayScale = 0 | 16 | 20 | 24 | 28 | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | 96 | 98 | 100;
|
|
46
47
|
type ColorWithScale<T extends string | number> = {
|
|
47
48
|
[K in T]: string;
|
|
48
49
|
};
|
|
@@ -23,12 +23,10 @@ export declare const customizable: {
|
|
|
23
23
|
blueDeep: string;
|
|
24
24
|
violet: string;
|
|
25
25
|
purple: string;
|
|
26
|
+
yellow: string;
|
|
26
27
|
};
|
|
27
28
|
export declare const gray: {
|
|
28
29
|
0: string;
|
|
29
|
-
4: string;
|
|
30
|
-
8: string;
|
|
31
|
-
12: string;
|
|
32
30
|
16: string;
|
|
33
31
|
20: string;
|
|
34
32
|
24: string;
|
|
@@ -55,6 +53,7 @@ export declare const gray: {
|
|
|
55
53
|
};
|
|
56
54
|
export declare const whiteAlpha: {
|
|
57
55
|
4: string;
|
|
56
|
+
6: string;
|
|
58
57
|
8: string;
|
|
59
58
|
12: string;
|
|
60
59
|
16: string;
|
|
@@ -78,9 +77,11 @@ export declare const whiteAlpha: {
|
|
|
78
77
|
88: string;
|
|
79
78
|
92: string;
|
|
80
79
|
96: string;
|
|
80
|
+
100: string;
|
|
81
81
|
};
|
|
82
82
|
export declare const blackAlpha: {
|
|
83
83
|
4: string;
|
|
84
|
+
6: string;
|
|
84
85
|
8: string;
|
|
85
86
|
12: string;
|
|
86
87
|
16: string;
|
|
@@ -104,4 +105,5 @@ export declare const blackAlpha: {
|
|
|
104
105
|
88: string;
|
|
105
106
|
92: string;
|
|
106
107
|
96: string;
|
|
108
|
+
100: string;
|
|
107
109
|
};
|
|
@@ -23,12 +23,10 @@ export var customizable = {
|
|
|
23
23
|
blueDeep: '#366AF3',
|
|
24
24
|
violet: '#844BEC',
|
|
25
25
|
purple: '#B750D1',
|
|
26
|
+
yellow: '#FAB700',
|
|
26
27
|
};
|
|
27
28
|
export var gray = {
|
|
28
29
|
0: 'oklch(0% 0 0)',
|
|
29
|
-
4: 'oklch(4% 0 0)',
|
|
30
|
-
8: 'oklch(8% 0 0)',
|
|
31
|
-
12: 'oklch(12% 0 0)',
|
|
32
30
|
16: 'oklch(16% 0 0)',
|
|
33
31
|
20: 'oklch(20% 0 0)',
|
|
34
32
|
24: 'oklch(24% 0 0)',
|
|
@@ -55,6 +53,7 @@ export var gray = {
|
|
|
55
53
|
};
|
|
56
54
|
export var whiteAlpha = {
|
|
57
55
|
4: 'oklch(100% 0 0 / 0.04)',
|
|
56
|
+
6: 'oklch(100% 0 0 / 0.06)',
|
|
58
57
|
8: 'oklch(100% 0 0 / 0.08)',
|
|
59
58
|
12: 'oklch(100% 0 0 / 0.12)',
|
|
60
59
|
16: 'oklch(100% 0 0 / 0.16)',
|
|
@@ -78,9 +77,11 @@ export var whiteAlpha = {
|
|
|
78
77
|
88: 'oklch(100% 0 0 / 0.88)',
|
|
79
78
|
92: 'oklch(100% 0 0 / 0.92)',
|
|
80
79
|
96: 'oklch(100% 0 0 / 0.96)',
|
|
80
|
+
100: 'oklch(100% 0 0 / 1)',
|
|
81
81
|
};
|
|
82
82
|
export var blackAlpha = {
|
|
83
83
|
4: 'oklch(0% 0 0 / 0.04)',
|
|
84
|
+
6: 'oklch(0% 0 0 / 0.06)',
|
|
84
85
|
8: 'oklch(0% 0 0 / 0.08)',
|
|
85
86
|
12: 'oklch(0% 0 0 / 0.12)',
|
|
86
87
|
16: 'oklch(0% 0 0 / 0.16)',
|
|
@@ -104,4 +105,5 @@ export var blackAlpha = {
|
|
|
104
105
|
88: 'oklch(0% 0 0 / 0.88)',
|
|
105
106
|
92: 'oklch(0% 0 0 / 0.92)',
|
|
106
107
|
96: 'oklch(0% 0 0 / 0.96)',
|
|
108
|
+
100: 'oklch(0% 0 0 / 1)',
|
|
107
109
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const HOVER_LIGHT_L = -4;
|
|
2
|
+
export declare const HOVER_LIGHT_C = 0;
|
|
3
|
+
export declare const HOVER_DARK_L = 4;
|
|
4
|
+
export declare const HOVER_DARK_C = 0;
|
|
5
|
+
export declare const PRESSED_LIGHT_L = -8;
|
|
6
|
+
export declare const PRESSED_LIGHT_C = -0.03;
|
|
7
|
+
export declare const PRESSED_DARK_L = -4;
|
|
8
|
+
export declare const PRESSED_DARK_C = -0.03;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export var HOVER_LIGHT_L = -4;
|
|
2
|
+
export var HOVER_LIGHT_C = 0;
|
|
3
|
+
export var HOVER_DARK_L = +4;
|
|
4
|
+
export var HOVER_DARK_C = 0;
|
|
5
|
+
export var PRESSED_LIGHT_L = -8;
|
|
6
|
+
export var PRESSED_LIGHT_C = -0.03;
|
|
7
|
+
export var PRESSED_DARK_L = -4;
|
|
8
|
+
export var PRESSED_DARK_C = -0.03;
|
|
@@ -14,8 +14,9 @@ import { calcOnBrand, getPalette } from './helpers/get-palette';
|
|
|
14
14
|
import { getPromo } from './helpers/get-promo';
|
|
15
15
|
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
16
16
|
import { getLogo } from './helpers/get-logo';
|
|
17
|
+
import { getHover, getPressed } from './helpers/get-interactions';
|
|
17
18
|
export function getBaseTokens(_a) {
|
|
18
|
-
var brand = _a.brand,
|
|
19
|
+
var brand = _a.brand, _b = _a.accent, accent = _b === void 0 ? 'gray' : _b, _c = _a.system, system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
|
|
19
20
|
var brandColor = colorToHex(brand);
|
|
20
21
|
var brandPalette = getPalette({ color: brandColor });
|
|
21
22
|
var accentPalette;
|
|
@@ -24,10 +25,8 @@ export function getBaseTokens(_a) {
|
|
|
24
25
|
accentPalette = brandPalette;
|
|
25
26
|
break;
|
|
26
27
|
case 'gray':
|
|
27
|
-
accentPalette = undefined;
|
|
28
|
-
break;
|
|
29
28
|
default:
|
|
30
|
-
accentPalette =
|
|
29
|
+
accentPalette = undefined;
|
|
31
30
|
}
|
|
32
31
|
var warningPalette = getPalette({
|
|
33
32
|
color: system.warning,
|
|
@@ -37,54 +36,33 @@ export function getBaseTokens(_a) {
|
|
|
37
36
|
color: system.success,
|
|
38
37
|
});
|
|
39
38
|
var customizable = {};
|
|
40
|
-
for (var colorKey in DEFAULT_SWATCH.
|
|
39
|
+
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
41
40
|
// @ts-expect-error
|
|
42
41
|
customizable[colorKey] = getPalette({
|
|
43
42
|
// @ts-expect-error
|
|
44
|
-
color: DEFAULT_SWATCH.
|
|
43
|
+
color: DEFAULT_SWATCH.customizable[colorKey],
|
|
45
44
|
});
|
|
46
45
|
}
|
|
47
46
|
return {
|
|
48
|
-
brandLogo: getLogo(brand),
|
|
49
|
-
brandPromo: {
|
|
50
|
-
light: getPromo(brandColor),
|
|
51
|
-
dark: 'blue',
|
|
52
|
-
},
|
|
53
47
|
brand: {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
dark: brand,
|
|
58
|
-
},
|
|
59
|
-
// todo interactions
|
|
48
|
+
logo: getLogo(brandColor),
|
|
49
|
+
promo: getPromo(brandColor),
|
|
50
|
+
original: brandColor,
|
|
60
51
|
interactions: {
|
|
61
|
-
hover:
|
|
62
|
-
|
|
63
|
-
dark: '',
|
|
64
|
-
},
|
|
65
|
-
pressed: {
|
|
66
|
-
light: '',
|
|
67
|
-
dark: '',
|
|
68
|
-
},
|
|
52
|
+
hover: getHover(brandColor),
|
|
53
|
+
pressed: getPressed(brandColor),
|
|
69
54
|
},
|
|
70
55
|
palette: brandPalette,
|
|
71
56
|
},
|
|
72
57
|
accent: {
|
|
73
58
|
original: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
dark: accent === 'gray' ? accent : '#3d3d3d',
|
|
59
|
+
light: accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[36],
|
|
60
|
+
dark: accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[96],
|
|
77
61
|
},
|
|
78
|
-
// todo interactions
|
|
79
62
|
interactions: {
|
|
80
|
-
hover
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
pressed: {
|
|
85
|
-
light: '',
|
|
86
|
-
dark: '',
|
|
87
|
-
},
|
|
63
|
+
// TODO обработать hover/pressed для gray
|
|
64
|
+
hover: getHover(accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[36]),
|
|
65
|
+
pressed: getPressed(accent === 'brand' ? brandColor : DEFAULT_SWATCH.gray[36]),
|
|
88
66
|
},
|
|
89
67
|
palette: accentPalette || undefined,
|
|
90
68
|
},
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ConfigOptions } from './get-base-tokens';
|
|
2
|
+
import { getDefaultTokens } from './get-default-tokens';
|
|
3
|
+
import type { BaseTokens } from './types/base-tokens';
|
|
4
|
+
export interface Themed<T> {
|
|
5
|
+
light: T;
|
|
6
|
+
dark: T;
|
|
7
|
+
}
|
|
8
|
+
export type DefaultTokensFull = ReturnType<typeof getDefaultTokens>;
|
|
9
|
+
export type DefaultTokens = DefaultTokensFull['light' | 'dark'];
|
|
10
|
+
export interface SemanticConfigOptions<T> extends ConfigOptions {
|
|
11
|
+
theme?: 'light' | 'dark';
|
|
12
|
+
overrides?: (base: BaseTokens, defaults?: DefaultTokensFull, params?: SemanticConfigOptions<T>) => Themed<T>;
|
|
13
|
+
}
|
|
14
|
+
export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
|
|
15
|
+
export declare function getColors<T>(params: SemanticConfigOptions<T> & {
|
|
16
|
+
overrides: (base: BaseTokens) => Themed<T>;
|
|
17
|
+
}): Themed<T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { getBaseTokens } from './get-base-tokens';
|
|
2
|
+
import { getDefaultTokens } from './get-default-tokens';
|
|
3
|
+
var DEFAULT_THEME = 'light';
|
|
4
|
+
export function getColors(params) {
|
|
5
|
+
var theme = params.theme || DEFAULT_THEME;
|
|
6
|
+
var base = getBaseTokens(params);
|
|
7
|
+
var defaults = getDefaultTokens(base);
|
|
8
|
+
if (params.overrides) {
|
|
9
|
+
return params.overrides(base, defaults, params)[theme];
|
|
10
|
+
}
|
|
11
|
+
return defaults[theme];
|
|
12
|
+
}
|