@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
@@ -1,61 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getPressed = exports.getHover = void 0;
4
- var culori_1 = require('culori');
5
- var interaction_settings_1 = require('../constants/interaction-settings');
6
- function applyOklchDelta(oklchColor, dL, dC) {
7
- var _a = oklchColor.l,
8
- l = _a === void 0 ? 0 : _a,
9
- _b = oklchColor.c,
10
- c = _b === void 0 ? 0 : _b,
11
- _c = oklchColor.h,
12
- h = _c === void 0 ? 0 : _c;
13
- var safeH = h === undefined || isNaN(h) ? 0 : h;
14
- var newL = Math.max(0, Math.min(1, l + dL / 100));
15
- var newC = Math.max(0, c + dC);
16
- return 'oklch('.concat(newL.toFixed(3), ' ').concat(newC.toFixed(3), ' ').concat(safeH.toFixed(0), ')');
17
- }
18
- function getHover(hex) {
19
- var toOklch = (0, culori_1.converter)('oklch');
20
- var oklchColor = toOklch(hex);
21
- if (!oklchColor) {
22
- return { light: hex, dark: hex };
23
- }
24
- var lightHoverColor = applyOklchDelta(
25
- oklchColor,
26
- interaction_settings_1.HOVER_LIGHT_L,
27
- interaction_settings_1.HOVER_LIGHT_C
28
- );
29
- var darkHoverColor = applyOklchDelta(
30
- oklchColor,
31
- interaction_settings_1.HOVER_DARK_L,
32
- interaction_settings_1.HOVER_DARK_C
33
- );
34
- return {
35
- light: lightHoverColor,
36
- dark: darkHoverColor,
37
- };
38
- }
39
- exports.getHover = getHover;
40
- function getPressed(hex) {
41
- var toOklch = (0, culori_1.converter)('oklch');
42
- var oklchColor = toOklch(hex);
43
- if (!oklchColor) {
44
- return { light: hex, dark: hex };
45
- }
46
- var lightPressedColor = applyOklchDelta(
47
- oklchColor,
48
- interaction_settings_1.PRESSED_LIGHT_L,
49
- interaction_settings_1.PRESSED_LIGHT_C
50
- );
51
- var darkPressedColor = applyOklchDelta(
52
- oklchColor,
53
- interaction_settings_1.PRESSED_DARK_L,
54
- interaction_settings_1.PRESSED_DARK_C
55
- );
56
- return {
57
- light: lightPressedColor,
58
- dark: darkPressedColor,
59
- };
60
- }
61
- exports.getPressed = getPressed;
@@ -1,32 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getLogo = void 0;
4
- var culori_1 = require('culori');
5
- var logo_lightness_1 = require('../constants/logo-lightness');
6
- function getLogo(hex) {
7
- var toOklch = (0, culori_1.converter)('oklch');
8
- var oklchColor = toOklch(hex);
9
- var lightThemeLogoColor = hex;
10
- if (!oklchColor) {
11
- var fallbackColor = 'oklch('.concat(logo_lightness_1.MIN_LOGO_LIGHTNESS, '% 0 0)');
12
- return { light: hex, dark: fallbackColor };
13
- }
14
- var _a = oklchColor.l,
15
- l = _a === void 0 ? 0 : _a,
16
- _b = oklchColor.c,
17
- c = _b === void 0 ? 0 : _b;
18
- var h = oklchColor.h;
19
- var safeH = h === undefined || isNaN(h) ? 0 : h;
20
- l = l || 0;
21
- c = c || 0;
22
- var percentL = l * 100;
23
- if (percentL < logo_lightness_1.MIN_LOGO_LIGHTNESS) {
24
- l = logo_lightness_1.MIN_LOGO_LIGHTNESS / 100;
25
- }
26
- var darkThemeLogoColor = 'oklch('.concat(l.toFixed(3), ' ').concat(c.toFixed(3), ' ').concat(safeH.toFixed(0), ')');
27
- return {
28
- light: lightThemeLogoColor,
29
- dark: darkThemeLogoColor,
30
- };
31
- }
32
- exports.getLogo = getLogo;
@@ -1,76 +0,0 @@
1
- import type {
2
- GeneratorColorAbneyCorrection,
3
- GeneratorColorChromaSettingsGroup,
4
- GeneratorColorPalette,
5
- GeneratorColorWarningHuePatch,
6
- } from '../types/generator-tokens';
7
- interface GeneratePaletteParams {
8
- color: string;
9
- type?: 'default' | 'warning';
10
- settings?: {
11
- chromaSettings?: GeneratorColorChromaSettingsGroup;
12
- abneyCorrection?: GeneratorColorAbneyCorrection;
13
- promoHueShifts?: {
14
- [hueRange: number]: number;
15
- };
16
- warningHuePatch?: GeneratorColorWarningHuePatch;
17
- };
18
- }
19
- export declare function getPalette({
20
- color,
21
- type,
22
- settings: customSettings,
23
- }: GeneratePaletteParams): GeneratorColorPalette;
24
- export declare function getAbneyHueShift(
25
- lightness: number,
26
- currentHue: number,
27
- abneyData: GeneratorColorAbneyCorrection
28
- ): number;
29
- export declare function applyAbneyShift(
30
- lightness: number,
31
- currentHue: number,
32
- abneyData: GeneratorColorAbneyCorrection
33
- ): number;
34
- export declare function applyWarningHuePatch(
35
- currentHue: number,
36
- lightness: number,
37
- warningHuePatchData: GeneratorColorWarningHuePatch,
38
- isWarningMode: boolean
39
- ): number;
40
- export declare function calculateBaseHueAndCorrectionRange(
41
- inputColorString: string,
42
- abneyData: GeneratorColorAbneyCorrection
43
- ): {
44
- baseHue: number;
45
- correctionLightness: number;
46
- correctionHueRange: number;
47
- } | null;
48
- export declare function calcOnBrand(hex: string): {
49
- 4: string;
50
- 6: string;
51
- 8: string;
52
- 12: string;
53
- 16: string;
54
- 20: string;
55
- 24: string;
56
- 28: string;
57
- 32: string;
58
- 36: string;
59
- 40: string;
60
- 44: string;
61
- 48: string;
62
- 52: string;
63
- 56: string;
64
- 60: string;
65
- 64: string;
66
- 68: string;
67
- 72: string;
68
- 76: string;
69
- 80: string;
70
- 84: string;
71
- 88: string;
72
- 92: string;
73
- 96: string;
74
- 100: string;
75
- };
76
- export {};
@@ -1,287 +0,0 @@
1
- 'use strict';
2
- var __assign =
3
- (this && this.__assign) ||
4
- function () {
5
- __assign =
6
- Object.assign ||
7
- function (t) {
8
- for (var s, i = 1, n = arguments.length; i < n; i++) {
9
- s = arguments[i];
10
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
11
- }
12
- return t;
13
- };
14
- return __assign.apply(this, arguments);
15
- };
16
- var __createBinding =
17
- (this && this.__createBinding) ||
18
- (Object.create
19
- ? function (o, m, k, k2) {
20
- if (k2 === undefined) k2 = k;
21
- var desc = Object.getOwnPropertyDescriptor(m, k);
22
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
23
- desc = {
24
- enumerable: true,
25
- get: function () {
26
- return m[k];
27
- },
28
- };
29
- }
30
- Object.defineProperty(o, k2, desc);
31
- }
32
- : function (o, m, k, k2) {
33
- if (k2 === undefined) k2 = k;
34
- o[k2] = m[k];
35
- });
36
- var __setModuleDefault =
37
- (this && this.__setModuleDefault) ||
38
- (Object.create
39
- ? function (o, v) {
40
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
41
- }
42
- : function (o, v) {
43
- o['default'] = v;
44
- });
45
- var __importStar =
46
- (this && this.__importStar) ||
47
- function (mod) {
48
- if (mod && mod.__esModule) return mod;
49
- var result = {};
50
- if (mod != null)
51
- for (var k in mod)
52
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
53
- __setModuleDefault(result, mod);
54
- return result;
55
- };
56
- var __spreadArray =
57
- (this && this.__spreadArray) ||
58
- function (to, from, pack) {
59
- if (pack || arguments.length === 2)
60
- for (var i = 0, l = from.length, ar; i < l; i++) {
61
- if (ar || !(i in from)) {
62
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
63
- ar[i] = from[i];
64
- }
65
- }
66
- return to.concat(ar || Array.prototype.slice.call(from));
67
- };
68
- Object.defineProperty(exports, '__esModule', { value: true });
69
- exports.calcOnBrand =
70
- exports.calculateBaseHueAndCorrectionRange =
71
- exports.applyWarningHuePatch =
72
- exports.applyAbneyShift =
73
- exports.getAbneyHueShift =
74
- exports.getPalette =
75
- void 0;
76
- var culori_1 = require('culori');
77
- var apca_w3_1 = require('apca-w3');
78
- var DefaultSwatch = __importStar(require('../constants/default-swatch'));
79
- var chroma_settings_1 = require('../constants/chroma-settings');
80
- var abney_correction_1 = require('../constants/abney-correction');
81
- var promo_hue_shift_1 = require('../constants/promo-hue-shift');
82
- var warning_hue_patch_1 = require('../constants/warning-hue-patch');
83
- function getPalette(_a) {
84
- var color = _a.color,
85
- _b = _a.type,
86
- type = _b === void 0 ? 'default' : _b,
87
- customSettings = _a.settings;
88
- var defaultSettings = {
89
- chromaSettings: chroma_settings_1.CHROMA_SETTINGS,
90
- abneyCorrection: abney_correction_1.ABNEY_CORRECTION,
91
- promoHueShifts: promo_hue_shift_1.PROMO_HUE_SHIFTS,
92
- warningHuePatch: warning_hue_patch_1.WARNING_HUE_PATCH,
93
- };
94
- var settings = __assign(__assign({}, defaultSettings), customSettings);
95
- var toOklch = (0, culori_1.converter)('oklch');
96
- var oklchColor = toOklch(color);
97
- var currentHue = (oklchColor === null || oklchColor === void 0 ? void 0 : oklchColor.h) || 0;
98
- var toNorm = function (x) {
99
- return x / 100;
100
- };
101
- var calculateChromaValue = function (rel, min, max, baseChromaMax) {
102
- var raw = (baseChromaMax * rel) / 100;
103
- var value = raw;
104
- if (min !== undefined) {
105
- value = Math.max(toNorm(min), value);
106
- }
107
- if (max !== undefined) {
108
- value = Math.min(toNorm(max), value);
109
- }
110
- return Math.min(value, baseChromaMax);
111
- };
112
- var result = {
113
- vivid: {},
114
- normal: {},
115
- dim: {},
116
- };
117
- var isWarning = type === 'warning';
118
- for (var Lstr in settings.chromaSettings) {
119
- var L = +Lstr;
120
- if (L === 100) {
121
- result.vivid[L] = 'oklch(100% 0 0)';
122
- result.normal[L] = 'oklch(100% 0 0)';
123
- result.dim[L] = 'oklch(100% 0 0)';
124
- continue;
125
- }
126
- var hueAfterWarningPatch = applyWarningHuePatch(currentHue, L, settings.warningHuePatch, isWarning);
127
- var appliedHueShift = applyAbneyShift(L, hueAfterWarningPatch, settings.abneyCorrection);
128
- var chromaMax = (0, culori_1.clampChroma)({ mode: 'oklch', l: L / 100, c: 1, h: appliedHueShift }, 'oklch').c;
129
- var currentParams = settings.chromaSettings[L];
130
- var vividN = calculateChromaValue(
131
- currentParams.vivid.rel,
132
- currentParams.vivid.min,
133
- currentParams.vivid.max,
134
- chromaMax
135
- );
136
- var normN = calculateChromaValue(
137
- currentParams.normal.rel,
138
- currentParams.normal.min,
139
- currentParams.normal.max,
140
- chromaMax
141
- );
142
- var dimN = calculateChromaValue(currentParams.dim.rel, currentParams.dim.min, currentParams.dim.max, chromaMax);
143
- result.vivid[L] = 'oklch('.concat(L, '% ').concat(vividN.toFixed(3), ' ').concat(appliedHueShift.toFixed(0), ')');
144
- result.normal[L] = 'oklch('.concat(L, '% ').concat(normN.toFixed(3), ' ').concat(appliedHueShift.toFixed(0), ')');
145
- result.dim[L] = 'oklch('.concat(L, '% ').concat(dimN.toFixed(3), ' ').concat(appliedHueShift.toFixed(0), ')');
146
- }
147
- return result;
148
- }
149
- exports.getPalette = getPalette;
150
- function getAbneyHueShift(lightness, currentHue, abneyData) {
151
- var lightnessData = abneyData[lightness];
152
- if (!lightnessData) {
153
- return 0;
154
- }
155
- var hueRanges = Object.keys(lightnessData)
156
- .map(Number)
157
- .sort(function (a, b) {
158
- return a - b;
159
- });
160
- var selectedHueRange = hueRanges[0];
161
- for (var i = 0; i < hueRanges.length; i++) {
162
- var startRange = hueRanges[i];
163
- var endRange = hueRanges[i + 1] !== undefined ? hueRanges[i + 1] : 360;
164
- if (currentHue >= startRange && currentHue < endRange) {
165
- selectedHueRange = startRange;
166
- break;
167
- }
168
- if (i === hueRanges.length - 1 && currentHue >= startRange && currentHue < 360) {
169
- selectedHueRange = startRange;
170
- break;
171
- }
172
- }
173
- return lightnessData[selectedHueRange] !== undefined ? lightnessData[selectedHueRange] : 0;
174
- }
175
- exports.getAbneyHueShift = getAbneyHueShift;
176
- function applyAbneyShift(lightness, currentHue, abneyData) {
177
- var abneyShift = getAbneyHueShift(lightness, currentHue, abneyData);
178
- return (currentHue + abneyShift + 360) % 360;
179
- }
180
- exports.applyAbneyShift = applyAbneyShift;
181
- function applyWarningHuePatch(currentHue, lightness, warningHuePatchData, isWarningMode) {
182
- if (isWarningMode) {
183
- var patch = warningHuePatchData[lightness];
184
- if (patch !== undefined) {
185
- return (currentHue + patch + 360) % 360;
186
- }
187
- }
188
- return currentHue;
189
- }
190
- exports.applyWarningHuePatch = applyWarningHuePatch;
191
- function findClosestLightnessStep(targetL, availableLightnessSteps) {
192
- if (availableLightnessSteps.length === 0) {
193
- return targetL;
194
- }
195
- var sortedSteps = __spreadArray([], availableLightnessSteps, true).sort(function (a, b) {
196
- return a - b;
197
- });
198
- var closestStep = sortedSteps[0];
199
- var minDiff = Math.abs(targetL - closestStep);
200
- for (var i = 1; i < sortedSteps.length; i++) {
201
- var currentStep = sortedSteps[i];
202
- var diff = Math.abs(targetL - currentStep);
203
- if (diff < minDiff || (diff === minDiff && currentStep > closestStep)) {
204
- minDiff = diff;
205
- closestStep = currentStep;
206
- }
207
- }
208
- return closestStep;
209
- }
210
- function calculateBaseHueAndCorrectionRange(inputColorString, abneyData) {
211
- var toOklch = (0, culori_1.converter)('oklch');
212
- var oklch = toOklch(inputColorString);
213
- if (!oklch) {
214
- console.warn('Could not parse color string: '.concat(inputColorString));
215
- return null;
216
- }
217
- var targetLightness = Math.round(oklch.l * 100);
218
- var targetHue = oklch.h;
219
- if (isNaN(targetHue)) {
220
- console.warn('Achromatic color detected ('.concat(inputColorString, '). Defaulting hue to 0.'));
221
- targetHue = 0;
222
- }
223
- var availableLightnessSteps = Object.keys(abneyData).map(Number);
224
- if (availableLightnessSteps.length === 0) {
225
- console.warn('Abney correction data is empty, cannot calculate base hue.');
226
- return null;
227
- }
228
- var closestLightness = findClosestLightnessStep(targetLightness, availableLightnessSteps);
229
- var lightnessCorrectionData = abneyData[closestLightness];
230
- if (!lightnessCorrectionData) {
231
- console.warn('No Abney correction data for lightness '.concat(closestLightness, '.'));
232
- return null;
233
- }
234
- var correctedHueMap = Object.entries(lightnessCorrectionData).map(function (_a) {
235
- var rawHueStr = _a[0],
236
- shift = _a[1];
237
- var rawHue = Number(rawHueStr);
238
- return {
239
- rawHue: rawHue,
240
- shift: shift,
241
- correctedHue: (rawHue + shift + 360) % 360,
242
- };
243
- });
244
- correctedHueMap.sort(function (a, b) {
245
- if (a.correctedHue !== b.correctedHue) {
246
- return a.correctedHue - b.correctedHue;
247
- }
248
- return a.rawHue - b.rawHue;
249
- });
250
- if (correctedHueMap.length === 0) {
251
- console.warn('No hue ranges defined for lightness '.concat(closestLightness, '.'));
252
- return null;
253
- }
254
- var findCorrectRange = function () {
255
- var nextRangeIndex = correctedHueMap.findIndex(function (range) {
256
- return range.correctedHue > targetHue;
257
- });
258
- if (nextRangeIndex === 0) {
259
- return correctedHueMap[correctedHueMap.length - 1];
260
- }
261
- if (nextRangeIndex > 0) {
262
- return correctedHueMap[nextRangeIndex - 1];
263
- }
264
- return correctedHueMap[correctedHueMap.length - 1];
265
- };
266
- var selectedRange = findCorrectRange();
267
- if (!selectedRange) {
268
- console.error('Could not determine the correct hue range.');
269
- return null;
270
- }
271
- var baseHue = (targetHue - selectedRange.shift + 360) % 360;
272
- return {
273
- baseHue: baseHue,
274
- correctionLightness: closestLightness,
275
- correctionHueRange: selectedRange.rawHue,
276
- };
277
- }
278
- exports.calculateBaseHueAndCorrectionRange = calculateBaseHueAndCorrectionRange;
279
- function calcOnBrand(hex) {
280
- var whiteContrast = Math.abs(Number((0, apca_w3_1.calcAPCA)('#fff', hex)));
281
- var blackContrast = Math.abs(Number((0, apca_w3_1.calcAPCA)('#000', hex)));
282
- if (whiteContrast + 10 >= blackContrast) {
283
- return DefaultSwatch.whiteAlpha;
284
- }
285
- return DefaultSwatch.blackAlpha;
286
- }
287
- exports.calcOnBrand = calcOnBrand;
@@ -1,12 +0,0 @@
1
- export declare function getPromo(
2
- color: string,
3
- hueShifts?: {
4
- [hueRange: number]: number;
5
- }
6
- ): string;
7
- export declare function getPromoHueShift(
8
- currentHue: number,
9
- promoHueShifts: {
10
- [hueRange: number]: number;
11
- }
12
- ): number;
@@ -1,56 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getPromoHueShift = exports.getPromo = void 0;
4
- var culori_1 = require('culori');
5
- var promo_hue_shift_1 = require('../constants/promo-hue-shift');
6
- function getPromo(color, hueShifts) {
7
- if (hueShifts === void 0) {
8
- hueShifts = promo_hue_shift_1.PROMO_HUE_SHIFTS;
9
- }
10
- var toOklch = (0, culori_1.converter)('oklch');
11
- var oklchColor = toOklch(color);
12
- if (!oklchColor) {
13
- throw new Error('Invalid color string: '.concat(color));
14
- }
15
- var currentHue = oklchColor.h;
16
- var promoHueShift = getPromoHueShift(currentHue, hueShifts);
17
- var correctedHue = (currentHue + promoHueShift + 360) % 360;
18
- var promoLightness = oklchColor.l * 100;
19
- if (promoLightness >= 50) {
20
- promoLightness = promoLightness - 32;
21
- }
22
- promoLightness = Math.min(Math.max(promoLightness, 30), 34);
23
- var promoChroma = 0.1;
24
- var finalLightness = Math.round(promoLightness) / 100;
25
- var finalChroma = Math.round(promoChroma * 100) / 100;
26
- var promoOklch = {
27
- mode: 'oklch',
28
- l: finalLightness,
29
- c: finalChroma,
30
- h: correctedHue,
31
- };
32
- return (0, culori_1.formatHex)((0, culori_1.clampChroma)(promoOklch, 'oklch'));
33
- }
34
- exports.getPromo = getPromo;
35
- function getPromoHueShift(currentHue, promoHueShifts) {
36
- var hueRanges = Object.keys(promoHueShifts)
37
- .map(Number)
38
- .sort(function (a, b) {
39
- return a - b;
40
- });
41
- var selectedHueRange = hueRanges[0];
42
- for (var i = 0; i < hueRanges.length; i++) {
43
- var startRange = hueRanges[i];
44
- var endRange = hueRanges[i + 1] !== undefined ? hueRanges[i + 1] : 360;
45
- if (currentHue >= startRange && currentHue < endRange) {
46
- selectedHueRange = startRange;
47
- break;
48
- }
49
- if (i === hueRanges.length - 1 && (currentHue >= startRange || currentHue < hueRanges[0])) {
50
- selectedHueRange = startRange;
51
- break;
52
- }
53
- }
54
- return promoHueShifts[selectedHueRange] !== undefined ? promoHueShifts[selectedHueRange] : 0;
55
- }
56
- exports.getPromoHueShift = getPromoHueShift;
@@ -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 {};
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,2 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
@@ -1,15 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.kebabCaseToCamelCase = exports.camelCaseToKebabCase = void 0;
4
- var camelCaseToKebabCase = function (str) {
5
- return str.replace(/[A-Z]/g, function (match) {
6
- return '-'.concat(match.toLowerCase());
7
- });
8
- };
9
- exports.camelCaseToKebabCase = camelCaseToKebabCase;
10
- var kebabCaseToCamelCase = function (str) {
11
- return str.replace(/-(\w)/g, function (_, c) {
12
- return c.toUpperCase();
13
- });
14
- };
15
- exports.kebabCaseToCamelCase = kebabCaseToCamelCase;