@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.
Files changed (174) hide show
  1. package/README.md +104 -171
  2. package/colors.less +319 -0
  3. package/colors.scss +319 -0
  4. package/lib/consts/default-swatch.d.ts +108 -0
  5. package/lib/consts/default-swatch.js +108 -0
  6. package/{dist/esm/constants/default-swatch.js → lib/consts/default-swatch.ts} +11 -7
  7. package/lib/consts/params/abney-correction.d.ts +2 -0
  8. package/lib/consts/params/abney-correction.js +1102 -0
  9. package/{dist/cjs/constants/abney-correction.js → lib/consts/params/abney-correction.ts} +3 -4
  10. package/lib/consts/params/chroma-params.d.ts +2 -0
  11. package/lib/consts/params/chroma-params.js +102 -0
  12. package/{dist/esm/constants/chroma-settings.js → lib/consts/params/chroma-params.ts} +3 -1
  13. package/lib/consts/params/interactions.ts +9 -0
  14. package/lib/consts/params/logo-lightness.d.ts +1 -0
  15. package/lib/consts/params/logo-lightness.js +1 -0
  16. package/lib/consts/params/logo-lightness.ts +1 -0
  17. package/{dist/cjs/constants → lib/consts/params}/promo-hue-shift.d.ts +1 -1
  18. package/lib/consts/params/promo-hue-shift.js +11 -0
  19. package/{dist/esm/constants/promo-hue-shift.js → lib/consts/params/promo-hue-shift.ts} +1 -1
  20. package/{dist/cjs/constants → lib/consts/params}/warning-hue-patch.d.ts +1 -1
  21. package/lib/consts/params/warning-hue-patch.js +22 -0
  22. package/{dist/esm/constants/warning-hue-patch.js → lib/consts/params/warning-hue-patch.ts} +1 -1
  23. package/lib/get-colors-base.d.ts +11 -0
  24. package/lib/get-colors-base.js +78 -0
  25. package/lib/get-colors-base.ts +99 -0
  26. package/lib/get-colors-default-tokens.d.ts +645 -0
  27. package/lib/get-colors-default-tokens.js +647 -0
  28. package/lib/get-colors-default-tokens.ts +646 -0
  29. package/lib/get-colors.d.ts +40 -0
  30. package/lib/get-colors.js +28 -0
  31. package/lib/get-colors.ts +65 -0
  32. package/{dist/cjs → lib}/helpers/get-interactions.d.ts +2 -2
  33. package/lib/helpers/get-interactions.js +35 -0
  34. package/lib/helpers/get-interactions.ts +64 -0
  35. package/{dist/cjs → lib}/helpers/get-logo.d.ts +2 -2
  36. package/lib/helpers/get-logo.js +25 -0
  37. package/lib/helpers/get-logo.ts +40 -0
  38. package/lib/helpers/get-palette.d.ts +51 -0
  39. package/lib/helpers/get-palette.js +204 -0
  40. package/lib/helpers/get-palette.ts +261 -0
  41. package/lib/helpers/get-promo.d.ts +6 -0
  42. package/lib/helpers/get-promo.js +47 -0
  43. package/lib/helpers/get-promo.ts +55 -0
  44. package/lib/types/tokens-base-generator.d.ts +43 -0
  45. package/{dist/cjs/types/generator-tokens.d.ts → lib/types/tokens-base-generator.ts} +12 -17
  46. package/lib/types/tokens-base.d.ts +55 -0
  47. package/{dist/esm/types/base-tokens.d.ts → lib/types/tokens-base.ts} +7 -2
  48. package/lib/types/tokens.d.ts +12 -0
  49. package/lib/types/tokens.js +1 -0
  50. package/lib/types/tokens.ts +18 -0
  51. package/lib/utils/convert-color.d.ts +3 -0
  52. package/lib/utils/convert-color.js +144 -0
  53. package/lib/utils/convert-color.ts +163 -0
  54. package/lib/utils/format-variable.js +6 -0
  55. package/lib/utils/format-variable.ts +7 -0
  56. package/package.json +44 -19
  57. package/{dist/tokens → tokens}/brand-blue-deep_accent-brand.css +33 -33
  58. package/{dist/tokens → tokens}/brand-blue-deep_accent-gray.css +33 -33
  59. package/{dist/tokens → tokens}/brand-blue_accent-brand.css +33 -33
  60. package/{dist/tokens → tokens}/brand-blue_accent-gray.css +33 -33
  61. package/{dist/tokens → tokens}/brand-green_accent-brand.css +33 -33
  62. package/{dist/tokens → tokens}/brand-green_accent-gray.css +33 -33
  63. package/{dist/tokens → tokens}/brand-mint_accent-brand.css +33 -33
  64. package/{dist/tokens → tokens}/brand-mint_accent-gray.css +33 -33
  65. package/{dist/tokens → tokens}/brand-orange_accent-gray.css +33 -33
  66. package/{dist/tokens → tokens}/brand-purple_accent-brand.css +33 -33
  67. package/{dist/tokens → tokens}/brand-purple_accent-gray.css +33 -33
  68. package/{dist/tokens → tokens}/brand-red_accent-gray.css +33 -33
  69. package/{dist/tokens → tokens}/brand-violet_accent-brand.css +33 -33
  70. package/{dist/tokens → tokens}/brand-violet_accent-gray.css +33 -33
  71. package/tokens-mobile/brand-blue-deep_accent-brand.json +718 -0
  72. package/tokens-mobile/brand-blue-deep_accent-gray.json +718 -0
  73. package/tokens-mobile/brand-blue_accent-brand.json +718 -0
  74. package/tokens-mobile/brand-blue_accent-gray.json +718 -0
  75. package/tokens-mobile/brand-green_accent-brand.json +718 -0
  76. package/tokens-mobile/brand-green_accent-gray.json +718 -0
  77. package/tokens-mobile/brand-mint_accent-brand.json +718 -0
  78. package/tokens-mobile/brand-mint_accent-gray.json +718 -0
  79. package/tokens-mobile/brand-orange_accent-gray.json +718 -0
  80. package/tokens-mobile/brand-purple_accent-brand.json +718 -0
  81. package/tokens-mobile/brand-purple_accent-gray.json +718 -0
  82. package/tokens-mobile/brand-red_accent-gray.json +718 -0
  83. package/tokens-mobile/brand-violet_accent-brand.json +718 -0
  84. package/tokens-mobile/brand-violet_accent-gray.json +718 -0
  85. package/dist/cjs/constants/abney-correction.d.ts +0 -2
  86. package/dist/cjs/constants/chroma-settings.d.ts +0 -2
  87. package/dist/cjs/constants/chroma-settings.js +0 -105
  88. package/dist/cjs/constants/default-swatch.d.ts +0 -109
  89. package/dist/cjs/constants/default-swatch.js +0 -112
  90. package/dist/cjs/constants/interaction-settings.js +0 -19
  91. package/dist/cjs/constants/logo-lightness.d.ts +0 -1
  92. package/dist/cjs/constants/logo-lightness.js +0 -4
  93. package/dist/cjs/constants/promo-hue-shift.js +0 -14
  94. package/dist/cjs/constants/warning-hue-patch.js +0 -25
  95. package/dist/cjs/get-base-tokens.d.ts +0 -26
  96. package/dist/cjs/get-base-tokens.js +0 -319
  97. package/dist/cjs/get-colors.d.ts +0 -20
  98. package/dist/cjs/get-colors.js +0 -20
  99. package/dist/cjs/get-default-tokens.d.ts +0 -645
  100. package/dist/cjs/get-default-tokens.js +0 -996
  101. package/dist/cjs/helpers/get-interactions.js +0 -61
  102. package/dist/cjs/helpers/get-logo.js +0 -32
  103. package/dist/cjs/helpers/get-palette.d.ts +0 -76
  104. package/dist/cjs/helpers/get-palette.js +0 -287
  105. package/dist/cjs/helpers/get-promo.d.ts +0 -12
  106. package/dist/cjs/helpers/get-promo.js +0 -56
  107. package/dist/cjs/types/base-tokens.d.ts +0 -125
  108. package/dist/cjs/types/base-tokens.js +0 -2
  109. package/dist/cjs/types/generator-tokens.js +0 -2
  110. package/dist/cjs/utils/format-variable.js +0 -15
  111. package/dist/colors.default-dark.js +0 -332
  112. package/dist/colors.default-light.js +0 -336
  113. package/dist/colors.less +0 -319
  114. package/dist/colors.scss +0 -319
  115. package/dist/esm/constants/abney-correction.d.ts +0 -2
  116. package/dist/esm/constants/abney-correction.js +0 -1102
  117. package/dist/esm/constants/chroma-settings.d.ts +0 -2
  118. package/dist/esm/constants/default-swatch.d.ts +0 -109
  119. package/dist/esm/constants/interaction-settings.d.ts +0 -8
  120. package/dist/esm/constants/logo-lightness.d.ts +0 -1
  121. package/dist/esm/constants/logo-lightness.js +0 -1
  122. package/dist/esm/constants/promo-hue-shift.d.ts +0 -3
  123. package/dist/esm/constants/warning-hue-patch.d.ts +0 -3
  124. package/dist/esm/get-base-tokens.d.ts +0 -26
  125. package/dist/esm/get-base-tokens.js +0 -257
  126. package/dist/esm/get-colors.d.ts +0 -20
  127. package/dist/esm/get-colors.js +0 -16
  128. package/dist/esm/get-default-tokens.d.ts +0 -645
  129. package/dist/esm/get-default-tokens.js +0 -992
  130. package/dist/esm/helpers/get-interactions.d.ts +0 -7
  131. package/dist/esm/helpers/get-interactions.js +0 -49
  132. package/dist/esm/helpers/get-logo.d.ts +0 -6
  133. package/dist/esm/helpers/get-logo.js +0 -28
  134. package/dist/esm/helpers/get-palette.d.ts +0 -76
  135. package/dist/esm/helpers/get-palette.js +0 -232
  136. package/dist/esm/helpers/get-promo.d.ts +0 -12
  137. package/dist/esm/helpers/get-promo.js +0 -51
  138. package/dist/esm/types/generator-tokens.d.ts +0 -43
  139. package/dist/esm/utils/format-variable.d.ts +0 -2
  140. package/dist/esm/utils/format-variable.js +0 -10
  141. package/dist/tokens-js/brand-blue-deep_accent-brand.js +0 -644
  142. package/dist/tokens-js/brand-blue-deep_accent-gray.js +0 -644
  143. package/dist/tokens-js/brand-blue_accent-brand.js +0 -644
  144. package/dist/tokens-js/brand-blue_accent-gray.js +0 -644
  145. package/dist/tokens-js/brand-green_accent-brand.js +0 -644
  146. package/dist/tokens-js/brand-green_accent-gray.js +0 -644
  147. package/dist/tokens-js/brand-mint_accent-brand.js +0 -644
  148. package/dist/tokens-js/brand-mint_accent-gray.js +0 -644
  149. package/dist/tokens-js/brand-orange_accent-gray.js +0 -644
  150. package/dist/tokens-js/brand-purple_accent-brand.js +0 -644
  151. package/dist/tokens-js/brand-purple_accent-gray.js +0 -644
  152. package/dist/tokens-js/brand-red_accent-gray.js +0 -644
  153. package/dist/tokens-js/brand-violet_accent-brand.js +0 -644
  154. package/dist/tokens-js/brand-violet_accent-gray.js +0 -644
  155. package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +0 -718
  156. package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +0 -718
  157. package/dist/tokens-mobile/brand-blue_accent-brand.json +0 -718
  158. package/dist/tokens-mobile/brand-blue_accent-gray.json +0 -718
  159. package/dist/tokens-mobile/brand-green_accent-brand.json +0 -718
  160. package/dist/tokens-mobile/brand-green_accent-gray.json +0 -718
  161. package/dist/tokens-mobile/brand-mint_accent-brand.json +0 -718
  162. package/dist/tokens-mobile/brand-mint_accent-gray.json +0 -718
  163. package/dist/tokens-mobile/brand-orange_accent-gray.json +0 -718
  164. package/dist/tokens-mobile/brand-purple_accent-brand.json +0 -718
  165. package/dist/tokens-mobile/brand-purple_accent-gray.json +0 -718
  166. package/dist/tokens-mobile/brand-red_accent-gray.json +0 -718
  167. package/dist/tokens-mobile/brand-violet_accent-brand.json +0 -718
  168. package/dist/tokens-mobile/brand-violet_accent-gray.json +0 -718
  169. /package/{dist/colors.js → colors.js} +0 -0
  170. /package/{dist/cjs/constants/interaction-settings.d.ts → lib/consts/params/interactions.d.ts} +0 -0
  171. /package/{dist/esm/constants/interaction-settings.js → lib/consts/params/interactions.js} +0 -0
  172. /package/{dist/esm/types/base-tokens.js → lib/types/tokens-base-generator.js} +0 -0
  173. /package/{dist/esm/types/generator-tokens.js → lib/types/tokens-base.js} +0 -0
  174. /package/{dist/cjs → lib}/utils/format-variable.d.ts +0 -0
