@skbkontur/colors 2.0.0-alpha.2 → 2.0.0-alpha.4
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 +104 -171
- 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/constants/default-swatch.js → lib/consts/default-swatch.ts} +11 -7
- package/lib/consts/params/abney-correction.d.ts +2 -0
- package/lib/consts/params/abney-correction.js +1102 -0
- package/{dist/cjs/constants/abney-correction.js → lib/consts/params/abney-correction.ts} +3 -4
- package/lib/consts/params/chroma-params.d.ts +2 -0
- package/lib/consts/params/chroma-params.js +102 -0
- package/{dist/esm/constants/chroma-settings.js → lib/consts/params/chroma-params.ts} +3 -1
- package/lib/consts/params/interactions.ts +9 -0
- package/lib/consts/params/logo-lightness.d.ts +1 -0
- package/lib/consts/params/logo-lightness.js +1 -0
- package/lib/consts/params/logo-lightness.ts +1 -0
- package/{dist/cjs/constants → lib/consts/params}/promo-hue-shift.d.ts +1 -1
- package/lib/consts/params/promo-hue-shift.js +11 -0
- package/{dist/esm/constants/promo-hue-shift.js → lib/consts/params/promo-hue-shift.ts} +1 -1
- package/{dist/cjs/constants → lib/consts/params}/warning-hue-patch.d.ts +1 -1
- package/lib/consts/params/warning-hue-patch.js +22 -0
- package/{dist/esm/constants/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/lib/get-colors-base.ts +99 -0
- 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 +40 -0
- package/lib/get-colors.js +28 -0
- package/lib/get-colors.ts +65 -0
- package/{dist/cjs → 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/cjs → 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/cjs/types/generator-tokens.d.ts → lib/types/tokens-base-generator.ts} +12 -17
- package/lib/types/tokens-base.d.ts +55 -0
- package/{dist/esm/types/base-tokens.d.ts → lib/types/tokens-base.ts} +7 -2
- package/lib/types/tokens.d.ts +12 -0
- package/lib/types/tokens.js +1 -0
- package/lib/types/tokens.ts +18 -0
- package/lib/utils/convert-color.d.ts +3 -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 +44 -19
- package/{dist/tokens → tokens}/brand-blue-deep_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-blue-deep_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-blue_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-blue_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-green_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-green_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-mint_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-mint_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-orange_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-purple_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-purple_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-red_accent-gray.css +33 -33
- package/{dist/tokens → tokens}/brand-violet_accent-brand.css +33 -33
- package/{dist/tokens → tokens}/brand-violet_accent-gray.css +33 -33
- package/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
- package/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
- package/tokens-mobile/brand-blue_accent-brand.json +718 -0
- package/tokens-mobile/brand-blue_accent-gray.json +718 -0
- package/tokens-mobile/brand-green_accent-brand.json +718 -0
- package/tokens-mobile/brand-green_accent-gray.json +718 -0
- package/tokens-mobile/brand-mint_accent-brand.json +718 -0
- package/tokens-mobile/brand-mint_accent-gray.json +718 -0
- package/tokens-mobile/brand-orange_accent-gray.json +718 -0
- package/tokens-mobile/brand-purple_accent-brand.json +718 -0
- package/tokens-mobile/brand-purple_accent-gray.json +718 -0
- package/tokens-mobile/brand-red_accent-gray.json +718 -0
- package/tokens-mobile/brand-violet_accent-brand.json +718 -0
- package/tokens-mobile/brand-violet_accent-gray.json +718 -0
- package/dist/cjs/constants/abney-correction.d.ts +0 -2
- package/dist/cjs/constants/chroma-settings.d.ts +0 -2
- package/dist/cjs/constants/chroma-settings.js +0 -105
- package/dist/cjs/constants/default-swatch.d.ts +0 -109
- package/dist/cjs/constants/default-swatch.js +0 -112
- package/dist/cjs/constants/interaction-settings.js +0 -19
- package/dist/cjs/constants/logo-lightness.d.ts +0 -1
- package/dist/cjs/constants/logo-lightness.js +0 -4
- package/dist/cjs/constants/promo-hue-shift.js +0 -14
- package/dist/cjs/constants/warning-hue-patch.js +0 -25
- package/dist/cjs/get-base-tokens.d.ts +0 -26
- package/dist/cjs/get-base-tokens.js +0 -319
- package/dist/cjs/get-colors.d.ts +0 -20
- package/dist/cjs/get-colors.js +0 -20
- package/dist/cjs/get-default-tokens.d.ts +0 -645
- package/dist/cjs/get-default-tokens.js +0 -996
- package/dist/cjs/helpers/get-interactions.js +0 -61
- package/dist/cjs/helpers/get-logo.js +0 -32
- package/dist/cjs/helpers/get-palette.d.ts +0 -76
- package/dist/cjs/helpers/get-palette.js +0 -287
- package/dist/cjs/helpers/get-promo.d.ts +0 -12
- package/dist/cjs/helpers/get-promo.js +0 -56
- package/dist/cjs/types/base-tokens.d.ts +0 -125
- package/dist/cjs/types/base-tokens.js +0 -2
- package/dist/cjs/types/generator-tokens.js +0 -2
- package/dist/cjs/utils/format-variable.js +0 -15
- 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/constants/abney-correction.d.ts +0 -2
- package/dist/esm/constants/abney-correction.js +0 -1102
- package/dist/esm/constants/chroma-settings.d.ts +0 -2
- package/dist/esm/constants/default-swatch.d.ts +0 -109
- package/dist/esm/constants/interaction-settings.d.ts +0 -8
- package/dist/esm/constants/logo-lightness.d.ts +0 -1
- package/dist/esm/constants/logo-lightness.js +0 -1
- package/dist/esm/constants/promo-hue-shift.d.ts +0 -3
- package/dist/esm/constants/warning-hue-patch.d.ts +0 -3
- package/dist/esm/get-base-tokens.d.ts +0 -26
- package/dist/esm/get-base-tokens.js +0 -257
- package/dist/esm/get-colors.d.ts +0 -20
- package/dist/esm/get-colors.js +0 -16
- 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.d.ts +0 -7
- package/dist/esm/helpers/get-interactions.js +0 -49
- package/dist/esm/helpers/get-logo.d.ts +0 -6
- 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/types/generator-tokens.d.ts +0 -43
- package/dist/esm/utils/format-variable.d.ts +0 -2
- 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/dist/tokens-mobile/brand-blue-deep_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-blue_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-blue_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-green_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-green_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-mint_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-mint_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-orange_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-purple_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-purple_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-red_accent-gray.json +0 -718
- package/dist/tokens-mobile/brand-violet_accent-brand.json +0 -718
- package/dist/tokens-mobile/brand-violet_accent-gray.json +0 -718
- /package/{dist/colors.js → colors.js} +0 -0
- /package/{dist/cjs/constants/interaction-settings.d.ts → lib/consts/params/interactions.d.ts} +0 -0
- /package/{dist/esm/constants/interaction-settings.js → lib/consts/params/interactions.js} +0 -0
- /package/{dist/esm/types/base-tokens.js → lib/types/tokens-base-generator.js} +0 -0
- /package/{dist/esm/types/generator-tokens.js → lib/types/tokens-base.js} +0 -0
- /package/{dist/cjs → lib}/utils/format-variable.d.ts +0 -0
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
export declare const brand: {
|
|
2
|
-
red: string;
|
|
3
|
-
orange: string;
|
|
4
|
-
green: string;
|
|
5
|
-
mint: string;
|
|
6
|
-
blue: string;
|
|
7
|
-
blueDeep: string;
|
|
8
|
-
violet: string;
|
|
9
|
-
purple: string;
|
|
10
|
-
};
|
|
11
|
-
export declare const system: {
|
|
12
|
-
warning: string;
|
|
13
|
-
error: string;
|
|
14
|
-
success: string;
|
|
15
|
-
accent: string;
|
|
16
|
-
};
|
|
17
|
-
export declare const customizable: {
|
|
18
|
-
red: string;
|
|
19
|
-
orange: string;
|
|
20
|
-
green: string;
|
|
21
|
-
mint: string;
|
|
22
|
-
blue: string;
|
|
23
|
-
blueDeep: string;
|
|
24
|
-
violet: string;
|
|
25
|
-
purple: string;
|
|
26
|
-
yellow: string;
|
|
27
|
-
};
|
|
28
|
-
export declare const gray: {
|
|
29
|
-
0: string;
|
|
30
|
-
16: string;
|
|
31
|
-
20: string;
|
|
32
|
-
24: string;
|
|
33
|
-
28: string;
|
|
34
|
-
32: string;
|
|
35
|
-
36: string;
|
|
36
|
-
40: string;
|
|
37
|
-
44: string;
|
|
38
|
-
48: string;
|
|
39
|
-
52: string;
|
|
40
|
-
56: string;
|
|
41
|
-
60: string;
|
|
42
|
-
64: string;
|
|
43
|
-
68: string;
|
|
44
|
-
72: string;
|
|
45
|
-
76: string;
|
|
46
|
-
80: string;
|
|
47
|
-
84: string;
|
|
48
|
-
88: string;
|
|
49
|
-
92: string;
|
|
50
|
-
96: string;
|
|
51
|
-
98: string;
|
|
52
|
-
100: string;
|
|
53
|
-
};
|
|
54
|
-
export declare const whiteAlpha: {
|
|
55
|
-
4: string;
|
|
56
|
-
6: string;
|
|
57
|
-
8: string;
|
|
58
|
-
12: string;
|
|
59
|
-
16: string;
|
|
60
|
-
20: string;
|
|
61
|
-
24: string;
|
|
62
|
-
28: string;
|
|
63
|
-
32: string;
|
|
64
|
-
36: string;
|
|
65
|
-
40: string;
|
|
66
|
-
44: string;
|
|
67
|
-
48: string;
|
|
68
|
-
52: string;
|
|
69
|
-
56: string;
|
|
70
|
-
60: string;
|
|
71
|
-
64: string;
|
|
72
|
-
68: string;
|
|
73
|
-
72: string;
|
|
74
|
-
76: string;
|
|
75
|
-
80: string;
|
|
76
|
-
84: string;
|
|
77
|
-
88: string;
|
|
78
|
-
92: string;
|
|
79
|
-
96: string;
|
|
80
|
-
100: string;
|
|
81
|
-
};
|
|
82
|
-
export declare const blackAlpha: {
|
|
83
|
-
4: string;
|
|
84
|
-
6: string;
|
|
85
|
-
8: string;
|
|
86
|
-
12: string;
|
|
87
|
-
16: string;
|
|
88
|
-
20: string;
|
|
89
|
-
24: string;
|
|
90
|
-
28: string;
|
|
91
|
-
32: string;
|
|
92
|
-
36: string;
|
|
93
|
-
40: string;
|
|
94
|
-
44: string;
|
|
95
|
-
48: string;
|
|
96
|
-
52: string;
|
|
97
|
-
56: string;
|
|
98
|
-
60: string;
|
|
99
|
-
64: string;
|
|
100
|
-
68: string;
|
|
101
|
-
72: string;
|
|
102
|
-
76: string;
|
|
103
|
-
80: string;
|
|
104
|
-
84: string;
|
|
105
|
-
88: string;
|
|
106
|
-
92: string;
|
|
107
|
-
96: string;
|
|
108
|
-
100: string;
|
|
109
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const MIN_LOGO_LIGHTNESS = 64;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export var MIN_LOGO_LIGHTNESS = 64;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
2
|
-
import type { BaseTokens } from './types/base-tokens';
|
|
3
|
-
type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
|
|
4
|
-
export declare const ACCENT_PARAMS: string[];
|
|
5
|
-
export interface ColorObject {
|
|
6
|
-
[key: string]: ColorValue;
|
|
7
|
-
}
|
|
8
|
-
export type ColorValue = string | ColorObject | ColorValue[];
|
|
9
|
-
type ColorStructure = ColorObject | ColorValue[];
|
|
10
|
-
export type ColorFormat = 'hex/rgba' | 'rgb/rgba' | 'oklch' | 'hex-aarrggbb';
|
|
11
|
-
export interface ConfigOptions {
|
|
12
|
-
brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
|
|
13
|
-
accent: PresetOrCustom<(typeof ACCENT_PARAMS)[number]>;
|
|
14
|
-
system?: typeof DEFAULT_SWATCH.system;
|
|
15
|
-
format?: ColorFormat;
|
|
16
|
-
}
|
|
17
|
-
export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
|
|
18
|
-
export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
|
|
19
|
-
export declare const convertOklchToRgba: (oklchString: string) => string;
|
|
20
|
-
export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
|
|
21
|
-
export declare const convertHexToRgbString: (hexString: string) => string;
|
|
22
|
-
export declare function convertHexValuesToRgb(obj: ColorStructure): ColorStructure;
|
|
23
|
-
export declare const convertToAarrggbb: (colorString: string) => string;
|
|
24
|
-
export declare function convertToAarrggbbRecursive(obj: ColorStructure): ColorStructure;
|
|
25
|
-
export declare function convertColorFormat(obj: ColorStructure, format?: ColorFormat): ColorStructure;
|
|
26
|
-
export {};
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import { converter, formatHex } from 'culori';
|
|
2
|
-
import { calcOnBrand, getPalette } from './helpers/get-palette';
|
|
3
|
-
import { getPromo } from './helpers/get-promo';
|
|
4
|
-
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
5
|
-
import { getLogo } from './helpers/get-logo';
|
|
6
|
-
import { getHover, getPressed } from './helpers/get-interactions';
|
|
7
|
-
export var ACCENT_PARAMS = ['brand', 'gray'];
|
|
8
|
-
export function getBaseTokens(_a) {
|
|
9
|
-
var brand = _a.brand,
|
|
10
|
-
_b = _a.accent,
|
|
11
|
-
accent = _b === void 0 ? 'gray' : _b,
|
|
12
|
-
_c = _a.system,
|
|
13
|
-
system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
|
|
14
|
-
var isPresetColor = brand in DEFAULT_SWATCH.brand;
|
|
15
|
-
var brandColor;
|
|
16
|
-
if (isPresetColor) {
|
|
17
|
-
brandColor = DEFAULT_SWATCH.brand[brand];
|
|
18
|
-
} else {
|
|
19
|
-
brandColor = brand;
|
|
20
|
-
}
|
|
21
|
-
var accentColor;
|
|
22
|
-
if (accent === 'brand') {
|
|
23
|
-
accentColor = brandColor;
|
|
24
|
-
} else if (accent !== 'gray') {
|
|
25
|
-
accentColor = accent;
|
|
26
|
-
}
|
|
27
|
-
var brandPalette = getPalette({ color: brandColor });
|
|
28
|
-
var accentPalette;
|
|
29
|
-
if (accent === 'brand') {
|
|
30
|
-
accentPalette = brandPalette;
|
|
31
|
-
} else if (accent !== 'gray' && accentColor) {
|
|
32
|
-
accentPalette = getPalette({ color: accentColor });
|
|
33
|
-
}
|
|
34
|
-
var customizablePalettes = {};
|
|
35
|
-
for (var colorKey in DEFAULT_SWATCH.customizable) {
|
|
36
|
-
var key = colorKey;
|
|
37
|
-
if (key === brand && isPresetColor) {
|
|
38
|
-
customizablePalettes[key] = brandPalette;
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
customizablePalettes[key] = getPalette({
|
|
42
|
-
color: DEFAULT_SWATCH.customizable[key],
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
brand: {
|
|
47
|
-
logo: getLogo(brandColor),
|
|
48
|
-
promo: getPromo(brandColor),
|
|
49
|
-
original: brandColor,
|
|
50
|
-
interactions: {
|
|
51
|
-
hover: getHover(brandColor),
|
|
52
|
-
pressed: getPressed(brandColor),
|
|
53
|
-
},
|
|
54
|
-
palette: brandPalette,
|
|
55
|
-
},
|
|
56
|
-
accent: accentColor
|
|
57
|
-
? {
|
|
58
|
-
original: {
|
|
59
|
-
light: accentColor,
|
|
60
|
-
dark: accentColor,
|
|
61
|
-
},
|
|
62
|
-
interactions: {
|
|
63
|
-
hover: getHover(accentColor),
|
|
64
|
-
pressed: getPressed(accentColor),
|
|
65
|
-
},
|
|
66
|
-
palette: accentPalette,
|
|
67
|
-
}
|
|
68
|
-
: undefined,
|
|
69
|
-
warning: getPalette({ color: system.warning }),
|
|
70
|
-
error: getPalette({ color: system.error }),
|
|
71
|
-
success: getPalette({ color: system.success }),
|
|
72
|
-
gray: DEFAULT_SWATCH.gray,
|
|
73
|
-
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
74
|
-
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
75
|
-
onBrand: calcOnBrand(brandColor),
|
|
76
|
-
onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
|
|
77
|
-
customizable: customizablePalettes,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
export function convertOklchToHex(obj) {
|
|
81
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
82
|
-
return obj;
|
|
83
|
-
}
|
|
84
|
-
if (Array.isArray(obj)) {
|
|
85
|
-
return obj.map(function (item) {
|
|
86
|
-
if (typeof item === 'object' && item !== null) {
|
|
87
|
-
return convertOklchToHex(item);
|
|
88
|
-
}
|
|
89
|
-
return item;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
var newObj = {};
|
|
93
|
-
for (var key in obj) {
|
|
94
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
95
|
-
var value = obj[key];
|
|
96
|
-
if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
|
|
97
|
-
var oklchColor = converter('oklch')(value);
|
|
98
|
-
var rgbColor = converter('rgb')(oklchColor);
|
|
99
|
-
value = formatHex(rgbColor);
|
|
100
|
-
}
|
|
101
|
-
if (typeof value === 'object' && value !== null) {
|
|
102
|
-
newObj[key] = convertOklchToHex(value);
|
|
103
|
-
} else {
|
|
104
|
-
newObj[key] = value;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
return newObj;
|
|
109
|
-
}
|
|
110
|
-
export var convertOklchToRgba = function (oklchString) {
|
|
111
|
-
var _a;
|
|
112
|
-
var oklch = converter('oklch')(oklchString);
|
|
113
|
-
var rgb = converter('rgb')(oklch);
|
|
114
|
-
var r = Math.round(rgb.r * 255);
|
|
115
|
-
var g = Math.round(rgb.g * 255);
|
|
116
|
-
var b = Math.round(rgb.b * 255);
|
|
117
|
-
var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
|
|
118
|
-
return 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
|
|
119
|
-
};
|
|
120
|
-
export function convertAlphaOklchToRgba(obj) {
|
|
121
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
122
|
-
return obj;
|
|
123
|
-
}
|
|
124
|
-
if (Array.isArray(obj)) {
|
|
125
|
-
return obj.map(function (item) {
|
|
126
|
-
if (typeof item === 'object' && item !== null) {
|
|
127
|
-
return convertAlphaOklchToRgba(item);
|
|
128
|
-
}
|
|
129
|
-
return item;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
var newObj = {};
|
|
133
|
-
for (var key in obj) {
|
|
134
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
135
|
-
var value = obj[key];
|
|
136
|
-
// Конвертируем OKLCH с альфа-каналом (содержит '/') в RGBA
|
|
137
|
-
if (typeof value === 'string' && value.includes('oklch(')) {
|
|
138
|
-
value = convertOklchToRgba(value);
|
|
139
|
-
}
|
|
140
|
-
if (typeof value === 'object' && value !== null) {
|
|
141
|
-
newObj[key] = convertAlphaOklchToRgba(value);
|
|
142
|
-
} else {
|
|
143
|
-
newObj[key] = value;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return newObj;
|
|
148
|
-
}
|
|
149
|
-
export var convertHexToRgbString = function (hexString) {
|
|
150
|
-
var _a;
|
|
151
|
-
var color = converter('rgb')(hexString);
|
|
152
|
-
if (!color) {
|
|
153
|
-
return hexString;
|
|
154
|
-
}
|
|
155
|
-
var r = Math.round(color.r * 255);
|
|
156
|
-
var g = Math.round(color.g * 255);
|
|
157
|
-
var b = Math.round(color.b * 255);
|
|
158
|
-
var alpha = (_a = color.alpha) !== null && _a !== void 0 ? _a : 1;
|
|
159
|
-
return alpha === 1
|
|
160
|
-
? 'rgb('.concat(r, ', ').concat(g, ', ').concat(b, ')')
|
|
161
|
-
: 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
|
|
162
|
-
};
|
|
163
|
-
export function convertHexValuesToRgb(obj) {
|
|
164
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
165
|
-
return obj;
|
|
166
|
-
}
|
|
167
|
-
if (Array.isArray(obj)) {
|
|
168
|
-
return obj.map(function (item) {
|
|
169
|
-
if (typeof item === 'object' && item !== null) {
|
|
170
|
-
return convertHexValuesToRgb(item);
|
|
171
|
-
}
|
|
172
|
-
return item;
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
var newObj = {};
|
|
176
|
-
for (var key in obj) {
|
|
177
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
178
|
-
var value = obj[key];
|
|
179
|
-
// Конвертируем HEX-строки в RGB(A)-строки
|
|
180
|
-
if (typeof value === 'string' && value.startsWith('#')) {
|
|
181
|
-
newObj[key] = convertHexToRgbString(value);
|
|
182
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
183
|
-
newObj[key] = convertHexValuesToRgb(value);
|
|
184
|
-
} else {
|
|
185
|
-
newObj[key] = value;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
return newObj;
|
|
190
|
-
}
|
|
191
|
-
export var convertToAarrggbb = function (colorString) {
|
|
192
|
-
var _a;
|
|
193
|
-
var color = converter('rgb')(colorString);
|
|
194
|
-
if (!color) {
|
|
195
|
-
return colorString;
|
|
196
|
-
}
|
|
197
|
-
var r = Math.round(color.r * 255);
|
|
198
|
-
var g = Math.round(color.g * 255);
|
|
199
|
-
var b = Math.round(color.b * 255);
|
|
200
|
-
var alpha = Math.round(((_a = color.alpha) !== null && _a !== void 0 ? _a : 1) * 255);
|
|
201
|
-
var toHex = function (c) {
|
|
202
|
-
return c.toString(16).padStart(2, '0');
|
|
203
|
-
};
|
|
204
|
-
var rgbHex = ''.concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).toUpperCase();
|
|
205
|
-
if (alpha === 255) {
|
|
206
|
-
return '#'.concat(rgbHex);
|
|
207
|
-
}
|
|
208
|
-
return '#'.concat(toHex(alpha)).concat(rgbHex).toUpperCase();
|
|
209
|
-
};
|
|
210
|
-
export function convertToAarrggbbRecursive(obj) {
|
|
211
|
-
if (typeof obj !== 'object' || obj === null) {
|
|
212
|
-
return obj;
|
|
213
|
-
}
|
|
214
|
-
if (Array.isArray(obj)) {
|
|
215
|
-
return obj.map(function (item) {
|
|
216
|
-
if (typeof item === 'object' && item !== null) {
|
|
217
|
-
return convertToAarrggbbRecursive(item);
|
|
218
|
-
}
|
|
219
|
-
return item;
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
|
-
var newObj = {};
|
|
223
|
-
for (var key in obj) {
|
|
224
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
225
|
-
var value = obj[key];
|
|
226
|
-
// Конвертируем строки цветов (HEX, RGBA) в AARRGGBB
|
|
227
|
-
if (typeof value === 'string') {
|
|
228
|
-
newObj[key] = convertToAarrggbb(value); // Измененная логика в этой функции
|
|
229
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
230
|
-
newObj[key] = convertToAarrggbbRecursive(value);
|
|
231
|
-
} else {
|
|
232
|
-
newObj[key] = value;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return newObj;
|
|
237
|
-
}
|
|
238
|
-
export function convertColorFormat(obj, format) {
|
|
239
|
-
if (format === void 0) {
|
|
240
|
-
format = 'hex/rgba';
|
|
241
|
-
}
|
|
242
|
-
var result = obj;
|
|
243
|
-
result = convertOklchToHex(obj);
|
|
244
|
-
result = convertAlphaOklchToRgba(result);
|
|
245
|
-
switch (format) {
|
|
246
|
-
case 'oklch':
|
|
247
|
-
return obj;
|
|
248
|
-
case 'hex/rgba':
|
|
249
|
-
return result;
|
|
250
|
-
case 'rgb/rgba':
|
|
251
|
-
return convertHexValuesToRgb(result);
|
|
252
|
-
case 'hex-aarrggbb':
|
|
253
|
-
return convertToAarrggbbRecursive(result);
|
|
254
|
-
default:
|
|
255
|
-
return result;
|
|
256
|
-
}
|
|
257
|
-
}
|
package/dist/esm/get-colors.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { type ConfigOptions, type ColorFormat } 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
|
-
format?: ColorFormat;
|
|
14
|
-
}
|
|
15
|
-
export declare function getColors(params: SemanticConfigOptions<DefaultTokens>): DefaultTokens;
|
|
16
|
-
export declare function getColors<T>(
|
|
17
|
-
params: SemanticConfigOptions<T> & {
|
|
18
|
-
overrides: (base: BaseTokens) => Themed<T>;
|
|
19
|
-
}
|
|
20
|
-
): Themed<T>;
|
package/dist/esm/get-colors.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getBaseTokens, convertColorFormat } 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
|
-
var result;
|
|
9
|
-
if (params.overrides) {
|
|
10
|
-
result = params.overrides(base, defaults, params)[theme];
|
|
11
|
-
} else {
|
|
12
|
-
result = defaults[theme];
|
|
13
|
-
}
|
|
14
|
-
var finalResult = convertColorFormat(result, params.format);
|
|
15
|
-
return finalResult;
|
|
16
|
-
}
|