@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.
Files changed (126) hide show
  1. package/CHANGELOG.md +84 -0
  2. package/README.md +104 -171
  3. package/dist/colors.default-dark.js +326 -319
  4. package/dist/colors.default-light.js +329 -319
  5. package/dist/colors.js +319 -319
  6. package/dist/colors.less +319 -319
  7. package/dist/colors.scss +319 -319
  8. package/dist/esm/consts/params/abney-correction.d.ts +2 -0
  9. package/dist/esm/consts/params/chroma-params.d.ts +2 -0
  10. package/dist/esm/{constants/chroma-settings.js → consts/params/chroma-params.js} +1 -1
  11. package/dist/esm/consts/params/logo-lightness.d.ts +1 -0
  12. package/dist/esm/consts/params/logo-lightness.js +1 -0
  13. package/dist/esm/get-colors-base.d.ts +12 -0
  14. package/dist/esm/get-colors-base.js +81 -0
  15. package/dist/{cjs/get-default-tokens.d.ts → esm/get-colors-default-tokens.d.ts} +2 -2
  16. package/dist/{cjs/get-default-tokens.js → esm/get-colors-default-tokens.js} +34 -38
  17. package/dist/esm/get-colors.d.ts +3 -9
  18. package/dist/esm/get-colors.js +6 -13
  19. package/dist/esm/get-default-tokens.d.ts +1 -1
  20. package/dist/esm/get-default-tokens.js +33 -33
  21. package/dist/esm/helpers/get-interactions.js +1 -1
  22. package/dist/esm/helpers/get-logo.js +4 -4
  23. package/dist/esm/helpers/get-palette.d.ts +3 -3
  24. package/dist/esm/helpers/get-palette.js +9 -9
  25. package/dist/esm/helpers/get-promo.js +1 -1
  26. package/dist/esm/types/{generator-tokens.d.ts → tokens-base-generator.d.ts} +2 -2
  27. package/dist/esm/types/tokens.d.ts +12 -0
  28. package/dist/esm/types/tokens.js +1 -0
  29. package/dist/esm/utils/convert-color.d.ts +3 -0
  30. package/dist/esm/utils/convert-color.js +133 -0
  31. package/dist/tokens/brand-blue-deep_accent-brand.css +33 -33
  32. package/dist/tokens/brand-blue-deep_accent-gray.css +33 -33
  33. package/dist/tokens/brand-blue_accent-brand.css +33 -33
  34. package/dist/tokens/brand-blue_accent-gray.css +33 -33
  35. package/dist/tokens/brand-green_accent-brand.css +33 -33
  36. package/dist/tokens/brand-green_accent-gray.css +33 -33
  37. package/dist/tokens/brand-mint_accent-brand.css +33 -33
  38. package/dist/tokens/brand-mint_accent-gray.css +33 -33
  39. package/dist/tokens/brand-orange_accent-gray.css +33 -33
  40. package/dist/tokens/brand-purple_accent-brand.css +33 -33
  41. package/dist/tokens/brand-purple_accent-gray.css +33 -33
  42. package/dist/tokens/brand-red_accent-gray.css +33 -33
  43. package/dist/tokens/brand-violet_accent-brand.css +33 -33
  44. package/dist/tokens/brand-violet_accent-gray.css +33 -33
  45. package/dist/tokens-js/brand-blue-deep_accent-brand.js +33 -33
  46. package/dist/tokens-js/brand-blue-deep_accent-gray.js +33 -33
  47. package/dist/tokens-js/brand-blue_accent-brand.js +33 -33
  48. package/dist/tokens-js/brand-blue_accent-gray.js +33 -33
  49. package/dist/tokens-js/brand-green_accent-brand.js +33 -33
  50. package/dist/tokens-js/brand-green_accent-gray.js +33 -33
  51. package/dist/tokens-js/brand-mint_accent-brand.js +33 -33
  52. package/dist/tokens-js/brand-mint_accent-gray.js +33 -33
  53. package/dist/tokens-js/brand-orange_accent-gray.js +33 -33
  54. package/dist/tokens-js/brand-purple_accent-brand.js +33 -33
  55. package/dist/tokens-js/brand-purple_accent-gray.js +33 -33
  56. package/dist/tokens-js/brand-red_accent-gray.js +33 -33
  57. package/dist/tokens-js/brand-violet_accent-brand.js +33 -33
  58. package/dist/tokens-js/brand-violet_accent-gray.js +33 -33
  59. package/dist/tokens-mobile/brand-blue-deep_accent-brand.json +304 -304
  60. package/dist/tokens-mobile/brand-blue-deep_accent-gray.json +304 -304
  61. package/dist/tokens-mobile/brand-blue_accent-brand.json +304 -304
  62. package/dist/tokens-mobile/brand-blue_accent-gray.json +304 -304
  63. package/dist/tokens-mobile/brand-green_accent-brand.json +304 -304
  64. package/dist/tokens-mobile/brand-green_accent-gray.json +304 -304
  65. package/dist/tokens-mobile/brand-mint_accent-brand.json +304 -304
  66. package/dist/tokens-mobile/brand-mint_accent-gray.json +304 -304
  67. package/dist/tokens-mobile/brand-orange_accent-gray.json +303 -303
  68. package/dist/tokens-mobile/brand-purple_accent-brand.json +304 -304
  69. package/dist/tokens-mobile/brand-purple_accent-gray.json +304 -304
  70. package/dist/tokens-mobile/brand-red_accent-gray.json +303 -303
  71. package/dist/tokens-mobile/brand-violet_accent-brand.json +300 -300
  72. package/dist/tokens-mobile/brand-violet_accent-gray.json +302 -302
  73. package/package.json +13 -22
  74. package/scripts/babel-register.js +4 -0
  75. package/scripts/tokens-base.json +3499 -0
  76. package/scripts/tokens.json +710 -0
  77. package/dist/cjs/constants/abney-correction.d.ts +0 -2
  78. package/dist/cjs/constants/abney-correction.js +0 -1105
  79. package/dist/cjs/constants/chroma-settings.d.ts +0 -2
  80. package/dist/cjs/constants/chroma-settings.js +0 -105
  81. package/dist/cjs/constants/default-swatch.js +0 -112
  82. package/dist/cjs/constants/interaction-settings.js +0 -19
  83. package/dist/cjs/constants/logo-lightness.d.ts +0 -1
  84. package/dist/cjs/constants/logo-lightness.js +0 -4
  85. package/dist/cjs/constants/promo-hue-shift.js +0 -14
  86. package/dist/cjs/constants/warning-hue-patch.js +0 -25
  87. package/dist/cjs/get-base-tokens.d.ts +0 -19
  88. package/dist/cjs/get-base-tokens.js +0 -199
  89. package/dist/cjs/get-colors.d.ts +0 -19
  90. package/dist/cjs/get-colors.js +0 -25
  91. package/dist/cjs/helpers/get-interactions.d.ts +0 -7
  92. package/dist/cjs/helpers/get-interactions.js +0 -61
  93. package/dist/cjs/helpers/get-logo.d.ts +0 -6
  94. package/dist/cjs/helpers/get-logo.js +0 -32
  95. package/dist/cjs/helpers/get-palette.d.ts +0 -76
  96. package/dist/cjs/helpers/get-palette.js +0 -287
  97. package/dist/cjs/helpers/get-promo.d.ts +0 -12
  98. package/dist/cjs/helpers/get-promo.js +0 -56
  99. package/dist/cjs/types/base-tokens.js +0 -2
  100. package/dist/cjs/types/generator-tokens.d.ts +0 -43
  101. package/dist/cjs/types/generator-tokens.js +0 -2
  102. package/dist/cjs/utils/format-variable.d.ts +0 -2
  103. package/dist/cjs/utils/format-variable.js +0 -15
  104. package/dist/esm/constants/abney-correction.d.ts +0 -2
  105. package/dist/esm/constants/chroma-settings.d.ts +0 -2
  106. package/dist/esm/constants/default-swatch.d.ts +0 -109
  107. package/dist/esm/constants/interaction-settings.d.ts +0 -8
  108. package/dist/esm/constants/logo-lightness.d.ts +0 -1
  109. package/dist/esm/constants/logo-lightness.js +0 -1
  110. package/dist/esm/constants/promo-hue-shift.d.ts +0 -3
  111. package/dist/esm/constants/warning-hue-patch.d.ts +0 -3
  112. package/dist/esm/get-base-tokens.d.ts +0 -19
  113. package/dist/esm/get-base-tokens.js +0 -147
  114. package/dist/esm/types/base-tokens.d.ts +0 -125
  115. /package/dist/{cjs/constants → esm/consts}/default-swatch.d.ts +0 -0
  116. /package/dist/esm/{constants → consts}/default-swatch.js +0 -0
  117. /package/dist/esm/{constants → consts/params}/abney-correction.js +0 -0
  118. /package/dist/{cjs/constants/interaction-settings.d.ts → esm/consts/params/interactions.d.ts} +0 -0
  119. /package/dist/esm/{constants/interaction-settings.js → consts/params/interactions.js} +0 -0
  120. /package/dist/{cjs/constants → esm/consts/params}/promo-hue-shift.d.ts +0 -0
  121. /package/dist/esm/{constants → consts/params}/promo-hue-shift.js +0 -0
  122. /package/dist/{cjs/constants → esm/consts/params}/warning-hue-patch.d.ts +0 -0
  123. /package/dist/esm/{constants → consts/params}/warning-hue-patch.js +0 -0
  124. /package/dist/esm/types/{base-tokens.js → tokens-base-generator.js} +0 -0
  125. /package/dist/{cjs/types/base-tokens.d.ts → esm/types/tokens-base.d.ts} +0 -0
  126. /package/dist/esm/types/{generator-tokens.js → tokens-base.js} +0 -0
