@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,22 +1,22 @@
|
|
|
1
1
|
export var WARNING_HUE_PATCH = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
22
|
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
2
2
|
import type { BaseTokens } from './types/base-tokens';
|
|
3
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[];
|
|
4
10
|
export interface ConfigOptions {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
11
|
+
brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
|
|
12
|
+
accent: PresetOrCustom<(typeof ACCENT_PARAMS)[number]>;
|
|
13
|
+
system?: typeof DEFAULT_SWATCH.system;
|
|
8
14
|
}
|
|
9
15
|
export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
|
|
10
|
-
export declare
|
|
11
|
-
export declare const camelCaseToKebabCase: (str: string) => string;
|
|
12
|
-
export declare const kebabCaseToCamelCase: (str: string) => string;
|
|
13
|
-
export declare function convertOklchToHex(obj: any): any;
|
|
16
|
+
export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
|
|
14
17
|
export declare const convertOklchToRgba: (oklchString: string) => string;
|
|
15
|
-
export declare function convertAlphaOklchToRgba(obj:
|
|
16
|
-
export declare function flattenObject(obj: any, prefix?: string): any;
|
|
18
|
+
export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
|
|
17
19
|
export {};
|
|
@@ -1,189 +1,147 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { converter, formatHex } from 'culori';
|
|
13
2
|
import { calcOnBrand, getPalette } from './helpers/get-palette';
|
|
14
3
|
import { getPromo } from './helpers/get-promo';
|
|
15
4
|
import * as DEFAULT_SWATCH from './constants/default-swatch';
|
|
16
5
|
import { getLogo } from './helpers/get-logo';
|
|
6
|
+
import { getHover, getPressed } from './helpers/get-interactions';
|
|
7
|
+
export var ACCENT_PARAMS = ['brand', 'gray'];
|
|
17
8
|
export function getBaseTokens(_a) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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;
|
|
31
40
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
var errorPalette = getPalette({ color: system.error });
|
|
36
|
-
var successPalette = getPalette({
|
|
37
|
-
color: system.success,
|
|
41
|
+
customizablePalettes[key] = getPalette({
|
|
42
|
+
color: DEFAULT_SWATCH.customizable[key],
|
|
38
43
|
});
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
// todo Fix gray
|
|
75
|
-
light: accent === 'gray' ? accent : '#3d3d3d',
|
|
76
|
-
dark: accent === 'gray' ? accent : '#3d3d3d',
|
|
77
|
-
},
|
|
78
|
-
// todo interactions
|
|
79
|
-
interactions: {
|
|
80
|
-
hover: {
|
|
81
|
-
light: '',
|
|
82
|
-
dark: '',
|
|
83
|
-
},
|
|
84
|
-
pressed: {
|
|
85
|
-
light: '',
|
|
86
|
-
dark: '',
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
palette: accentPalette || undefined,
|
|
90
|
-
},
|
|
91
|
-
warning: warningPalette,
|
|
92
|
-
error: errorPalette,
|
|
93
|
-
success: successPalette,
|
|
94
|
-
gray: DEFAULT_SWATCH.gray,
|
|
95
|
-
whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
|
|
96
|
-
blackAlpha: DEFAULT_SWATCH.blackAlpha,
|
|
97
|
-
onBrand: calcOnBrand(brandColor),
|
|
98
|
-
customizable: customizable,
|
|
99
|
-
};
|
|
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
|
+
};
|
|
100
79
|
}
|
|
101
|
-
export var colorToHex = function (color) {
|
|
102
|
-
if (DEFAULT_SWATCH.brand[color]) {
|
|
103
|
-
return DEFAULT_SWATCH.brand[color];
|
|
104
|
-
}
|
|
105
|
-
return color;
|
|
106
|
-
};
|
|
107
|
-
export var camelCaseToKebabCase = function (str) {
|
|
108
|
-
return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
|
|
109
|
-
};
|
|
110
|
-
export var kebabCaseToCamelCase = function (str) {
|
|
111
|
-
return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
|
|
112
|
-
};
|
|
113
80
|
export function convertOklchToHex(obj) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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
|
+
}
|
|
135
106
|
}
|
|
136
|
-
|
|
107
|
+
}
|
|
108
|
+
return newObj;
|
|
137
109
|
}
|
|
138
110
|
export var convertOklchToRgba = function (oklchString) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
var alpha = oklch.alpha;
|
|
148
|
-
return "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(alpha, ")");
|
|
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, ')');
|
|
149
119
|
};
|
|
150
120
|
export function convertAlphaOklchToRgba(obj) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
export function flattenObject(obj, prefix) {
|
|
175
|
-
if (prefix === void 0) { prefix = ''; }
|
|
176
|
-
var result = {};
|
|
177
|
-
for (var key in obj) {
|
|
178
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
179
|
-
var newKey = prefix ? "".concat(prefix, "-").concat(camelCaseToKebabCase(key)) : key;
|
|
180
|
-
if (typeof obj[key] === 'object' && !Array.isArray(obj[key])) {
|
|
181
|
-
result = __assign(__assign({}, result), flattenObject(obj[key], newKey));
|
|
182
|
-
}
|
|
183
|
-
else {
|
|
184
|
-
result[newKey] = obj[key];
|
|
185
|
-
}
|
|
186
|
-
}
|
|
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
|
+
if (typeof value === 'string' && value.includes('oklch(')) {
|
|
137
|
+
value = convertOklchToRgba(value);
|
|
138
|
+
}
|
|
139
|
+
if (typeof value === 'object' && value !== null) {
|
|
140
|
+
newObj[key] = convertAlphaOklchToRgba(value);
|
|
141
|
+
} else {
|
|
142
|
+
newObj[key] = value;
|
|
143
|
+
}
|
|
187
144
|
}
|
|
188
|
-
|
|
145
|
+
}
|
|
146
|
+
return newObj;
|
|
189
147
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
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>(
|
|
16
|
+
params: SemanticConfigOptions<T> & {
|
|
17
|
+
overrides: (base: BaseTokens) => Themed<T>;
|
|
18
|
+
}
|
|
19
|
+
): 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
|
+
}
|