@skbkontur/colors 1.1.2-75bba.0 → 1.1.2-cbc4b.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 +1 -0
- package/dist/cjs/constants/default-swatch.js +1 -0
- 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 +11 -24
- package/dist/cjs/{get-tokens.d.ts → get-colors.d.ts} +4 -3
- package/dist/cjs/get-colors.js +14 -0
- package/dist/cjs/get-default-tokens.d.ts +8 -8
- package/dist/cjs/get-default-tokens.js +13 -13
- package/dist/cjs/helpers/get-interactions.d.ts +7 -0
- package/dist/cjs/helpers/get-interactions.js +40 -0
- package/dist/cjs/types/base-tokens.d.ts +1 -0
- package/dist/esm/constants/default-swatch.d.ts +1 -0
- package/dist/esm/constants/default-swatch.js +1 -0
- 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 +11 -24
- package/dist/esm/{get-tokens.d.ts → get-colors.d.ts} +4 -3
- package/dist/esm/get-colors.js +10 -0
- package/dist/esm/get-default-tokens.d.ts +8 -8
- package/dist/esm/get-default-tokens.js +13 -13
- package/dist/esm/helpers/get-interactions.d.ts +7 -0
- package/dist/esm/helpers/get-interactions.js +35 -0
- package/dist/esm/types/base-tokens.d.ts +1 -0
- package/package.json +3 -3
- package/dist/cjs/get-tokens.js +0 -13
- package/dist/esm/get-tokens.js +0 -9
|
@@ -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,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PRESSED_DARK_C = exports.PRESSED_DARK_L = exports.PRESSED_LIGHT_C = exports.PRESSED_LIGHT_L = exports.HOVER_DARK_C = exports.HOVER_DARK_L = exports.HOVER_LIGHT_C = exports.HOVER_LIGHT_L = void 0;
|
|
4
|
+
exports.HOVER_LIGHT_L = -4;
|
|
5
|
+
exports.HOVER_LIGHT_C = 0;
|
|
6
|
+
exports.HOVER_DARK_L = +4;
|
|
7
|
+
exports.HOVER_DARK_C = 0;
|
|
8
|
+
exports.PRESSED_LIGHT_L = -8;
|
|
9
|
+
exports.PRESSED_LIGHT_C = -0.03;
|
|
10
|
+
exports.PRESSED_DARK_L = -4;
|
|
11
|
+
exports.PRESSED_DARK_C = -0.03;
|
|
@@ -40,8 +40,9 @@ var get_palette_1 = require("./helpers/get-palette");
|
|
|
40
40
|
var get_promo_1 = require("./helpers/get-promo");
|
|
41
41
|
var DEFAULT_SWATCH = __importStar(require("./constants/default-swatch"));
|
|
42
42
|
var get_logo_1 = require("./helpers/get-logo");
|
|
43
|
+
var get_interactions_1 = require("./helpers/get-interactions");
|
|
43
44
|
function getBaseTokens(_a) {
|
|
44
|
-
var brand = _a.brand,
|
|
45
|
+
var brand = _a.brand, _b = _a.accent, accent = _b === void 0 ? 'gray' : _b, _c = _a.system, system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
|
|
45
46
|
var brandColor = (0, exports.colorToHex)(brand);
|
|
46
47
|
var brandPalette = (0, get_palette_1.getPalette)({ color: brandColor });
|
|
47
48
|
var accentPalette;
|
|
@@ -63,11 +64,11 @@ function getBaseTokens(_a) {
|
|
|
63
64
|
color: system.success,
|
|
64
65
|
});
|
|
65
66
|
var customizable = {};
|
|
66
|
-
for (var colorKey in DEFAULT_SWATCH.
|
|
67
|
+
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
67
68
|
// @ts-expect-error
|
|
68
69
|
customizable[colorKey] = (0, get_palette_1.getPalette)({
|
|
69
70
|
// @ts-expect-error
|
|
70
|
-
color: DEFAULT_SWATCH.
|
|
71
|
+
color: DEFAULT_SWATCH.customizable[colorKey],
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
74
|
return {
|
|
@@ -82,35 +83,21 @@ function getBaseTokens(_a) {
|
|
|
82
83
|
light: brand,
|
|
83
84
|
dark: brand,
|
|
84
85
|
},
|
|
85
|
-
// todo interactions
|
|
86
86
|
interactions: {
|
|
87
|
-
hover:
|
|
88
|
-
|
|
89
|
-
dark: '',
|
|
90
|
-
},
|
|
91
|
-
pressed: {
|
|
92
|
-
light: '',
|
|
93
|
-
dark: '',
|
|
94
|
-
},
|
|
87
|
+
hover: (0, get_interactions_1.getHover)(brand),
|
|
88
|
+
pressed: (0, get_interactions_1.getPressed)(brand),
|
|
95
89
|
},
|
|
96
90
|
palette: brandPalette,
|
|
97
91
|
},
|
|
98
92
|
accent: {
|
|
99
93
|
original: {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
dark: accent === 'gray' ? accent : '#3d3d3d',
|
|
94
|
+
light: accent === 'gray' ? accent : DEFAULT_SWATCH.gray[36],
|
|
95
|
+
dark: accent === 'gray' ? accent : DEFAULT_SWATCH.gray[96],
|
|
103
96
|
},
|
|
104
|
-
// todo interactions
|
|
105
97
|
interactions: {
|
|
106
|
-
hover
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
pressed: {
|
|
111
|
-
light: '',
|
|
112
|
-
dark: '',
|
|
113
|
-
},
|
|
98
|
+
// TODO обработать hover/pressed для gray
|
|
99
|
+
hover: (0, get_interactions_1.getHover)(accent),
|
|
100
|
+
pressed: (0, get_interactions_1.getPressed)(accent),
|
|
114
101
|
},
|
|
115
102
|
palette: accentPalette || undefined,
|
|
116
103
|
},
|
|
@@ -5,11 +5,12 @@ export interface Themed<T> {
|
|
|
5
5
|
light: T;
|
|
6
6
|
dark: T;
|
|
7
7
|
}
|
|
8
|
-
export type DefaultTokens = ReturnType<typeof getDefaultTokens
|
|
8
|
+
export type DefaultTokens = ReturnType<typeof getDefaultTokens>['light' | 'dark'];
|
|
9
9
|
export interface SemanticConfigOptions<DefaultTokens> extends ConfigOptions {
|
|
10
|
+
theme?: 'light' | 'dark';
|
|
10
11
|
overrides?: (base: BaseTokens) => Themed<DefaultTokens>;
|
|
11
12
|
}
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
|
|
14
|
+
export declare function getColors<T>(params: SemanticConfigOptions<T> & {
|
|
14
15
|
overrides: (base: BaseTokens) => Themed<T>;
|
|
15
16
|
}): Themed<T>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getColors = void 0;
|
|
4
|
+
var get_base_tokens_1 = require("./get-base-tokens");
|
|
5
|
+
var get_default_tokens_1 = require("./get-default-tokens");
|
|
6
|
+
// TODO: оптимизация получения light и dark
|
|
7
|
+
function getColors(params) {
|
|
8
|
+
var base = (0, get_base_tokens_1.getBaseTokens)(params);
|
|
9
|
+
if (params.overrides) {
|
|
10
|
+
return params.overrides(base)[params.theme || 'light'];
|
|
11
|
+
}
|
|
12
|
+
return (0, get_default_tokens_1.getDefaultTokens)(base)[params.theme || 'light'];
|
|
13
|
+
}
|
|
14
|
+
exports.getColors = getColors;
|
|
@@ -628,6 +628,13 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
|
|
|
628
628
|
pale: string;
|
|
629
629
|
faint: string;
|
|
630
630
|
};
|
|
631
|
+
yellow: {
|
|
632
|
+
heavy: string;
|
|
633
|
+
bold: string;
|
|
634
|
+
soft: string;
|
|
635
|
+
pale: string;
|
|
636
|
+
faint: string;
|
|
637
|
+
};
|
|
631
638
|
};
|
|
632
639
|
};
|
|
633
640
|
dark: {
|
|
@@ -1259,14 +1266,7 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
|
|
|
1259
1266
|
pale: string;
|
|
1260
1267
|
faint: string;
|
|
1261
1268
|
};
|
|
1262
|
-
|
|
1263
|
-
heavy: string;
|
|
1264
|
-
bold: string;
|
|
1265
|
-
soft: string;
|
|
1266
|
-
pale: string;
|
|
1267
|
-
faint: string;
|
|
1268
|
-
};
|
|
1269
|
-
black: {
|
|
1269
|
+
yellow: {
|
|
1270
1270
|
heavy: string;
|
|
1271
1271
|
bold: string;
|
|
1272
1272
|
soft: string;
|
|
@@ -632,6 +632,13 @@ var getDefaultTokens = function (base) {
|
|
|
632
632
|
pale: base.customizable.purple.vivid[92],
|
|
633
633
|
faint: base.customizable.purple.vivid[96],
|
|
634
634
|
},
|
|
635
|
+
yellow: {
|
|
636
|
+
heavy: base.customizable.yellow.vivid[48],
|
|
637
|
+
bold: base.customizable.yellow.vivid[68],
|
|
638
|
+
soft: base.customizable.yellow.vivid[80],
|
|
639
|
+
pale: base.customizable.yellow.vivid[92],
|
|
640
|
+
faint: base.customizable.yellow.vivid[96],
|
|
641
|
+
},
|
|
635
642
|
},
|
|
636
643
|
},
|
|
637
644
|
dark: {
|
|
@@ -1263,19 +1270,12 @@ var getDefaultTokens = function (base) {
|
|
|
1263
1270
|
pale: base.customizable.purple.vivid[92],
|
|
1264
1271
|
faint: base.customizable.purple.vivid[96],
|
|
1265
1272
|
},
|
|
1266
|
-
|
|
1267
|
-
heavy: base.
|
|
1268
|
-
bold: base.
|
|
1269
|
-
soft: base.
|
|
1270
|
-
pale: base.
|
|
1271
|
-
faint: base.
|
|
1272
|
-
},
|
|
1273
|
-
black: {
|
|
1274
|
-
heavy: base.gray[36],
|
|
1275
|
-
bold: base.gray[52],
|
|
1276
|
-
soft: base.gray[76],
|
|
1277
|
-
pale: base.gray[88],
|
|
1278
|
-
faint: base.gray[92],
|
|
1273
|
+
yellow: {
|
|
1274
|
+
heavy: base.customizable.yellow.vivid[48],
|
|
1275
|
+
bold: base.customizable.yellow.vivid[68],
|
|
1276
|
+
soft: base.customizable.yellow.vivid[80],
|
|
1277
|
+
pale: base.customizable.yellow.vivid[92],
|
|
1278
|
+
faint: base.customizable.yellow.vivid[96],
|
|
1279
1279
|
},
|
|
1280
1280
|
},
|
|
1281
1281
|
},
|
|
@@ -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;
|
|
@@ -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;
|
|
@@ -37,11 +38,11 @@ export function getBaseTokens(_a) {
|
|
|
37
38
|
color: system.success,
|
|
38
39
|
});
|
|
39
40
|
var customizable = {};
|
|
40
|
-
for (var colorKey in DEFAULT_SWATCH.
|
|
41
|
+
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
41
42
|
// @ts-expect-error
|
|
42
43
|
customizable[colorKey] = getPalette({
|
|
43
44
|
// @ts-expect-error
|
|
44
|
-
color: DEFAULT_SWATCH.
|
|
45
|
+
color: DEFAULT_SWATCH.customizable[colorKey],
|
|
45
46
|
});
|
|
46
47
|
}
|
|
47
48
|
return {
|
|
@@ -56,35 +57,21 @@ export function getBaseTokens(_a) {
|
|
|
56
57
|
light: brand,
|
|
57
58
|
dark: brand,
|
|
58
59
|
},
|
|
59
|
-
// todo interactions
|
|
60
60
|
interactions: {
|
|
61
|
-
hover:
|
|
62
|
-
|
|
63
|
-
dark: '',
|
|
64
|
-
},
|
|
65
|
-
pressed: {
|
|
66
|
-
light: '',
|
|
67
|
-
dark: '',
|
|
68
|
-
},
|
|
61
|
+
hover: getHover(brand),
|
|
62
|
+
pressed: getPressed(brand),
|
|
69
63
|
},
|
|
70
64
|
palette: brandPalette,
|
|
71
65
|
},
|
|
72
66
|
accent: {
|
|
73
67
|
original: {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
dark: accent === 'gray' ? accent : '#3d3d3d',
|
|
68
|
+
light: accent === 'gray' ? accent : DEFAULT_SWATCH.gray[36],
|
|
69
|
+
dark: accent === 'gray' ? accent : DEFAULT_SWATCH.gray[96],
|
|
77
70
|
},
|
|
78
|
-
// todo interactions
|
|
79
71
|
interactions: {
|
|
80
|
-
hover
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
},
|
|
84
|
-
pressed: {
|
|
85
|
-
light: '',
|
|
86
|
-
dark: '',
|
|
87
|
-
},
|
|
72
|
+
// TODO обработать hover/pressed для gray
|
|
73
|
+
hover: getHover(accent),
|
|
74
|
+
pressed: getPressed(accent),
|
|
88
75
|
},
|
|
89
76
|
palette: accentPalette || undefined,
|
|
90
77
|
},
|
|
@@ -5,11 +5,12 @@ export interface Themed<T> {
|
|
|
5
5
|
light: T;
|
|
6
6
|
dark: T;
|
|
7
7
|
}
|
|
8
|
-
export type DefaultTokens = ReturnType<typeof getDefaultTokens
|
|
8
|
+
export type DefaultTokens = ReturnType<typeof getDefaultTokens>['light' | 'dark'];
|
|
9
9
|
export interface SemanticConfigOptions<DefaultTokens> extends ConfigOptions {
|
|
10
|
+
theme?: 'light' | 'dark';
|
|
10
11
|
overrides?: (base: BaseTokens) => Themed<DefaultTokens>;
|
|
11
12
|
}
|
|
12
|
-
export declare function
|
|
13
|
-
export declare function
|
|
13
|
+
export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
|
|
14
|
+
export declare function getColors<T>(params: SemanticConfigOptions<T> & {
|
|
14
15
|
overrides: (base: BaseTokens) => Themed<T>;
|
|
15
16
|
}): Themed<T>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { getBaseTokens } from './get-base-tokens';
|
|
2
|
+
import { getDefaultTokens } from './get-default-tokens';
|
|
3
|
+
// TODO: оптимизация получения light и dark
|
|
4
|
+
export function getColors(params) {
|
|
5
|
+
var base = getBaseTokens(params);
|
|
6
|
+
if (params.overrides) {
|
|
7
|
+
return params.overrides(base)[params.theme || 'light'];
|
|
8
|
+
}
|
|
9
|
+
return getDefaultTokens(base)[params.theme || 'light'];
|
|
10
|
+
}
|
|
@@ -628,6 +628,13 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
|
|
|
628
628
|
pale: string;
|
|
629
629
|
faint: string;
|
|
630
630
|
};
|
|
631
|
+
yellow: {
|
|
632
|
+
heavy: string;
|
|
633
|
+
bold: string;
|
|
634
|
+
soft: string;
|
|
635
|
+
pale: string;
|
|
636
|
+
faint: string;
|
|
637
|
+
};
|
|
631
638
|
};
|
|
632
639
|
};
|
|
633
640
|
dark: {
|
|
@@ -1259,14 +1266,7 @@ export declare const getDefaultTokens: (base: BaseTokens) => {
|
|
|
1259
1266
|
pale: string;
|
|
1260
1267
|
faint: string;
|
|
1261
1268
|
};
|
|
1262
|
-
|
|
1263
|
-
heavy: string;
|
|
1264
|
-
bold: string;
|
|
1265
|
-
soft: string;
|
|
1266
|
-
pale: string;
|
|
1267
|
-
faint: string;
|
|
1268
|
-
};
|
|
1269
|
-
black: {
|
|
1269
|
+
yellow: {
|
|
1270
1270
|
heavy: string;
|
|
1271
1271
|
bold: string;
|
|
1272
1272
|
soft: string;
|
|
@@ -629,6 +629,13 @@ export var getDefaultTokens = function (base) {
|
|
|
629
629
|
pale: base.customizable.purple.vivid[92],
|
|
630
630
|
faint: base.customizable.purple.vivid[96],
|
|
631
631
|
},
|
|
632
|
+
yellow: {
|
|
633
|
+
heavy: base.customizable.yellow.vivid[48],
|
|
634
|
+
bold: base.customizable.yellow.vivid[68],
|
|
635
|
+
soft: base.customizable.yellow.vivid[80],
|
|
636
|
+
pale: base.customizable.yellow.vivid[92],
|
|
637
|
+
faint: base.customizable.yellow.vivid[96],
|
|
638
|
+
},
|
|
632
639
|
},
|
|
633
640
|
},
|
|
634
641
|
dark: {
|
|
@@ -1260,19 +1267,12 @@ export var getDefaultTokens = function (base) {
|
|
|
1260
1267
|
pale: base.customizable.purple.vivid[92],
|
|
1261
1268
|
faint: base.customizable.purple.vivid[96],
|
|
1262
1269
|
},
|
|
1263
|
-
|
|
1264
|
-
heavy: base.
|
|
1265
|
-
bold: base.
|
|
1266
|
-
soft: base.
|
|
1267
|
-
pale: base.
|
|
1268
|
-
faint: base.
|
|
1269
|
-
},
|
|
1270
|
-
black: {
|
|
1271
|
-
heavy: base.gray[36],
|
|
1272
|
-
bold: base.gray[52],
|
|
1273
|
-
soft: base.gray[76],
|
|
1274
|
-
pale: base.gray[88],
|
|
1275
|
-
faint: base.gray[92],
|
|
1270
|
+
yellow: {
|
|
1271
|
+
heavy: base.customizable.yellow.vivid[48],
|
|
1272
|
+
bold: base.customizable.yellow.vivid[68],
|
|
1273
|
+
soft: base.customizable.yellow.vivid[80],
|
|
1274
|
+
pale: base.customizable.yellow.vivid[92],
|
|
1275
|
+
faint: base.customizable.yellow.vivid[96],
|
|
1276
1276
|
},
|
|
1277
1277
|
},
|
|
1278
1278
|
},
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { converter } from 'culori';
|
|
2
|
+
import { HOVER_LIGHT_L, HOVER_LIGHT_C, HOVER_DARK_L, HOVER_DARK_C, PRESSED_LIGHT_L, PRESSED_LIGHT_C, PRESSED_DARK_L, PRESSED_DARK_C, } from '../constants/interaction-settings';
|
|
3
|
+
function applyOklchDelta(oklchColor, dL, dC) {
|
|
4
|
+
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;
|
|
5
|
+
var safeH = h === undefined || isNaN(h) ? 0 : h;
|
|
6
|
+
var newL = Math.max(0, Math.min(1, l + dL / 100));
|
|
7
|
+
var newC = Math.max(0, c + dC);
|
|
8
|
+
return "oklch(".concat(newL.toFixed(3), " ").concat(newC.toFixed(3), " ").concat(safeH.toFixed(0), ")");
|
|
9
|
+
}
|
|
10
|
+
export function getHover(hex) {
|
|
11
|
+
var toOklch = converter('oklch');
|
|
12
|
+
var oklchColor = toOklch(hex);
|
|
13
|
+
if (!oklchColor) {
|
|
14
|
+
return { light: hex, dark: hex };
|
|
15
|
+
}
|
|
16
|
+
var lightHoverColor = applyOklchDelta(oklchColor, HOVER_LIGHT_L, HOVER_LIGHT_C);
|
|
17
|
+
var darkHoverColor = applyOklchDelta(oklchColor, HOVER_DARK_L, HOVER_DARK_C);
|
|
18
|
+
return {
|
|
19
|
+
light: lightHoverColor,
|
|
20
|
+
dark: darkHoverColor,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function getPressed(hex) {
|
|
24
|
+
var toOklch = converter('oklch');
|
|
25
|
+
var oklchColor = toOklch(hex);
|
|
26
|
+
if (!oklchColor) {
|
|
27
|
+
return { light: hex, dark: hex };
|
|
28
|
+
}
|
|
29
|
+
var lightPressedColor = applyOklchDelta(oklchColor, PRESSED_LIGHT_L, PRESSED_LIGHT_C);
|
|
30
|
+
var darkPressedColor = applyOklchDelta(oklchColor, PRESSED_DARK_L, PRESSED_DARK_C);
|
|
31
|
+
return {
|
|
32
|
+
light: lightPressedColor,
|
|
33
|
+
dark: darkPressedColor,
|
|
34
|
+
};
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skbkontur/colors",
|
|
3
|
-
"version": "1.1.2-
|
|
3
|
+
"version": "1.1.2-cbc4b.0",
|
|
4
4
|
"author": "Kontur",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"registry": "https://registry.npmjs.org/"
|
|
8
8
|
},
|
|
9
|
-
"module": "dist/esm/get-
|
|
10
|
-
"main": "dist/cjs/get-
|
|
9
|
+
"module": "dist/esm/get-colors.js",
|
|
10
|
+
"main": "dist/cjs/get-colors.js",
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"clean": "git clean -fdxqe node_modules",
|
package/dist/cjs/get-tokens.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTokens = void 0;
|
|
4
|
-
var get_base_tokens_1 = require("./get-base-tokens");
|
|
5
|
-
var get_default_tokens_1 = require("./get-default-tokens");
|
|
6
|
-
function getTokens(params) {
|
|
7
|
-
var base = (0, get_base_tokens_1.getBaseTokens)(params);
|
|
8
|
-
if (params.overrides) {
|
|
9
|
-
return params.overrides(base);
|
|
10
|
-
}
|
|
11
|
-
return (0, get_default_tokens_1.getDefaultTokens)(base);
|
|
12
|
-
}
|
|
13
|
-
exports.getTokens = getTokens;
|
package/dist/esm/get-tokens.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { getBaseTokens } from './get-base-tokens';
|
|
2
|
-
import { getDefaultTokens } from './get-default-tokens';
|
|
3
|
-
export function getTokens(params) {
|
|
4
|
-
var base = getBaseTokens(params);
|
|
5
|
-
if (params.overrides) {
|
|
6
|
-
return params.overrides(base);
|
|
7
|
-
}
|
|
8
|
-
return getDefaultTokens(base);
|
|
9
|
-
}
|