@skbkontur/colors 2.0.0-alpha.1 → 2.0.0-alpha.3
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/CHANGELOG.md +84 -0
- package/README.md +104 -171
- package/dist/colors.default-dark.js +326 -319
- package/dist/colors.default-light.js +329 -319
- package/dist/colors.js +319 -319
- package/dist/colors.less +319 -319
- package/dist/colors.scss +319 -319
- package/dist/esm/consts/params/abney-correction.d.ts +2 -0
- package/dist/esm/consts/params/chroma-params.d.ts +2 -0
- package/dist/esm/{constants/chroma-settings.js → consts/params/chroma-params.js} +1 -1
- package/dist/esm/consts/params/logo-lightness.d.ts +1 -0
- package/dist/esm/consts/params/logo-lightness.js +1 -0
- package/dist/esm/get-colors-base.d.ts +12 -0
- package/dist/esm/get-colors-base.js +81 -0
- package/dist/{cjs/get-default-tokens.d.ts → esm/get-colors-default-tokens.d.ts} +2 -2
- package/dist/{cjs/get-default-tokens.js → esm/get-colors-default-tokens.js} +34 -38
- package/dist/esm/get-colors.d.ts +3 -9
- package/dist/esm/get-colors.js +6 -13
- package/dist/esm/get-default-tokens.d.ts +1 -1
- package/dist/esm/get-default-tokens.js +33 -33
- package/dist/esm/helpers/get-interactions.js +1 -1
- package/dist/esm/helpers/get-logo.js +4 -4
- package/dist/esm/helpers/get-palette.d.ts +3 -3
- package/dist/esm/helpers/get-palette.js +9 -9
- package/dist/esm/helpers/get-promo.js +1 -1
- package/dist/esm/types/{generator-tokens.d.ts → tokens-base-generator.d.ts} +2 -2
- package/dist/esm/types/tokens.d.ts +12 -0
- package/dist/esm/types/tokens.js +1 -0
- package/dist/esm/utils/convert-color.d.ts +3 -0
- package/dist/esm/utils/convert-color.js +133 -0
- package/dist/tokens/brand-blue-deep_accent-brand.css +33 -33
- package/dist/tokens/brand-blue-deep_accent-gray.css +33 -33
- package/dist/tokens/brand-blue_accent-brand.css +33 -33
- package/dist/tokens/brand-blue_accent-gray.css +33 -33
- package/dist/tokens/brand-green_accent-brand.css +33 -33
- package/dist/tokens/brand-green_accent-gray.css +33 -33
- package/dist/tokens/brand-mint_accent-brand.css +33 -33
- package/dist/tokens/brand-mint_accent-gray.css +33 -33
- package/dist/tokens/brand-orange_accent-gray.css +33 -33
- package/dist/tokens/brand-purple_accent-brand.css +33 -33
- package/dist/tokens/brand-purple_accent-gray.css +33 -33
- package/dist/tokens/brand-red_accent-gray.css +33 -33
- package/dist/tokens/brand-violet_accent-brand.css +33 -33
- package/dist/tokens/brand-violet_accent-gray.css +33 -33
- package/dist/tokens-js/brand-blue-deep_accent-brand.js +33 -33
- package/dist/tokens-js/brand-blue-deep_accent-gray.js +33 -33
- package/dist/tokens-js/brand-blue_accent-brand.js +33 -33
- package/dist/tokens-js/brand-blue_accent-gray.js +33 -33
- package/dist/tokens-js/brand-green_accent-brand.js +33 -33
- package/dist/tokens-js/brand-green_accent-gray.js +33 -33
- package/dist/tokens-js/brand-mint_accent-brand.js +33 -33
- package/dist/tokens-js/brand-mint_accent-gray.js +33 -33
- package/dist/tokens-js/brand-orange_accent-gray.js +33 -33
- package/dist/tokens-js/brand-purple_accent-brand.js +33 -33
- package/dist/tokens-js/brand-purple_accent-gray.js +33 -33
- package/dist/tokens-js/brand-red_accent-gray.js +33 -33
- package/dist/tokens-js/brand-violet_accent-brand.js +33 -33
- package/dist/tokens-js/brand-violet_accent-gray.js +33 -33
- package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +304 -304
- package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +304 -304
- package/dist/tokens-mobile/brand-blue_accent-brand.json +304 -304
- package/dist/tokens-mobile/brand-blue_accent-gray.json +304 -304
- package/dist/tokens-mobile/brand-green_accent-brand.json +304 -304
- package/dist/tokens-mobile/brand-green_accent-gray.json +304 -304
- package/dist/tokens-mobile/brand-mint_accent-brand.json +304 -304
- package/dist/tokens-mobile/brand-mint_accent-gray.json +304 -304
- package/dist/tokens-mobile/brand-orange_accent-gray.json +303 -303
- package/dist/tokens-mobile/brand-purple_accent-brand.json +304 -304
- package/dist/tokens-mobile/brand-purple_accent-gray.json +304 -304
- package/dist/tokens-mobile/brand-red_accent-gray.json +303 -303
- package/dist/tokens-mobile/brand-violet_accent-brand.json +300 -300
- package/dist/tokens-mobile/brand-violet_accent-gray.json +302 -302
- package/package.json +13 -22
- package/scripts/babel-register.js +4 -0
- package/scripts/tokens-base.json +3499 -0
- package/scripts/tokens.json +710 -0
- package/dist/cjs/constants/abney-correction.d.ts +0 -2
- package/dist/cjs/constants/abney-correction.js +0 -1105
- 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.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 -19
- package/dist/cjs/get-base-tokens.js +0 -199
- package/dist/cjs/get-colors.d.ts +0 -19
- package/dist/cjs/get-colors.js +0 -25
- package/dist/cjs/helpers/get-interactions.d.ts +0 -7
- package/dist/cjs/helpers/get-interactions.js +0 -61
- package/dist/cjs/helpers/get-logo.d.ts +0 -6
- 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.js +0 -2
- package/dist/cjs/types/generator-tokens.d.ts +0 -43
- package/dist/cjs/types/generator-tokens.js +0 -2
- package/dist/cjs/utils/format-variable.d.ts +0 -2
- package/dist/cjs/utils/format-variable.js +0 -15
- package/dist/esm/constants/abney-correction.d.ts +0 -2
- 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 -19
- package/dist/esm/get-base-tokens.js +0 -147
- package/dist/esm/types/base-tokens.d.ts +0 -125
- /package/dist/{cjs/constants → esm/consts}/default-swatch.d.ts +0 -0
- /package/dist/esm/{constants → consts}/default-swatch.js +0 -0
- /package/dist/esm/{constants → consts/params}/abney-correction.js +0 -0
- /package/dist/{cjs/constants/interaction-settings.d.ts → esm/consts/params/interactions.d.ts} +0 -0
- /package/dist/esm/{constants/interaction-settings.js → consts/params/interactions.js} +0 -0
- /package/dist/{cjs/constants → esm/consts/params}/promo-hue-shift.d.ts +0 -0
- /package/dist/esm/{constants → consts/params}/promo-hue-shift.js +0 -0
- /package/dist/{cjs/constants → esm/consts/params}/warning-hue-patch.d.ts +0 -0
- /package/dist/esm/{constants → consts/params}/warning-hue-patch.js +0 -0
- /package/dist/esm/types/{base-tokens.js → tokens-base-generator.js} +0 -0
- /package/dist/{cjs/types/base-tokens.d.ts → esm/types/tokens-base.d.ts} +0 -0
- /package/dist/esm/types/{generator-tokens.js → tokens-base.js} +0 -0
|
@@ -1,147 +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
|
-
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
|
-
}
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
return newObj;
|
|
147
|
-
}
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
export interface BaseTokens {
|
|
2
|
-
brand: {
|
|
3
|
-
logo: ThemedValue;
|
|
4
|
-
original: string;
|
|
5
|
-
promo: string;
|
|
6
|
-
interactions: {
|
|
7
|
-
hover: ThemedValue;
|
|
8
|
-
pressed: ThemedValue;
|
|
9
|
-
};
|
|
10
|
-
palette: ColorPalette;
|
|
11
|
-
};
|
|
12
|
-
accent?: {
|
|
13
|
-
original: ThemedValue;
|
|
14
|
-
interactions: {
|
|
15
|
-
hover: ThemedValue;
|
|
16
|
-
pressed: ThemedValue;
|
|
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
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export interface ColorPalette {
|
|
41
|
-
vivid: ColorWithScale<ChromaScale>;
|
|
42
|
-
normal: ColorWithScale<ChromaScale>;
|
|
43
|
-
dim: ColorWithScale<ChromaScale>;
|
|
44
|
-
}
|
|
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;
|
|
118
|
-
type ColorWithScale<T extends string | number> = {
|
|
119
|
-
[K in T]: string;
|
|
120
|
-
};
|
|
121
|
-
export interface ThemedValue {
|
|
122
|
-
light: string;
|
|
123
|
-
dark: string;
|
|
124
|
-
}
|
|
125
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/dist/{cjs/constants/interaction-settings.d.ts → esm/consts/params/interactions.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|