@wordpress/theme 0.1.1-next.2f1c7c01b.0 → 0.2.1-next.16d95556a.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 (106) hide show
  1. package/README.md +5 -1
  2. package/bin/generate-primitive-tokens/index.ts +1 -1
  3. package/bin/terrazzo-plugin-ds-tokens-docs/index.ts +5 -24
  4. package/bin/terrazzo-plugin-inline-alias-values/index.ts +84 -0
  5. package/bin/terrazzo-plugin-known-wpds-css-variables/index.ts +19 -39
  6. package/build/color-ramps/index.js +5 -5
  7. package/build/color-ramps/index.js.map +2 -2
  8. package/build/color-ramps/lib/constants.js +4 -4
  9. package/build/color-ramps/lib/constants.js.map +2 -2
  10. package/build/color-ramps/lib/default-ramps.js +154 -154
  11. package/build/color-ramps/lib/default-ramps.js.map +2 -2
  12. package/build/color-ramps/lib/find-color-with-constraints.js +36 -53
  13. package/build/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  14. package/build/color-ramps/lib/index.js +72 -64
  15. package/build/color-ramps/lib/index.js.map +2 -2
  16. package/build/color-ramps/lib/ramp-configs.js +3 -3
  17. package/build/color-ramps/lib/ramp-configs.js.map +1 -1
  18. package/build/color-ramps/lib/types.js.map +1 -1
  19. package/build/color-ramps/lib/utils.js +63 -2
  20. package/build/color-ramps/lib/utils.js.map +2 -2
  21. package/build/prebuilt/js/design-tokens.js +5 -10
  22. package/build/prebuilt/js/design-tokens.js.map +2 -2
  23. package/build/prebuilt/json/figma.json +105 -905
  24. package/build/prebuilt/ts/color-tokens.js +137 -0
  25. package/build/prebuilt/ts/color-tokens.js.map +7 -0
  26. package/build/token-id.js +30 -0
  27. package/build/token-id.js.map +7 -0
  28. package/build/use-theme-provider-styles.js +15 -27
  29. package/build/use-theme-provider-styles.js.map +3 -3
  30. package/build-module/color-ramps/index.js +5 -5
  31. package/build-module/color-ramps/index.js.map +2 -2
  32. package/build-module/color-ramps/lib/constants.js +3 -3
  33. package/build-module/color-ramps/lib/constants.js.map +2 -2
  34. package/build-module/color-ramps/lib/default-ramps.js +154 -154
  35. package/build-module/color-ramps/lib/default-ramps.js.map +2 -2
  36. package/build-module/color-ramps/lib/find-color-with-constraints.js +38 -60
  37. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  38. package/build-module/color-ramps/lib/index.js +76 -66
  39. package/build-module/color-ramps/lib/index.js.map +2 -2
  40. package/build-module/color-ramps/lib/ramp-configs.js +3 -3
  41. package/build-module/color-ramps/lib/ramp-configs.js.map +1 -1
  42. package/build-module/color-ramps/lib/utils.js +63 -2
  43. package/build-module/color-ramps/lib/utils.js.map +2 -2
  44. package/build-module/prebuilt/js/design-tokens.js +5 -10
  45. package/build-module/prebuilt/js/design-tokens.js.map +2 -2
  46. package/build-module/prebuilt/json/figma.json +105 -905
  47. package/build-module/prebuilt/ts/color-tokens.js +117 -0
  48. package/build-module/prebuilt/ts/color-tokens.js.map +7 -0
  49. package/build-module/token-id.js +6 -0
  50. package/build-module/token-id.js.map +7 -0
  51. package/build-module/use-theme-provider-styles.js +15 -27
  52. package/build-module/use-theme-provider-styles.js.map +2 -2
  53. package/build-types/color-ramps/lib/constants.d.ts +2 -2
  54. package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
  55. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +2 -3
  56. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -1
  57. package/build-types/color-ramps/lib/index.d.ts.map +1 -1
  58. package/build-types/color-ramps/lib/types.d.ts +2 -4
  59. package/build-types/color-ramps/lib/types.d.ts.map +1 -1
  60. package/build-types/color-ramps/lib/utils.d.ts +21 -2
  61. package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
  62. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
  63. package/build-types/color-ramps/stories/ramp-table.d.ts +2 -4
  64. package/build-types/color-ramps/stories/ramp-table.d.ts.map +1 -1
  65. package/build-types/prebuilt/ts/color-tokens.d.ts +7 -0
  66. package/build-types/prebuilt/ts/color-tokens.d.ts.map +1 -0
  67. package/build-types/stories/index.story.d.ts.map +1 -1
  68. package/build-types/theme-provider.d.ts.map +1 -1
  69. package/build-types/token-id.d.ts +9 -0
  70. package/build-types/token-id.d.ts.map +1 -0
  71. package/build-types/use-theme-provider-styles.d.ts.map +1 -1
  72. package/docs/ds-tokens.md +10 -178
  73. package/package.json +4 -4
  74. package/src/color-ramps/index.ts +5 -5
  75. package/src/color-ramps/lib/constants.ts +7 -5
  76. package/src/color-ramps/lib/default-ramps.ts +154 -154
  77. package/src/color-ramps/lib/find-color-with-constraints.ts +53 -77
  78. package/src/color-ramps/lib/index.ts +100 -100
  79. package/src/color-ramps/lib/ramp-configs.ts +3 -3
  80. package/src/color-ramps/lib/types.ts +2 -7
  81. package/src/color-ramps/lib/utils.ts +109 -5
  82. package/src/color-ramps/stories/index.story.tsx +4 -1
  83. package/src/color-ramps/stories/ramp-table.tsx +15 -26
  84. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +16891 -1059
  85. package/src/color-ramps/test/index.test.ts +43 -16
  86. package/src/prebuilt/css/design-tokens.css +88 -413
  87. package/src/prebuilt/js/design-tokens.js +5 -10
  88. package/src/prebuilt/json/figma.json +105 -905
  89. package/src/prebuilt/ts/color-tokens.ts +117 -0
  90. package/src/stories/index.story.tsx +4 -18
  91. package/src/test/token-id.test.ts +12 -0
  92. package/src/token-id.ts +9 -0
  93. package/src/use-theme-provider-styles.ts +17 -35
  94. package/terrazzo.config.ts +15 -12
  95. package/tokens/color.json +82 -82
  96. package/tokens/dimension.json +75 -0
  97. package/tsconfig.bin.tsbuildinfo +1 -1
  98. package/tsconfig.src.tsbuildinfo +1 -1
  99. package/build/prebuilt/ts/design-tokens.js +0 -391
  100. package/build/prebuilt/ts/design-tokens.js.map +0 -7
  101. package/build-module/prebuilt/ts/design-tokens.js +0 -371
  102. package/build-module/prebuilt/ts/design-tokens.js.map +0 -7
  103. package/build-types/prebuilt/ts/design-tokens.d.ts +0 -7
  104. package/build-types/prebuilt/ts/design-tokens.d.ts.map +0 -1
  105. package/src/prebuilt/ts/design-tokens.ts +0 -371
  106. package/tokens/spacing.json +0 -45
