@wordpress/theme 0.2.0 → 0.2.1-next.dc3f6d3c1.0

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 (76) hide show
  1. package/README.md +5 -1
  2. package/bin/generate-primitive-tokens/index.ts +1 -1
  3. package/build/color-ramps/index.js +17 -13
  4. package/build/color-ramps/index.js.map +2 -2
  5. package/build/color-ramps/lib/color-utils.js +5 -0
  6. package/build/color-ramps/lib/color-utils.js.map +2 -2
  7. package/build/color-ramps/lib/constants.js +1 -1
  8. package/build/color-ramps/lib/constants.js.map +1 -1
  9. package/build/color-ramps/lib/default-ramps.js +154 -154
  10. package/build/color-ramps/lib/default-ramps.js.map +2 -2
  11. package/build/color-ramps/lib/find-color-with-constraints.js +1 -1
  12. package/build/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  13. package/build/color-ramps/lib/index.js +18 -11
  14. package/build/color-ramps/lib/index.js.map +2 -2
  15. package/build/color-ramps/lib/ramp-configs.js +2 -2
  16. package/build/color-ramps/lib/ramp-configs.js.map +1 -1
  17. package/build/color-ramps/lib/types.js.map +1 -1
  18. package/build/color-ramps/lib/utils.js +4 -8
  19. package/build/color-ramps/lib/utils.js.map +2 -2
  20. package/build/prebuilt/json/figma.json +51 -51
  21. package/build/use-theme-provider-styles.js +1 -4
  22. package/build/use-theme-provider-styles.js.map +2 -2
  23. package/build-module/color-ramps/index.js +18 -14
  24. package/build-module/color-ramps/index.js.map +2 -2
  25. package/build-module/color-ramps/lib/color-utils.js +7 -1
  26. package/build-module/color-ramps/lib/color-utils.js.map +2 -2
  27. package/build-module/color-ramps/lib/constants.js +1 -1
  28. package/build-module/color-ramps/lib/constants.js.map +1 -1
  29. package/build-module/color-ramps/lib/default-ramps.js +154 -154
  30. package/build-module/color-ramps/lib/default-ramps.js.map +2 -2
  31. package/build-module/color-ramps/lib/find-color-with-constraints.js +2 -2
  32. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  33. package/build-module/color-ramps/lib/index.js +17 -11
  34. package/build-module/color-ramps/lib/index.js.map +2 -2
  35. package/build-module/color-ramps/lib/ramp-configs.js +2 -2
  36. package/build-module/color-ramps/lib/ramp-configs.js.map +1 -1
  37. package/build-module/color-ramps/lib/utils.js +0 -3
  38. package/build-module/color-ramps/lib/utils.js.map +2 -2
  39. package/build-module/prebuilt/json/figma.json +51 -51
  40. package/build-module/use-theme-provider-styles.js +1 -4
  41. package/build-module/use-theme-provider-styles.js.map +2 -2
  42. package/build-types/color-ramps/index.d.ts +1 -0
  43. package/build-types/color-ramps/index.d.ts.map +1 -1
  44. package/build-types/color-ramps/lib/color-utils.d.ts +5 -0
  45. package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -1
  46. package/build-types/color-ramps/lib/constants.d.ts +1 -1
  47. package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
  48. package/build-types/color-ramps/lib/index.d.ts.map +1 -1
  49. package/build-types/color-ramps/lib/types.d.ts +2 -4
  50. package/build-types/color-ramps/lib/types.d.ts.map +1 -1
  51. package/build-types/color-ramps/lib/utils.d.ts +0 -5
  52. package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
  53. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
  54. package/build-types/color-ramps/stories/ramp-table.d.ts +2 -4
  55. package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -1
  56. package/build-types/use-theme-provider-styles.d.ts.map +1 -1
  57. package/package.json +4 -4
  58. package/src/color-ramps/index.ts +17 -12
  59. package/src/color-ramps/lib/color-utils.ts +11 -0
  60. package/src/color-ramps/lib/constants.ts +3 -3
  61. package/src/color-ramps/lib/default-ramps.ts +154 -154
  62. package/src/color-ramps/lib/find-color-with-constraints.ts +2 -2
  63. package/src/color-ramps/lib/index.ts +27 -24
  64. package/src/color-ramps/lib/ramp-configs.ts +2 -2
  65. package/src/color-ramps/lib/types.ts +2 -7
  66. package/src/color-ramps/lib/utils.ts +1 -8
  67. package/src/color-ramps/stories/index.story.tsx +11 -5
  68. package/src/color-ramps/stories/ramp-table.tsx +15 -26
  69. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +11717 -41231
  70. package/src/color-ramps/test/index.test.ts +2 -2
  71. package/src/prebuilt/css/design-tokens.css +51 -51
  72. package/src/prebuilt/json/figma.json +51 -51
  73. package/src/use-theme-provider-styles.ts +1 -4
  74. package/tokens/color.json +88 -88
  75. package/tsconfig.bin.tsbuildinfo +1 -1
  76. package/tsconfig.src.tsbuildinfo +1 -1
@@ -50,13 +50,13 @@
50
50
  },
51
51
  "Color/Semantic/Background/Brand/bgSur-brand": {
52
52
  "value": {
53
- ".": "#edf0fa"
53
+ ".": "#ecf0f9"
54
54
  },
55
55
  "description": "Background color for surfaces with brand tone and normal emphasis."
56
56
  },
57
57
  "Color/Semantic/Background/Success/bgSur-success": {
58
58
  "value": {
59
- ".": "#cdf5d3"
59
+ ".": "#cbf5d1"
60
60
  },
61
61
  "description": "Background color for surfaces with success tone and normal emphasis."
62
62
  },
@@ -68,7 +68,7 @@
68
68
  },
69
69
  "Color/Semantic/Background/Info/bgSur-info": {
70
70
  "value": {
71
- ".": "#e0ebf8"
71
+ ".": "#dfebf8"
72
72
  },
73
73
  "description": "Background color for surfaces with info tone and normal emphasis."
74
74
  },
@@ -80,7 +80,7 @@
80
80
  },
81
81
  "Color/Semantic/Background/Warning/bgSur-warning": {
82
82
  "value": {
83
- ".": "#f8e9cd"
83
+ ".": "#f8e8cc"
84
84
  },
85
85
  "description": "Background color for surfaces with warning tone and normal emphasis."
86
86
  },
@@ -92,7 +92,7 @@
92
92
  },
93
93
  "Color/Semantic/Background/Caution/bgSur-caution": {
94
94
  "value": {
95
- ".": "#f8ebb5"
95
+ ".": "#f7eab3"
96
96
  },
97
97
  "description": "Background color for surfaces with caution tone and normal emphasis."
98
98
  },
@@ -104,7 +104,7 @@
104
104
  },
105
105
  "Color/Semantic/Background/Error/bgSur-error": {
106
106
  "value": {
107
- ".": "#fae5e2"
107
+ ".": "#fae4e1"
108
108
  },
109
109
  "description": "Background color for surfaces with error tone and normal emphasis."
110
110
  },
