@skbkontur/colors 2.0.5 → 2.0.6-alpha.1

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 (43) hide show
  1. package/default-dark.d.ts +34 -34
  2. package/default-dark.js +34 -34
  3. package/default-light.d.ts +35 -35
  4. package/default-light.js +35 -35
  5. package/lib/consts/default-swatch.js +2 -2
  6. package/lib/consts/default-swatch.ts +2 -2
  7. package/lib/get-colors-base.js +5 -4
  8. package/lib/get-colors-base.ts +5 -4
  9. package/lib/helpers/get-on-brand.d.ts +28 -0
  10. package/lib/helpers/get-on-brand.js +10 -0
  11. package/lib/helpers/get-on-brand.ts +13 -0
  12. package/lib/helpers/get-palette.d.ts +3 -36
  13. package/lib/helpers/get-palette.js +65 -98
  14. package/lib/helpers/get-palette.ts +73 -117
  15. package/package.json +1 -1
  16. package/tokens/brand-blue-deep_accent-brand.css +69 -69
  17. package/tokens/brand-blue-deep_accent-gray.css +69 -69
  18. package/tokens/brand-blue_accent-brand.css +69 -69
  19. package/tokens/brand-blue_accent-gray.css +69 -69
  20. package/tokens/brand-green_accent-brand.css +69 -69
  21. package/tokens/brand-green_accent-gray.css +69 -69
  22. package/tokens/brand-mint_accent-brand.css +69 -69
  23. package/tokens/brand-mint_accent-gray.css +69 -69
  24. package/tokens/brand-orange_accent-gray.css +88 -88
  25. package/tokens/brand-purple_accent-brand.css +69 -69
  26. package/tokens/brand-purple_accent-gray.css +69 -69
  27. package/tokens/brand-red_accent-gray.css +69 -69
  28. package/tokens/brand-violet_accent-brand.css +69 -69
  29. package/tokens/brand-violet_accent-gray.css +69 -69
  30. package/tokens-mobile/brand-blue-deep_accent-brand.json +38 -38
  31. package/tokens-mobile/brand-blue-deep_accent-gray.json +38 -38
  32. package/tokens-mobile/brand-blue_accent-brand.json +38 -38
  33. package/tokens-mobile/brand-blue_accent-gray.json +38 -38
  34. package/tokens-mobile/brand-green_accent-brand.json +38 -38
  35. package/tokens-mobile/brand-green_accent-gray.json +38 -38
  36. package/tokens-mobile/brand-mint_accent-brand.json +38 -38
  37. package/tokens-mobile/brand-mint_accent-gray.json +38 -38
  38. package/tokens-mobile/brand-orange_accent-gray.json +46 -46
  39. package/tokens-mobile/brand-purple_accent-brand.json +38 -38
  40. package/tokens-mobile/brand-purple_accent-gray.json +38 -38
  41. package/tokens-mobile/brand-red_accent-gray.json +38 -38
  42. package/tokens-mobile/brand-violet_accent-brand.json +38 -38
  43. package/tokens-mobile/brand-violet_accent-gray.json +38 -38
package/default-light.js CHANGED
@@ -17,9 +17,9 @@ export var textInvertedNeutralSoft = 'var(--k-color-text-inverted-neutral-soft,
17
17
  export var textInvertedSuccessHeavy = 'var(--k-color-text-inverted-success-heavy, #00c655)';
18
18
  export var textInvertedSuccessHeavyHover = 'var(--k-color-text-inverted-success-heavy-hover, #4ede76)';
19
19
  export var textInvertedSuccessHeavyPressed = 'var(--k-color-text-inverted-success-heavy-pressed, #4fa161)';
20
- export var textInvertedWarningHeavy = 'var(--k-color-text-inverted-warning-heavy, #f8ae00)';
21
- export var textInvertedWarningHeavyHover = 'var(--k-color-text-inverted-warning-heavy-hover, #ffbf0b)';
22
- export var textInvertedWarningHeavyPressed = 'var(--k-color-text-inverted-warning-heavy-pressed, #cc9a51)';
20
+ export var textInvertedWarningHeavy = 'var(--k-color-text-inverted-warning-heavy, #faac00)';
21
+ export var textInvertedWarningHeavyHover = 'var(--k-color-text-inverted-warning-heavy-hover, #ffbe26)';
22
+ export var textInvertedWarningHeavyPressed = 'var(--k-color-text-inverted-warning-heavy-pressed, #d29750)';
23
23
  export var textLogo = 'var(--k-color-text-logo, #FE4C4C)';
24
24
  export var textNeutralFaint = 'var(--k-color-text-neutral-faint, rgba(0, 0, 0, 0.32))';
25
25
  export var textNeutralHeavy = 'var(--k-color-text-neutral-heavy, rgba(0, 0, 0, 0.88))';
@@ -28,9 +28,9 @@ export var textNeutralSoft = 'var(--k-color-text-neutral-soft, rgba(0, 0, 0, 0.5
28
28
  export var textSuccessHeavy = 'var(--k-color-text-success-heavy, #007f34)';
29
29
  export var textSuccessHeavyHover = 'var(--k-color-text-success-heavy-hover, #009b41)';
30
30
  export var textSuccessHeavyPressed = 'var(--k-color-text-success-heavy-pressed, #3a6a43)';
31
- export var textWarningHeavy = 'var(--k-color-text-warning-heavy, #bc7d00)';
32
- export var textWarningHeavyHover = 'var(--k-color-text-warning-heavy-hover, #db9400)';
33
- export var textWarningHeavyPressed = 'var(--k-color-text-warning-heavy-pressed, #a37736)';
31
+ export var textWarningHeavy = 'var(--k-color-text-warning-heavy, #cc7204)';
32
+ export var textWarningHeavyHover = 'var(--k-color-text-warning-heavy-hover, #e28f05)';
33
+ export var textWarningHeavyPressed = 'var(--k-color-text-warning-heavy-pressed, #a9733c)';
34
34
  export var textConstFaintBlack = 'var(--k-color-text-const-faint-black, rgba(0, 0, 0, 0.32))';