package/docs/ds-tokens.md CHANGED
@@ -109,6 +109,16 @@ Do not edit directly.
109
109
  | `--wpds-color-stroke-interactive-error-strong` | Accessible stroke color used for interactive error-toned elements with strong emphasis. |
110
110
  | `--wpds-color-stroke-focus-brand` | Accessible stroke color applied to focus rings. |
111
111
 
112
+ ### Dimension
113
+
114
+ | Variable name | Description |
115
+ | ------------------------------------------ | -------------------------------- |
116
+ | `--wpds-dimension-base` | Base dimension unit |
117
+ | `--wpds-dimension-padding-surface-x-small` | Extra small spacing for surfaces |
118
+ | `--wpds-dimension-padding-surface-small` | Small spacing for surfaces |
119
+ | `--wpds-dimension-padding-surface-medium` | Medium spacing for surfaces |
120
+ | `--wpds-dimension-padding-surface-large` | Large spacing for surfaces |
121
+
112
122
  ### Elevation
113
123
 
114
124
  | Variable name | Description |
@@ -118,21 +128,6 @@ Do not edit directly.
118
128
  | `--wpds-elevation-medium` | For components that offer additional actions. Example: Menus, Command Palette |
119
129
  | `--wpds-elevation-large` | For components that confirm decisions or handle necessary interruptions. Example: Modals. |
120
130
 
121
- ### Spacing
122
-
123
- | Variable name | Description |
124
- | ------------------- | ------------------- |
125
- | `--wpds-spacing-05` | Extra small spacing |
126
- | `--wpds-spacing-10` | Small spacing |
127
- | `--wpds-spacing-15` | Medium spacing |
128
- | `--wpds-spacing-20` | Large spacing |
129
- | `--wpds-spacing-30` | Extra large spacing |
130
- | `--wpds-spacing-40` | 2X large spacing |
131
- | `--wpds-spacing-50` | 3X large spacing |
132
- | `--wpds-spacing-60` | 4X large spacing |
133
- | `--wpds-spacing-70` | 5X large spacing |
134
- | `--wpds-spacing-80` | 6X large spacing |
135
-
136
131
  ### Typography
137
132
 
138
133
  | Variable name | Description |
@@ -152,166 +147,3 @@ Do not edit directly.
152
147
  | `--wpds-font-line-height-large` | Large line height |
153
148
  | `--wpds-font-line-height-x-large` | Extra large line height |
154
149
  | `--wpds-font-line-height-2x-large` | 2X large line height |
