@wordpress/theme 0.1.0 → 0.1.1-next.2f1c7c01b.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 (142) hide show
  1. package/README.md +69 -9
  2. package/bin/generate-default-ramps/index.ts +49 -0
  3. package/bin/generate-primitive-tokens/index.ts +14 -9
  4. package/bin/terrazzo-plugin-figma-ds-token-manager/index.ts +11 -4
  5. package/build/color-ramps/index.js +21 -39
  6. package/build/color-ramps/index.js.map +3 -3
  7. package/build/color-ramps/lib/color-utils.js +39 -0
  8. package/build/color-ramps/lib/color-utils.js.map +7 -0
  9. package/build/color-ramps/lib/constants.js +18 -25
  10. package/build/color-ramps/lib/constants.js.map +3 -3
  11. package/build/color-ramps/lib/default-ramps.js +220 -0
  12. package/build/color-ramps/lib/default-ramps.js.map +7 -0
  13. package/build/color-ramps/lib/find-color-with-constraints.js +57 -71
  14. package/build/color-ramps/lib/find-color-with-constraints.js.map +3 -3
  15. package/build/color-ramps/lib/index.js +25 -68
  16. package/build/color-ramps/lib/index.js.map +3 -3
  17. package/build/color-ramps/lib/ramp-configs.js +12 -11
  18. package/build/color-ramps/lib/ramp-configs.js.map +1 -1
  19. package/build/color-ramps/lib/register-color-spaces.js +7 -0
  20. package/build/color-ramps/lib/register-color-spaces.js.map +7 -0
  21. package/build/color-ramps/lib/taper-chroma.js +35 -27
  22. package/build/color-ramps/lib/taper-chroma.js.map +3 -3
  23. package/build/color-ramps/lib/types.js +2 -1
  24. package/build/color-ramps/lib/types.js.map +1 -1
  25. package/build/color-ramps/lib/utils.js +12 -9
  26. package/build/color-ramps/lib/utils.js.map +2 -2
  27. package/build/context.js +3 -2
  28. package/build/context.js.map +1 -1
  29. package/build/index.js +2 -1
  30. package/build/index.js.map +1 -1
  31. package/build/lock-unlock.js +3 -2
  32. package/build/lock-unlock.js.map +1 -1
  33. package/build/prebuilt/js/design-tokens.js +14 -1
  34. package/build/prebuilt/js/design-tokens.js.map +2 -2
  35. package/build/prebuilt/json/figma.json +214 -32
  36. package/build/prebuilt/ts/design-tokens.js +38 -1
  37. package/build/prebuilt/ts/design-tokens.js.map +2 -2
  38. package/build/private-apis.js +3 -2
  39. package/build/private-apis.js.map +1 -1
  40. package/build/theme-provider.js +19 -17
  41. package/build/theme-provider.js.map +4 -4
  42. package/build/types/css-modules.d.js +0 -1
  43. package/build/types.js +2 -1
  44. package/build/types.js.map +1 -1
  45. package/build/use-theme-provider-styles.js +50 -36
  46. package/build/use-theme-provider-styles.js.map +3 -3
  47. package/build-module/color-ramps/index.js +20 -28
  48. package/build-module/color-ramps/index.js.map +2 -2
  49. package/build-module/color-ramps/lib/color-utils.js +19 -0
  50. package/build-module/color-ramps/lib/color-utils.js.map +7 -0
  51. package/build-module/color-ramps/lib/constants.js +13 -10
  52. package/build-module/color-ramps/lib/constants.js.map +2 -2
  53. package/build-module/color-ramps/lib/default-ramps.js +196 -0
  54. package/build-module/color-ramps/lib/default-ramps.js.map +7 -0
  55. package/build-module/color-ramps/lib/find-color-with-constraints.js +56 -60
  56. package/build-module/color-ramps/lib/find-color-with-constraints.js.map +2 -2
  57. package/build-module/color-ramps/lib/index.js +28 -55
  58. package/build-module/color-ramps/lib/index.js.map +3 -3
  59. package/build-module/color-ramps/lib/ramp-configs.js +11 -10
  60. package/build-module/color-ramps/lib/ramp-configs.js.map +1 -1
  61. package/build-module/color-ramps/lib/register-color-spaces.js +7 -0
  62. package/build-module/color-ramps/lib/register-color-spaces.js.map +7 -0
  63. package/build-module/color-ramps/lib/taper-chroma.js +40 -16
  64. package/build-module/color-ramps/lib/taper-chroma.js.map +2 -2
  65. package/build-module/color-ramps/lib/utils.js +7 -4
  66. package/build-module/color-ramps/lib/utils.js.map +2 -2
  67. package/build-module/context.js +2 -1
  68. package/build-module/context.js.map +1 -1
  69. package/build-module/index.js +1 -0
  70. package/build-module/index.js.map +1 -1
  71. package/build-module/lock-unlock.js +2 -1
  72. package/build-module/lock-unlock.js.map +1 -1
  73. package/build-module/prebuilt/js/design-tokens.js +13 -0
  74. package/build-module/prebuilt/js/design-tokens.js.map +2 -2
  75. package/build-module/prebuilt/json/figma.json +214 -32
  76. package/build-module/prebuilt/ts/design-tokens.js +37 -0
  77. package/build-module/prebuilt/ts/design-tokens.js.map +2 -2
  78. package/build-module/private-apis.js +2 -1
  79. package/build-module/private-apis.js.map +1 -1
  80. package/build-module/theme-provider.js +18 -6
  81. package/build-module/theme-provider.js.map +3 -3
  82. package/build-module/use-theme-provider-styles.js +52 -31
  83. package/build-module/use-theme-provider-styles.js.map +2 -2
  84. package/build-types/color-ramps/index.d.ts +9 -16
  85. package/build-types/color-ramps/index.d.ts.map +1 -1
  86. package/build-types/color-ramps/lib/color-utils.d.ts +22 -0
  87. package/build-types/color-ramps/lib/color-utils.d.ts.map +1 -0
  88. package/build-types/color-ramps/lib/constants.d.ts +6 -8
  89. package/build-types/color-ramps/lib/constants.d.ts.map +1 -1
  90. package/build-types/color-ramps/lib/default-ramps.d.ts +7 -0
  91. package/build-types/color-ramps/lib/default-ramps.d.ts.map +1 -0
  92. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts +7 -5
  93. package/build-types/color-ramps/lib/find-color-with-constraints.d.ts.map +1 -1
  94. package/build-types/color-ramps/lib/index.d.ts +5 -2
  95. package/build-types/color-ramps/lib/index.d.ts.map +1 -1
  96. package/build-types/color-ramps/lib/register-color-spaces.d.ts +2 -0
  97. package/build-types/color-ramps/lib/register-color-spaces.d.ts.map +1 -0
  98. package/build-types/color-ramps/lib/taper-chroma.d.ts +7 -3
  99. package/build-types/color-ramps/lib/taper-chroma.d.ts.map +1 -1
  100. package/build-types/color-ramps/lib/utils.d.ts +7 -3
  101. package/build-types/color-ramps/lib/utils.d.ts.map +1 -1
  102. package/build-types/color-ramps/stories/index.story.d.ts.map +1 -1
  103. package/build-types/prebuilt/ts/design-tokens.d.ts.map +1 -1
  104. package/build-types/use-theme-provider-styles.d.ts +4 -0
  105. package/build-types/use-theme-provider-styles.d.ts.map +1 -1
  106. package/docs/ds-tokens.md +34 -0
  107. package/package.json +19 -9
  108. package/src/color-ramps/index.ts +24 -41
  109. package/src/color-ramps/lib/color-utils.ts +34 -0
  110. package/src/color-ramps/lib/constants.ts +8 -6
  111. package/src/color-ramps/lib/default-ramps.ts +200 -0
  112. package/src/color-ramps/lib/find-color-with-constraints.ts +70 -79
  113. package/src/color-ramps/lib/index.ts +27 -61
  114. package/src/color-ramps/lib/register-color-spaces.ts +13 -0
  115. package/src/color-ramps/lib/taper-chroma.ts +47 -19
  116. package/src/color-ramps/lib/utils.ts +8 -9
  117. package/src/color-ramps/stories/index.story.tsx +16 -22
  118. package/src/color-ramps/test/__snapshots__/index.test.ts.snap +96 -96
  119. package/src/color-ramps/test/index.test.ts +27 -15
  120. package/src/prebuilt/css/design-tokens.css +90 -32
  121. package/src/prebuilt/js/design-tokens.js +12 -0
  122. package/src/prebuilt/json/figma.json +214 -32
  123. package/src/prebuilt/ts/design-tokens.ts +36 -0
  124. package/src/use-theme-provider-styles.ts +47 -25
  125. package/tokens/color.json +184 -32
  126. package/tsconfig.bin.json +13 -0
  127. package/tsconfig.bin.tsbuildinfo +1 -0
  128. package/tsconfig.json +6 -4
  129. package/tsconfig.src.json +9 -0
  130. package/tsconfig.src.tsbuildinfo +1 -0
  131. package/bin/build-tokens.js +0 -83
  132. package/build/color-ramps/lib/cache-utils.js +0 -57
  133. package/build/color-ramps/lib/cache-utils.js.map +0 -7
  134. package/build/style.module.css.js +0 -2
  135. package/build-module/color-ramps/lib/cache-utils.js +0 -31
  136. package/build-module/color-ramps/lib/cache-utils.js.map +0 -7
  137. package/build-module/style.module.css.js +0 -1
  138. package/build-style/style.css +0 -3
  139. package/build-types/color-ramps/lib/cache-utils.d.ts +0 -22
  140. package/build-types/color-ramps/lib/cache-utils.d.ts.map +0 -1
  141. package/src/color-ramps/lib/cache-utils.ts +0 -56
  142. package/tsconfig.tsbuildinfo +0 -1