@@ -128,7 +128,7 @@
128
128
  },
129
129
  "Color/Semantic/Background/Neutral/bgInt-neutral-disabled": {
130
130
  "value": {
131
- ".": "#e3e3e3"
131
+ ".": "#e2e2e2"
132
132
  },
133
133
  "description": "Background color for interactive elements with neutral tone and normal emphasis, in their disabled state."
134
134
  },
@@ -146,7 +146,7 @@
146
146
  },
147
147
  "Color/Semantic/Background/Neutral/bgInt-neutral-strong-disabled": {
148
148
  "value": {
149
- ".": "#d3d3d3"
149
+ ".": "#d2d2d2"
150
150
  },
151
151
  "description": "Background color for interactive elements with neutral tone and strong emphasis, in their disabled state."
152
152
  },
@@ -164,7 +164,7 @@
164
164
  },
165
165
  "Color/Semantic/Background/Neutral/bgInt-neutral-weak-disabled": {
166
166
  "value": {
167
- ".": "#e3e3e3"
167
+ ".": "#e2e2e2"
168
168
  },
169
169
  "description": "Background color for interactive elements with neutral tone and weak emphasis, in their disabled state."
170
170
  },
@@ -182,7 +182,7 @@
182
182
  },
183
183
  "Color/Semantic/Background/Brand/bgInt-brand-disabled": {
184
184
  "value": {
185
- ".": "#e3e3e3"
185
+ ".": "#e2e2e2"
186
186
  },
187
187
  "description": "Background color for interactive elements with brand tone and normal emphasis, in their disabled state."
188
188
  },
@@ -194,13 +194,13 @@
194
194
  },
195
195
  "Color/Semantic/Background/Brand/bgInt-brand-strong-active": {
196
196
  "value": {
197
- ".": "#2e49da"
197
+ ".": "#2e49d9"
198
198
  },
199
199
  "description": "Background color for interactive elements with brand tone and strong emphasis that are hovered, focused, or active."
200
200
  },
201
201
  "Color/Semantic/Background/Brand/bgInt-brand-strong-disabled": {
202
202
  "value": {
203
- ".": "#d3d3d3"
203
+ ".": "#d2d2d2"
204
204
  },
205
205
  "description": "Background color for interactive elements with brand tone and strong emphasis, in their disabled state."
206
206
  },
@@ -212,37 +212,37 @@
212
212
  },
213
213
  "Color/Semantic/Background/Brand/bgInt-brand-weak-active": {
214
214
  "value": {
215
- ".": "#e5ebf7"
215
+ ".": "#e4eaf7"
216
216
  },
217
217
  "description": "Background color for interactive elements with brand tone and weak emphasis that are hovered, focused, or active."
218
218
  },
219
219
  "Color/Semantic/Background/Brand/bgInt-brand-weak-disabled": {
220
220
  "value": {
221
- ".": "#e3e3e3"
221
+ ".": "#e2e2e2"
222
222
  },
223
223
  "description": "Background color for interactive elements with brand tone and weak emphasis, in their disabled state."
224
224
  },
225
225
  "Color/Semantic/Background/Neutral/bgTra-neutral-weak": {
226
226
  "value": {
227
- ".": "#cfcfcf"
227
+ ".": "#e0e0e0"
228
228
  },
229
229
  "description": "Background color for tracks with a neutral tone and weak emphasis (eg. scrollbar track)."
230
230
  },
231
231
  "Color/Semantic/Background/Neutral/bgTra-neutral": {
232
232
  "value": {
233
- ".": "#adadad"
233
+ ".": "#d8d8d8"
234
234
  },
235
235
  "description": "Background color for tracks with a neutral tone and normal emphasis (eg. slider or progressbar track)."
236
236
  },
237
237
  "Color/Semantic/Background/Neutral/bgThu-neutral-weak": {
238
238
  "value": {
239
- ".": "#8b8b8b"
239
+ ".": "#8a8a8a"
240
240
  },
241
241
  "description": "Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb)."
242
242
  },
243
243
  "Color/Semantic/Background/Neutral/bgThu-neutral-weak-active": {
244
244
  "value": {
245
- ".": "#6d6d6d"
245
+ ".": "#6c6c6c"
246
246
  },
247
247
  "description": "Background color for thumbs with a neutral tone and weak emphasis (eg. scrollbar thumb) that are hovered, focused, or active."
248
248
  },
@@ -260,7 +260,7 @@
260
260
  },
261
261
  "Color/Semantic/Background/Brand/bgThu-brand-disabled": {
262
262
  "value": {
263
- ".": "#adadad"
263
+ ".": "#d8d8d8"
264
264
  },
265
265
  "description": "Background color for thumbs with a brand tone and normal emphasis (eg. slider thumb and filled track), in their disabled state."
266
266
  },
@@ -272,61 +272,61 @@
272
272
  },
273
273
  "Color/Semantic/Foreground/Neutral/fgCon-neutral-weak": {
274
274
  "value": {
275
- ".": "#6e6e6e"
275
+ ".": "#6d6d6d"
276
276
  },
277
277
  "description": "Foreground color for content like text with weak emphasis."
278
278
  },
279
279
  "Color/Semantic/Foreground/Success/fgCon-success": {
280
280
  "value": {
281
- ".": "#002b00"
281
+ ".": "#002900"
282
282
  },
283
283
  "description": "Foreground color for content like text with success tone and normal emphasis."
284
284
  },
285
285
  "Color/Semantic/Foreground/Success/fgCon-success-weak": {
286
286
  "value": {
287
- ".": "#008031"
287
+ ".": "#007f30"
288
288
  },
289
289
  "description": "Foreground color for content like text with success tone and weak emphasis."
290
290
  },
291
291
  "Color/Semantic/Foreground/Info/fgCon-info": {
292
292
  "value": {
293
- ".": "#001758"
293
+ ".": "#001b4f"
294
294
  },
295
295
  "description": "Foreground color for content like text with info tone and normal emphasis."
296
296
  },
297
297
  "Color/Semantic/Foreground/Info/fgCon-info-weak": {
298
298
  "value": {
299
- ".": "#006dd9"
299
+ ".": "#006bd7"
300
300
  },
301
301
  "description": "Foreground color for content like text with info tone and weak emphasis."
302
302
  },
303
303
  "Color/Semantic/Foreground/Warning/fgCon-warning": {
304
304
  "value": {
305
- ".": "#2f1800"
305
+ ".": "#2e1900"
306
306
  },
307
307
  "description": "Foreground color for content like text with warning tone and normal emphasis."
308
308
  },
309
309
  "Color/Semantic/Foreground/Warning/fgCon-warning-weak": {
310
310
  "value": {
311
- ".": "#976300"
311
+ ".": "#936400"
312
312
  },
313
313
  "description": "Foreground color for content like text with warning tone and weak emphasis."
314
314
  },