155
-
156
- ## Primitive tokens
157
-
158
- **🚨 Note: These tokens are only private implementation details of the Theme, and should never be referenced / consumed directly in the code.**
159
-
160
- ### Color (private)
161
-
162
- | Variable name | Description |
163
- | ------------------------------------------------ | ----------- |
164
- | `--wpds-color-private-primary-bg-fill1` | N/A |
165
- | `--wpds-color-private-primary-fg-fill` | N/A |
166
- | `--wpds-color-private-primary-bg-fill2` | N/A |
167
- | `--wpds-color-private-primary-surface2` | N/A |
168
- | `--wpds-color-private-primary-surface6` | N/A |
169
- | `--wpds-color-private-primary-surface5` | N/A |
170
- | `--wpds-color-private-primary-surface4` | N/A |
171
- | `--wpds-color-private-primary-surface3` | N/A |
172
- | `--wpds-color-private-primary-fg-surface4` | N/A |
173
- | `--wpds-color-private-primary-fg-surface3` | N/A |
174
- | `--wpds-color-private-primary-fg-surface2` | N/A |
175
- | `--wpds-color-private-primary-fg-surface1` | N/A |
176
- | `--wpds-color-private-primary-stroke3` | N/A |
177
- | `--wpds-color-private-primary-stroke4` | N/A |
178
- | `--wpds-color-private-primary-stroke2` | N/A |
179
- | `--wpds-color-private-primary-stroke1` | N/A |
180
- | `--wpds-color-private-primary-bg-fill-dark` | N/A |
181
- | `--wpds-color-private-primary-fg-fill-dark` | N/A |
182
- | `--wpds-color-private-primary-bg-fill-inverted2` | N/A |
183
- | `--wpds-color-private-primary-bg-fill-inverted1` | N/A |
184
- | `--wpds-color-private-primary-fg-fill-inverted` | N/A |
185
- | `--wpds-color-private-primary-surface1` | N/A |
186
- | `--wpds-color-private-info-bg-fill1` | N/A |
187
- | `--wpds-color-private-info-fg-fill` | N/A |
188
- | `--wpds-color-private-info-bg-fill2` | N/A |
189
- | `--wpds-color-private-info-surface2` | N/A |
190
- | `--wpds-color-private-info-surface6` | N/A |
191
- | `--wpds-color-private-info-surface5` | N/A |
192
- | `--wpds-color-private-info-surface4` | N/A |
193
- | `--wpds-color-private-info-surface3` | N/A |
194
- | `--wpds-color-private-info-fg-surface4` | N/A |
195
- | `--wpds-color-private-info-fg-surface3` | N/A |
196
- | `--wpds-color-private-info-fg-surface2` | N/A |
197
- | `--wpds-color-private-info-fg-surface1` | N/A |
198
- | `--wpds-color-private-info-stroke3` | N/A |
199
- | `--wpds-color-private-info-stroke4` | N/A |
200
- | `--wpds-color-private-info-stroke2` | N/A |
201
- | `--wpds-color-private-info-stroke1` | N/A |
202
- | `--wpds-color-private-info-bg-fill-dark` | N/A |
203
- | `--wpds-color-private-info-fg-fill-dark` | N/A |
204
- | `--wpds-color-private-info-bg-fill-inverted2` | N/A |
205
- | `--wpds-color-private-info-bg-fill-inverted1` | N/A |
206
- | `--wpds-color-private-info-fg-fill-inverted` | N/A |
207
- | `--wpds-color-private-info-surface1` | N/A |
208
- | `--wpds-color-private-success-bg-fill1` | N/A |
209
- | `--wpds-color-private-success-fg-fill` | N/A |
210
- | `--wpds-color-private-success-bg-fill2` | N/A |
211
- | `--wpds-color-private-success-surface2` | N/A |
212
- | `--wpds-color-private-success-surface6` | N/A |
213
- | `--wpds-color-private-success-surface5` | N/A |
214
- | `--wpds-color-private-success-surface4` | N/A |
215
- | `--wpds-color-private-success-surface3` | N/A |
216
- | `--wpds-color-private-success-fg-surface4` | N/A |
217
- | `--wpds-color-private-success-fg-surface3` | N/A |
218
- | `--wpds-color-private-success-fg-surface2` | N/A |
219
- | `--wpds-color-private-success-fg-surface1` | N/A |
220
- | `--wpds-color-private-success-stroke3` | N/A |
221
- | `--wpds-color-private-success-stroke4` | N/A |
222
- | `--wpds-color-private-success-stroke2` | N/A |
223
- | `--wpds-color-private-success-stroke1` | N/A |
224
- | `--wpds-color-private-success-bg-fill-dark` | N/A |
225
- | `--wpds-color-private-success-fg-fill-dark` | N/A |
226
- | `--wpds-color-private-success-bg-fill-inverted2` | N/A |
227
- | `--wpds-color-private-success-bg-fill-inverted1` | N/A |
228
- | `--wpds-color-private-success-fg-fill-inverted` | N/A |
229
- | `--wpds-color-private-success-surface1` | N/A |
230
- | `--wpds-color-private-warning-bg-fill1` | N/A |
231
- | `--wpds-color-private-warning-fg-fill` | N/A |
232
- | `--wpds-color-private-warning-bg-fill2` | N/A |
233
- | `--wpds-color-private-warning-surface2` | N/A |
234
- | `--wpds-color-private-warning-surface6` | N/A |
235
- | `--wpds-color-private-warning-surface5` | N/A |
236
- | `--wpds-color-private-warning-surface4` | N/A |
237
- | `--wpds-color-private-warning-surface3` | N/A |
238
- | `--wpds-color-private-warning-fg-surface4` | N/A |
239
- | `--wpds-color-private-warning-fg-surface3` | N/A |
240
- | `--wpds-color-private-warning-fg-surface2` | N/A |
241
- | `--wpds-color-private-warning-fg-surface1` | N/A |
242
- | `--wpds-color-private-warning-stroke3` | N/A |
243
- | `--wpds-color-private-warning-stroke4` | N/A |
244
- | `--wpds-color-private-warning-stroke2` | N/A |
245
- | `--wpds-color-private-warning-stroke1` | N/A |
246
- | `--wpds-color-private-warning-bg-fill-dark` | N/A |
247
- | `--wpds-color-private-warning-fg-fill-dark` | N/A |
248
- | `--wpds-color-private-warning-bg-fill-inverted2` | N/A |
249
- | `--wpds-color-private-warning-bg-fill-inverted1` | N/A |
250
- | `--wpds-color-private-warning-fg-fill-inverted` | N/A |
251
- | `--wpds-color-private-warning-surface1` | N/A |
252
- | `--wpds-color-private-error-bg-fill1` | N/A |
253
- | `--wpds-color-private-error-fg-fill` | N/A |
254
- | `--wpds-color-private-error-bg-fill2` | N/A |
255
- | `--wpds-color-private-error-surface2` | N/A |
256
- | `--wpds-color-private-error-surface6` | N/A |
257
- | `--wpds-color-private-error-surface5` | N/A |
258
- | `--wpds-color-private-error-surface4` | N/A |
259
- | `--wpds-color-private-error-surface3` | N/A |
260
- | `--wpds-color-private-error-fg-surface4` | N/A |
261
- | `--wpds-color-private-error-fg-surface3` | N/A |
262
- | `--wpds-color-private-error-fg-surface2` | N/A |
263
- | `--wpds-color-private-error-fg-surface1` | N/A |
264
- | `--wpds-color-private-error-stroke3` | N/A |
265
- | `--wpds-color-private-error-stroke4` | N/A |
266
- | `--wpds-color-private-error-stroke2` | N/A |
267
- | `--wpds-color-private-error-stroke1` | N/A |
268
- | `--wpds-color-private-error-bg-fill-dark` | N/A |
269
- | `--wpds-color-private-error-fg-fill-dark` | N/A |
270
- | `--wpds-color-private-error-bg-fill-inverted2` | N/A |
271
- | `--wpds-color-private-error-bg-fill-inverted1` | N/A |
272
- | `--wpds-color-private-error-fg-fill-inverted` | N/A |
273
- | `--wpds-color-private-error-surface1` | N/A |
274
- | `--wpds-color-private-bg-surface2` | N/A |
275
- | `--wpds-color-private-bg-bg-fill1` | N/A |
276
- | `--wpds-color-private-bg-fg-fill` | N/A |
277
- | `--wpds-color-private-bg-bg-fill2` | N/A |
278
- | `--wpds-color-private-bg-surface6` | N/A |
279
- | `--wpds-color-private-bg-surface5` | N/A |
280
- | `--wpds-color-private-bg-surface4` | N/A |
281
- | `--wpds-color-private-bg-surface3` | N/A |
282
- | `--wpds-color-private-bg-fg-surface4` | N/A |
283
- | `--wpds-color-private-bg-fg-surface3` | N/A |
284
- | `--wpds-color-private-bg-fg-surface2` | N/A |
285
- | `--wpds-color-private-bg-fg-surface1` | N/A |
286
- | `--wpds-color-private-bg-stroke3` | N/A |
287
- | `--wpds-color-private-bg-stroke4` | N/A |
288
- | `--wpds-color-private-bg-stroke2` | N/A |
289
- | `--wpds-color-private-bg-stroke1` | N/A |
290
- | `--wpds-color-private-bg-bg-fill-dark` | N/A |
291
- | `--wpds-color-private-bg-fg-fill-dark` | N/A |
292
- | `--wpds-color-private-bg-bg-fill-inverted2` | N/A |
293
- | `--wpds-color-private-bg-bg-fill-inverted1` | N/A |
294
- | `--wpds-color-private-bg-fg-fill-inverted` | N/A |
295
- | `--wpds-color-private-bg-surface1` | N/A |
296
- | `--wpds-color-private-caution-bg-fill1` | N/A |
297
- | `--wpds-color-private-caution-fg-fill` | N/A |
298
- | `--wpds-color-private-caution-bg-fill2` | N/A |
299
- | `--wpds-color-private-caution-surface2` | N/A |
300
- | `--wpds-color-private-caution-surface6` | N/A |
301
- | `--wpds-color-private-caution-surface5` | N/A |
302
- | `--wpds-color-private-caution-surface4` | N/A |
303
- | `--wpds-color-private-caution-surface3` | N/A |
304
- | `--wpds-color-private-caution-fg-surface4` | N/A |
305
- | `--wpds-color-private-caution-fg-surface3` | N/A |
306
- | `--wpds-color-private-caution-fg-surface2` | N/A |
307
- | `--wpds-color-private-caution-fg-surface1` | N/A |
308
- | `--wpds-color-private-caution-stroke3` | N/A |
309
- | `--wpds-color-private-caution-stroke4` | N/A |
310
- | `--wpds-color-private-caution-stroke2` | N/A |
311
- | `--wpds-color-private-caution-stroke1` | N/A |
312
- | `--wpds-color-private-caution-bg-fill-dark` | N/A |
313
- | `--wpds-color-private-caution-fg-fill-dark` | N/A |
314
- | `--wpds-color-private-caution-bg-fill-inverted2` | N/A |
315
- | `--wpds-color-private-caution-bg-fill-inverted1` | N/A |
316
- | `--wpds-color-private-caution-fg-fill-inverted` | N/A |
317
- | `--wpds-color-private-caution-surface1` | N/A |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/theme",
3
- "version": "0.1.1-next.2f1c7c01b.0",
3
+ "version": "0.2.1-next.16d95556a.0",
4
4
  "description": "Theme and context provider for the WordPress Design System.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -43,8 +43,8 @@