35
35
  export var textConstFaintWhite = 'var(--k-color-text-const-faint-white, rgba(255, 255, 255, 0.4))';
36
36
  export var textConstHeavyBlack = 'var(--k-color-text-const-heavy-black, rgba(0, 0, 0, 0.88))';
@@ -62,9 +62,9 @@ export var shapeBoldNeutralPressed = 'var(--k-color-shape-bold-neutral-pressed,
62
62
  export var shapeBoldSuccess = 'var(--k-color-shape-bold-success, #00a948)';
63
63
  export var shapeBoldSuccessHover = 'var(--k-color-shape-bold-success-hover, #009b41)';
64
64
  export var shapeBoldSuccessPressed = 'var(--k-color-shape-bold-success-pressed, #178b3f)';
65
- export var shapeBoldWarning = 'var(--k-color-shape-bold-warning, #ffbf0b)';
66
- export var shapeBoldWarningHover = 'var(--k-color-shape-bold-warning-hover, #f8ae00)';
67
- export var shapeBoldWarningPressed = 'var(--k-color-shape-bold-warning-pressed, #e5a331)';
65
+ export var shapeBoldWarning = 'var(--k-color-shape-bold-warning, #ffbe26)';
66
+ export var shapeBoldWarningHover = 'var(--k-color-shape-bold-warning-hover, #faac00)';
67
+ export var shapeBoldWarningPressed = 'var(--k-color-shape-bold-warning-pressed, #e7a132)';
68
68
  export var shapeFaintAccent = 'var(--k-color-shape-faint-accent, rgba(0, 0, 0, 0.12))';
69
69
  export var shapeFaintAccentHover = 'var(--k-color-shape-faint-accent-hover, rgba(0, 0, 0, 0.16))';
70
70
  export var shapeFaintAccentPressed = 'var(--k-color-shape-faint-accent-pressed, rgba(0, 0, 0, 0.24))';
@@ -80,13 +80,13 @@ export var shapeFaintNeutralAlphaPressed = 'var(--k-color-shape-faint-neutral-al
80
80
  export var shapeFaintSuccess = 'var(--k-color-shape-faint-success, #defbe2)';
81
81
  export var shapeFaintSuccessHover = 'var(--k-color-shape-faint-success-hover, #c3f3ca)';
82
82
  export var shapeFaintSuccessPressed = 'var(--k-color-shape-faint-success-pressed, #d1edd5)';
83
- export var shapeFaintWarning = 'var(--k-color-shape-faint-warning, #fff3bd)';
84
- export var shapeFaintWarningHover = 'var(--k-color-shape-faint-warning-hover, #f4e5ad)';
85
- export var shapeFaintWarningPressed = 'var(--k-color-shape-faint-warning-pressed, #ede5c4)';
83
+ export var shapeFaintWarning = 'var(--k-color-shape-faint-warning, #fff2c1)';
84
+ export var shapeFaintWarningHover = 'var(--k-color-shape-faint-warning-hover, #f5e4ac)';
85
+ export var shapeFaintWarningPressed = 'var(--k-color-shape-faint-warning-pressed, #eee5c4)';
86
86
  export var shapeHeavyError = 'var(--k-color-shape-heavy-error, #6b1f1e)';
87
87
  export var shapeHeavyNeutral = 'var(--k-color-shape-heavy-neutral, #292929)';
88
88
  export var shapeHeavySuccess = 'var(--k-color-shape-heavy-success, #0b4a1f)';
89
- export var shapeHeavyWarning = 'var(--k-color-shape-heavy-warning, #543600)';
89
+ export var shapeHeavyWarning = 'var(--k-color-shape-heavy-warning, #563500)';
90
90
  export var shapeOtherAccentBoldDisabled = 'var(--k-color-shape-other-accent-bold-disabled, rgba(0, 0, 0, 0.32))';
91
91
  export var shapeOtherBacklessHover = 'var(--k-color-shape-other-backless-hover, rgba(0, 0, 0, 0.06))';
92
92
  export var shapeOtherBacklessPressed = 'var(--k-color-shape-other-backless-pressed, rgba(0, 0, 0, 0.16))';
@@ -124,9 +124,9 @@ export var shapePaleNeutralAlphaPressed = 'var(--k-color-shape-pale-neutral-alph
124
124
  export var shapePaleSuccess = 'var(--k-color-shape-pale-success, #c3f3ca)';
125
125
  export var shapePaleSuccessHover = 'var(--k-color-shape-pale-success-hover, #a7ebb2)';
126
126
  export var shapePaleSuccessPressed = 'var(--k-color-shape-pale-success-pressed, #bae4c0)';
127
- export var shapePaleWarning = 'var(--k-color-shape-pale-warning, #fbe48d)';
128
- export var shapePaleWarningHover = 'var(--k-color-shape-pale-warning-hover, #f2d585)';
129
- export var shapePaleWarningPressed = 'var(--k-color-shape-pale-warning-pressed, #e9d6a5)';
127
+ export var shapePaleWarning = 'var(--k-color-shape-pale-warning, #fee38d)';
128
+ export var shapePaleWarningHover = 'var(--k-color-shape-pale-warning-hover, #f4d485)';
129
+ export var shapePaleWarningPressed = 'var(--k-color-shape-pale-warning-pressed, #ead6a5)';
130
130
  export var shapeSoftAccent = 'var(--k-color-shape-soft-accent, rgba(0, 0, 0, 0.32))';