315
315
  "Color/Semantic/Foreground/Caution/fgCon-caution": {
316
316
  "value": {
317
- ".": "#291d00"
317
+ ".": "#281d00"
318
318
  },
319
319
  "description": "Foreground color for content like text with caution tone and normal emphasis."
320
320
  },
321
321
  "Color/Semantic/Foreground/Caution/fgCon-caution-weak": {
322
322
  "value": {
323
- ".": "#876b00"
323
+ ".": "#836b00"
324
324
  },
325
325
  "description": "Foreground color for content like text with caution tone and weak emphasis."
326
326
  },
327
327
  "Color/Semantic/Foreground/Error/fgCon-error": {
328
328
  "value": {
329
- ".": "#4a0000"
329
+ ".": "#470000"
330
330
  },
331
331
  "description": "Foreground color for content like text with error tone and normal emphasis."
332
332
  },
@@ -350,7 +350,7 @@
350
350
  },
351
351
  "Color/Semantic/Foreground/Neutral/fgInt-neutral-disabled": {
352
352
  "value": {
353
- ".": "#8b8b8b"
353
+ ".": "#8a8a8a"
354
354
  },
355
355
  "description": "Foreground color for interactive elements with neutral tone and normal emphasis, in their disabled state."
356
356
  },
@@ -368,19 +368,19 @@
368
368
  },
369
369
  "Color/Semantic/Foreground/Neutral/fgInt-neutral-strong-disabled": {
370
370
  "value": {
371
- ".": "#6e6e6e"
371
+ ".": "#6d6d6d"
372
372
  },
373
373
  "description": "Foreground color for interactive elements with neutral tone and strong emphasis, in their disabled state."
374
374
  },
375
375
  "Color/Semantic/Foreground/Neutral/fgInt-neutral-weak": {
376
376
  "value": {
377
- ".": "#6e6e6e"
377
+ ".": "#6d6d6d"
378
378
  },
379
379
  "description": "Foreground color for interactive elements with neutral tone and weak emphasis."
380
380
  },
381
381
  "Color/Semantic/Foreground/Neutral/fgInt-neutral-weak-disabled": {
382
382
  "value": {
383
- ".": "#8b8b8b"
383
+ ".": "#8a8a8a"
384
384
  },
385
385
  "description": "Foreground color for interactive elements with neutral tone and weak emphasis, in their disabled state."
386
386
  },
@@ -398,7 +398,7 @@
398
398
  },
399
399
  "Color/Semantic/Foreground/Brand/fgInt-brand-disabled": {
400
400
  "value": {
401
- ".": "#8b8b8b"
401
+ ".": "#8a8a8a"
402
402
  },
403
403
  "description": "Foreground color for interactive elements with brand tone and normal emphasis, in their disabled state."
404
404
  },
@@ -416,31 +416,31 @@
416
416
  },
417
417
  "Color/Semantic/Foreground/Brand/fgInt-brand-strong-disabled": {
418
418
  "value": {
419
- ".": "#6e6e6e"
419
+ ".": "#6d6d6d"
420
420
  },
421
421
  "description": "Foreground color for interactive elements with brand tone and strong emphasis, in their disabled state."
422
422
  },
423
423
  "Color/Semantic/Stroke/Neutral/strokeSur-neutral": {
424
424
  "value": {
425
- ".": "#adadad"
425
+ ".": "#d8d8d8"
426
426
  },
427
427
  "description": "Decorative stroke color used to define neutrally-toned surface boundaries with normal emphasis."
428
428
  },
429
429
  "Color/Semantic/Stroke/Neutral/strokeSur-neutral-weak": {
430
430
  "value": {
431
- ".": "#cfcfcf"
431
+ ".": "#e0e0e0"
432
432
  },
433
433
  "description": "Decorative stroke color used to define neutrally-toned surface boundaries with weak emphasis."
434
434
  },
435
435
  "Color/Semantic/Stroke/Neutral/strokeSur-neutral-strong": {
436
436
  "value": {
437
- ".": "#8b8b8b"
437
+ ".": "#8a8a8a"
438
438
  },
439
439
  "description": "Decorative stroke color used to define neutrally-toned surface boundaries with strong emphasis."
440
440
  },
441
441
  "Color/Semantic/Stroke/Brand/strokeSur-brand": {
442
442
  "value": {
443
- ".": "#91a2cf"
443
+ ".": "#a2b1d6"
444
444
  },
445
445
  "description": "Decorative stroke color used to define brand-toned surface boundaries with normal emphasis."
446
446
  },
@@ -452,43 +452,43 @@
452
452
  },
453
453
  "Color/Semantic/Stroke/Success/strokeSur-success": {
454
454
  "value": {
455
- ".": "#77ba84"
455
+ ".": "#82c98f"
456
456
  },
457
457
  "description": "Decorative stroke color used to define success-toned surface boundaries with normal emphasis."
458
458
  },
459
459
  "Color/Semantic/Stroke/Success/strokeSur-success-strong": {
460
460
  "value": {
461
- ".": "#008031"
461
+ ".": "#007f30"
462
462
  },
463
463
  "description": "Decorative stroke color used to define success-toned surface boundaries with strong emphasis."
464
464
  },
465
465
  "Color/Semantic/Stroke/Info/strokeSur-info": {
466
466
  "value": {
467
- ".": "#8aaed6"
467
+ ".": "#9fbcdd"
468
468
  },
469
469
  "description": "Decorative stroke color used to define info-toned surface boundaries with normal emphasis."
470
470
  },
471
471
  "Color/Semantic/Stroke/Info/strokeSur-info-strong": {
472
472
  "value": {
473
- ".": "#006dd9"
473
+ ".": "#006bd7"
474
474
  },
475
475
  "description": "Decorative stroke color used to define info-toned surface boundaries with strong emphasis."
476
476
  },
477
477
  "Color/Semantic/Stroke/Warning/strokeSur-warning": {
478
478
  "value": {
479
- ".": "#c2a776"
479
+ ".": "#d2b581"
480
480
  },
481
481
  "description": "Decorative stroke color used to define warning-toned surface boundaries with normal emphasis."
482
482
  },
483
483
  "Color/Semantic/Stroke/Warning/strokeSur-warning-strong": {
484
484
  "value": {
485
- ".": "#976300"
485
+ ".": "#936400"
486
486
  },
487
487
  "description": "Decorative stroke color used to define warning-toned surface boundaries with strong emphasis."
488
488
  },
489
489
  "Color/Semantic/Stroke/Error/strokeSur-error": {
490
490
  "value": {
491
- ".": "#dc8e83"
491
+ ".": "#e1a198"
492
492
  },
493
493
  "description": "Decorative stroke color used to define error-toned surface boundaries with normal emphasis."
494
494
  },
@@ -500,25 +500,25 @@
500
500
  },
501
501
  "Color/Semantic/Stroke/Neutral/strokeInt-neutral": {
502
502
  "value": {
503
- ".": "#8b8b8b"
503
+ ".": "#8a8a8a"
504
504
  },
505
505
  "description": "Accessible stroke color used for interactive neutrally-toned elements with normal emphasis."
506
506
  },