@@ -1,2 +0,0 @@
1
- import type { GeneratorColorChromaSettingsGroup } from '../types/generator-tokens';
2
- export declare const CHROMA_SETTINGS: GeneratorColorChromaSettingsGroup;
@@ -1,105 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.CHROMA_SETTINGS = void 0;
4
- exports.CHROMA_SETTINGS = {
5
- 20: {
6
- vivid: { rel: 100, max: 12 },
7
- normal: { rel: 66, min: 4.4, max: 8 },
8
- dim: { rel: 46, min: 2, max: 4.4 },
9
- },
10
- 24: {
11
- vivid: { rel: 100, max: 14.2 },
12
- normal: { rel: 68, min: 5.7, max: 10 },
13
- dim: { rel: 48, min: 2.8, max: 5.7 },
14
- },
15
- 28: {
16
- vivid: { rel: 100, max: 15.8 },
17
- normal: { rel: 70, min: 7, max: 11.8 },
18
- dim: { rel: 50, min: 3.6, max: 7 },
19
- },
20
- 32: {
21
- vivid: { rel: 100, max: 17.1 },
22
- normal: { rel: 72, min: 8.2, max: 13.2 },
23
- dim: { rel: 52, min: 4.4, max: 8.2 },
24
- },
25
- 36: {
26
- vivid: { rel: 100, max: 18 },
27
- normal: { rel: 74, min: 9.4, max: 14.4 },
28
- dim: { rel: 54, min: 5.2, max: 9.4 },
29
- },
30
- 40: {
31
- vivid: { rel: 100, max: 18.8 },
32
- normal: { rel: 76, min: 10.6, max: 15.6 },
33
- dim: { rel: 56, min: 6, max: 10.6 },
34
- },
35
- 44: {
36
- vivid: { rel: 100, max: 19.6 },
37
- normal: { rel: 78, min: 11.7, max: 16.6 },
38
- dim: { rel: 58, min: 6.8, max: 11.7 },
39
- },
40
- 48: {
41
- vivid: { rel: 100, max: 20.3 },
42
- normal: { rel: 80, min: 12.8, max: 17.5 },
43
- dim: { rel: 60, min: 7.6, max: 12.8 },
44
- },
45
- 52: {
46
- vivid: { rel: 100, max: 21 },
47
- normal: { rel: 82, min: 13.9, max: 18.4 },
48
- dim: { rel: 62, min: 8.4, max: 13.9 },
49
- },
50
- 56: {
51
- vivid: { rel: 100, max: 21.6 },
52
- normal: { rel: 84, min: 15, max: 19.2 },
53
- dim: { rel: 64, min: 9.2, max: 15 },
54
- },
55
- 60: {
56
- vivid: { rel: 100, max: 22 },
57
- normal: { rel: 86, min: 15.9, max: 19.9 },
58
- dim: { rel: 66, min: 9.9, max: 15.9 },
59
- },
60
- 64: {
61
- vivid: { rel: 100, max: 22.2 },
62
- normal: { rel: 88, min: 16.2, max: 20.2 },
63
- dim: { rel: 68, min: 10.2, max: 16.2 },
64
- },
65
- 68: {
66
- vivid: { rel: 100, max: 21.9 },
67
- normal: { rel: 90, min: 15.8, max: 19.8 },
68
- dim: { rel: 70, min: 9.6, max: 15.8 },
69
- },
70
- 72: {
71
- vivid: { rel: 100, max: 21.2 },
72
- normal: { rel: 92, min: 14.8, max: 18.8 },
73
- dim: { rel: 72, min: 8.4, max: 14.8 },
74
- },
75
- 76: {
76
- vivid: { rel: 100, max: 20.3 },
77
- normal: { rel: 90, min: 13.1, max: 17.5 },
78
- dim: { rel: 70, min: 7, max: 13.1 },
79
- },
80
- 80: {
81
- vivid: { rel: 100, max: 19 },
82
- normal: { rel: 88, min: 11.2, max: 15.6 },
83
- dim: { rel: 68, min: 5.6, max: 11.2 },
84
- },
85
- 84: {
86
- vivid: { rel: 100, max: 17.1 },
87
- normal: { rel: 86, min: 9, max: 13.4 },
88
- dim: { rel: 66, min: 4.4, max: 9 },
89
- },
90
- 88: {
91
- vivid: { rel: 100, max: 14.2 },
92
- normal: { rel: 84, min: 6.7, max: 10.4 },
93
- dim: { rel: 64, min: 3.2, max: 6.7 },
94
- },
95
- 92: {
96
- vivid: { rel: 100, max: 11 },
97
- normal: { rel: 82, min: 4.4, max: 7.4 },
98
- dim: { rel: 62, min: 2.2, max: 4.4 },
99
- },
100
- 96: {
101
- vivid: { rel: 100, max: 7 },
102
- normal: { rel: 80, min: 2.6, max: 4.4 },
103
- dim: { rel: 60, min: 1.5, max: 2.6 },
104
- },
105
- };
@@ -1,112 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.blackAlpha = exports.whiteAlpha = exports.gray = exports.customizable = exports.system = exports.brand = void 0;
4
- exports.brand = {
5
- red: '#FE4C4C',
6
- orange: '#FC7630',
7
- green: '#26AD50',
8
- mint: '#00BEA2',
9
- blue: '#2291FF',
10
- blueDeep: '#366AF3',
11
- violet: '#844BEC',
12
- purple: '#B750D1',
13
- };
14
- exports.system = {
15
- warning: '#FDAA00',
16
- error: '#E62B34',
17
- success: '#009A40',
18
- accent: '#2291FF',
19
- };
20
- exports.customizable = {
21
- red: '#FE4C4C',
22
- orange: '#FC7630',
23
- green: '#26AD50',
24
- mint: '#00BEA2',
25
- blue: '#2291FF',
26
- blueDeep: '#366AF3',
27
- violet: '#844BEC',
28
- purple: '#B750D1',
29
- yellow: '#FAB700',
30
- };
31
- exports.gray = {
32
- 0: 'oklch(0% 0 0)',
33
- 16: 'oklch(16% 0 0)',
34
- 20: 'oklch(20% 0 0)',
35
- 24: 'oklch(24% 0 0)',
36
- 28: 'oklch(28% 0 0)',
37
- 32: 'oklch(32% 0 0)',
38
- 36: 'oklch(36% 0 0)',
39
- 40: 'oklch(40% 0 0)',
40
- 44: 'oklch(44% 0 0)',
41
- 48: 'oklch(48% 0 0)',
42
- 52: 'oklch(52% 0 0)',
43
- 56: 'oklch(56% 0 0)',
44
- 60: 'oklch(60% 0 0)',
45
- 64: 'oklch(64% 0 0)',
46
- 68: 'oklch(68% 0 0)',
47
- 72: 'oklch(72% 0 0)',
48
- 76: 'oklch(76% 0 0)',
49
- 80: 'oklch(80% 0 0)',
50
- 84: 'oklch(84% 0 0)',
51
- 88: 'oklch(88% 0 0)',
52
- 92: 'oklch(92% 0 0)',
53
- 96: 'oklch(96% 0 0)',
54
- 98: 'oklch(98% 0 0)',
55
- 100: 'oklch(100% 0 0)',
56
- };
57
- exports.whiteAlpha = {
58
- 4: 'oklch(100% 0 0 / 0.04)',
59
- 6: 'oklch(100% 0 0 / 0.06)',
60
- 8: 'oklch(100% 0 0 / 0.08)',
61
- 12: 'oklch(100% 0 0 / 0.12)',
62
- 16: 'oklch(100% 0 0 / 0.16)',
63
- 20: 'oklch(100% 0 0 / 0.2)',
64
- 24: 'oklch(100% 0 0 / 0.24)',
65
- 28: 'oklch(100% 0 0 / 0.28)',
66
- 32: 'oklch(100% 0 0 / 0.32)',
67
- 36: 'oklch(100% 0 0 / 0.36)',
68
- 40: 'oklch(100% 0 0 / 0.4)',
69
- 44: 'oklch(100% 0 0 / 0.44)',
70
- 48: 'oklch(100% 0 0 / 0.48)',
71
- 52: 'oklch(100% 0 0 / 0.52)',
72
- 56: 'oklch(100% 0 0 / 0.56)',
73
- 60: 'oklch(100% 0 0 / 0.6)',
74
- 64: 'oklch(100% 0 0 / 0.64)',
75
- 68: 'oklch(100% 0 0 / 0.68)',
76
- 72: 'oklch(100% 0 0 / 0.72)',
77
- 76: 'oklch(100% 0 0 / 0.76)',
78
- 80: 'oklch(100% 0 0 / 0.8)',
79
- 84: 'oklch(100% 0 0 / 0.84)',
80
- 88: 'oklch(100% 0 0 / 0.88)',
81
- 92: 'oklch(100% 0 0 / 0.92)',
82
- 96: 'oklch(100% 0 0 / 0.96)',
83
- 100: 'oklch(100% 0 0 / 1)',
84
- };
85
- exports.blackAlpha = {
86
- 4: 'oklch(0% 0 0 / 0.04)',
87
- 6: 'oklch(0% 0 0 / 0.06)',
88
- 8: 'oklch(0% 0 0 / 0.08)',
89
- 12: 'oklch(0% 0 0 / 0.12)',
90
- 16: 'oklch(0% 0 0 / 0.16)',
91
- 20: 'oklch(0% 0 0 / 0.2)',
92
- 24: 'oklch(0% 0 0 / 0.24)',
93
- 28: 'oklch(0% 0 0 / 0.28)',
94
- 32: 'oklch(0% 0 0 / 0.32)',
95
- 36: 'oklch(0% 0 0 / 0.36)',
96
- 40: 'oklch(0% 0 0 / 0.4)',
97
- 44: 'oklch(0% 0 0 / 0.44)',
98
- 48: 'oklch(0% 0 0 / 0.48)',
99
- 52: 'oklch(0% 0 0 / 0.52)',
100
- 56: 'oklch(0% 0 0 / 0.56)',
101
- 60: 'oklch(0% 0 0 / 0.6)',
102
- 64: 'oklch(0% 0 0 / 0.64)',
103
- 68: 'oklch(0% 0 0 / 0.68)',
104
- 72: 'oklch(0% 0 0 / 0.72)',
105
- 76: 'oklch(0% 0 0 / 0.76)',
106
- 80: 'oklch(0% 0 0 / 0.8)',
107
- 84: 'oklch(0% 0 0 / 0.84)',
108
- 88: 'oklch(0% 0 0 / 0.88)',
109
- 92: 'oklch(0% 0 0 / 0.92)',
110
- 96: 'oklch(0% 0 0 / 0.96)',
111
- 100: 'oklch(0% 0 0 / 1)',
112
- };
@@ -1,19 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.PRESSED_DARK_C =
4
- exports.PRESSED_DARK_L =
5
- exports.PRESSED_LIGHT_C =
6
- exports.PRESSED_LIGHT_L =
7
- exports.HOVER_DARK_C =
8
- exports.HOVER_DARK_L =
9
- exports.HOVER_LIGHT_C =
10
- exports.HOVER_LIGHT_L =
11
- void 0;
12
- exports.HOVER_LIGHT_L = -4;
13
- exports.HOVER_LIGHT_C = 0;
14
- exports.HOVER_DARK_L = +4;
15
- exports.HOVER_DARK_C = 0;
16
- exports.PRESSED_LIGHT_L = -8;
17
- exports.PRESSED_LIGHT_C = -0.03;
18
- exports.PRESSED_DARK_L = -4;
19
- exports.PRESSED_DARK_C = -0.03;
@@ -1 +0,0 @@
1
- export declare const MIN_LOGO_LIGHTNESS = 64;
@@ -1,4 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.MIN_LOGO_LIGHTNESS = void 0;
4
- exports.MIN_LOGO_LIGHTNESS = 64;
@@ -1,14 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.PROMO_HUE_SHIFTS = void 0;
4
- exports.PROMO_HUE_SHIFTS = {
5
- 0: -24,
6
- 25: -32,
7
- 44: -35,
8
- 148: 40,
9
- 177: 51,
10
- 253: 11,
11
- 264: 14,
12
- 294: 0,
13
- 319: -24,
14
- };
@@ -1,25 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.WARNING_HUE_PATCH = void 0;
4
- exports.WARNING_HUE_PATCH = {
5
- 96: 0,
6
- 92: 0,
7
- 88: 0,
8
- 84: 0,
9
- 80: 0,
10
- 76: 0,
11
- 72: -4,
12
- 68: -8,
13
- 64: -12,
14
- 60: -8,
15
- 56: -4,
16
- 52: -2,
17
- 48: 0,
18
- 44: 0,
19
- 40: 0,
20
- 36: 0,
21
- 32: 0,
22
- 28: 0,
23
- 24: 0,
24
- 20: 0,
25
- };
@@ -1,19 +0,0 @@
1
- import * as DEFAULT_SWATCH from './constants/default-swatch';
2
- import type { BaseTokens } from './types/base-tokens';
3
- type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
4
- export declare const ACCENT_PARAMS: string[];
5
- export interface ColorObject {
6
- [key: string]: ColorValue;
7
- }
8
- export type ColorValue = string | ColorObject | ColorValue[];
9
- type ColorStructure = ColorObject | ColorValue[];
10
- export interface ConfigOptions {
11
- brand: PresetOrCustom<keyof typeof DEFAULT_SWATCH.brand>;
12
- accent: PresetOrCustom<(typeof ACCENT_PARAMS)[number]>;
13
- system?: typeof DEFAULT_SWATCH.system;
14
- }
15
- export declare function getBaseTokens({ brand, accent, system }: ConfigOptions): BaseTokens;
16
- export declare function convertOklchToHex(obj: ColorStructure): ColorStructure;
17
- export declare const convertOklchToRgba: (oklchString: string) => string;
18
- export declare function convertAlphaOklchToRgba(obj: ColorStructure): ColorStructure;
19
- export {};
@@ -1,199 +0,0 @@
1
- 'use strict';
2
- var __createBinding =
3
- (this && this.__createBinding) ||
4
- (Object.create
5
- ? function (o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- var desc = Object.getOwnPropertyDescriptor(m, k);
8
- if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
9
- desc = {
10
- enumerable: true,
11
- get: function () {
12
- return m[k];
13
- },
14
- };
15
- }
16
- Object.defineProperty(o, k2, desc);
17
- }
18
- : function (o, m, k, k2) {
19
- if (k2 === undefined) k2 = k;
20
- o[k2] = m[k];
21
- });
22
- var __setModuleDefault =
23
- (this && this.__setModuleDefault) ||
24
- (Object.create
25
- ? function (o, v) {
26
- Object.defineProperty(o, 'default', { enumerable: true, value: v });
27
- }
28
- : function (o, v) {
29
- o['default'] = v;
30
- });
31
- var __importStar =
32
- (this && this.__importStar) ||
33
- function (mod) {
34
- if (mod && mod.__esModule) return mod;
35
- var result = {};
36
- if (mod != null)
37
- for (var k in mod)
38
- if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
39
- __setModuleDefault(result, mod);
40
- return result;
41
- };
42
- Object.defineProperty(exports, '__esModule', { value: true });
43
- exports.convertAlphaOklchToRgba =
44
- exports.convertOklchToRgba =
45
- exports.convertOklchToHex =
46
- exports.getBaseTokens =
47
- exports.ACCENT_PARAMS =
48
- void 0;
49
- var culori_1 = require('culori');
50
- var get_palette_1 = require('./helpers/get-palette');
51
- var get_promo_1 = require('./helpers/get-promo');
52
- var DEFAULT_SWATCH = __importStar(require('./constants/default-swatch'));
53
- var get_logo_1 = require('./helpers/get-logo');
54
- var get_interactions_1 = require('./helpers/get-interactions');
55
- exports.ACCENT_PARAMS = ['brand', 'gray'];
56
- function getBaseTokens(_a) {
57
- var brand = _a.brand,
58
- _b = _a.accent,
59
- accent = _b === void 0 ? 'gray' : _b,
60
- _c = _a.system,
61
- system = _c === void 0 ? DEFAULT_SWATCH.system : _c;
62
- var isPresetColor = brand in DEFAULT_SWATCH.brand;
63
- var brandColor;
64
- if (isPresetColor) {
65
- brandColor = DEFAULT_SWATCH.brand[brand];
66
- } else {
67
- brandColor = brand;
68
- }
69
- var accentColor;
70
- if (accent === 'brand') {
71
- accentColor = brandColor;
72
- } else if (accent !== 'gray') {
73
- accentColor = accent;
74
- }
75
- var brandPalette = (0, get_palette_1.getPalette)({ color: brandColor });
76
- var accentPalette;
77
- if (accent === 'brand') {
78
- accentPalette = brandPalette;
79
- } else if (accent !== 'gray' && accentColor) {
80
- accentPalette = (0, get_palette_1.getPalette)({ color: accentColor });
81
- }
82
- var customizablePalettes = {};
83
- for (var colorKey in DEFAULT_SWATCH.customizable) {
84
- var key = colorKey;
85
- if (key === brand && isPresetColor) {
86
- customizablePalettes[key] = brandPalette;
87
- continue;
88
- }
89
- customizablePalettes[key] = (0, get_palette_1.getPalette)({
90
- color: DEFAULT_SWATCH.customizable[key],
91
- });
92
- }
93
- return {
94
- brand: {
95
- logo: (0, get_logo_1.getLogo)(brandColor),
96
- promo: (0, get_promo_1.getPromo)(brandColor),
97
- original: brandColor,
98
- interactions: {
99
- hover: (0, get_interactions_1.getHover)(brandColor),
100
- pressed: (0, get_interactions_1.getPressed)(brandColor),
101
- },
102
- palette: brandPalette,
103
- },
104
- accent: accentColor
105
- ? {
106
- original: {
107
- light: accentColor,
108
- dark: accentColor,
109
- },
110
- interactions: {
111
- hover: (0, get_interactions_1.getHover)(accentColor),
112
- pressed: (0, get_interactions_1.getPressed)(accentColor),
113
- },
114
- palette: accentPalette,
115
- }
116
- : undefined,
117
- warning: (0, get_palette_1.getPalette)({ color: system.warning }),
118
- error: (0, get_palette_1.getPalette)({ color: system.error }),
119
- success: (0, get_palette_1.getPalette)({ color: system.success }),
120
- gray: DEFAULT_SWATCH.gray,
121
- whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
122
- blackAlpha: DEFAULT_SWATCH.blackAlpha,
123
- onBrand: (0, get_palette_1.calcOnBrand)(brandColor),
124
- onAccent: accentColor ? (0, get_palette_1.calcOnBrand)(accentColor) : undefined,
125
- customizable: customizablePalettes,
126
- };
127
- }
128
- exports.getBaseTokens = getBaseTokens;
129
- function convertOklchToHex(obj) {
130
- if (typeof obj !== 'object' || obj === null) {
131
- return obj;
132
- }
133
- if (Array.isArray(obj)) {
134
- return obj.map(function (item) {
135
- if (typeof item === 'object' && item !== null) {
136
- return convertOklchToHex(item);
137
- }
138
- return item;
139
- });
140
- }
141
- var newObj = {};
142
- for (var key in obj) {
143
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
144
- var value = obj[key];
145
- if (typeof value === 'string' && value.startsWith('oklch(') && !value.includes('/')) {
146
- var oklchColor = (0, culori_1.converter)('oklch')(value);
147
- var rgbColor = (0, culori_1.converter)('rgb')(oklchColor);
148
- value = (0, culori_1.formatHex)(rgbColor);
149
- }
150
- if (typeof value === 'object' && value !== null) {
151
- newObj[key] = convertOklchToHex(value);
152
- } else {
153
- newObj[key] = value;
154
- }
155
- }
156
- }
157
- return newObj;
158
- }
159
- exports.convertOklchToHex = convertOklchToHex;
160
- var convertOklchToRgba = function (oklchString) {
161
- var _a;
162
- var oklch = (0, culori_1.converter)('oklch')(oklchString);
163
- var rgb = (0, culori_1.converter)('rgb')(oklch);
164
- var r = Math.round(rgb.r * 255);
165
- var g = Math.round(rgb.g * 255);
166
- var b = Math.round(rgb.b * 255);
167
- var alpha = (_a = oklch.alpha) !== null && _a !== void 0 ? _a : 1;
168
- return 'rgba('.concat(r, ', ').concat(g, ', ').concat(b, ', ').concat(alpha, ')');
169
- };
170
- exports.convertOklchToRgba = convertOklchToRgba;
171
- function convertAlphaOklchToRgba(obj) {
172
- if (typeof obj !== 'object' || obj === null) {
173
- return obj;
174
- }
175
- if (Array.isArray(obj)) {
176
- return obj.map(function (item) {
177
- if (typeof item === 'object' && item !== null) {
178
- return convertAlphaOklchToRgba(item);
179
- }
180
- return item;
181
- });
182
- }
183
- var newObj = {};
184
- for (var key in obj) {
185
- if (Object.prototype.hasOwnProperty.call(obj, key)) {
186
- var value = obj[key];
187
- if (typeof value === 'string' && value.includes('oklch(')) {
188
- value = (0, exports.convertOklchToRgba)(value);
189
- }
190
- if (typeof value === 'object' && value !== null) {
191
- newObj[key] = convertAlphaOklchToRgba(value);
192
- } else {
193
- newObj[key] = value;
194
- }
195
- }
196
- }
197
- return newObj;
198
- }
199
- exports.convertAlphaOklchToRgba = convertAlphaOklchToRgba;
@@ -1,19 +0,0 @@
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>;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, '__esModule', { value: true });
3
- exports.getColors = void 0;
4
- var get_base_tokens_1 = require('./get-base-tokens'); //
5
- var get_default_tokens_1 = require('./get-default-tokens');
6
- var DEFAULT_THEME = 'light';
7
- function getColors(params) {
8
- var theme = params.theme || DEFAULT_THEME;
9
- var base = (0, get_base_tokens_1.getBaseTokens)(params);
10
- var defaults = (0, get_default_tokens_1.getDefaultTokens)(base);
11
- var result;
12
- // 1. Получаем базовый объект цветов (либо дефолтный, либо переопределенный)
13
- if (params.overrides) {
14
- result = params.overrides(base, defaults, params)[theme];
15
- } else {
16
- result = defaults[theme];
17
- }
18
- // 2. Конвертируем oklch без прозрачности в HEX
19
- // Используем 'as any', так как конвертеры рассчитаны на рекурсивную структуру ColorStructure
20
- var hexConverted = (0, get_base_tokens_1.convertOklchToHex)(result);
21
- // 3. Конвертируем оставшиеся oklch (с прозрачностью) в RGBA
22
- var finalResult = (0, get_base_tokens_1.convertAlphaOklchToRgba)(hexConverted);
23
- return finalResult;
24
- }
25
- exports.getColors = getColors;
@@ -1,7 +0,0 @@
1
- interface InteractionColors {
2
- light: string;
3
- dark: string;
4
- }
5
- export declare function getHover(hex: string): InteractionColors;
6
- export declare function getPressed(hex: string): InteractionColors;
7
- export {};
@@ -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,6 +0,0 @@
1
- interface LogoColors {
2
- light: string;
3
- dark: string;
4
- }
5
- export declare function getLogo(hex: string): LogoColors;
6
- export {};
@@ -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;