131
131
  export var shapeSoftAccentHover = 'var(--k-color-shape-soft-accent-hover, rgba(0, 0, 0, 0.4))';
132
132
  export var shapeSoftAccentPressed = 'var(--k-color-shape-soft-accent-pressed, rgba(0, 0, 0, 0.48))';
@@ -142,9 +142,9 @@ export var shapeSoftNeutralAlphaPressed = 'var(--k-color-shape-soft-neutral-alph
142
142
  export var shapeSoftSuccess = 'var(--k-color-shape-soft-success, #6cd984)';
143
143
  export var shapeSoftSuccessHover = 'var(--k-color-shape-soft-success-hover, #4ecf70)';
144
144
  export var shapeSoftSuccessPressed = 'var(--k-color-shape-soft-success-pressed, #58be6f)';
145
- export var shapeSoftWarning = 'var(--k-color-shape-soft-warning, #fcd35d)';
146
- export var shapeSoftWarningHover = 'var(--k-color-shape-soft-warning-hover, #f4c359)';
147
- export var shapeSoftWarningPressed = 'var(--k-color-shape-soft-warning-pressed, #e5b566)';
145
+ export var shapeSoftWarning = 'var(--k-color-shape-soft-warning, #fed25d)';
146
+ export var shapeSoftWarningHover = 'var(--k-color-shape-soft-warning-hover, #f6c15a)';
147
+ export var shapeSoftWarningPressed = 'var(--k-color-shape-soft-warning-pressed, #e7b467)';
148
148
  export var shapeInvertedBacklessHover = 'var(--k-color-shape-inverted-backless-hover, rgba(255, 255, 255, 0.06))';
149
149
  export var shapeInvertedBacklessPressed = 'var(--k-color-shape-inverted-backless-pressed, rgba(255, 255, 255, 0.04))';
150
150
  export var shapeInvertedDisabled = 'var(--k-color-shape-inverted-disabled, rgba(255, 255, 255, 0.06))';
@@ -215,9 +215,9 @@ export var lineOnBrandOriginalPale = 'var(--k-color-line-on-brand-original-pale,
215
215
  export var lineSuccessBold = 'var(--k-color-line-success-bold, #008d3a)';
216
216
  export var lineSuccessBoldHover = 'var(--k-color-line-success-bold-hover, #00b74e)';
217
217
  export var lineSuccessBoldPressed = 'var(--k-color-line-success-bold-pressed, #458552)';
218
- export var lineWarningBold = 'var(--k-color-line-warning-bold, #f8ae00)';
219
- export var lineWarningBoldHover = 'var(--k-color-line-warning-bold-hover, #db9400)';
220
- export var lineWarningBoldPressed = 'var(--k-color-line-warning-bold-pressed, #bd8f4d)';
218
+ export var lineWarningBold = 'var(--k-color-line-warning-bold, #faac00)';
219
+ export var lineWarningBoldHover = 'var(--k-color-line-warning-bold-hover, #e28f05)';
220
+ export var lineWarningBoldPressed = 'var(--k-color-line-warning-bold-pressed, #c6894d)';
221
221
  export var lineInvertedAccentBold = 'var(--k-color-line-inverted-accent-bold, #d7d7d7)';
222
222
  export var lineInvertedAccentBoldHover = 'var(--k-color-line-inverted-accent-bold-hover, #ffffff)';
223
223
  export var lineInvertedAccentBoldPressed = 'var(--k-color-line-inverted-accent-bold-pressed, rgba(255, 255, 255, 0.64))';
@@ -237,9 +237,9 @@ export var lineInvertedNeutralPalePressed = 'var(--k-color-line-inverted-neutral
237
237
  export var lineInvertedSuccessBold = 'var(--k-color-line-inverted-success-bold, #009b41)';
238
238
  export var lineInvertedSuccessBoldHover = 'var(--k-color-line-inverted-success-bold-hover, #00b74e)';
239
239
  export var lineInvertedSuccessBoldPressed = 'var(--k-color-line-inverted-success-bold-pressed, #458552)';
240
- export var lineInvertedWarningBold = 'var(--k-color-line-inverted-warning-bold, #f8ae00)';
241
- export var lineInvertedWarningBoldHover = 'var(--k-color-line-inverted-warning-bold-hover, #ffbf0b)';
242
- export var lineInvertedWarningBoldPressed = 'var(--k-color-line-inverted-warning-bold-pressed, #cc9a51)';
240
+ export var lineInvertedWarningBold = 'var(--k-color-line-inverted-warning-bold, #faac00)';
241
+ export var lineInvertedWarningBoldHover = 'var(--k-color-line-inverted-warning-bold-hover, #ffbe26)';
242
+ export var lineInvertedWarningBoldPressed = 'var(--k-color-line-inverted-warning-bold-pressed, #d29750)';
243
243
  export var lineConstFaintBlack = 'var(--k-color-line-const-faint-black, rgba(0, 0, 0, 0.12))';
244
244
  export var lineConstFaintWhite = 'var(--k-color-line-const-faint-white, rgba(255, 255, 255, 0.12))';
245
245
  export var lineConstPaleBlack = 'var(--k-color-line-const-pale-black, rgba(0, 0, 0, 0.24))';
@@ -268,52 +268,52 @@ export var customizableBoldBlueDeep = 'var(--k-color-customizable-bold-blue-deep
268
268
  export var customizableBoldGray = 'var(--k-color-customizable-bold-gray, #a4a4a4)';
269
269
  export var customizableBoldGreen = 'var(--k-color-customizable-bold-green, #00b74e)';
270
270
  export var customizableBoldMint = 'var(--k-color-customizable-bold-mint, #05bfa3)';