507
507
  "Color/Semantic/Stroke/Neutral/strokeInt-neutral-active": {
508
508
  "value": {
509
- ".": "#6d6d6d"
509
+ ".": "#6c6c6c"
510
510
  },
511
511
  "description": "Accessible stroke color used for interactive neutrally-toned elements with normal emphasis that are hovered, focused, or active."
512
512
  },
513
513
  "Color/Semantic/Stroke/Neutral/strokeInt-neutral-disabled": {
514
514
  "value": {
515
- ".": "#adadad"
515
+ ".": "#d8d8d8"
516
516
  },
517
517
  "description": "Accessible stroke color used for interactive neutrally-toned elements with normal emphasis, in their disabled state."
518
518
  },
519
519
  "Color/Semantic/Stroke/Neutral/strokeInt-neutral-strong": {
520
520
  "value": {
521
- ".": "#6d6d6d"
521
+ ".": "#6c6c6c"
522
522
  },
523
523
  "description": "Accessible stroke color used for interactive neutrally-toned elements with strong emphasis."
524
524
  },
@@ -536,7 +536,7 @@
536
536
  },
537
537
  "Color/Semantic/Stroke/Brand/strokeInt-brand-disabled": {
538
538
  "value": {
539
- ".": "#adadad"
539
+ ".": "#d8d8d8"
540
540
  },
541
541
  "description": "Accessible stroke color used for interactive brand-toned elements with normal emphasis, in their disabled state."
542
542
  },
@@ -162,10 +162,7 @@ function colorTokensCSS(computedColorRamps) {
162
162
  const key = `${rampName}-${tokenName}`;
163
163
  const aliasedBy = import_color_tokens.default[key] ?? [];
164
164
  for (const aliasedId of aliasedBy) {
165
- entries.push([
166
- `--wpds-color-${aliasedId}`,
167
- tokenValue.color
168
- ]);
165
+ entries.push([`--wpds-color-${aliasedId}`, tokenValue]);
169
166
  }
170
167
  }