@@ -0,0 +1,144 @@
1
+ import { converter, formatHex } from 'culori';
2
+ export function convertColorFormat(obj, format) {
3
+ if (format === void 0) { format = 'hex/rgba'; }
4
+ if (format === 'oklch') {
5
+ return convertToOklchRecursive(obj);
6
+ }
7
+ var result = convertOklchToHex(obj);
8
+ result = convertAlphaOklchToRgba(result);
9
+ if (format === 'hex-aarrggbb') {
10
+ return convertToAarrggbbRecursive(result);
11
+ }
12
+ return result;
13
+ }
14
+ function convertToOklchRecursive(obj) {
15
+ if (typeof obj !== 'object' || obj === null) {
16
+ return obj;
17
+ }
18
+ if (Array.isArray(obj)) {
19
+ return obj.map(function (item) { return convertToOklchRecursive(item); });
20
+ }
21
+ var newObj = {};
22
+ var toOklch = converter('oklch');
23
+ for (var key in obj) {
24
+ var value = obj[key];
25
+ if (typeof value === 'string') {
26
+ if (value.startsWith('oklch(')) {
27
+ newObj[key] = value;
28
+ }
29
+ else {
30
+ var color = toOklch(value);
31
+ if (color) {
32
+ var l = (color.l * 100).toFixed(3);
33
+ var c = color.c.toFixed(3);
34
+ var h = (color.h || 0).toFixed(0);
35
+ var a = color.alpha !== undefined && color.alpha < 1 ? " / ".concat(color.alpha) : '';
36
+ newObj[key] = "oklch(".concat(l, "% ").concat(c, " ").concat(h).concat(a, ")");
37
+ }
38
+ else {
39
+ newObj[key] = value;
40
+ }
41
+ }
42
+ }
43
+ else if (typeof value === 'object' && value !== null) {
44
+ newObj[key] = convertToOklchRecursive(value);
45
+ }
46
+ else {
47
+ newObj[key] = value;
48
+ }
49
+ }
50
+ return newObj;
51
+ }
52
+ function convertOklchToHex(obj) {
53
+ if (typeof obj !== 'object' || obj === null) {
54
+ return obj;
55
+ }
56
+ if (Array.isArray(obj)) {
57
+ return obj.map(function (item) { return convertOklchToHex(item); });
58
+ }
59
+ var newObj = {};
60
+ for (var key in obj) {
61
+ var value = obj[key];
62
+ if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
63
+ var oklchColor = converter('oklch')(value);
64
+ newObj[key] = oklchColor ? formatHex(oklchColor) : value;
65
+ }
66
+ else if (typeof value === 'object' && value !== null) {
67
+ newObj[key] = convertOklchToHex(value);
68
+ }
69
+ else {
70
+ newObj[key] = value;
71
+ }
72
+ }
73
+ return newObj;
74
+ }
75
+ function convertAlphaOklchToRgba(obj) {
76
+ var _a;
77
+ if (typeof obj !== 'object' || obj === null) {
78
+ return obj;
79
+ }
80
+ if (Array.isArray(obj)) {
81
+ return obj.map(function (item) { return convertAlphaOklchToRgba(item); });
82
+ }
83
+ var newObj = {};
84
+ for (var key in obj) {
85
+ var value = obj[key];
86
+ if (typeof value === 'string' && value.startsWith('oklch(') && value.includes('/')) {
87
+ var rgbaColor = converter('rgb')(value);
88
+ if (rgbaColor) {
89
+ var r = Math.round(rgbaColor.r * 255);
90
+ var g = Math.round(rgbaColor.g * 255);
91
+ var b = Math.round(rgbaColor.b * 255);
92
+ var a = (_a = rgbaColor.alpha) !== null && _a !== void 0 ? _a : 1;
93
+ newObj[key] = "rgba(".concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(a, ")");
94
+ continue;
95
+ }
96
+ }
97
+ if (typeof value === 'object' && value !== null) {
98
+ newObj[key] = convertAlphaOklchToRgba(value);
99
+ }
100
+ else {
101
+ newObj[key] = value;
102
+ }
103
+ }
104
+ return newObj;
105
+ }
106
+ var convertToAarrggbb = function (colorString) {
107
+ var _a;
108
+ var color = converter('rgb')(colorString);
109
+ if (!color) {
110
+ return colorString;
111
+ }
112
+ var r = Math.round(color.r * 255);
113
+ var g = Math.round(color.g * 255);
114
+ var b = Math.round(color.b * 255);
115
+ var alpha = Math.round(((_a = color.alpha) !== null && _a !== void 0 ? _a : 1) * 255);
116
+ var toHex = function (c) { return c.toString(16).padStart(2, '0'); };
117
+ var rgbHex = "".concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).toUpperCase();
118
+ if (alpha === 255) {
119
+ return "#".concat(rgbHex);
120
+ }
121
+ return "#".concat(toHex(alpha)).concat(rgbHex).toUpperCase();
122
+ };
123
+ function convertToAarrggbbRecursive(obj) {
124
+ if (typeof obj !== 'object' || obj === null) {
125
+ return obj;
126
+ }
127
+ if (Array.isArray(obj)) {
128
+ return obj.map(function (item) { return convertToAarrggbbRecursive(item); });
129
+ }
130
+ var newObj = {};
131
+ for (var key in obj) {
132
+ var value = obj[key];
133
+ if (typeof value === 'string') {
134
+ newObj[key] = convertToAarrggbb(value);
135
+ }
136
+ else if (typeof value === 'object' && value !== null) {
137
+ newObj[key] = convertToAarrggbbRecursive(value);
138
+ }
139
+ else {
140
+ newObj[key] = value;
141
+ }
142
+ }
143
+ return newObj;
144
+ }
@@ -0,0 +1,163 @@
1
+ import { converter, formatHex, type Rgb } from 'culori';
2
+
3
+ import type { ColorObject, ColorStructure } from '../types/tokens.js';
4
+
5
+ export type ColorFormat = 'hex/rgba' | 'oklch' | 'hex-aarrggbb';
6
+
7
+ export function convertColorFormat(obj: ColorStructure, format: ColorFormat = 'hex/rgba'): ColorStructure {
8
+ if (format === 'oklch') {
9
+ return convertToOklchRecursive(obj);
10
+ }
11
+
12
+ let result = convertOklchToHex(obj);
13
+ result = convertAlphaOklchToRgba(result);
14
+
15
+ if (format === 'hex-aarrggbb') {
16
+ return convertToAarrggbbRecursive(result);
17
+ }
18
+
19
+ return result;
20
+ }
21
+
22
+ function convertToOklchRecursive(obj: ColorStructure): ColorStructure {
23
+ if (typeof obj !== 'object' || obj === null) {
24
+ return obj;
25
+ }
26
+
27
+ if (Array.isArray(obj)) {
28
+ return obj.map((item) => convertToOklchRecursive(item as ColorStructure));
29
+ }
30
+
31
+ const newObj: ColorObject = {};
32
+ const toOklch = converter('oklch');
33
+
34
+ for (const key in obj) {
35
+ const value = obj[key];
36
+
37
+ if (typeof value === 'string') {
38
+ if (value.startsWith('oklch(')) {
39
+ newObj[key] = value;
40
+ } else {
41
+ const color = toOklch(value);
42
+ if (color) {
43
+ const l = (color.l * 100).toFixed(3);
44
+ const c = color.c.toFixed(3);
45
+ const h = (color.h || 0).toFixed(0);
46
+ const a = color.alpha !== undefined && color.alpha < 1 ? ` / ${color.alpha}` : '';
47
+ newObj[key] = `oklch(${l}% ${c} ${h}${a})`;
48
+ } else {
49
+ newObj[key] = value;
50
+ }
51
+ }
52
+ } else if (typeof value === 'object' && value !== null) {
53
+ newObj[key] = convertToOklchRecursive(value as ColorStructure) as any;
54
+ } else {
55
+ newObj[key] = value;
56
+ }
57
+ }
58
+ return newObj as ColorStructure;
59
+ }
60
+
61
+ function convertOklchToHex(obj: ColorStructure): ColorStructure {
62
+ if (typeof obj !== 'object' || obj === null) {
63
+ return obj;
64
+ }
65
+
66
+ if (Array.isArray(obj)) {
67
+ return obj.map((item) => convertOklchToHex(item as ColorStructure));
68
+ }
69
+
70
+ const newObj: ColorObject = {};
71
+ for (const key in obj) {
72
+ const value = obj[key];
73
+
74
+ if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
75
+ const oklchColor = converter('oklch')(value);
76
+ newObj[key] = oklchColor ? formatHex(oklchColor) : value;
77
+ } else if (typeof value === 'object' && value !== null) {
78
+ newObj[key] = convertOklchToHex(value as ColorStructure) as any;
79
+ } else {
80
+ newObj[key] = value;
81
+ }
82
+ }
83
+ return newObj as ColorStructure;
84
+ }
85
+
86
+ function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure {
87
+ if (typeof obj !== 'object' || obj === null) {
88
+ return obj;
89
+ }
90
+
91
+ if (Array.isArray(obj)) {
92
+ return obj.map((item) => convertAlphaOklchToRgba(item as ColorStructure));
93
+ }
94
+
95
+ const newObj: ColorObject = {};
96
+ for (const key in obj) {
97
+ const value = obj[key];
98
+
99
+ if (typeof value === 'string' && value.startsWith('oklch(') && value.includes('/')) {
100
+ const rgbaColor = converter('rgb')(value);
101
+ if (rgbaColor) {
102
+ const r = Math.round(rgbaColor.r * 255);
103
+ const g = Math.round(rgbaColor.g * 255);
104
+ const b = Math.round(rgbaColor.b * 255);
105
+ const a = rgbaColor.alpha ?? 1;
106
+ newObj[key] = `rgba(${r}, ${g}, ${b}, ${a})`;
107
+ continue;
108
+ }
109
+ }
110
+
111
+ if (typeof value === 'object' && value !== null) {
112
+ newObj[key] = convertAlphaOklchToRgba(value as ColorStructure) as any;
113
+ } else {
114
+ newObj[key] = value;
115
+ }
116
+ }
117
+ return newObj as ColorStructure;
118
+ }
119
+
120
+ const convertToAarrggbb = (colorString: string): string => {
121
+ const color = converter('rgb')(colorString) as Rgb;
122
+ if (!color) {
123
+ return colorString;
124
+ }
125
+
126
+ const r = Math.round(color.r * 255);
127
+ const g = Math.round(color.g * 255);
128
+ const b = Math.round(color.b * 255);
129
+ const alpha = Math.round((color.alpha ?? 1) * 255);
130
+
131
+ const toHex = (c: number) => c.toString(16).padStart(2, '0');
132
+ const rgbHex = `${toHex(r)}${toHex(g)}${toHex(b)}`.toUpperCase();
133
+
134
+ if (alpha === 255) {
135
+ return `#${rgbHex}`;
136
+ }
137
+
138
+ return `#${toHex(alpha)}${rgbHex}`.toUpperCase();
139
+ };
140
+
141
+ function convertToAarrggbbRecursive(obj: ColorStructure): ColorStructure {
142
+ if (typeof obj !== 'object' || obj === null) {
143
+ return obj;
144
+ }
145
+
146
+ if (Array.isArray(obj)) {
147
+ return obj.map((item) => convertToAarrggbbRecursive(item as ColorStructure));
148
+ }
149
+
150
+ const newObj: ColorObject = {};
151
+ for (const key in obj) {
152
+ const value = obj[key];
153
+
154
+ if (typeof value === 'string') {
155
+ newObj[key] = convertToAarrggbb(value);
156
+ } else if (typeof value === 'object' && value !== null) {
157
+ newObj[key] = convertToAarrggbbRecursive(value as ColorStructure) as any;
158
+ } else {
159
+ newObj[key] = value;
160
+ }
161
+ }
162
+ return newObj as ColorStructure;
163
+ }
@@ -0,0 +1,6 @@
1
+ export var camelCaseToKebabCase = function (str) {
2
+ return str.replace(/[A-Z]/g, function (match) { return "-".concat(match.toLowerCase()); });
3
+ };
4
+ export var kebabCaseToCamelCase = function (str) {
5
+ return str.replace(/-(\w)/g, function (_, c) { return c.toUpperCase(); });
6
+ };
@@ -0,0 +1,7 @@
1
+ export const camelCaseToKebabCase = (str: string) => {
2
+ return str.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
3
+ };
4
+
5
+ export const kebabCaseToCamelCase = (str: string) => {
6
+ return str.replace(/-(\w)/g, (_, c) => c.toUpperCase());
7
+ };
package/package.json CHANGED
@@ -1,37 +1,62 @@
1
1
  {
2
2
  "name": "@skbkontur/colors",
3
- "version": "2.0.0-alpha.2",
3
+ "version": "2.0.0-alpha.4",
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-colors.js",
10
- "main": "dist/cjs/get-colors.js",
9
+ "type": "module",
11
10
  "license": "UNLICENSED",
12
- "scripts": {
13
- "clean": "git clean -fdxqe node_modules",
14
- "extract-tokens": "node --require ./scripts/babel-register -- scripts/extract-tokens-from-figma.ts",
15
- "build": "npm run build:cjs && npm run build:esm && npm run build:static",
16
- "build:cjs": "tsc -p tsconfig.cjs.json",
17
- "build:esm": "tsc -p tsconfig.esm.json",
18
- "build:static": "node --require ./scripts/babel-register -- scripts/generate.ts && prettier ./dist --write && npx stylelint \"**/*.{css,scss,less}\" --fix"
19
- },
20
11
  "sideEffects": false,
21
12
  "files": [
22
- "dist",
13
+ "/lib",
14
+ "/tokens",
15
+ "/tokens-mobile",
23
16
  "colors.*"
24
17
  ],
25
- "devDependencies": {
26
- "@babel/preset-typescript": "7.22.5",
27
- "@babel/register": "7.22.5",
28
- "@skbkontur/react-ui": "5.4.2",
29
- "rimraf": "^4.1.2"
18
+ "exports": {
19
+ "./package.json": "./package.json",
20
+ ".": "./colors.js",
21
+ "./colors.scss": "./colors.scss",
22
+ "./colors.less": "./colors.less",
23
+ "./get-colors": "./lib/get-colors.js",
24
+ "./light-default": "./colors-light-default.js",
25
+ "./dark-default": "./colors-dark-default.js",
26
+ "./tokens/brand-orange_accent-gray.css": "./tokens/brand-orange_accent-gray.css",
27
+ "./tokens/brand-blue_accent-gray.css": "./tokens/brand-blue_accent-gray.css",
28
+ "./tokens/brand-blue_accent-brand.css": "./tokens/brand-blue_accent-brand.css",
29
+ "./tokens/brand-blue-deep_accent-brand.css": "./tokens/brand-blue-deep_accent-brand.css",
30
+ "./tokens/brand-blue-deep_accent-gray.css": "./tokens/brand-blue-deep_accent-gray.css",
31
+ "./tokens/brand-green_accent-brand.css": "./tokens/brand-green_accent-brand.css",
32
+ "./tokens/brand-green_accent-gray.css": "./tokens/brand-green_accent-gray.css",
33
+ "./tokens/brand-mint_accent-brand.css": "./tokens/brand-mint_accent-brand.css",
34
+ "./tokens/brand-mint_accent-gray.css": "./tokens/brand-mint_accent-gray.css",
35
+ "./tokens/brand-purple_accent-brand.css": "./tokens/brand-purple_accent-brand.css",
36
+ "./tokens/brand-purple_accent-gray.css": "./tokens/brand-purple_accent-gray.css",
37
+ "./tokens/brand-violet_accent-brand.css": "./tokens/brand-violet_accent-brand.css",
38
+ "./tokens/brand-violet_accent-gray.css": "./tokens/brand-violet_accent-gray.css"
39
+ },
40
+ "scripts": {
41
+ "prebuild": "node --import=tsx scripts/create-tokens-from-figma.ts",
42
+ "build": "npm run build:static && npm run build:esm",
43
+ "build:esm": "tsc",
44
+ "build:static": "node --import=tsx scripts/create-tokens-files.ts && prettier . --write && npx stylelint \"**/*.{css,scss,less}\" --fix",
45
+ "test": "vitest run",
46
+ "test:watch": "vitest",
47
+ "clean": "git clean -fdxqe node_modules"
30
48
  },
31
49
  "dependencies": {
32
- "@types/apca-w3": "0.1.3",
33
- "@types/culori": "4.0.1",
34
50
  "apca-w3": "0.1.9",
35
51
  "culori": "4.0.2"
52
+ },
53
+ "devDependencies": {
54
+ "@skbkontur/react-ui": "5.5.1",
55
+ "@types/apca-w3": "0.1.3",
56
+ "@types/culori": "4.0.1",
57
+ "vitest": "^2.1.6"
58
+ },
59
+ "colors": {
60
+ "_": "./"
36
61
  }
37
62
  }
@@ -76,8 +76,8 @@
76
76
  --k-color-shape-faint-error-hover: #ffdadd;
77
77
  --k-color-shape-faint-error-pressed: #f5dee0;
78
78
  --k-color-shape-faint-neutral-alpha: rgba(0, 0, 0, 0.06);
79
- --k-color-shape-faint-neutral-alpha-hover: rgba(0, 0, 0, 0.08);
80
- --k-color-shape-faint-neutral-alpha-pressed: rgba(0, 0, 0, 0.12);
79
+ --k-color-shape-faint-neutral-alpha-hover: rgba(0, 0, 0, 0.12);
80
+ --k-color-shape-faint-neutral-alpha-pressed: rgba(0, 0, 0, 0.16);
81
81
  --k-color-shape-faint-success: #defbe2;
82
82
  --k-color-shape-faint-success-hover: #c3f3ca;
83
83
  --k-color-shape-faint-success-pressed: #d1edd5;
@@ -90,7 +90,7 @@
90
90
  --k-color-shape-heavy-warning: #543600;
91
91
  --k-color-shape-other-accent-bold-disabled: rgba(0, 0, 0, 0.32);
92
92
  --k-color-shape-other-backless-hover: rgba(0, 0, 0, 0.06);
93
- --k-color-shape-other-backless-pressed: rgba(0, 0, 0, 0.08);
93
+ --k-color-shape-other-backless-pressed: rgba(0, 0, 0, 0.16);
94
94
  --k-color-shape-other-base: #fff;
95
95
  --k-color-shape-other-base-hover: #f2f2f2;
96
96
  --k-color-shape-other-base-pressed: #e4e4e4;
@@ -107,7 +107,7 @@
107
107
  --k-color-shape-other-neutral-pale-solid: #e4e4e4;
108
108
  --k-color-shape-other-neutral-pale-solid-hover: #d7d7d7;
109
109
  --k-color-shape-other-neutral-pale-solid-pressed: #cacaca;
110
- --k-color-shape-other-neutral-soft-solid: #cacaca;
110
+ --k-color-shape-other-neutral-soft-solid: #d7d7d7;
111
111
  --k-color-shape-other-neutral-soft-solid-hover: #bebebe;
112
112
  --k-color-shape-other-neutral-soft-solid-pressed: #b1b1b1;
113
113
  --k-color-shape-pale-accent: #d2e7ff;
@@ -119,9 +119,9 @@
119
119
  --k-color-shape-pale-error: #ffdadd;
120
120
  --k-color-shape-pale-error-hover: #ffc7c7;
121
121
  --k-color-shape-pale-error-pressed: #f2cdcd;
122
- --k-color-shape-pale-neutral-alpha: rgba(0, 0, 0, 0.08);
123
- --k-color-shape-pale-neutral-alpha-hover: rgba(0, 0, 0, 0.12);
124
- --k-color-shape-pale-neutral-alpha-pressed: rgba(0, 0, 0, 0.16);
122
+ --k-color-shape-pale-neutral-alpha: rgba(0, 0, 0, 0.12);
123
+ --k-color-shape-pale-neutral-alpha-hover: rgba(0, 0, 0, 0.16);
124
+ --k-color-shape-pale-neutral-alpha-pressed: rgba(0, 0, 0, 0.24);
125
125
  --k-color-shape-pale-success: #c3f3ca;
126
126
  --k-color-shape-pale-success-hover: #a7ebb2;
127
127
  --k-color-shape-pale-success-pressed: #bae4c0;
@@ -155,12 +155,12 @@
155
155
  --k-color-shape-inverted-neutral-heavy: #fff;
156
156
  --k-color-shape-inverted-neutral-heavy-hover: rgba(255, 255, 255, 0.88);
157
157
  --k-color-shape-inverted-neutral-heavy-pressed: rgba(255, 255, 255, 0.72);
158
- --k-color-shape-inverted-neutral-pale-alpha: rgba(255, 255, 255, 0.08);
159
- --k-color-shape-inverted-neutral-pale-alpha-hover: rgba(255, 255, 255, 0.12);
158
+ --k-color-shape-inverted-neutral-pale-alpha: rgba(255, 255, 255, 0.12);
159
+ --k-color-shape-inverted-neutral-pale-alpha-hover: rgba(255, 255, 255, 0.16);
160
160
  --k-color-shape-inverted-neutral-pale-alpha-pressed: rgba(255, 255, 255, 0.06);
161
161
  --k-color-shape-inverted-neutral-soft-alpha: rgba(255, 255, 255, 0.16);
162
162
  --k-color-shape-inverted-neutral-soft-alpha-hover: rgba(255, 255, 255, 0.24);
163
- --k-color-shape-inverted-neutral-soft-alpha-pressed: rgba(255, 255, 255, 0.12);
163
+ --k-color-shape-inverted-neutral-soft-alpha-pressed: rgba(255, 255, 255, 0.08);
164
164
  --k-color-shape-const-backless-black-hover: rgba(0, 0, 0, 0.12);
165
165
  --k-color-shape-const-backless-black-pressed: rgba(0, 0, 0, 0.16);
166
166
  --k-color-shape-const-backless-white-hover: rgba(255, 255, 255, 0.12);
@@ -265,21 +265,21 @@
265
265
  --k-color-illustration-white: #fff;
266
266
  --k-color-customizable-bold-black: #696969;
267
267
  --k-color-customizable-bold-blue: #369bff;
268
- --k-color-customizable-bold-blue-deep: #6592ff;
268
+ --k-color-customizable-bold-blue-deep: #5183ff;
269
269
  --k-color-customizable-bold-gray: #a4a4a4;
270
270
  --k-color-customizable-bold-green: #00b74e;
271
- --k-color-customizable-bold-mint: #01b197;
271
+ --k-color-customizable-bold-mint: #05bfa3;
272
272
  --k-color-customizable-bold-orange: #f56600;
273
273
  --k-color-customizable-bold-purple: #cf60ec;
274
274
  --k-color-customizable-bold-red: #ff5352;
275
275
  --k-color-customizable-bold-violet: #a17bff;
276
- --k-color-customizable-bold-yellow: #dfa700;
276
+ --k-color-customizable-bold-yellow: #ecb400;
277
277
  --k-color-customizable-faint-black: #e4e4e4;
278
278
  --k-color-customizable-faint-blue: #e2f5ff;
279
279
  --k-color-customizable-faint-blue-deep: #e8f3ff;
280
280
  --k-color-customizable-faint-gray: #f2f2f2;
281
- --k-color-customizable-faint-green: #d4ffda;
282
- --k-color-customizable-faint-mint: #c8fff7;
281
+ --k-color-customizable-faint-green: #defbe2;
282
+ --k-color-customizable-faint-mint: #d2fcf6;
283
283
  --k-color-customizable-faint-orange: #ffeee1;
284
284
  --k-color-customizable-faint-purple: #ffeaff;
285
285
  --k-color-customizable-faint-red: #ffedef;
@@ -300,8 +300,8 @@
300
300
  --k-color-customizable-pale-blue: #c7ebff;
301
301
  --k-color-customizable-pale-blue-deep: #d2e7ff;
302
302
  --k-color-customizable-pale-gray: #e4e4e4;
303
- --k-color-customizable-pale-green: #b0fabd;
304
- --k-color-customizable-pale-mint: #88fdeb;
303
+ --k-color-customizable-pale-green: #c3f3ca;
304
+ --k-color-customizable-pale-mint: #adf5e9;
305
305
  --k-color-customizable-pale-orange: #ffddc6;
306
306
  --k-color-customizable-pale-purple: #fbd6ff;
307
307
  --k-color-customizable-pale-red: #ffdadd;
@@ -425,13 +425,13 @@
425
425
  --k-color-shape-other-low-pressed: rgba(0, 0, 0, 0.32);
426
426
  --k-color-shape-other-neutral-faint-solid: #333;
427
427
  --k-color-shape-other-neutral-faint-solid-hover: #3d3d3d;
428
- --k-color-shape-other-neutral-faint-solid-pressed: #292929;
428
+ --k-color-shape-other-neutral-faint-solid-pressed: #333;
429
429
  --k-color-shape-other-neutral-pale-solid: #3d3d3d;
430
430
  --k-color-shape-other-neutral-pale-solid-hover: #484848;
431
431
  --k-color-shape-other-neutral-pale-solid-pressed: #333;
432
- --k-color-shape-other-neutral-soft-solid: #525252;
432
+ --k-color-shape-other-neutral-soft-solid: #484848;
433
433
  --k-color-shape-other-neutral-soft-solid-hover: #5d5d5d;
434
- --k-color-shape-other-neutral-soft-solid-pressed: #484848;
434
+ --k-color-shape-other-neutral-soft-solid-pressed: #3d3d3d;
435
435
  --k-color-shape-pale-accent: #243a6e;
436
436
  --k-color-shape-pale-accent-hover: #2b4480;
437
437
  --k-color-shape-pale-accent-pressed: #1e305c;
@@ -441,8 +441,8 @@
441
441
  --k-color-shape-pale-error: #602a27;
442
442
  --k-color-shape-pale-error-hover: #71312e;
443
443
  --k-color-shape-pale-error-pressed: #502421;
444
- --k-color-shape-pale-neutral-alpha: rgba(255, 255, 255, 0.08);
445
- --k-color-shape-pale-neutral-alpha-hover: rgba(255, 255, 255, 0.12);
444
+ --k-color-shape-pale-neutral-alpha: rgba(255, 255, 255, 0.12);
445
+ --k-color-shape-pale-neutral-alpha-hover: rgba(255, 255, 255, 0.16);
446
446
  --k-color-shape-pale-neutral-alpha-pressed: rgba(255, 255, 255, 0.06);
447
447
  --k-color-shape-pale-success: #27452d;
448
448
  --k-color-shape-pale-success-hover: #2d5134;
@@ -461,7 +461,7 @@
461
461
  --k-color-shape-soft-error-pressed: #823835;
462
462
  --k-color-shape-soft-neutral-alpha: rgba(255, 255, 255, 0.16);
463
463
  --k-color-shape-soft-neutral-alpha-hover: rgba(255, 255, 255, 0.24);
464
- --k-color-shape-soft-neutral-alpha-pressed: rgba(255, 255, 255, 0.12);
464
+ --k-color-shape-soft-neutral-alpha-pressed: rgba(255, 255, 255, 0.08);
465
465
  --k-color-shape-soft-success: #3a6a43;
466
466
  --k-color-shape-soft-success-hover: #3f784b;
467
467
  --k-color-shape-soft-success-pressed: #345e3c;
@@ -469,17 +469,17 @@
469
469
  --k-color-shape-soft-warning-hover: #956c30;
470
470
  --k-color-shape-soft-warning-pressed: #775728;
471
471
  --k-color-shape-inverted-backless-hover: rgba(0, 0, 0, 0.06);
472
- --k-color-shape-inverted-backless-pressed: rgba(0, 0, 0, 0.08);
472
+ --k-color-shape-inverted-backless-pressed: rgba(0, 0, 0, 0.16);
473
473
  --k-color-shape-inverted-disabled: rgba(0, 0, 0, 0.06);
474
474
  --k-color-shape-inverted-neutral-faint-alpha: rgba(0, 0, 0, 0.06);
475
- --k-color-shape-inverted-neutral-faint-alpha-hover: rgba(0, 0, 0, 0.08);
476
- --k-color-shape-inverted-neutral-faint-alpha-pressed: rgba(0, 0, 0, 0.12);
475
+ --k-color-shape-inverted-neutral-faint-alpha-hover: rgba(0, 0, 0, 0.12);
476
+ --k-color-shape-inverted-neutral-faint-alpha-pressed: rgba(0, 0, 0, 0.16);
477
477
  --k-color-shape-inverted-neutral-heavy: rgba(0, 0, 0, 0.8);
478
478
  --k-color-shape-inverted-neutral-heavy-hover: rgba(0, 0, 0, 0.88);
479
479
  --k-color-shape-inverted-neutral-heavy-pressed: rgba(0, 0, 0, 0.72);
480
- --k-color-shape-inverted-neutral-pale-alpha: rgba(0, 0, 0, 0.08);
481
- --k-color-shape-inverted-neutral-pale-alpha-hover: rgba(0, 0, 0, 0.12);
482
- --k-color-shape-inverted-neutral-pale-alpha-pressed: rgba(0, 0, 0, 0.16);
480
+ --k-color-shape-inverted-neutral-pale-alpha: rgba(0, 0, 0, 0.12);
481
+ --k-color-shape-inverted-neutral-pale-alpha-hover: rgba(0, 0, 0, 0.16);
482
+ --k-color-shape-inverted-neutral-pale-alpha-pressed: rgba(0, 0, 0, 0.24);
483
483
  --k-color-shape-inverted-neutral-soft-alpha: rgba(0, 0, 0, 0.16);
484
484
  --k-color-shape-inverted-neutral-soft-alpha-hover: rgba(0, 0, 0, 0.24);
485
485
  --k-color-shape-inverted-neutral-soft-alpha-pressed: rgba(0, 0, 0, 0.32);
@@ -587,15 +587,15 @@
587
587
  --k-color-illustration-white: #fff;
588
588
  --k-color-customizable-bold-black: #b1b1b1;
589
589
  --k-color-customizable-bold-blue: #2b8df2;
590
- --k-color-customizable-bold-blue-deep: #5183ff;
590
+ --k-color-customizable-bold-blue-deep: #3e72ff;
591
591
  --k-color-customizable-bold-gray: #696969;
592
592
  --k-color-customizable-bold-green: #2ca651;
593
- --k-color-customizable-bold-mint: #00a38b;
594
- --k-color-customizable-bold-orange: #d96528;
593
+ --k-color-customizable-bold-mint: #01b197;
594
+ --k-color-customizable-bold-orange: #ed6d28;
595
595
  --k-color-customizable-bold-purple: #be5ad8;
596
596
  --k-color-customizable-bold-red: #ee4948;
597
597
  --k-color-customizable-bold-violet: #956ef2;
598
- --k-color-customizable-bold-yellow: #d19a00;
598
+ --k-color-customizable-bold-yellow: #dfa700;
599
599
  --k-color-customizable-faint-black: #484848;
600
600
  --k-color-customizable-faint-blue: #1f344d;
601
601
  --k-color-customizable-faint-blue-deep: #1e305c;