271
- export var customizableBoldOrange = 'var(--k-color-customizable-bold-orange, #f56600)';
271
+ export var customizableBoldOrange = 'var(--k-color-customizable-bold-orange, #f96100)';
272
272
  export var customizableBoldPurple = 'var(--k-color-customizable-bold-purple, #cf60ec)';
273
273
  export var customizableBoldRed = 'var(--k-color-customizable-bold-red, #ff5352)';
274
274
  export var customizableBoldViolet = 'var(--k-color-customizable-bold-violet, #a17bff)';
275
- export var customizableBoldYellow = 'var(--k-color-customizable-bold-yellow, #ecb400)';
275
+ export var customizableBoldYellow = 'var(--k-color-customizable-bold-yellow, #faac00)';
276
276
  export var customizableFaintBlack = 'var(--k-color-customizable-faint-black, #e4e4e4)';
277
277
  export var customizableFaintBlue = 'var(--k-color-customizable-faint-blue, #e2f5ff)';
278
278
  export var customizableFaintBlueDeep = 'var(--k-color-customizable-faint-blue-deep, #e8f3ff)';
279
279
  export var customizableFaintGray = 'var(--k-color-customizable-faint-gray, #f2f2f2)';
280
280
  export var customizableFaintGreen = 'var(--k-color-customizable-faint-green, #defbe2)';
281
281
  export var customizableFaintMint = 'var(--k-color-customizable-faint-mint, #d2fcf6)';
282
- export var customizableFaintOrange = 'var(--k-color-customizable-faint-orange, #ffeee1)';
282
+ export var customizableFaintOrange = 'var(--k-color-customizable-faint-orange, #ffeee2)';
283
283
  export var customizableFaintPurple = 'var(--k-color-customizable-faint-purple, #ffeaff)';
284
284
  export var customizableFaintRed = 'var(--k-color-customizable-faint-red, #ffedef)';
285
285
  export var customizableFaintViolet = 'var(--k-color-customizable-faint-violet, #f1f0ff)';
286
- export var customizableFaintYellow = 'var(--k-color-customizable-faint-yellow, #faf5be)';
286
+ export var customizableFaintYellow = 'var(--k-color-customizable-faint-yellow, #fff2c1)';
287
287
  export var customizableHeavyBlack = 'var(--k-color-customizable-heavy-black, #3d3d3d)';
288
288
  export var customizableHeavyBlue = 'var(--k-color-customizable-heavy-blue, #005dae)';
289
289
  export var customizableHeavyBlueDeep = 'var(--k-color-customizable-heavy-blue-deep, #234ece)';
290
290
  export var customizableHeavyGray = 'var(--k-color-customizable-heavy-gray, #747474)';
291
291
  export var customizableHeavyGreen = 'var(--k-color-customizable-heavy-green, #00722d)';
292
292
  export var customizableHeavyMint = 'var(--k-color-customizable-heavy-mint, #027b68)';
293
- export var customizableHeavyOrange = 'var(--k-color-customizable-heavy-orange, #9a3d00)';
293
+ export var customizableHeavyOrange = 'var(--k-color-customizable-heavy-orange, #9c3a00)';
294
294
  export var customizableHeavyPurple = 'var(--k-color-customizable-heavy-purple, #8b22a4)';
295
295
  export var customizableHeavyRed = 'var(--k-color-customizable-heavy-red, #c50220)';
296
296
  export var customizableHeavyViolet = 'var(--k-color-customizable-heavy-violet, #6936c2)';
297
- export var customizableHeavyYellow = 'var(--k-color-customizable-heavy-yellow, #966c01)';
297
+ export var customizableHeavyYellow = 'var(--k-color-customizable-heavy-yellow, #9f6700)';
298
298
  export var customizablePaleBlack = 'var(--k-color-customizable-pale-black, #d7d7d7)';
299
299
  export var customizablePaleBlue = 'var(--k-color-customizable-pale-blue, #c7ebff)';
300
300
  export var customizablePaleBlueDeep = 'var(--k-color-customizable-pale-blue-deep, #d2e7ff)';
301
301
  export var customizablePaleGray = 'var(--k-color-customizable-pale-gray, #e4e4e4)';
302
302
  export var customizablePaleGreen = 'var(--k-color-customizable-pale-green, #c3f3ca)';
303
303
  export var customizablePaleMint = 'var(--k-color-customizable-pale-mint, #adf5e9)';
304
- export var customizablePaleOrange = 'var(--k-color-customizable-pale-orange, #ffddc6)';
304
+ export var customizablePaleOrange = 'var(--k-color-customizable-pale-orange, #ffddc7)';
305
305
  export var customizablePalePurple = 'var(--k-color-customizable-pale-purple, #fbd6ff)';
306
306
  export var customizablePaleRed = 'var(--k-color-customizable-pale-red, #ffdadd)';
307
307
  export var customizablePaleViolet = 'var(--k-color-customizable-pale-violet, #e4e0ff)';
308
- export var customizablePaleYellow = 'var(--k-color-customizable-pale-yellow, #f5e78f)';
308
+ export var customizablePaleYellow = 'var(--k-color-customizable-pale-yellow, #fee38d)';
309
309
  export var customizableSoftBlack = 'var(--k-color-customizable-soft-black, #b1b1b1)';
310
310
  export var customizableSoftBlue = 'var(--k-color-customizable-soft-blue, #80c5ff)';
311
311
  export var customizableSoftBlueDeep = 'var(--k-color-customizable-soft-blue-deep, #99bfff)';
312
312
  export var customizableSoftGray = 'var(--k-color-customizable-soft-gray, #d7d7d7)';
313
313
  export var customizableSoftGreen = 'var(--k-color-customizable-soft-green, #6cd984)';