43
43
  "build-module/color-ramps/lib/register-color-spaces.js"
44
44
  ],
45
45
  "dependencies": {
46
- "@wordpress/element": "^6.34.1-next.2f1c7c01b.0",
47
- "@wordpress/private-apis": "^1.34.1-next.2f1c7c01b.0",
46
+ "@wordpress/element": "^6.35.1-next.16d95556a.0",
47
+ "@wordpress/private-apis": "^1.35.1-next.16d95556a.0",
48
48
  "colorjs.io": "^0.5.2",
49
49
  "memize": "^2.1.0"
50
50
  },
@@ -64,5 +64,5 @@
64
64
  "build": "npm run build:tokens && npm run build:default-ramps",
65
65
  "postbuild": "prettier --write tokens/color.json src/prebuilt src/color-ramps/lib/default-ramps.ts docs"
66
66
  },
67
- "gitHead": "c6ddcdf455bc02567a2c9e03de6862a2061b85e8"
67
+ "gitHead": "59a9383612bbe16e21af84d13b035bfbca7fe833"
68
68
  }
@@ -44,7 +44,7 @@ function getBgRampInfo( ramp: InternalRampResult ): {
44
44
  pinLightness: {
45
45
  stepName: STEP_TO_PIN,
46
46
  value: clampAccentScaleReferenceLightness(
47
- get( parse( ramp.ramp[ STEP_TO_PIN ].color ), [ OKLCH, 'l' ] ),
47
+ get( parse( ramp.ramp[ STEP_TO_PIN ] ), [ OKLCH, 'l' ] ),
48
48
  ramp.direction
49
49
  ),
50
50
  },
@@ -96,8 +96,8 @@ export function checkAccessibleCombinations( {
96
96
  CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
97
97
  for ( const bg of bgs ) {
98
98
  for ( const fg of fgs ) {
99
- const bgColor = parse( ramp.ramp[ bg ].color );
100
- const fgColor = parse( ramp.ramp[ fg ].color );
99
+ const bgColor = parse( ramp.ramp[ bg ] );
100
+ const fgColor = parse( ramp.ramp[ fg ] );
101
101
  if ( getContrast( bgColor, fgColor ) < target ) {
102
102
  unmetTargets.push( {
103
103
  bgName: bg,
@@ -116,8 +116,8 @@ export function checkAccessibleCombinations( {
116
116
  CONTRAST_COMBINATIONS.forEach( ( { bgs, fgs, target } ) => {
117
117
  for ( const bg of bgs ) {
118
118
  for ( const fg of fgs ) {
119
- const bgColor = parse( bgRamp.ramp[ bg ].color );
120
- const fgColor = parse( ramp.ramp[ fg ].color );
119
+ const bgColor = parse( bgRamp.ramp[ bg ] );
120
+ const fgColor = parse( ramp.ramp[ fg ] );
121
121
  if ( getContrast( bgColor, fgColor ) < target ) {
122
122
  unmetTargets.push( {
123
123
  bgName: bg,
@@ -12,9 +12,11 @@ import type { Ramp } from './types';
12
12
  export const WHITE = to( 'white', OKLCH );
13
13
  export const BLACK = to( 'black', OKLCH );
14
14
 
15
- // Margin added to target contrasts to counter for algorithm approximations
16
- // and rounding errors.
17
- export const UNIVERSAL_CONTRAST_TOPUP = 0.05;
15
+ // Margin added to target contrasts to counter for algorithm approximations and rounding errors.
16
+ // - the `CONTRAST_EPSILON` value is 0.004, so the real contrast can be lower by this amount.
17
+ // - the max contrast between adjacent RGB values is 1.016, so half of the difference (0.008) can be rounding error.
18
+ // - the sum is 0.012: the margin we add to ensure that the target contrast is met after all the rounding.
19
+ export const UNIVERSAL_CONTRAST_TOPUP = 0.012;
18
20
 
19
21
  // When enabling "lighter direction" bias, this is the amount by which
20
22
  // black text contrast needs to be greater than white text contrast.
@@ -33,8 +35,8 @@ export const ACCENT_SCALE_BASE_LIGHTNESS_THRESHOLDS = {
33
35
  darker: { min: 0.75, max: 0.98 },
34
36
  } as const;
35
37
 
36
- // Lightness precision we aim for. Approximately 1/256, resolution of an 8-bit number.
37
- export const LIGHTNESS_EPSILON = 4e-3;
38
+ // Contrast precision we aim for. Approximately 1/256, resolution of an 8-bit number.
39
+ export const CONTRAST_EPSILON = 4e-3;
38
40
 
39
41
  export const MAX_BISECTION_ITERATIONS = 10;
40
42
 
@@ -10,190 +10,190 @@ export const DEFAULT_RAMPS: Record<
10
10
  > = {
11
11
  bg: {
12
12
  ramp: {
13
- surface2: { color: '#f8f8f8', warning: false },
14
- bgFill1: { color: '#555', warning: false },
15
- fgFill: { color: '#f0f0f0', warning: false },
16
- bgFill2: { color: '#474747', warning: false },
17
- surface6: { color: '#d0d0d0', warning: false },
18
- surface5: { color: '#dfdfdf', warning: false },
19
- surface4: { color: '#eaeaea', warning: false },
20
- surface3: { color: '#fff', warning: false },
21
- fgSurface4: { color: '#1e1e1e', warning: false },
22
- fgSurface3: { color: '#6d6d6d', warning: false },
23
- fgSurface2: { color: '#898989', warning: false },
24
- fgSurface1: { color: '#a9a9a9', warning: false },
25
- stroke3: { color: '#898989', warning: false },
26
- stroke4: { color: '#6a6a6a', warning: false },
27
- stroke2: { color: '#adadad', warning: false },
28
- stroke1: { color: '#d0d0d0', warning: false },
29
- bgFillDark: { color: '#1e1e1e', warning: false },
30
- fgFillDark: { color: '#f0f0f0', warning: false },
31
- bgFillInverted2: { color: '#1e1e1e', warning: false },
32
- bgFillInverted1: { color: '#2f2f2f', warning: false },
33
- fgFillInverted: { color: '#f0f0f0', warning: false },
34
- surface1: { color: '#f0f0f0', warning: false },
13
+ surface2: '#f8f8f8',
14
+ bgFill1: '#555',
15
+ fgFill: '#f0f0f0',
16
+ bgFill2: '#494949',
17
+ surface6: '#d3d3d3',
18
+ surface5: '#e3e3e3',
19
+ surface4: '#eaeaea',
20
+ surface3: '#fff',
21
+ fgSurface4: '#1e1e1e',
22
+ fgSurface3: '#6e6e6e',
23
+ fgSurface2: '#8b8b8b',
24
+ fgSurface1: '#ababab',
25
+ stroke3: '#8b8b8b',
26
+ stroke4: '#6d6d6d',
27
+ stroke2: '#adadad',
28
+ stroke1: '#cfcfcf',
29
+ bgFillDark: '#1e1e1e',
30
+ fgFillDark: '#f0f0f0',
31
+ bgFillInverted2: '#1e1e1e',
32
+ bgFillInverted1: '#2d2d2d',
33
+ fgFillInverted: '#f0f0f0',
34
+ surface1: '#f0f0f0',
35
35
  },
36
36
  direction: 'darker',
37
37
  },
38
38
  primary: {
39
39
  ramp: {
40
- bgFill1: { color: '#3858e9', warning: false },
41
- fgFill: { color: '#eff0f2', warning: false },
42
- bgFill2: { color: '#2c47d7', warning: false },
43
- surface2: { color: '#f6f8fc', warning: false },
44
- surface6: { color: '#c4d0ee', warning: false },
45
- surface5: { color: '#d8e0f3', warning: false },
46
- surface4: { color: '#e5eaf7', warning: false },
47
- surface3: { color: '#fff', warning: false },
48
- fgSurface4: { color: '#080071', warning: false },
49
- fgSurface3: { color: '#3858e9', warning: false },
50
- fgSurface2: { color: '#5780ff', warning: false },
51
- fgSurface1: { color: '#81a7ff', warning: false },
52
- stroke3: { color: '#3858e9', warning: false },
53
- stroke4: { color: '#2236c7', warning: false },
54
- stroke2: { color: '#6f85c0', warning: false },
55
- stroke1: { color: '#92a4cf', warning: false },
56
- bgFillDark: { color: '#1b1e26', warning: false },
57
- fgFillDark: { color: '#eff0f2', warning: false },
58
- bgFillInverted2: { color: '#1b1e26', warning: false },
59
- bgFillInverted1: { color: '#1401a4', warning: false },
60
- fgFillInverted: { color: '#eff0f2', warning: false },
61
- surface1: { color: '#ecf0f9', warning: false },
40
+ bgFill1: '#3858e9',
41
+ fgFill: '#eff0f2',
42
+ bgFill2: '#2e49da',
43
+ surface2: '#f6f8fc',
44
+ surface6: '#c7d3ef',
45
+ surface5: '#dce3f5',
46
+ surface4: '#e5ebf7',
47
+ surface3: '#fff',
48
+ fgSurface4: '#080071',
49
+ fgSurface3: '#3858e9',
50
+ fgSurface2: '#5881ff',
51
+ fgSurface1: '#84a9ff',
52
+ stroke3: '#3858e9',
53
+ stroke4: '#2337c8',
54
+ stroke2: '#6d83bf',
55
+ stroke1: '#91a2cf',
56
+ bgFillDark: '#1b1e26',
57
+ fgFillDark: '#eff0f2',
58
+ bgFillInverted2: '#1b1e26',
59
+ bgFillInverted1: '#12009f',
60
+ fgFillInverted: '#eff0f2',
61
+ surface1: '#edf0fa',
62
62
  },
63
63
  direction: 'darker',
64
64
  },
65
65
  info: {
66
66
  ramp: {
67
- bgFill1: { color: '#0090ff', warning: false },
68
- fgFill: { color: '#1b1e23', warning: false },
69
- bgFill2: { color: '#007eec', warning: false },
70
- surface2: { color: '#f5f9fd', warning: false },
71
- surface6: { color: '#bad3f0', warning: false },
72
- surface5: { color: '#d1e1f5', warning: false },
73
- surface4: { color: '#e1ecf8', warning: false },
74
- surface3: { color: '#fff', warning: false },
75
- fgSurface4: { color: '#001758', warning: false },
76
- fgSurface3: { color: '#006cd8', warning: false },
77
- fgSurface2: { color: '#008bfa', warning: false },
78
- fgSurface1: { color: '#4dafff', warning: false },
79
- stroke3: { color: '#006cd8', warning: false },
80
- stroke4: { color: '#004bb5', warning: false },
81
- stroke2: { color: '#5e90c7', warning: false },
82
- stroke1: { color: '#8baed6', warning: false },
83
- bgFillDark: { color: '#1b1e23', warning: false },
84
- fgFillDark: { color: '#eff0f2', warning: false },
85
- bgFillInverted2: { color: '#1b1e23', warning: false },
86
- bgFillInverted1: { color: '#00297a', warning: false },
87
- fgFillInverted: { color: '#eff0f2', warning: false },
88
- surface1: { color: '#e9f1fa', warning: false },
67
+ bgFill1: '#0090ff',
68
+ fgFill: '#1b1e23',
69
+ bgFill2: '#0081ef',
70
+ surface2: '#f5f9fd',
71
+ surface6: '#bed6f1',
72
+ surface5: '#d5e5f6',
73
+ surface4: '#e0ebf8',
74
+ surface3: '#fff',
75
+ fgSurface4: '#001758',
76
+ fgSurface3: '#006dd9',
77
+ fgSurface2: '#008cfb',
78
+ fgSurface1: '#53b1ff',
79
+ stroke3: '#006dd9',
80
+ stroke4: '#004eb8',
81
+ stroke2: '#5d8fc6',
82
+ stroke1: '#8aaed6',
83
+ bgFillDark: '#1b1e23',
84
+ fgFillDark: '#eff0f2',
85
+ bgFillInverted2: '#1b1e23',
86
+ bgFillInverted1: '#002675',
87
+ fgFillInverted: '#eff0f2',
88
+ surface1: '#eaf1fa',
89
89
  },
90
90
  direction: 'darker',
91
91
  },
92
92
  success: {
93
93
  ramp: {
94
- bgFill1: { color: '#4ab866', warning: false },
95
- fgFill: { color: '#1b1f1c', warning: false },
96
- bgFill2: { color: '#34a554', warning: false },
97
- surface2: { color: '#f0fcf2', warning: false },
98
- surface6: { color: '#7be792', warning: false },
99
- surface5: { color: '#acf0b7', warning: false },
100
- surface4: { color: '#cdf5d3', warning: false },
101
- surface3: { color: '#fff', warning: false },
102
- fgSurface4: { color: '#002b00', warning: false },
103
- fgSurface3: { color: '#008030', warning: false },
104
- fgSurface2: { color: '#2a9e4d', warning: false },
105
- fgSurface1: { color: '#52bf6d', warning: false },
106
- stroke3: { color: '#008030', warning: false },
107
- stroke4: { color: '#006113', warning: false },
108
- stroke2: { color: '#62996c', warning: false },
109
- stroke1: { color: '#78ba84', warning: false },
110
- bgFillDark: { color: '#1b1f1c', warning: false },
111
- fgFillDark: { color: '#edf2ed', warning: false },
112
- bgFillInverted2: { color: '#1b1f1c', warning: false },
113
- bgFillInverted1: { color: '#003a00', warning: false },
114
- fgFillInverted: { color: '#edf2ed', warning: false },
115
- surface1: { color: '#ddf8e0', warning: false },
94
+ bgFill1: '#4ab866',
95
+ fgFill: '#1b1f1c',
96
+ bgFill2: '#37a857',
97
+ surface2: '#f0fcf2',
98
+ surface6: '#7eea95',
99
+ surface5: '#b7f2c1',
100
+ surface4: '#cdf5d3',
101
+ surface3: '#fff',
102
+ fgSurface4: '#002b00',
103
+ fgSurface3: '#008031',
104
+ fgSurface2: '#2c9f4e',
105
+ fgSurface1: '#54c16f',
106
+ stroke3: '#008031',
107
+ stroke4: '#006314',
108
+ stroke2: '#61986b',
109
+ stroke1: '#77ba84',
110
+ bgFillDark: '#1b1f1c',
111
+ fgFillDark: '#edf2ed',
112
+ bgFillInverted2: '#1b1f1c',
113
+ bgFillInverted1: '#003800',
114
+ fgFillInverted: '#edf2ed',
115
+ surface1: '#ddf8e1',
116
116
  },
117
117
  direction: 'darker',
118
118
  },
119
119
  caution: {
120
120
  ramp: {
121
- bgFill1: { color: '#f0d149', warning: false },
122
- fgFill: { color: '#1f1e1b', warning: false },
123
- bgFill2: { color: '#dabb2b', warning: false },
124
- surface2: { color: '#fdf9e7', warning: false },
125
- surface6: { color: '#e7d070', warning: false },
126
- surface5: { color: '#f4e08c', warning: false },
127
- surface4: { color: '#f8ebb6', warning: false },
128
- surface3: { color: '#fff', warning: false },
129
- fgSurface4: { color: '#291d00', warning: false },
130
- fgSurface3: { color: '#866a00', warning: false },
131
- fgSurface2: { color: '#a58700', warning: false },
132
- fgSurface1: { color: '#c6a800', warning: false },
133
- stroke3: { color: '#866a00', warning: false },
134
- stroke4: { color: '#644e00', warning: false },
135
- stroke2: { color: '#988d60', warning: false },
136
- stroke1: { color: '#b8ab76', warning: false },
137
- bgFillDark: { color: '#1f1e1b', warning: false },
138
- fgFillDark: { color: '#f6f1da', warning: false },
139
- bgFillInverted2: { color: '#1f1e1b', warning: false },
140
- bgFillInverted1: { color: '#3d2d00', warning: false },
141
- fgFillInverted: { color: '#f6f1da', warning: false },
142
- surface1: { color: '#faf1cb', warning: false },
121
+ bgFill1: '#f0d149',
122
+ fgFill: '#1f1e1b',
123
+ bgFill2: '#ddbe30',
124
+ surface2: '#fdf9e7',
125
+ surface6: '#ecd367',
126
+ surface5: '#f5e399',
127
+ surface4: '#f8ebb5',
128
+ surface3: '#fff',
129
+ fgSurface4: '#291d00',
130
+ fgSurface3: '#876b00',
131
+ fgSurface2: '#a78900',
132
+ fgSurface1: '#c9aa00',
133
+ stroke3: '#876b00',
134
+ stroke4: '#675000',
135
+ stroke2: '#978c60',
136
+ stroke1: '#b8ab75',
137
+ bgFillDark: '#1f1e1b',
138
+ fgFillDark: '#f6f1da',
139
+ bgFillInverted2: '#1f1e1b',
140
+ bgFillInverted1: '#3a2b00',
141
+ fgFillInverted: '#f6f1da',
142
+ surface1: '#faf1cd',
143
143
  },
144
144
  direction: 'darker',
145
145
  },
146
146
  warning: {
147
147
  ramp: {
148
- bgFill1: { color: '#f0b849', warning: false },
149
- fgFill: { color: '#1f1e1b', warning: false },
150
- bgFill2: { color: '#dba430', warning: false },
151
- surface2: { color: '#fdf7ee', warning: false },
152
- surface6: { color: '#f0cb89', warning: false },
153
- surface5: { color: '#f5ddb2', warning: false },
154
- surface4: { color: '#f8e9cd', warning: false },
155
- surface3: { color: '#fff', warning: false },
156
- fgSurface4: { color: '#2f1800', warning: false },
157
- fgSurface3: { color: '#966200', warning: false },
158
- fgSurface2: { color: '#b58000', warning: false },
159
- fgSurface1: { color: '#d7a02b', warning: false },
160
- stroke3: { color: '#966200', warning: false },
161
- stroke4: { color: '#724700', warning: false },
162
- stroke2: { color: '#a08961', warning: false },
163
- stroke1: { color: '#c2a777', warning: false },
164
- bgFillDark: { color: '#1f1e1b', warning: false },
165
- fgFillDark: { color: '#f3f0e9', warning: false },
166
- bgFillInverted2: { color: '#1f1e1b', warning: false },
167
- bgFillInverted1: { color: '#472900', warning: false },
168
- fgFillInverted: { color: '#f3f0e9', warning: false },
169
- surface1: { color: '#faefdb', warning: false },
148
+ bgFill1: '#f0b849',
149
+ fgFill: '#1f1e1b',
150
+ bgFill2: '#dea633',
151
+ surface2: '#fdf7ee',
152
+ surface6: '#f1ce90',
153
+ surface5: '#f6e0bb',
154
+ surface4: '#f8e9cd',
155
+ surface3: '#fff',
156
+ fgSurface4: '#2f1800',
157
+ fgSurface3: '#976300',
158
+ fgSurface2: '#b78100',
159
+ fgSurface1: '#d9a22e',
160
+ stroke3: '#976300',
161
+ stroke4: '#754900',
162
+ stroke2: '#9f8860',
163
+ stroke1: '#c2a776',
164
+ bgFillDark: '#1f1e1b',
165
+ fgFillDark: '#f3f0e9',
166
+ bgFillInverted2: '#1f1e1b',
167
+ bgFillInverted1: '#432600',
168
+ fgFillInverted: '#f3f0e9',
169
+ surface1: '#faefdc',
170
170
  },
171
171
  direction: 'darker',
172
172
  },
173
173
  error: {
174
174
  ramp: {
175
- bgFill1: { color: '#cc1818', warning: false },
176
- fgFill: { color: '#f2efef', warning: false },
177
- bgFill2: { color: '#b90000', warning: false },
178
- surface2: { color: '#fdf6f5', warning: false },
179
- surface6: { color: '#f5c5be', warning: false },
180
- surface5: { color: '#f8d8d3', warning: false },
181
- surface4: { color: '#fae6e2', warning: false },
182
- surface3: { color: '#fff', warning: false },
183
- fgSurface4: { color: '#4a0000', warning: false },
184
- fgSurface3: { color: '#cc1818', warning: false },
185
- fgSurface2: { color: '#f64b40', warning: false },
186
- fgSurface1: { color: '#ff8070', warning: false },
187
- stroke3: { color: '#cc1818', warning: false },
188
- stroke4: { color: '#a40000', warning: false },
189
- stroke2: { color: '#cd695d', warning: false },
190
- stroke1: { color: '#dc9085', warning: false },
191
- bgFillDark: { color: '#231c1b', warning: false },
192
- fgFillDark: { color: '#f2efef', warning: false },
193
- bgFillInverted2: { color: '#231c1b', warning: false },
194
- bgFillInverted1: { color: '#6d0000', warning: false },
195
- fgFillInverted: { color: '#f2efef', warning: false },
196
- surface1: { color: '#fcecea', warning: false },
175
+ bgFill1: '#cc1818',
176
+ fgFill: '#f2efef',
177
+ bgFill2: '#bc0001',
178
+ surface2: '#fdf6f5',
179
+ surface6: '#f5c9c2',
180
+ surface5: '#f9dcd8',
181
+ surface4: '#fae5e2',
182
+ surface3: '#fff',
183
+ fgSurface4: '#4a0000',
184
+ fgSurface3: '#cc1818',
185
+ fgSurface2: '#f84d41',
186
+ fgSurface1: '#ff8373',
187
+ stroke3: '#cc1818',
188
+ stroke4: '#a70000',
189
+ stroke2: '#ca675c',
190
+ stroke1: '#dc8e83',
191
+ bgFillDark: '#231c1b',
192
+ fgFillDark: '#f2efef',
193
+ bgFillInverted2: '#231c1b',
194
+ bgFillInverted1: '#680000',
195
+ fgFillInverted: '#f2efef',
196
+ surface1: '#fcedea',
197
197
  },
198
198
  direction: 'darker',
199
199
  },