@@ -0,0 +1,196 @@
1
+ // packages/theme/src/color-ramps/lib/default-ramps.ts
2
+ var DEFAULT_RAMPS = {
3
+ bg: {
4
+ ramp: {
5
+ surface2: { color: "#f8f8f8", warning: false },
6
+ bgFill1: { color: "#555", warning: false },
7
+ fgFill: { color: "#f0f0f0", warning: false },
8
+ bgFill2: { color: "#474747", warning: false },
9
+ surface6: { color: "#d0d0d0", warning: false },
10
+ surface5: { color: "#dfdfdf", warning: false },
11
+ surface4: { color: "#eaeaea", warning: false },
12
+ surface3: { color: "#fff", warning: false },
13
+ fgSurface4: { color: "#1e1e1e", warning: false },
14
+ fgSurface3: { color: "#6d6d6d", warning: false },
15
+ fgSurface2: { color: "#898989", warning: false },
16
+ fgSurface1: { color: "#a9a9a9", warning: false },
17
+ stroke3: { color: "#898989", warning: false },
18
+ stroke4: { color: "#6a6a6a", warning: false },
19
+ stroke2: { color: "#adadad", warning: false },
20
+ stroke1: { color: "#d0d0d0", warning: false },
21
+ bgFillDark: { color: "#1e1e1e", warning: false },
22
+ fgFillDark: { color: "#f0f0f0", warning: false },
23
+ bgFillInverted2: { color: "#1e1e1e", warning: false },
24
+ bgFillInverted1: { color: "#2f2f2f", warning: false },
25
+ fgFillInverted: { color: "#f0f0f0", warning: false },
26
+ surface1: { color: "#f0f0f0", warning: false }
27
+ },
28
+ direction: "darker"
29
+ },
30
+ primary: {
31
+ ramp: {
32
+ bgFill1: { color: "#3858e9", warning: false },
33
+ fgFill: { color: "#eff0f2", warning: false },
34
+ bgFill2: { color: "#2c47d7", warning: false },
35
+ surface2: { color: "#f6f8fc", warning: false },
36
+ surface6: { color: "#c4d0ee", warning: false },
37
+ surface5: { color: "#d8e0f3", warning: false },
38
+ surface4: { color: "#e5eaf7", warning: false },
39
+ surface3: { color: "#fff", warning: false },
40
+ fgSurface4: { color: "#080071", warning: false },
41
+ fgSurface3: { color: "#3858e9", warning: false },
42
+ fgSurface2: { color: "#5780ff", warning: false },
43
+ fgSurface1: { color: "#81a7ff", warning: false },
44
+ stroke3: { color: "#3858e9", warning: false },
45
+ stroke4: { color: "#2236c7", warning: false },
46
+ stroke2: { color: "#6f85c0", warning: false },
47
+ stroke1: { color: "#92a4cf", warning: false },
48
+ bgFillDark: { color: "#1b1e26", warning: false },
49
+ fgFillDark: { color: "#eff0f2", warning: false },
50
+ bgFillInverted2: { color: "#1b1e26", warning: false },
51
+ bgFillInverted1: { color: "#1401a4", warning: false },
52
+ fgFillInverted: { color: "#eff0f2", warning: false },
53
+ surface1: { color: "#ecf0f9", warning: false }
54
+ },
55
+ direction: "darker"
56
+ },
57
+ info: {
58
+ ramp: {
59
+ bgFill1: { color: "#0090ff", warning: false },
60
+ fgFill: { color: "#1b1e23", warning: false },
61
+ bgFill2: { color: "#007eec", warning: false },
62
+ surface2: { color: "#f5f9fd", warning: false },
63
+ surface6: { color: "#bad3f0", warning: false },
64
+ surface5: { color: "#d1e1f5", warning: false },
65
+ surface4: { color: "#e1ecf8", warning: false },
66
+ surface3: { color: "#fff", warning: false },
67
+ fgSurface4: { color: "#001758", warning: false },
68
+ fgSurface3: { color: "#006cd8", warning: false },
69
+ fgSurface2: { color: "#008bfa", warning: false },
70
+ fgSurface1: { color: "#4dafff", warning: false },
71
+ stroke3: { color: "#006cd8", warning: false },
72
+ stroke4: { color: "#004bb5", warning: false },
73
+ stroke2: { color: "#5e90c7", warning: false },
74
+ stroke1: { color: "#8baed6", warning: false },
75
+ bgFillDark: { color: "#1b1e23", warning: false },
76
+ fgFillDark: { color: "#eff0f2", warning: false },
77
+ bgFillInverted2: { color: "#1b1e23", warning: false },
78
+ bgFillInverted1: { color: "#00297a", warning: false },
79
+ fgFillInverted: { color: "#eff0f2", warning: false },
80
+ surface1: { color: "#e9f1fa", warning: false }
81
+ },
82
+ direction: "darker"
83
+ },
84
+ success: {
85
+ ramp: {
86
+ bgFill1: { color: "#4ab866", warning: false },
87
+ fgFill: { color: "#1b1f1c", warning: false },
88
+ bgFill2: { color: "#34a554", warning: false },
89
+ surface2: { color: "#f0fcf2", warning: false },
90
+ surface6: { color: "#7be792", warning: false },
91
+ surface5: { color: "#acf0b7", warning: false },
92
+ surface4: { color: "#cdf5d3", warning: false },
93
+ surface3: { color: "#fff", warning: false },
94
+ fgSurface4: { color: "#002b00", warning: false },
95
+ fgSurface3: { color: "#008030", warning: false },
96
+ fgSurface2: { color: "#2a9e4d", warning: false },
97
+ fgSurface1: { color: "#52bf6d", warning: false },
98
+ stroke3: { color: "#008030", warning: false },
99
+ stroke4: { color: "#006113", warning: false },
100
+ stroke2: { color: "#62996c", warning: false },
101
+ stroke1: { color: "#78ba84", warning: false },
102
+ bgFillDark: { color: "#1b1f1c", warning: false },
103
+ fgFillDark: { color: "#edf2ed", warning: false },
104
+ bgFillInverted2: { color: "#1b1f1c", warning: false },
105
+ bgFillInverted1: { color: "#003a00", warning: false },
106
+ fgFillInverted: { color: "#edf2ed", warning: false },
107
+ surface1: { color: "#ddf8e0", warning: false }
108
+ },
109
+ direction: "darker"
110
+ },
111
+ caution: {
112
+ ramp: {
113
+ bgFill1: { color: "#f0d149", warning: false },
114
+ fgFill: { color: "#1f1e1b", warning: false },
115
+ bgFill2: { color: "#dabb2b", warning: false },
116
+ surface2: { color: "#fdf9e7", warning: false },
117
+ surface6: { color: "#e7d070", warning: false },
118
+ surface5: { color: "#f4e08c", warning: false },
119
+ surface4: { color: "#f8ebb6", warning: false },
120
+ surface3: { color: "#fff", warning: false },
121
+ fgSurface4: { color: "#291d00", warning: false },
122
+ fgSurface3: { color: "#866a00", warning: false },
123
+ fgSurface2: { color: "#a58700", warning: false },
124
+ fgSurface1: { color: "#c6a800", warning: false },
125
+ stroke3: { color: "#866a00", warning: false },
126
+ stroke4: { color: "#644e00", warning: false },
127
+ stroke2: { color: "#988d60", warning: false },
128
+ stroke1: { color: "#b8ab76", warning: false },
129
+ bgFillDark: { color: "#1f1e1b", warning: false },
130
+ fgFillDark: { color: "#f6f1da", warning: false },
131
+ bgFillInverted2: { color: "#1f1e1b", warning: false },
132
+ bgFillInverted1: { color: "#3d2d00", warning: false },
133
+ fgFillInverted: { color: "#f6f1da", warning: false },
134
+ surface1: { color: "#faf1cb", warning: false }
135
+ },
136
+ direction: "darker"
137
+ },
138
+ warning: {
139
+ ramp: {
140
+ bgFill1: { color: "#f0b849", warning: false },
141
+ fgFill: { color: "#1f1e1b", warning: false },
142
+ bgFill2: { color: "#dba430", warning: false },
143
+ surface2: { color: "#fdf7ee", warning: false },
144
+ surface6: { color: "#f0cb89", warning: false },
145
+ surface5: { color: "#f5ddb2", warning: false },
146
+ surface4: { color: "#f8e9cd", warning: false },
147
+ surface3: { color: "#fff", warning: false },
148
+ fgSurface4: { color: "#2f1800", warning: false },
149
+ fgSurface3: { color: "#966200", warning: false },
150
+ fgSurface2: { color: "#b58000", warning: false },
151
+ fgSurface1: { color: "#d7a02b", warning: false },
152
+ stroke3: { color: "#966200", warning: false },
153
+ stroke4: { color: "#724700", warning: false },
154
+ stroke2: { color: "#a08961", warning: false },
155
+ stroke1: { color: "#c2a777", warning: false },
156
+ bgFillDark: { color: "#1f1e1b", warning: false },
157
+ fgFillDark: { color: "#f3f0e9", warning: false },
158
+ bgFillInverted2: { color: "#1f1e1b", warning: false },
159
+ bgFillInverted1: { color: "#472900", warning: false },
160
+ fgFillInverted: { color: "#f3f0e9", warning: false },
161
+ surface1: { color: "#faefdb", warning: false }
162
+ },
163
+ direction: "darker"
164
+ },
165
+ error: {
166
+ ramp: {
167
+ bgFill1: { color: "#cc1818", warning: false },
168
+ fgFill: { color: "#f2efef", warning: false },
169
+ bgFill2: { color: "#b90000", warning: false },
170
+ surface2: { color: "#fdf6f5", warning: false },
171
+ surface6: { color: "#f5c5be", warning: false },
172
+ surface5: { color: "#f8d8d3", warning: false },
173
+ surface4: { color: "#fae6e2", warning: false },
174
+ surface3: { color: "#fff", warning: false },
175
+ fgSurface4: { color: "#4a0000", warning: false },
176
+ fgSurface3: { color: "#cc1818", warning: false },
177
+ fgSurface2: { color: "#f64b40", warning: false },
178
+ fgSurface1: { color: "#ff8070", warning: false },
179
+ stroke3: { color: "#cc1818", warning: false },
180
+ stroke4: { color: "#a40000", warning: false },
181
+ stroke2: { color: "#cd695d", warning: false },
182
+ stroke1: { color: "#dc9085", warning: false },
183
+ bgFillDark: { color: "#231c1b", warning: false },
184
+ fgFillDark: { color: "#f2efef", warning: false },
185
+ bgFillInverted2: { color: "#231c1b", warning: false },
186
+ bgFillInverted1: { color: "#6d0000", warning: false },
187
+ fgFillInverted: { color: "#f2efef", warning: false },
188
+ surface1: { color: "#fcecea", warning: false }
189
+ },
190
+ direction: "darker"
191
+ }
192
+ };
193
+ export {
194
+ DEFAULT_RAMPS
195
+ };
196
+ //# sourceMappingURL=default-ramps.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/color-ramps/lib/default-ramps.ts"],
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport type { RampResult } from './types';\nimport type { DEFAULT_SEED_COLORS } from './constants';\n\nexport const DEFAULT_RAMPS: Record<\n\tkeyof typeof DEFAULT_SEED_COLORS,\n\tRampResult\n> = {\n\tbg: {\n\t\tramp: {\n\t\t\tsurface2: { color: '#f8f8f8', warning: false },\n\t\t\tbgFill1: { color: '#555', warning: false },\n\t\t\tfgFill: { color: '#f0f0f0', warning: false },\n\t\t\tbgFill2: { color: '#474747', warning: false },\n\t\t\tsurface6: { color: '#d0d0d0', warning: false },\n\t\t\tsurface5: { color: '#dfdfdf', warning: false },\n\t\t\tsurface4: { color: '#eaeaea', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#1e1e1e', warning: false },\n\t\t\tfgSurface3: { color: '#6d6d6d', warning: false },\n\t\t\tfgSurface2: { color: '#898989', warning: false },\n\t\t\tfgSurface1: { color: '#a9a9a9', warning: false },\n\t\t\tstroke3: { color: '#898989', warning: false },\n\t\t\tstroke4: { color: '#6a6a6a', warning: false },\n\t\t\tstroke2: { color: '#adadad', warning: false },\n\t\t\tstroke1: { color: '#d0d0d0', warning: false },\n\t\t\tbgFillDark: { color: '#1e1e1e', warning: false },\n\t\t\tfgFillDark: { color: '#f0f0f0', warning: false },\n\t\t\tbgFillInverted2: { color: '#1e1e1e', warning: false },\n\t\t\tbgFillInverted1: { color: '#2f2f2f', warning: false },\n\t\t\tfgFillInverted: { color: '#f0f0f0', warning: false },\n\t\t\tsurface1: { color: '#f0f0f0', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tprimary: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#3858e9', warning: false },\n\t\t\tfgFill: { color: '#eff0f2', warning: false },\n\t\t\tbgFill2: { color: '#2c47d7', warning: false },\n\t\t\tsurface2: { color: '#f6f8fc', warning: false },\n\t\t\tsurface6: { color: '#c4d0ee', warning: false },\n\t\t\tsurface5: { color: '#d8e0f3', warning: false },\n\t\t\tsurface4: { color: '#e5eaf7', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#080071', warning: false },\n\t\t\tfgSurface3: { color: '#3858e9', warning: false },\n\t\t\tfgSurface2: { color: '#5780ff', warning: false },\n\t\t\tfgSurface1: { color: '#81a7ff', warning: false },\n\t\t\tstroke3: { color: '#3858e9', warning: false },\n\t\t\tstroke4: { color: '#2236c7', warning: false },\n\t\t\tstroke2: { color: '#6f85c0', warning: false },\n\t\t\tstroke1: { color: '#92a4cf', warning: false },\n\t\t\tbgFillDark: { color: '#1b1e26', warning: false },\n\t\t\tfgFillDark: { color: '#eff0f2', warning: false },\n\t\t\tbgFillInverted2: { color: '#1b1e26', warning: false },\n\t\t\tbgFillInverted1: { color: '#1401a4', warning: false },\n\t\t\tfgFillInverted: { color: '#eff0f2', warning: false },\n\t\t\tsurface1: { color: '#ecf0f9', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tinfo: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#0090ff', warning: false },\n\t\t\tfgFill: { color: '#1b1e23', warning: false },\n\t\t\tbgFill2: { color: '#007eec', warning: false },\n\t\t\tsurface2: { color: '#f5f9fd', warning: false },\n\t\t\tsurface6: { color: '#bad3f0', warning: false },\n\t\t\tsurface5: { color: '#d1e1f5', warning: false },\n\t\t\tsurface4: { color: '#e1ecf8', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#001758', warning: false },\n\t\t\tfgSurface3: { color: '#006cd8', warning: false },\n\t\t\tfgSurface2: { color: '#008bfa', warning: false },\n\t\t\tfgSurface1: { color: '#4dafff', warning: false },\n\t\t\tstroke3: { color: '#006cd8', warning: false },\n\t\t\tstroke4: { color: '#004bb5', warning: false },\n\t\t\tstroke2: { color: '#5e90c7', warning: false },\n\t\t\tstroke1: { color: '#8baed6', warning: false },\n\t\t\tbgFillDark: { color: '#1b1e23', warning: false },\n\t\t\tfgFillDark: { color: '#eff0f2', warning: false },\n\t\t\tbgFillInverted2: { color: '#1b1e23', warning: false },\n\t\t\tbgFillInverted1: { color: '#00297a', warning: false },\n\t\t\tfgFillInverted: { color: '#eff0f2', warning: false },\n\t\t\tsurface1: { color: '#e9f1fa', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tsuccess: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#4ab866', warning: false },\n\t\t\tfgFill: { color: '#1b1f1c', warning: false },\n\t\t\tbgFill2: { color: '#34a554', warning: false },\n\t\t\tsurface2: { color: '#f0fcf2', warning: false },\n\t\t\tsurface6: { color: '#7be792', warning: false },\n\t\t\tsurface5: { color: '#acf0b7', warning: false },\n\t\t\tsurface4: { color: '#cdf5d3', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#002b00', warning: false },\n\t\t\tfgSurface3: { color: '#008030', warning: false },\n\t\t\tfgSurface2: { color: '#2a9e4d', warning: false },\n\t\t\tfgSurface1: { color: '#52bf6d', warning: false },\n\t\t\tstroke3: { color: '#008030', warning: false },\n\t\t\tstroke4: { color: '#006113', warning: false },\n\t\t\tstroke2: { color: '#62996c', warning: false },\n\t\t\tstroke1: { color: '#78ba84', warning: false },\n\t\t\tbgFillDark: { color: '#1b1f1c', warning: false },\n\t\t\tfgFillDark: { color: '#edf2ed', warning: false },\n\t\t\tbgFillInverted2: { color: '#1b1f1c', warning: false },\n\t\t\tbgFillInverted1: { color: '#003a00', warning: false },\n\t\t\tfgFillInverted: { color: '#edf2ed', warning: false },\n\t\t\tsurface1: { color: '#ddf8e0', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\tcaution: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#f0d149', warning: false },\n\t\t\tfgFill: { color: '#1f1e1b', warning: false },\n\t\t\tbgFill2: { color: '#dabb2b', warning: false },\n\t\t\tsurface2: { color: '#fdf9e7', warning: false },\n\t\t\tsurface6: { color: '#e7d070', warning: false },\n\t\t\tsurface5: { color: '#f4e08c', warning: false },\n\t\t\tsurface4: { color: '#f8ebb6', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#291d00', warning: false },\n\t\t\tfgSurface3: { color: '#866a00', warning: false },\n\t\t\tfgSurface2: { color: '#a58700', warning: false },\n\t\t\tfgSurface1: { color: '#c6a800', warning: false },\n\t\t\tstroke3: { color: '#866a00', warning: false },\n\t\t\tstroke4: { color: '#644e00', warning: false },\n\t\t\tstroke2: { color: '#988d60', warning: false },\n\t\t\tstroke1: { color: '#b8ab76', warning: false },\n\t\t\tbgFillDark: { color: '#1f1e1b', warning: false },\n\t\t\tfgFillDark: { color: '#f6f1da', warning: false },\n\t\t\tbgFillInverted2: { color: '#1f1e1b', warning: false },\n\t\t\tbgFillInverted1: { color: '#3d2d00', warning: false },\n\t\t\tfgFillInverted: { color: '#f6f1da', warning: false },\n\t\t\tsurface1: { color: '#faf1cb', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\twarning: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#f0b849', warning: false },\n\t\t\tfgFill: { color: '#1f1e1b', warning: false },\n\t\t\tbgFill2: { color: '#dba430', warning: false },\n\t\t\tsurface2: { color: '#fdf7ee', warning: false },\n\t\t\tsurface6: { color: '#f0cb89', warning: false },\n\t\t\tsurface5: { color: '#f5ddb2', warning: false },\n\t\t\tsurface4: { color: '#f8e9cd', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#2f1800', warning: false },\n\t\t\tfgSurface3: { color: '#966200', warning: false },\n\t\t\tfgSurface2: { color: '#b58000', warning: false },\n\t\t\tfgSurface1: { color: '#d7a02b', warning: false },\n\t\t\tstroke3: { color: '#966200', warning: false },\n\t\t\tstroke4: { color: '#724700', warning: false },\n\t\t\tstroke2: { color: '#a08961', warning: false },\n\t\t\tstroke1: { color: '#c2a777', warning: false },\n\t\t\tbgFillDark: { color: '#1f1e1b', warning: false },\n\t\t\tfgFillDark: { color: '#f3f0e9', warning: false },\n\t\t\tbgFillInverted2: { color: '#1f1e1b', warning: false },\n\t\t\tbgFillInverted1: { color: '#472900', warning: false },\n\t\t\tfgFillInverted: { color: '#f3f0e9', warning: false },\n\t\t\tsurface1: { color: '#faefdb', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n\terror: {\n\t\tramp: {\n\t\t\tbgFill1: { color: '#cc1818', warning: false },\n\t\t\tfgFill: { color: '#f2efef', warning: false },\n\t\t\tbgFill2: { color: '#b90000', warning: false },\n\t\t\tsurface2: { color: '#fdf6f5', warning: false },\n\t\t\tsurface6: { color: '#f5c5be', warning: false },\n\t\t\tsurface5: { color: '#f8d8d3', warning: false },\n\t\t\tsurface4: { color: '#fae6e2', warning: false },\n\t\t\tsurface3: { color: '#fff', warning: false },\n\t\t\tfgSurface4: { color: '#4a0000', warning: false },\n\t\t\tfgSurface3: { color: '#cc1818', warning: false },\n\t\t\tfgSurface2: { color: '#f64b40', warning: false },\n\t\t\tfgSurface1: { color: '#ff8070', warning: false },\n\t\t\tstroke3: { color: '#cc1818', warning: false },\n\t\t\tstroke4: { color: '#a40000', warning: false },\n\t\t\tstroke2: { color: '#cd695d', warning: false },\n\t\t\tstroke1: { color: '#dc9085', warning: false },\n\t\t\tbgFillDark: { color: '#231c1b', warning: false },\n\t\t\tfgFillDark: { color: '#f2efef', warning: false },\n\t\t\tbgFillInverted2: { color: '#231c1b', warning: false },\n\t\t\tbgFillInverted1: { color: '#6d0000', warning: false },\n\t\t\tfgFillInverted: { color: '#f2efef', warning: false },\n\t\t\tsurface1: { color: '#fcecea', warning: false },\n\t\t},\n\t\tdirection: 'darker',\n\t},\n};\n"],
5
+ "mappings": ";AAMO,IAAM,gBAGT;AAAA,EACH,IAAI;AAAA,IACH,MAAM;AAAA,MACL,UAAU,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC7C,SAAS,EAAE,OAAO,QAAQ,SAAS,MAAM;AAAA,MACzC,QAAQ,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC3C,SAAS,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC5C,UAAU,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC7C,UAAU,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC7C,UAAU,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC7C,UAAU,EAAE,OAAO,QAAQ,SAAS,MAAM;AAAA,MAC1C,YAAY,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC/C,YAAY,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC/C,YAAY,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC/C,YAAY,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC/C,SAAS,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC5C,SAAS,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC5C,SAAS,EAAE,OAAO,WAAW,SAAS,MAAM;AAAA,MAC5C,SAAS,EAAE,OAAO,WAAW,SAAS,MAAM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";
1
+ // packages/theme/src/color-ramps/lib/find-color-with-constraints.ts
2
+ import { get, OKLCH } from "colorjs.io/fn";
3
+ import "./register-color-spaces";
2
4
  import { clampToGamut } from "./utils";
3
5
  import {
4
6
  WHITE,
@@ -6,38 +8,36 @@ import {
6
8
  LIGHTNESS_EPSILON,
7
9
  MAX_BISECTION_ITERATIONS
8
10
  } from "./constants";
9
- import { getCachedContrast } from "./cache-utils";
11
+ import { getContrast } from "./color-utils";
10
12
  import { taperChroma } from "./taper-chroma";
11
13
  function findColorMeetingRequirements(reference, seed, target, direction, {
12
14
  lightnessConstraint,
13
15
  taperChromaOptions,
14
- strict = true,
15
- debug = false
16
+ strict = true
16
17
  } = {}) {
17
18
  if (target <= 1) {
18
- return { color: seed.clone(), reached: true, achieved: 1 };
19
+ return { color: seed, reached: true, achieved: 1 };
19
20
  }
20
- if (lightnessConstraint) {
21
- let newL = lightnessConstraint.value;
22
- let newC = seed.oklch.c;
21
+ function getColorForL(l) {
22
+ let newL = l;
23
+ let newC = get(seed, [OKLCH, "c"]);
23
24
  if (taperChromaOptions) {
24
- ({ l: newL, c: newC } = taperChroma(
25
- seed,
26
- newL,
27
- taperChromaOptions
28
- ));
29
- }
30
- const colorWithExactL = clampToGamut(
31
- new Color("oklch", [newL, newC, seed.oklch.h])
32
- );
33
- const exactLContrast = getCachedContrast(reference, colorWithExactL);
34
- if (debug) {
35
- console.log(
36
- `Succeeded with ${lightnessConstraint.type} lightness`,
37
- lightnessConstraint.value,
38
- colorWithExactL.oklch.l
39
- );
25
+ const tapered = taperChroma(seed, newL, taperChromaOptions);
26
+ if ("l" in tapered && "c" in tapered) {
27
+ newL = tapered.l;
28
+ newC = tapered.c;
29
+ } else {
30
+ return tapered;
31
+ }
40
32
  }
33
+ return clampToGamut({
34
+ spaceId: "oklch",
35
+ coords: [newL, newC, get(seed, [OKLCH, "h"])]
36
+ });
37
+ }
38
+ if (lightnessConstraint) {
39
+ const colorWithExactL = getColorForL(lightnessConstraint.value);
40
+ const exactLContrast = getContrast(reference, colorWithExactL);
41
41
  if (lightnessConstraint.type === "force" || exactLContrast >= target) {
42
42
  return {
43
43
  color: colorWithExactL,
@@ -48,62 +48,58 @@ function findColorMeetingRequirements(reference, seed, target, direction, {
48
48
  }
49
49
  const mostContrastingL = direction === "lighter" ? 1 : 0;
50
50
  const mostContrastingColor = direction === "lighter" ? WHITE : BLACK;
51
- const highestPossibleContrast = getCachedContrast(
52
- reference,
53
- mostContrastingColor
54
- );
55
- if (highestPossibleContrast < target) {
51
+ const highestContrast = getContrast(reference, mostContrastingColor);
52
+ if (highestContrast < target) {
56
53
  if (strict) {
57
54
  throw new Error(
58
55
  `Contrast target ${target.toFixed(
59
56
  2
60
- )}:1 unreachable in ${direction} direction against ${mostContrastingColor.toString()}(boundary achieves ${highestPossibleContrast.toFixed(
61
- 3
62
- )}:1).`
63
- );
64
- }
65
- if (debug) {
66
- console.log(
67
- "Did not succeeded because it reached the limit",
68
- mostContrastingL
57
+ )}:1 unreachable in ${direction} direction(boundary achieves ${highestContrast.toFixed(3)}:1).`
69
58
  );
70
59
  }
71
60
  return {
72
61
  color: mostContrastingColor,
73
62
  reached: false,
74
- achieved: highestPossibleContrast
63
+ achieved: highestContrast
75
64
  };
76
65
  }
77
- let worseL = reference.oklch.l;
66
+ let worseL = get(reference, [OKLCH, "l"]);
67
+ let worseContrast = 1;
68
+ let replacedWorse = false;
78
69
  let betterL = mostContrastingL;
79
- let bestContrastFound = highestPossibleContrast;
80
- let resultingColor = mostContrastingColor;
81
- for (let i = 0; i < MAX_BISECTION_ITERATIONS && Math.abs(betterL - worseL) > LIGHTNESS_EPSILON; i++) {
82
- let newL = (worseL + betterL) / 2;
83
- let newC = seed.oklch.c;
84
- if (taperChromaOptions) {
85
- ({ l: newL, c: newC } = taperChroma(
86
- seed,
87
- newL,
88
- taperChromaOptions
89
- ));
70
+ let betterContrast = highestContrast;
71
+ let replacedBetter = false;
72
+ let bestColor = mostContrastingColor;
73
+ let bestContrast = highestContrast;
74
+ for (let i = 0; i < MAX_BISECTION_ITERATIONS; i++) {
75
+ const newL = (worseL * (betterContrast - target) - betterL * (worseContrast - target)) / (betterContrast - worseContrast);
76
+ bestColor = getColorForL(newL);
77
+ bestContrast = getContrast(reference, bestColor);
78
+ if (Math.abs(bestContrast - target) <= LIGHTNESS_EPSILON) {
79
+ break;
90
80
  }
91
- const newColor = clampToGamut(
92
- new Color("oklch", [newL, newC, seed.oklch.h])
93
- );
94
- const newContrast = getCachedContrast(reference, newColor);
95
- if (newContrast >= target) {
81
+ if (bestContrast >= target) {
96
82
  betterL = newL;
97
- bestContrastFound = newContrast;
98
- resultingColor = newColor;
83
+ betterContrast = bestContrast;
84
+ if (replacedBetter) {
85
+ worseContrast = (worseContrast + target) / 2;
86
+ }
87
+ replacedBetter = true;
88
+ replacedWorse = false;
99
89
  } else {
100
90
  worseL = newL;
91
+ worseContrast = bestContrast;
92
+ if (replacedWorse) {
93
+ betterContrast = (betterContrast + target) / 2;
94
+ }
95
+ replacedWorse = true;
96
+ replacedBetter = false;
101
97
  }
102
98
  }
103
99
  return {
104
- color: resultingColor,
100
+ color: bestColor,
105
101
  reached: true,
106
- achieved: bestContrastFound
102
+ achieved: bestContrast
107
103
  };
108
104
  }
109
105
  export {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/color-ramps/lib/find-color-with-constraints.ts"],
4
- "sourcesContent": ["/**\n * External dependencies\n */\nimport Color from 'colorjs.io';\n\n/**\n * Internal dependencies\n */\nimport { clampToGamut } from './utils';\nimport {\n\tWHITE,\n\tBLACK,\n\tLIGHTNESS_EPSILON,\n\tMAX_BISECTION_ITERATIONS,\n} from './constants';\nimport { getCachedContrast } from './cache-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Solve for L such that:\n * - the L applied to the seed meets the contrast target against the reference\n * - the search is performed in one direction (ie lighter / darker)\n * - more constraints can be applied around lightness\n * - chroma could be tapered\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.strict\n * @param options.debug\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: Color,\n\tseed: Color,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t\tstrict = true,\n\t\tdebug = false,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t\tstrict?: boolean;\n\t\tdebug?: boolean;\n\t} = {}\n): { color: Color; reached: boolean; achieved: number } {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn { color: seed.clone(), reached: true, achieved: 1 };\n\t}\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tlet newL = lightnessConstraint.value;\n\t\tlet newC = seed.oklch.c;\n\n\t\tif ( taperChromaOptions ) {\n\t\t\t( { l: newL, c: newC } = taperChroma(\n\t\t\t\tseed,\n\t\t\t\tnewL,\n\t\t\t\ttaperChromaOptions\n\t\t\t) );\n\t\t}\n\n\t\tconst colorWithExactL = clampToGamut(\n\t\t\tnew Color( 'oklch', [ newL, newC, seed.oklch.h ] )\n\t\t);\n\t\tconst exactLContrast = getCachedContrast( reference, colorWithExactL );\n\n\t\tif ( debug ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(\n\t\t\t\t`Succeeded with ${ lightnessConstraint.type } lightness`,\n\t\t\t\tlightnessConstraint.value,\n\t\t\t\tcolorWithExactL.oklch.l\n\t\t\t);\n\t\t}\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\tlightnessConstraint.type === 'force' ||\n\t\t\texactLContrast >= target\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrast >= target,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestPossibleContrast = getCachedContrast(\n\t\treference,\n\t\tmostContrastingColor\n\t);\n\n\t// If even the most contrasting color can't reach the target,\n\t// the target is unreachable.\n\tif ( highestPossibleContrast < target ) {\n\t\tif ( strict ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Contrast target ${ target.toFixed(\n\t\t\t\t\t2\n\t\t\t\t) }:1 unreachable in ${ direction } direction against ${ mostContrastingColor.toString() }` +\n\t\t\t\t\t`(boundary achieves ${ highestPossibleContrast.toFixed(\n\t\t\t\t\t\t3\n\t\t\t\t\t) }:1).`\n\t\t\t);\n\t\t}\n\n\t\tif ( debug ) {\n\t\t\t// eslint-disable-next-line no-console\n\t\t\tconsole.log(\n\t\t\t\t'Did not succeeded because it reached the limit',\n\t\t\t\tmostContrastingL\n\t\t\t);\n\t\t}\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: false,\n\t\t\tachieved: highestPossibleContrast,\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tlet worseL = reference.oklch.l;\n\tlet betterL = mostContrastingL;\n\n\tlet bestContrastFound = highestPossibleContrast;\n\tlet resultingColor = mostContrastingColor;\n\n\tfor (\n\t\tlet i = 0;\n\t\ti < MAX_BISECTION_ITERATIONS &&\n\t\tMath.abs( betterL - worseL ) > LIGHTNESS_EPSILON;\n\t\ti++\n\t) {\n\t\tlet newL = ( worseL + betterL ) / 2;\n\t\tlet newC = seed.oklch.c;\n\n\t\tif ( taperChromaOptions ) {\n\t\t\t( { l: newL, c: newC } = taperChroma(\n\t\t\t\tseed,\n\t\t\t\tnewL,\n\t\t\t\ttaperChromaOptions\n\t\t\t) );\n\t\t}\n\n\t\tconst newColor = clampToGamut(\n\t\t\tnew Color( 'oklch', [ newL, newC, seed.oklch.h ] )\n\t\t);\n\t\tconst newContrast = getCachedContrast( reference, newColor );\n\n\t\tif ( newContrast >= target ) {\n\t\t\tbetterL = newL;\n\t\t\t// Only update the resulting color when the target is met, this ensuring\n\t\t\t// at the end of the search the target is always met.\n\t\t\tbestContrastFound = newContrast;\n\t\t\tresultingColor = newColor;\n\t\t} else {\n\t\t\tworseL = newL;\n\t\t}\n\t}\n\n\treturn {\n\t\tcolor: resultingColor,\n\t\treached: true,\n\t\tachieved: bestContrastFound,\n\t};\n}\n"],
5
- "mappings": "AAGA,OAAO,WAAW;AAKlB,SAAS,oBAAoB;AAC7B;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,yBAAyB;AAClC,SAAkC,mBAAmB;AAoB9C,SAAS,6BACf,WACA,MACA,QACA,WACA;AAAA,EACC;AAAA,EACA;AAAA,EACA,SAAS;AAAA,EACT,QAAQ;AACT,IAQI,CAAC,GACkD;AAGvD,MAAK,UAAU,GAAI;AAClB,WAAO,EAAE,OAAO,KAAK,MAAM,GAAG,SAAS,MAAM,UAAU,EAAE;AAAA,EAC1D;AAEA,MAAK,qBAAsB;AAI1B,QAAI,OAAO,oBAAoB;AAC/B,QAAI,OAAO,KAAK,MAAM;AAEtB,QAAK,oBAAqB;AACzB,OAAE,EAAE,GAAG,MAAM,GAAG,KAAK,IAAI;AAAA,QACxB;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAEA,UAAM,kBAAkB;AAAA,MACvB,IAAI,MAAO,SAAS,CAAE,MAAM,MAAM,KAAK,MAAM,CAA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,UAAM,WAAW;AAAA,MAChB,IAAI,MAAO,SAAS,CAAE,MAAM,MAAM,KAAK,MAAM,CAAE,CAAE;AAAA,IAClD;AACA,UAAM,cAAc,kBAAmB,WAAW,QAAS;AAE3D,QAAK,eAAe,QAAS;AAC5B,gBAAU;AAGV,0BAAoB;AACpB,uBAAiB;AAAA,IAClB,OAAO;AACN,eAAS;AAAA,IACV;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,EACX;AACD;",
4
+ "sourcesContent": ["/**\n * External dependencies\n */\nimport { get, OKLCH, type ColorTypes } from 'colorjs.io/fn';\n\n/**\n * Internal dependencies\n */\nimport './register-color-spaces';\nimport { clampToGamut } from './utils';\nimport {\n\tWHITE,\n\tBLACK,\n\tLIGHTNESS_EPSILON,\n\tMAX_BISECTION_ITERATIONS,\n} from './constants';\nimport { getContrast } from './color-utils';\nimport { type TaperChromaOptions, taperChroma } from './taper-chroma';\n\n/**\n * Solve for L such that:\n * - the L applied to the seed meets the contrast target against the reference\n * - the search is performed in one direction (ie lighter / darker)\n * - more constraints can be applied around lightness\n * - chroma could be tapered\n * @param reference\n * @param seed\n * @param target\n * @param direction\n * @param options\n * @param options.strict\n * @param options.lightnessConstraint\n * @param options.lightnessConstraint.type\n * @param options.lightnessConstraint.value\n * @param options.taperChromaOptions\n */\nexport function findColorMeetingRequirements(\n\treference: ColorTypes,\n\tseed: ColorTypes,\n\ttarget: number,\n\tdirection: 'lighter' | 'darker',\n\t{\n\t\tlightnessConstraint,\n\t\ttaperChromaOptions,\n\t\tstrict = true,\n\t}: {\n\t\tlightnessConstraint?: {\n\t\t\ttype: 'force' | 'onlyIfSucceeds';\n\t\t\tvalue: number;\n\t\t};\n\t\ttaperChromaOptions?: TaperChromaOptions;\n\t\tstrict?: boolean;\n\t} = {}\n): { color: ColorTypes; reached: boolean; achieved: number } {\n\t// A target of 1 means same color.\n\t// A target lower than 1 doesn't make sense.\n\tif ( target <= 1 ) {\n\t\treturn { color: seed, reached: true, achieved: 1 };\n\t}\n\n\tfunction getColorForL( l: number ): ColorTypes {\n\t\tlet newL = l;\n\t\tlet newC = get( seed, [ OKLCH, 'c' ] );\n\n\t\tif ( taperChromaOptions ) {\n\t\t\tconst tapered = taperChroma( seed, newL, taperChromaOptions );\n\t\t\t// taperChroma returns either { l, c } or a ColorObject\n\t\t\tif ( 'l' in tapered && 'c' in tapered ) {\n\t\t\t\tnewL = tapered.l;\n\t\t\t\tnewC = tapered.c;\n\t\t\t} else {\n\t\t\t\t// It's already a ColorObject, return it directly\n\t\t\t\treturn tapered;\n\t\t\t}\n\t\t}\n\n\t\treturn clampToGamut( {\n\t\t\tspaceId: 'oklch',\n\t\t\tcoords: [ newL, newC, get( seed, [ OKLCH, 'h' ] ) ],\n\t\t} );\n\t}\n\n\tif ( lightnessConstraint ) {\n\t\t// Apply a specific L value.\n\t\t// Useful when pinning a step to a specific lightness, of to specify\n\t\t// min/max L values.\n\t\tconst colorWithExactL = getColorForL( lightnessConstraint.value );\n\t\tconst exactLContrast = getContrast( reference, colorWithExactL );\n\n\t\t// If the L constraint is of \"force\" type, apply it even when it doesn't\n\t\t// meet the contrast target.\n\t\tif (\n\t\t\tlightnessConstraint.type === 'force' ||\n\t\t\texactLContrast >= target\n\t\t) {\n\t\t\treturn {\n\t\t\t\tcolor: colorWithExactL,\n\t\t\t\treached: exactLContrast >= target,\n\t\t\t\tachieved: exactLContrast,\n\t\t\t};\n\t\t}\n\t}\n\n\t// Set the boundary based on the direction.\n\tconst mostContrastingL = direction === 'lighter' ? 1 : 0;\n\tconst mostContrastingColor = direction === 'lighter' ? WHITE : BLACK;\n\tconst highestContrast = getContrast( reference, mostContrastingColor );\n\n\t// If even the most contrasting color can't reach the target,\n\t// the target is unreachable.\n\tif ( highestContrast < target ) {\n\t\tif ( strict ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Contrast target ${ target.toFixed(\n\t\t\t\t\t2\n\t\t\t\t) }:1 unreachable in ${ direction } direction` +\n\t\t\t\t\t`(boundary achieves ${ highestContrast.toFixed( 3 ) }:1).`\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\tcolor: mostContrastingColor,\n\t\t\treached: false,\n\t\t\tachieved: highestContrast,\n\t\t};\n\t}\n\n\t// Bracket: low fails, high meets.\n\t// Originally this was seed.oklch.l \u2014 although it's an assumption that works\n\t// only when we know for sure the direction of the search.\n\t// TODO: can we bring this back to seed.oklch.l ?\n\tlet worseL = get( reference, [ OKLCH, 'l' ] );\n\tlet worseContrast = 1;\n\tlet replacedWorse = false;\n\tlet betterL = mostContrastingL;\n\tlet betterContrast = highestContrast;\n\tlet replacedBetter = false;\n\n\tlet bestColor: ColorTypes = mostContrastingColor;\n\tlet bestContrast = highestContrast;\n\n\tfor ( let i = 0; i < MAX_BISECTION_ITERATIONS; i++ ) {\n\t\t// Linear interpolation between worse and better L values, weighted by the contrast difference.\n\t\tconst newL =\n\t\t\t( worseL * ( betterContrast - target ) -\n\t\t\t\tbetterL * ( worseContrast - target ) ) /\n\t\t\t( betterContrast - worseContrast );\n\n\t\tbestColor = getColorForL( newL );\n\t\tbestContrast = getContrast( reference, bestColor );\n\n\t\tif ( Math.abs( bestContrast - target ) <= LIGHTNESS_EPSILON ) {\n\t\t\tbreak;\n\t\t}\n\n\t\t// Update one of the boundary L values, using the Illinois method.\n\t\tif ( bestContrast >= target ) {\n\t\t\tbetterL = newL;\n\t\t\tbetterContrast = bestContrast;\n\t\t\tif ( replacedBetter ) {\n\t\t\t\tworseContrast = ( worseContrast + target ) / 2;\n\t\t\t}\n\t\t\treplacedBetter = true;\n\t\t\treplacedWorse = false;\n\t\t} else {\n\t\t\tworseL = newL;\n\t\t\tworseContrast = bestContrast;\n\t\t\tif ( replacedWorse ) {\n\t\t\t\tbetterContrast = ( betterContrast + target ) / 2;\n\t\t\t}\n\t\t\treplacedWorse = true;\n\t\t\treplacedBetter = false;\n\t\t}\n\t}\n\n\treturn {\n\t\tc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AIrE,MAAK,kBAAkB,QAAS;AAC/B,QAAK,QAAS;AACb,YAAM,IAAI;AAAA,QACT,mBAAoB,OAAO;AAAA,UAC1B;AAAA,QACD,CAAE,qBAAsB,SAAU,gCACV,gBAAgB,QAAS,CAAE,CAAE;AAAA,MACtD;AAAA,IACD;AAEA,WAAO;AAAA,MACN,OAAO;AAAA,MACP,SAAS;AAAA,MACT,UAAU;AAAA,IACX;AAAA,EACD;AAMA,MAAI,SAAS,IAAK,WAAW,CAAE,OAAO,GAAI,CAAE;AAC5C,MAAI,gBAAgB;AACpB,MAAI,gBAAgB;AACpB,MAAI,UAAU;AACd,MAAI,iBAAiB;AACrB,MAAI,iBAAiB;AAErB,MAAI,YAAwB;AAC5B,MAAI,eAAe;AAEnB,WAAU,IAAI,GAAG,IAAI,0BAA0B,KAAM;AAEpD,UAAM,QACH,UAAW,iBAAiB,UAC7B,WAAY,gBAAgB,YAC3B,iBAAiB;AAEpB,gBAAY,aAAc,IAAK;AAC/B,mBAAe,YAAa,WAAW,SAAU;AAEjD,QAAK,KAAK,IAAK,eAAe,MAAO,KAAK,mBAAoB;AAC7D;AAAA,IACD;AAGA,QAAK,gBAAgB,QAAS;AAC7B,gBAAU;AACV,uBAAiB;AACjB,UAAK,gBAAiB;AACrB,yBAAkB,gBAAgB,UAAW;AAAA,MAC9C;AACA,uBAAiB;AACjB,sBAAgB;AAAA,IACjB,OAAO;AACN,eAAS;AACT,sBAAgB;AAChB,UAAK,eAAgB;AACpB,0BAAmB,iBAAiB,UAAW;AAAA,MAChD;AACA,sBAAgB;AAChB,uBAAiB;AAAA,IAClB;AAAA,EACD;AAEA,SAAO;AAAA,IACN,OAAO;AAAA,IACP,SAAS;AAAA,IACT,UAAU;AAAA,EACX;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,13 @@
1
- import Color from "colorjs.io";
2
- import { getCachedContrast, getColorString } from "./cache-utils";
1
+ // packages/theme/src/color-ramps/lib/index.ts
2
+ import {
3
+ clone,
4
+ get,
5
+ OKLCH,
6
+ parse,
7
+ set
8
+ } from "colorjs.io/fn";
9
+ import "./register-color-spaces";
10
+ import { getContrast, getColorString } from "./color-utils";
3
11
  import { findColorMeetingRequirements } from "./find-color-with-constraints";
4
12
  import {
5
13
  clampToGamut,
@@ -14,8 +22,7 @@ function calculateRamp({
14
22
  config,
15
23
  mainDir,
16
24
  oppDir,
17
- pinLightness,
18
- debug = false
25
+ pinLightness
19
26
  }) {
20
27
  const rampResults = {};
21
28
  let SATISFIED_ALL_CONTRAST_REQUIREMENTS = true;
@@ -24,7 +31,7 @@ function calculateRamp({
24
31
  const calculatedColors = /* @__PURE__ */ new Map();
25
32
  calculatedColors.set("seed", seed);
26
33
  for (const stepName of sortedSteps) {
27
- let computeDirection2 = function(color, followDirection) {
34
+ let computeDirection = function(color, followDirection) {
28
35
  if (followDirection === "main") {
29
36
  return mainDir;
30
37
  }
@@ -39,7 +46,6 @@ function calculateRamp({
39
46
  }
40
47
  return followDirection;
41
48
  };
42
- var computeDirection = computeDirection2;
43
49
  const {
44
50
  contrast,
45
51
  lightness: stepLightnessConstraint,
@@ -55,7 +61,7 @@ function calculateRamp({
55
61
  if (sameAsIfPossible) {
56
62
  const candidateColor = calculatedColors.get(sameAsIfPossible);
57
63
  if (candidateColor) {
58
- const candidateContrast = getCachedContrast(
64
+ const candidateContrast = getContrast(
59
65
  referenceColor,
60
66
  candidateColor
61
67
  );
@@ -70,7 +76,7 @@ function calculateRamp({
70
76
  }
71
77
  }
72
78
  }
73
- const computedDir = computeDirection2(
79
+ const computedDir = computeDirection(
74
80
  referenceColor,
75
81
  contrast.followDirection
76
82
  );
@@ -95,14 +101,13 @@ function calculateRamp({
95
101
  {
96
102
  strict: false,
97
103
  lightnessConstraint,
98
- taperChromaOptions,
99
- debug
104
+ taperChromaOptions
100
105
  }
101
106
  );
102
107
  if (!searchResults.reached && !contrast.ignoreWhenAdjustingSeed) {
103
108
  SATISFIED_ALL_CONTRAST_REQUIREMENTS = false;
104
109
  const deficitVsTarget = adjustedTarget - searchResults.achieved;
105
- const impactWeight = 1 / getCachedContrast(seed, referenceColor);
110
+ const impactWeight = 1 / getContrast(seed, referenceColor);
106
111
  const weightedDeficit = deficitVsTarget * impactWeight;
107
112
  if (weightedDeficit > MAX_WEIGHTED_DEFICIT) {
108
113
  MAX_WEIGHTED_DEFICIT = weightedDeficit;
@@ -124,12 +129,11 @@ function calculateRamp({
124
129
  function buildRamp(seedArg, config, {
125
130
  mainDirection,
126
131
  pinLightness,
127
- debug = false,
128
132
  rescaleToFitContrastTargets = true
129
133
  } = {}) {
130
134
  let seed;
131
135
  try {
132
- seed = clampToGamut(new Color(seedArg));
136
+ seed = clampToGamut(parse(seedArg));
133
137
  } catch (error) {
134
138
  throw new Error(
135
139
  `Invalid seed color "${seedArg}": ${error instanceof Error ? error.message : "Unknown error"}`
@@ -156,69 +160,38 @@ function buildRamp(seedArg, config, {
156
160
  config,
157
161
  mainDir,
158
162
  oppDir,
159
- pinLightness,
160
- debug
163
+ pinLightness
161
164
  });
162
165
  const toReturn = {
163
166
  ramp: rampResults,
164
167
  direction: mainDir
165
168
  };
166
- if (debug) {
167
- console.log(`First run`, {
168
- SATISFIED_ALL_CONTRAST_REQUIREMENTS,
169
- UNSATISFIED_DIRECTION,
170
- seed: seed.toString(),
171
- sortedSteps,
172
- config,
173
- mainDir,
174
- oppDir,
175
- pinLightness
176
- });
177
- }
178
169
  if (!SATISFIED_ALL_CONTRAST_REQUIREMENTS && rescaleToFitContrastTargets) {
179
- let worseSeedL = seed.oklch.l;
170
+ let worseSeedL = get(seed, [OKLCH, "l"]);
180
171
  let betterSeedL = UNSATISFIED_DIRECTION === "lighter" ? 0 : 1;
181
172
  for (let i = 0; i < MAX_BISECTION_ITERATIONS && Math.abs(betterSeedL - worseSeedL) > LIGHTNESS_EPSILON; i++) {
182
173
  const newSeed = clampToGamut(
183
- seed.clone().set({
184
- l: (worseSeedL + betterSeedL) / 2
185
- })
174
+ set(
175
+ clone(seed),
176
+ [OKLCH, "l"],
177
+ (worseSeedL + betterSeedL) / 2
178
+ )
186
179
  );
187
- if (debug) {
188
- console.log(`Iteration ${i}`, {
189
- worseSeedL,
190
- newSeedL: (worseSeedL + betterSeedL) / 2,
191
- betterSeedL
192
- });
193
- }
194
180
  const iterationResults = calculateRamp({
195
181
  seed: newSeed,
196
182
  sortedSteps,
197
183
  config,
198
184
  mainDir,
199
185
  oppDir,
200
- pinLightness,
201
- debug
186
+ pinLightness
202
187
  });
203
188
  if (iterationResults.SATISFIED_ALL_CONTRAST_REQUIREMENTS) {
204
- betterSeedL = newSeed.oklch.l;
189
+ betterSeedL = get(newSeed, [OKLCH, "l"]);
205
190
  toReturn.ramp = iterationResults.rampResults;
206
191
  } else if (UNSATISFIED_DIRECTION !== mainDir) {
207
- betterSeedL = newSeed.oklch.l;
192
+ betterSeedL = get(newSeed, [OKLCH, "l"]);
208
193
  } else {
209
- worseSeedL = newSeed.oklch.l;
210
- }
211
- if (debug) {
212
- console.log(`Retry #${i}`, {
213
- SATISFIED_ALL_CONTRAST_REQUIREMENTS,
214
- UNSATISFIED_DIRECTION,
215
- seed: newSeed.toString(),
216
- sortedSteps,
217
- config,
218
- mainDir,
219
- oppDir,
220
- pinLightness
221
- });
194
+ worseSeedL = get(newSeed, [OKLCH, "l"]);
222
195
  }
223
196
  }
224
197
  }