314
314
  export var customizableSoftMint = 'var(--k-color-customizable-soft-mint, #4fe6cc)';
315
- export var customizableSoftOrange = 'var(--k-color-customizable-soft-orange, #ffa56f)';
315
+ export var customizableSoftOrange = 'var(--k-color-customizable-soft-orange, #ffa573)';
316
316
  export var customizableSoftPurple = 'var(--k-color-customizable-soft-purple, #ea9aff)';
317
317
  export var customizableSoftRed = 'var(--k-color-customizable-soft-red, #ffa09b)';
318
318
  export var customizableSoftViolet = 'var(--k-color-customizable-soft-violet, #c1b0ff)';
319
- export var customizableSoftYellow = 'var(--k-color-customizable-soft-yellow, #f6d65e)';
319
+ export var customizableSoftYellow = 'var(--k-color-customizable-soft-yellow, #fed25d)';
@@ -9,7 +9,7 @@ export var brand = {
9
9
  purple: '#B750D1',
10
10
  };
11
11
  export var system = {
12
- warning: '#FDAA00',
12
+ warning: '#FAB800',
13
13
  error: '#E62B34',
14
14
  success: '#009A40',
15
15
  };
@@ -22,7 +22,7 @@ export var customizable = {
22
22
  blueDeep: '#366AF3',
23
23
  violet: '#844BEC',
24
24
  purple: '#B750D1',
25
- yellow: '#FAB700',
25
+ yellow: '#FAB800',
26
26
  };