171
168
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/use-theme-provider-styles.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport {\n\tparse,\n\tto,\n\tget,\n\tserialize,\n\tsRGB,\n\tHSL,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: ColorTypes ) {\n\tconst rgb = to( color, sRGB );\n\treturn [ get( rgb, 'srgb.r' ), get( rgb, 'srgb.g' ), get( rgb, 'srgb.b' ) ]\n\t\t.map( ( n ) => Math.round( n * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( parse( accent ), HSL );\n\n\tconst coords = parsedAccent.coords;\n\tconst darker10 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 5 ) ), // l (reduced by 5%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\tconst darker20 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 10 ) ), // l (reduced by 10%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\n\treturn [\n\t\t[\n\t\t\t'--wp-admin-theme-color',\n\t\t\tserialize( to( parsedAccent, sRGB ), { format: 'hex' } ),\n\t\t],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10',\n\t\t\tserialize( darker10, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20',\n\t\t\tserialize( darker20, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [\n\t\t\t\t\t`--wpds-color-${ aliasedId }`,\n\t\t\t\t\ttokenValue.color,\n\t\t\t\t] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = getCachedBgRamp( seeds.bg );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tgetCachedAccentRamp( seed, bgRamp )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,gBAQO;AACP,oBAAoB;AAKpB,qBAAoC;AAKpC,mCAAO;AACP,qBAA6B;AAC7B,0BAAwB;AACxB,yBAKO;AAKP,IAAM,sBAAkB,cAAAA,SAAS,gCAAa,EAAE,SAAS,GAAG,CAAE;AAC9D,IAAM,0BAAsB,cAAAA,SAAS,oCAAiB,EAAE,SAAS,GAAG,CAAE;AAEtE,IAAM,iCAA0C;AAAA,EAC/C,CAAE,gCAAgC,6BAA8B;AAAA,EAChE;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AAAA,EACA;AAAA,IACC;AAAA,IACA;AAAA,EACD;AACD;AAEA,SAAS,gBAAiB,OAAoB;AAC7C,QAAM,UAAM,cAAI,OAAO,cAAK;AAC5B,SAAO,KAAE,eAAK,KAAK,QAAS,OAAG,eAAK,KAAK,QAAS,OAAG,eAAK,KAAK,QAAS,CAAE,EACxE,I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ACN,2BAAmB;AAAA,UAClB;AAAA,UACA,oBAAqB,MAAM,MAAO;AAAA,QACnC;AAAA,MACD;AAAA,IACD,CAAE;AAEF,WAAO,eAAgB;AAAA,MACtB,SAAS,MAAM;AAAA,MACf;AAAA,IACD,CAAE;AAAA,EACH,GAAG,CAAE,SAAS,EAAG,CAAE;AAEnB,SAAO;AAAA,IACN;AAAA,IACA;AAAA,EACD;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport type { CSSProperties } from 'react';\nimport {\n\tparse,\n\tto,\n\tget,\n\tserialize,\n\tsRGB,\n\tHSL,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { useMemo, useContext } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport './color-ramps/lib/register-color-spaces';\nimport { ThemeContext } from './context';\nimport colorTokens from './prebuilt/ts/color-tokens';\nimport {\n\tbuildBgRamp,\n\tbuildAccentRamp,\n\tDEFAULT_SEED_COLORS,\n\ttype RampResult,\n} from './color-ramps';\nimport type { ThemeProviderProps } from './types';\n\ntype Entry = [ string, string ];\n\nconst getCachedBgRamp = memoize( buildBgRamp, { maxSize: 10 } );\nconst getCachedAccentRamp = memoize( buildAccentRamp, { maxSize: 10 } );\n\nconst legacyWpComponentsOverridesCSS: Entry[] = [\n\t[ '--wp-components-color-accent', 'var(--wp-admin-theme-color)' ],\n\t[\n\t\t'--wp-components-color-accent-darker-10',\n\t\t'var(--wp-admin-theme-color-darker-10)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-darker-20',\n\t\t'var(--wp-admin-theme-color-darker-20)',\n\t],\n\t[\n\t\t'--wp-components-color-accent-inverted',\n\t\t'var(--wpds-color-fg-interactive-brand-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-background',\n\t\t'var(--wpds-color-bg-surface-neutral-strong)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-foreground-inverted',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-100',\n\t\t'var(--wpds-color-bg-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-200',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-300',\n\t\t'var(--wpds-color-stroke-surface-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-400',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-600',\n\t\t'var(--wpds-color-stroke-interactive-neutral)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-700',\n\t\t'var(--wpds-color-fg-content-neutral-weak)',\n\t],\n\t[\n\t\t'--wp-components-color-gray-800',\n\t\t'var(--wpds-color-fg-content-neutral)',\n\t],\n];\n\nfunction customRgbFormat( color: ColorTypes ) {\n\tconst rgb = to( color, sRGB );\n\treturn [ get( rgb, 'srgb.r' ), get( rgb, 'srgb.g' ), get( rgb, 'srgb.b' ) ]\n\t\t.map( ( n ) => Math.round( n * 255 ) )\n\t\t.join( ', ' );\n}\n\nfunction legacyWpAdminThemeOverridesCSS( accent: string ): Entry[] {\n\tconst parsedAccent = to( parse( accent ), HSL );\n\n\tconst coords = parsedAccent.coords;\n\tconst darker10 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 5 ) ), // l (reduced by 5%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\tconst darker20 = to(\n\t\t{\n\t\t\tspace: HSL,\n\t\t\tcoords: [\n\t\t\t\tcoords[ 0 ], // h\n\t\t\t\tcoords[ 1 ], // s\n\t\t\t\tMath.max( 0, Math.min( 100, coords[ 2 ] - 10 ) ), // l (reduced by 10%)\n\t\t\t],\n\t\t},\n\t\tsRGB\n\t);\n\n\treturn [\n\t\t[\n\t\t\t'--wp-admin-theme-color',\n\t\t\tserialize( to( parsedAccent, sRGB ), { format: 'hex' } ),\n\t\t],\n\t\t[ '--wp-admin-theme-color--rgb', customRgbFormat( parsedAccent ) ],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10',\n\t\t\tserialize( darker10, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-10--rgb',\n\t\t\tcustomRgbFormat( darker10 ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20',\n\t\t\tserialize( darker20, { format: 'hex' } ),\n\t\t],\n\t\t[\n\t\t\t'--wp-admin-theme-color-darker-20--rgb',\n\t\t\tcustomRgbFormat( darker20 ),\n\t\t],\n\t];\n}\n\nfunction colorTokensCSS(\n\tcomputedColorRamps: Map< string, RampResult >\n): Entry[] {\n\tconst entries: Entry[] = [];\n\n\tfor ( const [ rampName, { ramp } ] of computedColorRamps ) {\n\t\tfor ( const [ tokenName, tokenValue ] of Object.entries( ramp ) ) {\n\t\t\tconst key = `${ rampName }-${ tokenName }`;\n\t\t\tconst aliasedBy = colorTokens[ key ] ?? [];\n\t\t\tfor ( const aliasedId of aliasedBy ) {\n\t\t\t\tentries.push( [ `--wpds-color-${ aliasedId }`, tokenValue ] );\n\t\t\t}\n\t\t}\n\t}\n\n\treturn entries;\n}\n\nfunction generateStyles( {\n\tprimary,\n\tcomputedColorRamps,\n}: {\n\tprimary: string;\n\tcomputedColorRamps: Map< string, RampResult >;\n} ): CSSProperties {\n\treturn Object.fromEntries(\n\t\t[\n\t\t\t// Semantic color tokens\n\t\t\tcolorTokensCSS( computedColorRamps ),\n\t\t\t// Legacy overrides\n\t\t\tlegacyWpAdminThemeOverridesCSS( primary ),\n\t\t\tlegacyWpComponentsOverridesCSS,\n\t\t].flat()\n\t);\n}\n\nexport function useThemeProviderStyles( {\n\tcolor = {},\n}: {\n\tcolor?: ThemeProviderProps[ 'color' ];\n} = {} ) {\n\tconst { resolvedSettings: inheritedSettings } = useContext( ThemeContext );\n\n\t// Compute settings:\n\t// - used provided prop value;\n\t// - otherwise, use inherited value from parent instance;\n\t// - otherwise, use fallback value (where applicable).\n\tconst primary =\n\t\tcolor.primary ??\n\t\tinheritedSettings.color?.primary ??\n\t\tDEFAULT_SEED_COLORS.primary;\n\tconst bg =\n\t\tcolor.bg ?? inheritedSettings.color?.bg ?? DEFAULT_SEED_COLORS.bg;\n\n\tconst resolvedSettings = useMemo(\n\t\t() => ( {\n\t\t\tcolor: {\n\t\t\t\tprimary,\n\t\t\t\tbg,\n\t\t\t},\n\t\t} ),\n\t\t[ primary, bg ]\n\t);\n\n\tconst themeProviderStyles = useMemo( () => {\n\t\t// Determine which seeds are needed for generating ramps.\n\t\tconst seeds = {\n\t\t\t...DEFAULT_SEED_COLORS,\n\t\t\tbg,\n\t\t\tprimary,\n\t\t};\n\n\t\t// Generate ramps.\n\t\tconst computedColorRamps = new Map< string, RampResult >();\n\t\tconst bgRamp = getCachedBgRamp( seeds.bg );\n\t\tObject.entries( seeds ).forEach( ( [ rampName, seed ] ) => {\n\t\t\tif ( rampName === 'bg' ) {\n\t\t\t\tcomputedColorRamps.set( rampName, bgRamp );\n\t\t\t} else {\n\t\t\t\tcomputedColorRamps.set(\n\t\t\t\t\trampName,\n\t\t\t\t\tgetCachedAccentRamp( seed, bgRamp )\n\t\t\t\t);\n\t\t\t}\n\t\t} );\n\n\t\treturn generateStyles( {\n\t\t\tprimary: seeds.primary,\n\t\t\tcomputedColorRamps,\n\t\t} );\n\t}, [ primary, bg ] );\n\n\treturn {\n\t\tresolvedSettings,\n\t\tthemeProviderStyles,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,gBAQO;AACP,oBAAoB;AAKpB,qBAAoC;AAKpC,mCAAO;AACP,qBAA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 -1,5 +1,5 @@
1
1
  // packages/theme/src/color-ramps/index.ts
2
- import { get, OKLCH, parse, serialize } from "colorjs.io/fn";
2
+ import { get, OKLCH, parse } from "colorjs.io/fn";
3
3
  import "./lib/register-color-spaces";
4
4
  import { buildRamp } from "./lib/index";
5
5
  import { clampAccentScaleReferenceLightness } from "./lib/utils";
@@ -20,7 +20,7 @@ function getBgRampInfo(ramp) {
20
20
  pinLightness: {
21
21
  stepName: STEP_TO_PIN,
22
22
  value: clampAccentScaleReferenceLightness(
23
- get(parse(ramp.ramp[STEP_TO_PIN].color), [OKLCH, "l"]),
23
+ get(parse(ramp.ramp[STEP_TO_PIN]), [OKLCH, "l"]),
24
24
  ramp.direction
25
25
  )
26
26
  }
@@ -42,15 +42,17 @@ function checkAccessibleCombinations({
42
42
  CONTRAST_COMBINATIONS.forEach(({ bgs, fgs, target }) => {
43
43
  for (const bg of bgs) {
44
44
  for (const fg of fgs) {
45
- const bgColor = parse(ramp.ramp[bg].color);
46
- const fgColor = parse(ramp.ramp[fg].color);
47
- if (getContrast(bgColor, fgColor) < target) {
45
+ const bgColor = ramp.ramp[bg];
46
+ const fgColor = ramp.ramp[fg];
47
+ const achievedContrast = getContrast(bgColor, fgColor);
48
+ if (achievedContrast < target) {
48
49
  unmetTargets.push({
49
50
  bgName: bg,
50
- bgColor: serialize(bgColor),
51
+ bgColor,
51
52
  fgName: fg,
52
- fgColor: serialize(fgColor),
53
- unmetContrast: target
53
+ fgColor,
54
+ unmetContrast: target,
55
+ achievedContrast
54
56
  });
55
57
  }
56
58
  }
@@ -61,15 +63,17 @@ function checkAccessibleCombinations({
61
63
  CONTRAST_COMBINATIONS.forEach(({ bgs, fgs, target }) => {
62
64
  for (const bg of bgs) {
63
65
  for (const fg of fgs) {
64
- const bgColor = parse(bgRamp.ramp[bg].color);
65
- const fgColor = parse(ramp.ramp[fg].color);
66
- if (getContrast(bgColor, fgColor) < target) {
66
+ const bgColor = bgRamp.ramp[bg];
67
+ const fgColor = ramp.ramp[fg];
68
+ const achievedContrast = getContrast(bgColor, fgColor);
69
+ if (achievedContrast < target) {
67
70
  unmetTargets.push({
68
71
  bgName: bg,
69
- bgColor: serialize(bgColor),
72
+ bgColor,
70
73
  fgName: fg,
71
- fgColor: serialize(fgColor),
72
- unmetContrast: target
74
+ fgColor,
75
+ unmetContrast: target,
76
+ achievedContrast
73
77
  });
74
78
  }
75
79
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/color-ramps/index.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, parse, serialize } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './lib/register-color-spaces';\nimport { buildRamp } from './lib/index';\nimport { clampAccentScaleReferenceLightness } from './lib/utils';\nimport { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';\nimport type {\n\tRampResult as InternalRampResult,\n\tRampDirection,\n\tRamp,\n} from './lib/types';\nimport { getContrast } from './lib/color-utils';\nimport { CONTRAST_COMBINATIONS } from './lib/constants';\nexport { DEFAULT_SEED_COLORS } from './lib/constants';\n\n/**\n * Creates a background ramp.\n * @param seed The seed color for the background ramp.\n */\nexport function buildBgRamp( seed: string ) {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\treturn buildRamp( seed, BG_RAMP_CONFIG );\n}\n\nconst STEP_TO_PIN = 'surface2';\nfunction getBgRampInfo( ramp: InternalRampResult ): {\n\tmainDirection: RampDirection;\n\tpinLightness: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} {\n\treturn {\n\t\tmainDirection: ramp.direction,\n\t\tpinLightness: {\n\t\t\tstepName: STEP_TO_PIN,\n\t\t\tvalue: clampAccentScaleReferenceLightness(\n\t\t\t\tget( parse( ramp.ramp[ STEP_TO_PIN ].color ), [ OKLCH, 'l' ] ),\n\t\t\t\tramp.direction\n\t\t\t),\n\t\t},\n\t};\n}\n\n/**\n * Creates an accent ramp (ie used by primary, success, info, warning and error\n * ramps).\n * @param seed The seed color for the accent ramp.\n * @param bgRamp The ramp of the background on which the accent is shown.\n */\nexport function buildAccentRamp(\n\tseed: string,\n\tbgRamp?: InternalRampResult\n): InternalRampResult {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\tconst bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;\n\treturn buildRamp( seed, ACCENT_RAMP_CONFIG, bgRampInfo );\n}\n\n/**\n * Checks that all bg/fg combinations generated by the ramps meet contrast\n * targets.\n * @param params\n * @param params.bgRamp\n * @param params.accentRamps\n */\nexport function checkAccessibleCombinations( {\n\tbgRamp,\n\taccentRamps = [],\n}: {\n\tbgRamp: InternalRampResult;\n\taccentRamps?: InternalRampResult[];\n} ) {\n\tconst unmetTargets: {\n\t\tbgName: keyof Ramp;\n\t\tbgColor: string;\n\t\tfgName: keyof Ramp;\n\t\tfgColor: string;\n\t\tunmetContrast: number;\n\t}[] = [];\n\n\t// Assess combinations within each ramp\n\t[ bgRamp, ...accentRamps ].forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = parse( ramp.ramp[ bg ].color );\n\t\t\t\t\tconst fgColor = parse( ramp.ramp[ fg ].color );\n\t\t\t\t\tif ( getContrast( bgColor, fgColor ) < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor: serialize( bgColor ),\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor: serialize( fgColor ),\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\t// Assess each accent ramp's fg color against bg ramp\n\taccentRamps.forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = parse( bgRamp.ramp[ bg ].color );\n\t\t\t\t\tconst fgColor = parse( ramp.ramp[ fg ].color );\n\t\t\t\t\tif ( getContrast( bgColor, fgColor ) < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor: serialize( bgColor ),\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor: serialize( fgColor ),\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\n\treturn unmetTargets;\n}\n\nexport type RampResult = InternalRampResult;\n"],
5
- "mappings": ";AAGA,SAAS,KAAK,OAAO,OAAO,iBAAiB;AAK7C,OAAO;AACP,SAAS,iBAAiB;AAC1B,SAAS,0CAA0C;AACnD,SAAS,gBAAgB,0BAA0B;AAMnD,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAM7B,SAAS,YAAa,MAAe;AAC3C,MAAK,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,IAAK;AACrD,UAAM,IAAI,MAAO,uCAAwC;AAAA,EAC1D;AAEA,SAAO,UAAW,MAAM,cAAe;AACxC;AAEA,IAAM,cAAc;AACpB,SAAS,cAAe,MAMtB;AACD,SAAO;AAAA,IACN,eAAe,KAAK;AAAA,IACpB,cAAc;AAAA,MACb,UAAU;AAAA,MACV,OAAO;AAAA,QACN,IAAK,MAAO,KAAK,KAAM,WAAY,EAAE,KAAM,GAAG,CAAE,OAAO,GAAI,CAAE;AAAA,QAC7D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AA,cACR,SAAS,UAAW,OAAQ;AAAA,cAC5B,QAAQ;AAAA,cACR,SAAS,UAAW,OAAQ;AAAA,cAC5B,eAAe;AAAA,YAChB,CAAE;AAAA,UACH;AAAA,QACD;AAAA,MACD;AAAA,IACD,CAAE;AAAA,EACH,CAAE;AAEF,SAAO;AACR;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, parse } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './lib/register-color-spaces';\nimport { buildRamp } from './lib/index';\nimport { clampAccentScaleReferenceLightness } from './lib/utils';\nimport { BG_RAMP_CONFIG, ACCENT_RAMP_CONFIG } from './lib/ramp-configs';\nimport type {\n\tRampResult as InternalRampResult,\n\tRampDirection,\n\tRamp,\n} from './lib/types';\nimport { getContrast } from './lib/color-utils';\nimport { CONTRAST_COMBINATIONS } from './lib/constants';\nexport { DEFAULT_SEED_COLORS } from './lib/constants';\n\n/**\n * Creates a background ramp.\n * @param seed The seed color for the background ramp.\n */\nexport function buildBgRamp( seed: string ) {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\treturn buildRamp( seed, BG_RAMP_CONFIG );\n}\n\nconst STEP_TO_PIN = 'surface2';\nfunction getBgRampInfo( ramp: InternalRampResult ): {\n\tmainDirection: RampDirection;\n\tpinLightness: {\n\t\tstepName: keyof Ramp;\n\t\tvalue: number;\n\t};\n} {\n\treturn {\n\t\tmainDirection: ramp.direction,\n\t\tpinLightness: {\n\t\t\tstepName: STEP_TO_PIN,\n\t\t\tvalue: clampAccentScaleReferenceLightness(\n\t\t\t\tget( parse( ramp.ramp[ STEP_TO_PIN ] ), [ OKLCH, 'l' ] ),\n\t\t\t\tramp.direction\n\t\t\t),\n\t\t},\n\t};\n}\n\n/**\n * Creates an accent ramp (ie used by primary, success, info, warning and error\n * ramps).\n * @param seed The seed color for the accent ramp.\n * @param bgRamp The ramp of the background on which the accent is shown.\n */\nexport function buildAccentRamp(\n\tseed: string,\n\tbgRamp?: InternalRampResult\n): InternalRampResult {\n\tif ( typeof seed !== 'string' || seed.trim() === '' ) {\n\t\tthrow new Error( 'Seed color must be a non-empty string' );\n\t}\n\n\tconst bgRampInfo = bgRamp ? getBgRampInfo( bgRamp ) : undefined;\n\treturn buildRamp( seed, ACCENT_RAMP_CONFIG, bgRampInfo );\n}\n\n/**\n * Checks that all bg/fg combinations generated by the ramps meet contrast\n * targets.\n * @param params\n * @param params.bgRamp\n * @param params.accentRamps\n */\nexport function checkAccessibleCombinations( {\n\tbgRamp,\n\taccentRamps = [],\n}: {\n\tbgRamp: InternalRampResult;\n\taccentRamps?: InternalRampResult[];\n} ) {\n\tconst unmetTargets: {\n\t\tbgName: keyof Ramp;\n\t\tbgColor: string;\n\t\tfgName: keyof Ramp;\n\t\tfgColor: string;\n\t\tunmetContrast: number;\n\t\tachievedContrast: number;\n\t}[] = [];\n\n\t// Assess combinations within each ramp\n\t[ bgRamp, ...accentRamps ].forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = ramp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\t// Assess each accent ramp's fg color against bg ramp\n\taccentRamps.forEach( ( ramp ) => {\n\t\tCONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {\n\t\t\tfor ( const bg of bgs ) {\n\t\t\t\tfor ( const fg of fgs ) {\n\t\t\t\t\tconst bgColor = bgRamp.ramp[ bg ];\n\t\t\t\t\tconst fgColor = ramp.ramp[ fg ];\n\t\t\t\t\tconst achievedContrast = getContrast( bgColor, fgColor );\n\t\t\t\t\tif ( achievedContrast < target ) {\n\t\t\t\t\t\tunmetTargets.push( {\n\t\t\t\t\t\t\tbgName: bg,\n\t\t\t\t\t\t\tbgColor,\n\t\t\t\t\t\t\tfgName: fg,\n\t\t\t\t\t\t\tfgColor,\n\t\t\t\t\t\t\tunmetContrast: target,\n\t\t\t\t\t\t\tachievedContrast,\n\t\t\t\t\t\t} );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t} );\n\t} );\n\n\treturn unmetTargets;\n}\n\nexport type RampResult = InternalRampResult;\n"],
5
+ "mappings": ";AAGA,SAAS,KAAK,OAAO,aAAa;AAKlC,OAAO;AACP,SAAS,iBAAiB;AAC1B,SAAS,0CAA0C;AACnD,SAAS,gBAAgB,0BAA0B;AAMnD,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAM7B,SAAS,YAAa,MAAe;AAC3C,MAAK,OAAO,SAAS,YAAY,KAAK,KAAK,MAAM,IAAK;AACrD,UAAM,IAAI,MAAO,uCAAwC;AAAA,EAC1D;AAEA,SAAO,UAAW,MAAM,cAAe;AACxC;AAEA,IAAM,cAAc;AACpB,SAAS,cAAe,MAMtB;AACD,SAAO;AAAA,IACN,eAAe,KAAK;AAAA,IACpB,cAAc;AAAA,MACb,UAAU;AAAA,MACV,OAAO;AAAA,QACN,IAAK,MAAO,KAAK,KAAM,WAAY,CAAE,GAAG,CAAE,OAAO,GAAI,CAAE;AAAA,QACvD,KAAK;AAAA,MACN;AAAA,IACD;AAAA,EACD;AACD;AAQO,SAAS,gBACf,MACA,QACqB;AACrB,MA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AAE;AAEF,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -1,9 +1,11 @@
1
1
  // packages/theme/src/color-ramps/lib/color-utils.ts
2
2
  import {
3
3
  to,
4
+ toGamut,
4
5
  serialize,
5
6
  contrastWCAG21,
6
- sRGB
7
+ sRGB,
8
+ OKLCH
7
9
  } from "colorjs.io/fn";
8
10
  import "./register-color-spaces";
9
11
  function getColorString(color) {
@@ -12,7 +14,11 @@ function getColorString(color) {
12
14
  function getContrast(colorA, colorB) {
13
15
  return contrastWCAG21(colorA, colorB);
14
16
  }
17
+ function clampToGamut(c) {
18
+ return to(toGamut(c, { space: sRGB, method: "css" }), OKLCH);
19
+ }
15
20
  export {
21
+ clampToGamut,
16
22
  getColorString,
17
23
  getContrast
18
24
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/color-ramps/lib/color-utils.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tto,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\treturn serialize( to( color, sRGB ), { format: 'hex', inGamut: true } );\n}\n\n/**\n * Get contrast value between two colors\n * @param colorA First color\n * @param colorB Second color\n * @return WCAG 2.1 contrast ratio\n */\nexport function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {\n\treturn contrastWCAG21( colorA, colorB );\n}\n"],
5
- "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAKP,OAAO;AAOA,SAAS,eAAgB,OAA4B;AAC3D,SAAO,UAAW,GAAI,OAAO,IAAK,GAAG,EAAE,QAAQ,OAAO,SAAS,KAAK,CAAE;AACvE;AAQO,SAAS,YAAa,QAAoB,QAA6B;AAC7E,SAAO,eAAgB,QAAQ,MAAO;AACvC;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport {\n\tto,\n\ttoGamut,\n\tserialize,\n\tcontrastWCAG21,\n\tsRGB,\n\tOKLCH,\n\ttype ColorTypes,\n} from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\n\n/**\n * Get string representation of a color\n * @param color Color object to stringify\n * @return String representation\n */\nexport function getColorString( color: ColorTypes ): string {\n\treturn serialize( to( color, sRGB ), { format: 'hex', inGamut: true } );\n}\n\n/**\n * Get contrast value between two colors\n * @param colorA First color\n * @param colorB Second color\n * @return WCAG 2.1 contrast ratio\n */\nexport function getContrast( colorA: ColorTypes, colorB: ColorTypes ): number {\n\treturn contrastWCAG21( colorA, colorB );\n}\n\n/**\n * Make sure that a color is valid in the sRGB gamut and convert it to OKLCH.\n * @param c\n */\nexport function clampToGamut( c: ColorTypes ) {\n\t// map into sRGB using CSS OKLCH method\n\treturn to( toGamut( c, { space: sRGB, method: 'css' } ), OKLCH );\n}\n"],
5
+ "mappings": ";AAGA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AAKP,OAAO;AAOA,SAAS,eAAgB,OAA4B;AAC3D,SAAO,UAAW,GAAI,OAAO,IAAK,GAAG,EAAE,QAAQ,OAAO,SAAS,KAAK,CAAE;AACvE;AAQO,SAAS,YAAa,QAAoB,QAA6B;AAC7E,SAAO,eAAgB,QAAQ,MAAO;AACvC;AAMO,SAAS,aAAc,GAAgB;AAE7C,SAAO,GAAI,QAAS,GAAG,EAAE,OAAO,MAAM,QAAQ,MAAM,CAAE,GAAG,KAAM;AAChE;",
6
6
  "names": []
7
7
  }
@@ -3,7 +3,7 @@ import { to, OKLCH } from "colorjs.io/fn";
3
3
  import "./register-color-spaces";
4
4
  var WHITE = to("white", OKLCH);
5
5
  var BLACK = to("black", OKLCH);
6
- var UNIVERSAL_CONTRAST_TOPUP = 0.012;
6
+ var UNIVERSAL_CONTRAST_TOPUP = 0.02;
7
7
  var WHITE_TEXT_CONTRAST_MARGIN = 3.1;
8
8
  var ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {
9
9
  lighter: { min: 0.2, max: 0.4 },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/color-ramps/lib/constants.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport { to, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport type { Ramp } from './types';\n\nexport const WHITE = to( 'white', OKLCH );\nexport const BLACK = to( 'black', OKLCH );\n\n// Margin added to target contrasts to counter for algorithm approximations and rounding errors.\n// - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.\n// - the max contrast between adjacent RGB values is 1.016, so half of the difference (0.008) can be rounding error.\n// - the sum is 0.012: the margin we add to ensure that the target contrast is met after all the rounding.\nexport const UNIVERSAL_CONTRAST_TOPUP = 0.012;\n\n// When enabling \"lighter direction\" bias, this is the amount by which\n// black text contrast needs to be greater than white text contrast.\n// The higher the value, the stronger the preference for white text.\n// The current value has been determined empirically as the highest value\n// that won't cause the algo not to be able to correctly solve all contrasts.\nexport const WHITE_TEXT_CONTRAST_MARGIN = 3.1;\n\n// These values are used as thresholds when trying to match the background\n// ramp's lightness while calculating an accent ramp. They prevent the accent\n// scale from being pinned to lightness values in the middle of the range,\n// which would cause the algorithm to struggle to satisfy the accent scale\n// constraints and therefore produce unexpected results.\nexport const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {\n\tlighter: { min: 0.2, max: 0.4 },\n\tdarker: { min: 0.75, max: 0.98 },\n} as const;\n\n// Contrast precision we aim for. Approximately 1/256, resolution of an 8-bit number.\nexport const CONTRAST_EPSILON = 4e-3;\n\nexport const MAX_BISECTION_ITERATIONS = 10;\n\nexport const CONTRAST_COMBINATIONS: {\n\tbgs: ( keyof Ramp )[];\n\tfgs: ( keyof Ramp )[];\n\ttarget: number;\n}[] = [\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'fgSurface3', 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface4', 'surface5' ],\n\t\tfgs: [ 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFill1' ],\n\t\tfgs: [ 'fgFill' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'stroke3' ],\n\t\ttarget: 3,\n\t},\n];\n\n// Used when generating the DTCG tokens and the static color ramps.\nexport const DEFAULT_SEED_COLORS = {\n\tbg: '#f8f8f8',\n\tprimary: '#3858e9',\n\tinfo: '#0090ff',\n\tsuccess: '#4ab866',\n\tcaution: '#f0d149',\n\twarning: '#f0b849',\n\terror: '#cc1818',\n};\n"],
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { to, OKLCH } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport type { Ramp } from './types';\n\nexport const WHITE = to( 'white', OKLCH );\nexport const BLACK = to( 'black', OKLCH );\n\n// Margin added to target contrasts to counter for algorithm approximations and rounding errors.\n// - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.\n// - the max contrast between adjacent RGB values is 1.016, so 0.016 is the maximum total rounding error between two values.\n// - the sum is 0.02: the margin we add to ensure that the target contrast is met after all the rounding.\nexport const UNIVERSAL_CONTRAST_TOPUP = 0.02;\n\n// When enabling \"lighter direction\" bias, this is the amount by which\n// black text contrast needs to be greater than white text contrast.\n// The higher the value, the stronger the preference for white text.\n// The current value has been determined empirically as the highest value\n// that won't cause the algo not to be able to correctly solve all contrasts.\nexport const WHITE_TEXT_CONTRAST_MARGIN = 3.1;\n\n// These values are used as thresholds when trying to match the background\n// ramp's lightness while calculating an accent ramp. They prevent the accent\n// scale from being pinned to lightness values in the middle of the range,\n// which would cause the algorithm to struggle to satisfy the accent scale\n// constraints and therefore produce unexpected results.\nexport const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {\n\tlighter: { min: 0.2, max: 0.4 },\n\tdarker: { min: 0.75, max: 0.98 },\n} as const;\n\n// Contrast precision we aim for. Approximately 1/256, resolution of an 8-bit number.\nexport const CONTRAST_EPSILON = 4e-3;\n\nexport const MAX_BISECTION_ITERATIONS = 10;\n\nexport const CONTRAST_COMBINATIONS: {\n\tbgs: ( keyof Ramp )[];\n\tfgs: ( keyof Ramp )[];\n\ttarget: number;\n}[] = [\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'fgSurface3', 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface4', 'surface5' ],\n\t\tfgs: [ 'fgSurface4' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFill1' ],\n\t\tfgs: [ 'fgFill' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'bgFillInverted1' ],\n\t\tfgs: [ 'fgFillInverted' ],\n\t\ttarget: 4.5,\n\t},\n\t{\n\t\tbgs: [ 'surface1', 'surface2', 'surface3' ],\n\t\tfgs: [ 'stroke3' ],\n\t\ttarget: 3,\n\t},\n];\n\n// Used when generating the DTCG tokens and the static color ramps.\nexport const DEFAULT_SEED_COLORS = {\n\tbg: '#f8f8f8',\n\tpr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