27
27
  export var gray = {
28
28
  0: 'oklch(0% 0 0)',
@@ -10,7 +10,7 @@ export const brand = {
10
10
  };
11
11
 
12
12
  export const system = {
13
- warning: '#FDAA00',
13
+ warning: '#FAB800',
14
14
  error: '#E62B34',
15
15
  success: '#009A40',
16
16
  };
@@ -24,7 +24,7 @@ export const customizable = {
24
24
  blueDeep: '#366AF3',
25
25
  violet: '#844BEC',
26
26
  purple: '#B750D1',
27
- yellow: '#FAB700',
27
+ yellow: '#FAB800',
28
28
  };
29
29
 
30
30
  export const gray = {
@@ -1,9 +1,10 @@
1
- import { calcOnBrand, getPalette } from './helpers/get-palette.js';
1
+ import { getPalette } from './helpers/get-palette.js';
2
2
  import { getHover, getPressed } from './helpers/get-interactions.js';
3
3
  import { getLogo } from './helpers/get-logo.js';
4
4
  import { getPromo } from './helpers/get-promo.js';
5
5
  import { convertColorFormat } from './utils/convert-color.js';
6
6
  import * as DEFAULT_SWATCH from './consts/default-swatch.js';
7
+ import { getOnBrand } from './helpers/get-on-brand.js';
7
8
  export function getColorsBase(_a) {
8
9
  var brand = _a.brand, accent = _a.accent, _b = _a.system, system = _b === void 0 ? DEFAULT_SWATCH.system : _b, _c = _a.format, format = _c === void 0 ? 'hex/rgba' : _c;
9
10
  var isPresetColor = brand in DEFAULT_SWATCH.brand;
@@ -64,14 +65,14 @@ export function getColorsBase(_a) {
64
65
  palette: accentPalette,
65
66
  }
66
67
  : undefined,
67
- warning: getPalette({ color: system.warning }),
68
+ warning: getPalette({ color: system.warning, type: 'warning' }),
68
69
  error: getPalette({ color: system.error }),
69
70
  success: getPalette({ color: system.success }),
70
71
  gray: DEFAULT_SWATCH.gray,
71
72
  whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
72
73
  blackAlpha: DEFAULT_SWATCH.blackAlpha,
73
- onBrand: calcOnBrand(brandColor),
74
- onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
74
+ onBrand: getOnBrand(brandColor),
75
+ onAccent: accentColor ? getOnBrand(accentColor) : undefined,
75
76
  customizable: customizablePalettes,
76
77
  };
77
78
  return convertColorFormat(result, format);
@@ -1,4 +1,4 @@
1
- import { calcOnBrand, getPalette } from './helpers/get-palette.js';
1
+ import { getPalette } from './helpers/get-palette.js';
2
2
  import { getHover, getPressed } from './helpers/get-interactions.js';
3
3
  import { getLogo } from './helpers/get-logo.js';
4
4
  import { getPromo } from './helpers/get-promo.js';
@@ -6,6 +6,7 @@ import { type ColorFormat, convertColorFormat } from './utils/convert-color.js';
6
6
  import { type ColorStructure } from './types/tokens.js';
7
7
  import * as DEFAULT_SWATCH from './consts/default-swatch.js';
8
8
  import type { TokensBase, ColorPalette } from './types/tokens-base.js';
9
+ import { getOnBrand } from './helpers/get-on-brand.js';
9
10
 
10
11
  export type PresetOrCustom<T extends string> = T | (string & Record<never, never>);
11
12
 
@@ -84,14 +85,14 @@ export function getColorsBase({
84
85
  palette: accentPalette,
85
86
  }
86
87
  : undefined,
87
- warning: getPalette({ color: system.warning }) as ColorPalette,
88
+ warning: getPalette({ color: system.warning, type: 'warning' }) as ColorPalette,
88
89
  error: getPalette({ color: system.error }) as ColorPalette,
89
90
  success: getPalette({ color: system.success }) as ColorPalette,
90
91
  gray: DEFAULT_SWATCH.gray,
91
92
  whiteAlpha: DEFAULT_SWATCH.whiteAlpha,
92
93
  blackAlpha: DEFAULT_SWATCH.blackAlpha,
93
- onBrand: calcOnBrand(brandColor),
94
- onAccent: accentColor ? calcOnBrand(accentColor) : undefined,
94
+ onBrand: getOnBrand(brandColor),
95
+ onAccent: accentColor ? getOnBrand(accentColor) : undefined,
95
96
  customizable: customizablePalettes,
96
97
  } as unknown as ColorStructure;
97
98
 
@@ -0,0 +1,28 @@
1
+ export declare function getOnBrand(hex: string): {
2
+ 4: string;
3
+ 6: string;
4
+ 8: string;
5
+ 12: string;
6
+ 16: string;
7
+ 20: string;
8
+ 24: string;
9
+ 28: string;
10
+ 32: string;
11
+ 36: string;
12
+ 40: string;
13
+ 44: string;
14
+ 48: string;
15
+ 52: string;
16
+ 56: string;
17
+ 60: string;
18
+ 64: string;
19
+ 68: string;
20
+ 72: string;
21
+ 76: string;
22
+ 80: string;
23
+ 84: string;
24
+ 88: string;
25
+ 92: string;
26
+ 96: string;
27
+ 100: string;
28
+ };
@@ -0,0 +1,10 @@
1
+ import { calcAPCA } from 'apca-w3';
2
+ import * as DefaultSwatch from '../../lib/consts/default-swatch.js';
3
+ export function getOnBrand(hex) {
4
+ var whiteContrast = Math.abs(Number(calcAPCA('#fff', hex)));
5
+ var blackContrast = Math.abs(Number(calcAPCA('#000', hex)));
6
+ if (whiteContrast + 10 >= blackContrast) {
7
+ return DefaultSwatch.whiteAlpha;
8
+ }
9
+ return DefaultSwatch.blackAlpha;
10
+ }
@@ -0,0 +1,13 @@
1
+ import { calcAPCA } from 'apca-w3';
2
+
3
+ import * as DefaultSwatch from '../../lib/consts/default-swatch.js';
4
+
5
+ export function getOnBrand(hex: string) {
6
+ const whiteContrast = Math.abs(Number(calcAPCA('#fff', hex)));
7
+ const blackContrast = Math.abs(Number(calcAPCA('#000', hex)));
8
+
9
+ if (whiteContrast + 10 >= blackContrast) {
10
+ return DefaultSwatch.whiteAlpha;
11
+ }
12
+ return DefaultSwatch.blackAlpha;
13
+ }
@@ -12,40 +12,7 @@ interface GeneratePaletteParams {
12
12
  };
13
13
  }
14
14
  export declare function getPalette({ color, type, settings: customSettings, }: GeneratePaletteParams): GeneratorColorPalette;
15
- export declare function getAbneyHueShift(lightness: number, currentHue: number, abneyData: GeneratorColorAbneyCorrection): number;
16
- export declare function applyAbneyShift(lightness: number, currentHue: number, abneyData: GeneratorColorAbneyCorrection): number;
17
- export declare function applyWarningHuePatch(currentHue: number, lightness: number, warningHuePatchData: GeneratorColorWarningHuePatch, isWarningMode: boolean): number;
18
- export declare function calculateBaseHueAndCorrectionRange(inputColorString: string, abneyData: GeneratorColorAbneyCorrection): {
19
- baseHue: number;
20
- correctionLightness: number;
21
- correctionHueRange: number;
22
- } | null;
23
- export declare function calcOnBrand(hex: string): {
24
- 4: string;
25
- 6: string;
26
- 8: string;
27
- 12: string;
28
- 16: string;
29
- 20: string;
30
- 24: string;
31
- 28: string;
32
- 32: string;
33
- 36: string;
34
- 40: string;
35
- 44: string;
36
- 48: string;
37
- 52: string;
38
- 56: string;
39
- 60: string;
40
- 64: string;
41
- 68: string;
42
- 72: string;
43
- 76: string;
44
- 80: string;
45
- 84: string;
46
- 88: string;
47
- 92: string;
48
- 96: string;
49
- 100: string;
50
- };
15
+ export declare function calcWarningHuePatch(currentHue: number, lightness: number, warningHuePatchData: GeneratorColorWarningHuePatch): number;
16
+ export declare function calcBaseHue(inputColorString: string, abneyData: GeneratorColorAbneyCorrection): number;
17
+ export declare function calcCorrectionRange(inputColorString: string, abneyData: GeneratorColorAbneyCorrection): number;
51
18
  export {};
@@ -19,14 +19,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
21
  import { clampChroma, converter } from 'culori';
22
- import { calcAPCA } from 'apca-w3';
23
- import * as DefaultSwatch from '../consts/default-swatch.js';
24
22
  import { CHROMA_PARAMS } from '../consts/params/chroma-params.js';
25
23
  import { ABNEY_CORRECTION } from '../consts/params/abney-correction.js';
26
24
  import { PROMO_HUE_SHIFTS } from '../consts/params/promo-hue-shift.js';
27
25
  import { WARNING_HUE_PATCH } from '../consts/params/warning-hue-patch.js';
26
+ var toOklch = converter('oklch');
28
27
  export function getPalette(_a) {
29
- var color = _a.color, _b = _a.type, type = _b === void 0 ? 'default' : _b, customSettings = _a.settings;
28
+ var _b;
29
+ var color = _a.color, _c = _a.type, type = _c === void 0 ? 'default' : _c, customSettings = _a.settings;
30
30
  var defaultSettings = {
31
31
  chromaSettings: CHROMA_PARAMS,
32
32
  abneyCorrection: ABNEY_CORRECTION,
@@ -34,9 +34,6 @@ export function getPalette(_a) {
34
34
  warningHuePatch: WARNING_HUE_PATCH,
35
35
  };
36
36
  var settings = __assign(__assign({}, defaultSettings), customSettings);
37
- var toOklch = converter('oklch');
38
- var oklchColor = toOklch(color);
39
- var currentHue = (oklchColor === null || oklchColor === void 0 ? void 0 : oklchColor.h) || 0;
40
37
  var toNorm = function (x) { return x / 100; };
41
38
  var calculateChromaValue = function (rel, min, max, baseChromaMax) {
42
39
  var raw = (baseChromaMax * rel) / 100;
@@ -55,6 +52,8 @@ export function getPalette(_a) {
55
52
  dim: {},
56
53
  };
57
54
  var isWarning = type === 'warning';
55
+ var baseHue = calcBaseHue(color, settings.abneyCorrection);
56
+ var correctionHueRange = calcCorrectionRange(color, settings.abneyCorrection);
58
57
  for (var Lstr in settings.chromaSettings) {
59
58
  var L = +Lstr;
60
59
  if (L === 100) {
@@ -63,52 +62,30 @@ export function getPalette(_a) {
63
62
  result.dim[L] = "oklch(100% 0 0)";
64
63
  continue;
65
64
  }
66
- var hueAfterWarningPatch = applyWarningHuePatch(currentHue, L, settings.warningHuePatch, isWarning);
67
- var appliedHueShift = applyAbneyShift(L, hueAfterWarningPatch, settings.abneyCorrection);
68
- var chromaMax = clampChroma({ mode: 'oklch', l: L / 100, c: 1, h: appliedHueShift }, 'oklch').c;
65
+ var hue = baseHue;
66
+ var lightnessCorrectionData = settings.abneyCorrection[L];
67
+ if (lightnessCorrectionData && correctionHueRange !== undefined) {
68
+ var shift = (_b = lightnessCorrectionData[correctionHueRange]) !== null && _b !== void 0 ? _b : 0;
69
+ hue = (baseHue + shift + 360) % 360;
70
+ }
71
+ if (isWarning) {
72
+ hue = calcWarningHuePatch(hue, L, settings.warningHuePatch);
73
+ }
74
+ var chromaMax = clampChroma({ mode: 'oklch', l: L / 100, c: 1, h: hue }, 'oklch').c;
69
75
  var currentParams = settings.chromaSettings[L];
70
76
  var vividN = calculateChromaValue(currentParams.vivid.rel, currentParams.vivid.min, currentParams.vivid.max, chromaMax);
71
77
  var normN = calculateChromaValue(currentParams.normal.rel, currentParams.normal.min, currentParams.normal.max, chromaMax);
72
78
  var dimN = calculateChromaValue(currentParams.dim.rel, currentParams.dim.min, currentParams.dim.max, chromaMax);
73
- result.vivid[L] = "oklch(".concat(L, "% ").concat(vividN.toFixed(3), " ").concat(appliedHueShift.toFixed(0), ")");
74
- result.normal[L] = "oklch(".concat(L, "% ").concat(normN.toFixed(3), " ").concat(appliedHueShift.toFixed(0), ")");
75
- result.dim[L] = "oklch(".concat(L, "% ").concat(dimN.toFixed(3), " ").concat(appliedHueShift.toFixed(0), ")");
79
+ result.vivid[L] = "oklch(".concat(L, "% ").concat(vividN.toFixed(3), " ").concat(hue.toFixed(0), ")");
80
+ result.normal[L] = "oklch(".concat(L, "% ").concat(normN.toFixed(3), " ").concat(hue.toFixed(0), ")");
81
+ result.dim[L] = "oklch(".concat(L, "% ").concat(dimN.toFixed(3), " ").concat(hue.toFixed(0), ")");
76
82
  }
77
83
  return result;
78
84
  }
79
- export function getAbneyHueShift(lightness, currentHue, abneyData) {
80
- var lightnessData = abneyData[lightness];
81
- if (!lightnessData) {
82
- return 0;
83
- }
84
- var hueRanges = Object.keys(lightnessData)
85
- .map(Number)
86
- .sort(function (a, b) { return a - b; });
87
- var selectedHueRange = hueRanges[0];
88
- for (var i = 0; i < hueRanges.length; i++) {
89
- var startRange = hueRanges[i];
90
- var endRange = hueRanges[i + 1] !== undefined ? hueRanges[i + 1] : 360;
91
- if (currentHue >= startRange && currentHue < endRange) {
92
- selectedHueRange = startRange;
93
- break;
94
- }
95
- if (i === hueRanges.length - 1 && currentHue >= startRange && currentHue < 360) {
96
- selectedHueRange = startRange;
97
- break;
98
- }
99
- }
100
- return lightnessData[selectedHueRange] !== undefined ? lightnessData[selectedHueRange] : 0;
101
- }
102
- export function applyAbneyShift(lightness, currentHue, abneyData) {
103
- var abneyShift = getAbneyHueShift(lightness, currentHue, abneyData);
104
- return (currentHue + abneyShift + 360) % 360;
105
- }
106
- export function applyWarningHuePatch(currentHue, lightness, warningHuePatchData, isWarningMode) {
107
- if (isWarningMode) {
108
- var patch = warningHuePatchData[lightness];
109
- if (patch !== undefined) {
110
- return (currentHue + patch + 360) % 360;
111
- }
85
+ export function calcWarningHuePatch(currentHue, lightness, warningHuePatchData) {
86
+ var patch = warningHuePatchData[lightness];
87
+ if (patch !== undefined) {
88
+ return (currentHue + patch + 360) % 360;
112
89
  }
113
90
  return currentHue;
114
91
  }
@@ -129,30 +106,13 @@ function findClosestLightnessStep(targetL, availableLightnessSteps) {
129
106
  }
130
107
  return closestStep;
131
108
  }
132
- export function calculateBaseHueAndCorrectionRange(inputColorString, abneyData) {
133
- var toOklch = converter('oklch');
134
- var oklch = toOklch(inputColorString);
135
- if (!oklch) {
136
- console.warn("Could not parse color string: ".concat(inputColorString));
137
- return null;
138
- }
139
- var targetLightness = Math.round(oklch.l * 100);
140
- var targetHue = oklch.h;
141
- if (isNaN(targetHue)) {
142
- console.warn("Achromatic color detected (".concat(inputColorString, "). Defaulting hue to 0."));
143
- targetHue = 0;
144
- }
109
+ export function calcBaseHue(inputColorString, abneyData) {
110
+ var colorOKLCH = toOklch(inputColorString);
111
+ var targetLightness = colorOKLCH.l * 100;
112
+ var targetHue = colorOKLCH.h;
145
113
  var availableLightnessSteps = Object.keys(abneyData).map(Number);
146
- if (availableLightnessSteps.length === 0) {
147
- console.warn('Abney correction data is empty, cannot calculate base hue.');
148
- return null;
149
- }
150
114
  var closestLightness = findClosestLightnessStep(targetLightness, availableLightnessSteps);
151
115
  var lightnessCorrectionData = abneyData[closestLightness];
152
- if (!lightnessCorrectionData) {
153
- console.warn("No Abney correction data for lightness ".concat(closestLightness, "."));
154
- return null;
155
- }
156
116
  var correctedHueMap = Object.entries(lightnessCorrectionData).map(function (_a) {
157
117
  var rawHueStr = _a[0], shift = _a[1];
158
118
  var rawHue = Number(rawHueStr);
@@ -162,43 +122,50 @@ export function calculateBaseHueAndCorrectionRange(inputColorString, abneyData)
162
122
  correctedHue: (rawHue + shift + 360) % 360,
163
123
  };
164
124
  });
165
- correctedHueMap.sort(function (a, b) {
166
- if (a.correctedHue !== b.correctedHue) {
167
- return a.correctedHue - b.correctedHue;
168
- }
169
- return a.rawHue - b.rawHue;
170
- });
125
+ correctedHueMap.sort(function (a, b) { return a.correctedHue - b.correctedHue; });
171
126
  if (correctedHueMap.length === 0) {
172
- console.warn("No hue ranges defined for lightness ".concat(closestLightness, "."));
173
- return null;
127
+ return targetHue;
174
128
  }
175
- var findCorrectRange = function () {
176
- var nextRangeIndex = correctedHueMap.findIndex(function (range) { return range.correctedHue > targetHue; });
177
- if (nextRangeIndex === 0) {
178
- return correctedHueMap[correctedHueMap.length - 1];
129
+ var selectedRange = correctedHueMap[correctedHueMap.length - 1];
130
+ for (var i = 0; i < correctedHueMap.length; i++) {
131
+ var current = correctedHueMap[i];
132
+ var next = correctedHueMap[i + 1];
133
+ if (!next) {
134
+ selectedRange = current;
135
+ break;
179
136
  }
180
- if (nextRangeIndex > 0) {
181
- return correctedHueMap[nextRangeIndex - 1];
137
+ if (targetHue >= current.correctedHue && targetHue < next.correctedHue) {
138
+ selectedRange = current;
139
+ break;
182
140
  }
183
- return correctedHueMap[correctedHueMap.length - 1];
184
- };
185
- var selectedRange = findCorrectRange();
186
- if (!selectedRange) {
187
- console.error('Could not determine the correct hue range.');
188
- return null;
189
141
  }
190
- var baseHue = (targetHue - selectedRange.shift + 360) % 360;
191
- return {
192
- baseHue: baseHue,
193
- correctionLightness: closestLightness,
194
- correctionHueRange: selectedRange.rawHue,
195
- };
142
+ return (targetHue - selectedRange.shift + 360) % 360;
196
143
  }
197
- export function calcOnBrand(hex) {
198
- var whiteContrast = Math.abs(Number(calcAPCA('#fff', hex)));
199
- var blackContrast = Math.abs(Number(calcAPCA('#000', hex)));
200
- if (whiteContrast + 10 >= blackContrast) {
201
- return DefaultSwatch.whiteAlpha;
144
+ export function calcCorrectionRange(inputColorString, abneyData) {
145
+ var colorOKLCH = toOklch(inputColorString);
146
+ var targetLightness = colorOKLCH.l * 100;
147
+ var targetHue = colorOKLCH.h;
148
+ var availableLightnessSteps = Object.keys(abneyData).map(Number);
149
+ var closestLightness = findClosestLightnessStep(targetLightness, availableLightnessSteps);
150
+ var lightnessCorrectionData = abneyData[closestLightness];
151
+ var correctedHueMap = Object.entries(lightnessCorrectionData).map(function (_a) {
152
+ var rawHueStr = _a[0], shift = _a[1];
153
+ var rawHue = Number(rawHueStr);
154
+ return {
155
+ rawHue: rawHue,
156
+ shift: shift,
157
+ correctedHue: (rawHue + shift + 360) % 360,
158
+ };
159
+ });
160
+ correctedHueMap.sort(function (a, b) { return a.correctedHue - b.correctedHue; });
161
+ var selectedRange = correctedHueMap[correctedHueMap.length - 1];
162
+ for (var i = 0; i < correctedHueMap.length; i++) {
163
+ var current = correctedHueMap[i];
164
+ var next = correctedHueMap[i + 1];
165
+ if (targetHue >= current.correctedHue && targetHue < next.correctedHue) {
166
+ selectedRange = current;
167
+ break;
168
+ }
202
169
  }
203
- return DefaultSwatch.blackAlpha;
170
+ return selectedRange.rawHue;
204
171
  }