@sanity/themer 0.0.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.
- package/LICENSE +21 -0
- package/README.md +138 -0
- package/dist/_chunks/mix.cjs +52 -0
- package/dist/_chunks/mix.cjs.map +1 -0
- package/dist/_chunks/mix.js +42 -0
- package/dist/_chunks/mix.js.map +1 -0
- package/dist/_chunks/presets.cjs +215 -0
- package/dist/_chunks/presets.cjs.map +1 -0
- package/dist/_chunks/presets.js +201 -0
- package/dist/_chunks/presets.js.map +1 -0
- package/dist/_chunks/types.d.cts +26 -0
- package/dist/_chunks/types.d.cts.map +1 -0
- package/dist/_chunks/types.d.ts +26 -0
- package/dist/_chunks/types.d.ts.map +1 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/legacy.cjs +1199 -0
- package/dist/legacy.cjs.map +1 -0
- package/dist/legacy.d.cts +166 -0
- package/dist/legacy.d.cts.map +1 -0
- package/dist/legacy.d.ts +166 -0
- package/dist/legacy.d.ts.map +1 -0
- package/dist/legacy.js +1199 -0
- package/dist/legacy.js.map +1 -0
- package/dist/tool.cjs +407 -0
- package/dist/tool.cjs.map +1 -0
- package/dist/tool.d.cts +45 -0
- package/dist/tool.d.cts.map +1 -0
- package/dist/tool.d.ts +45 -0
- package/dist/tool.d.ts.map +1 -0
- package/dist/tool.js +415 -0
- package/dist/tool.js.map +1 -0
- package/package.json +94 -0
package/dist/legacy.cjs
ADDED
|
@@ -0,0 +1,1199 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_mix = require("./_chunks/mix.cjs");
|
|
3
|
+
let _sanity_color = require("@sanity/color"), _sanity_ui_theme = require("@sanity/ui/theme");
|
|
4
|
+
/**
|
|
5
|
+
* Drops properties that are set to `undefined`, so that spreading the hue
|
|
6
|
+
* over defaults doesn't shadow them. The hosted Themer service used a
|
|
7
|
+
* `JSON.parse(JSON.stringify(…))` round trip for this.
|
|
8
|
+
*/
|
|
9
|
+
function dropUndefined(hue) {
|
|
10
|
+
if (!hue) return;
|
|
11
|
+
let result = {};
|
|
12
|
+
return hue.mid !== void 0 && (result.mid = hue.mid), hue.midPoint !== void 0 && (result.midPoint = hue.midPoint), hue.lightest !== void 0 && (result.lightest = hue.lightest), hue.darkest !== void 0 && (result.darkest = hue.darkest), result;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* The color palette from `@sanity/color@2.2.5`, vendored so that themes
|
|
16
|
+
* generated by this module keep producing the exact same colors as the hosted
|
|
17
|
+
* Themer service (themer.sanity.build), which bundles that version. The
|
|
18
|
+
* current `@sanity/color` palette has different values, so it cannot be used
|
|
19
|
+
* here without changing generated themes.
|
|
20
|
+
*/
|
|
21
|
+
/** @internal */
|
|
22
|
+
const black = {
|
|
23
|
+
title: "Black",
|
|
24
|
+
hex: "#101112"
|
|
25
|
+
}, white = {
|
|
26
|
+
title: "White",
|
|
27
|
+
hex: "#fff"
|
|
28
|
+
}, gray = {
|
|
29
|
+
50: {
|
|
30
|
+
title: "Gray 50",
|
|
31
|
+
hex: "#f2f3f5"
|
|
32
|
+
},
|
|
33
|
+
100: {
|
|
34
|
+
title: "Gray 100",
|
|
35
|
+
hex: "#e6e8ec"
|
|
36
|
+
},
|
|
37
|
+
200: {
|
|
38
|
+
title: "Gray 200",
|
|
39
|
+
hex: "#ced2d9"
|
|
40
|
+
},
|
|
41
|
+
300: {
|
|
42
|
+
title: "Gray 300",
|
|
43
|
+
hex: "#b6bcc6"
|
|
44
|
+
},
|
|
45
|
+
400: {
|
|
46
|
+
title: "Gray 400",
|
|
47
|
+
hex: "#9ea6b3"
|
|
48
|
+
},
|
|
49
|
+
500: {
|
|
50
|
+
title: "Gray 500",
|
|
51
|
+
hex: "#8690a0"
|
|
52
|
+
},
|
|
53
|
+
600: {
|
|
54
|
+
title: "Gray 600",
|
|
55
|
+
hex: "#6e7683"
|
|
56
|
+
},
|
|
57
|
+
700: {
|
|
58
|
+
title: "Gray 700",
|
|
59
|
+
hex: "#565d67"
|
|
60
|
+
},
|
|
61
|
+
800: {
|
|
62
|
+
title: "Gray 800",
|
|
63
|
+
hex: "#3f434a"
|
|
64
|
+
},
|
|
65
|
+
900: {
|
|
66
|
+
title: "Gray 900",
|
|
67
|
+
hex: "#272a2e"
|
|
68
|
+
},
|
|
69
|
+
950: {
|
|
70
|
+
title: "Gray 950",
|
|
71
|
+
hex: "#1b1d20"
|
|
72
|
+
}
|
|
73
|
+
}, blue = {
|
|
74
|
+
50: {
|
|
75
|
+
title: "Blue 50",
|
|
76
|
+
hex: "#e8f1fe"
|
|
77
|
+
},
|
|
78
|
+
100: {
|
|
79
|
+
title: "Blue 100",
|
|
80
|
+
hex: "#d2e3fe"
|
|
81
|
+
},
|
|
82
|
+
200: {
|
|
83
|
+
title: "Blue 200",
|
|
84
|
+
hex: "#a6c8fd"
|
|
85
|
+
},
|
|
86
|
+
300: {
|
|
87
|
+
title: "Blue 300",
|
|
88
|
+
hex: "#7aacfd"
|
|
89
|
+
},
|
|
90
|
+
400: {
|
|
91
|
+
title: "Blue 400",
|
|
92
|
+
hex: "#4e91fc"
|
|
93
|
+
},
|
|
94
|
+
500: {
|
|
95
|
+
title: "Blue 500",
|
|
96
|
+
hex: "#2276fc"
|
|
97
|
+
},
|
|
98
|
+
600: {
|
|
99
|
+
title: "Blue 600",
|
|
100
|
+
hex: "#1e61cd"
|
|
101
|
+
},
|
|
102
|
+
700: {
|
|
103
|
+
title: "Blue 700",
|
|
104
|
+
hex: "#1a4d9e"
|
|
105
|
+
},
|
|
106
|
+
800: {
|
|
107
|
+
title: "Blue 800",
|
|
108
|
+
hex: "#17396f"
|
|
109
|
+
},
|
|
110
|
+
900: {
|
|
111
|
+
title: "Blue 900",
|
|
112
|
+
hex: "#132540"
|
|
113
|
+
},
|
|
114
|
+
950: {
|
|
115
|
+
title: "Blue 950",
|
|
116
|
+
hex: "#111b29"
|
|
117
|
+
}
|
|
118
|
+
}, purple = {
|
|
119
|
+
50: {
|
|
120
|
+
title: "Purple 50",
|
|
121
|
+
hex: "#f8e9fe"
|
|
122
|
+
},
|
|
123
|
+
100: {
|
|
124
|
+
title: "Purple 100",
|
|
125
|
+
hex: "#f2d3fe"
|
|
126
|
+
},
|
|
127
|
+
200: {
|
|
128
|
+
title: "Purple 200",
|
|
129
|
+
hex: "#e6a7fd"
|
|
130
|
+
},
|
|
131
|
+
300: {
|
|
132
|
+
title: "Purple 300",
|
|
133
|
+
hex: "#d97bfd"
|
|
134
|
+
},
|
|
135
|
+
400: {
|
|
136
|
+
title: "Purple 400",
|
|
137
|
+
hex: "#cd4efc"
|
|
138
|
+
},
|
|
139
|
+
500: {
|
|
140
|
+
title: "Purple 500",
|
|
141
|
+
hex: "#c123fc"
|
|
142
|
+
},
|
|
143
|
+
600: {
|
|
144
|
+
title: "Purple 600",
|
|
145
|
+
hex: "#9d1fcd"
|
|
146
|
+
},
|
|
147
|
+
700: {
|
|
148
|
+
title: "Purple 700",
|
|
149
|
+
hex: "#7a1b9e"
|
|
150
|
+
},
|
|
151
|
+
800: {
|
|
152
|
+
title: "Purple 800",
|
|
153
|
+
hex: "#56186f"
|
|
154
|
+
},
|
|
155
|
+
900: {
|
|
156
|
+
title: "Purple 900",
|
|
157
|
+
hex: "#331440"
|
|
158
|
+
},
|
|
159
|
+
950: {
|
|
160
|
+
title: "Purple 950",
|
|
161
|
+
hex: "#211229"
|
|
162
|
+
}
|
|
163
|
+
}, magenta = {
|
|
164
|
+
50: {
|
|
165
|
+
title: "Magenta 50",
|
|
166
|
+
hex: "#fcebf5"
|
|
167
|
+
},
|
|
168
|
+
100: {
|
|
169
|
+
title: "Magenta 100",
|
|
170
|
+
hex: "#f9d7eb"
|
|
171
|
+
},
|
|
172
|
+
200: {
|
|
173
|
+
title: "Magenta 200",
|
|
174
|
+
hex: "#f4afd8"
|
|
175
|
+
},
|
|
176
|
+
300: {
|
|
177
|
+
title: "Magenta 300",
|
|
178
|
+
hex: "#ef87c4"
|
|
179
|
+
},
|
|
180
|
+
400: {
|
|
181
|
+
title: "Magenta 400",
|
|
182
|
+
hex: "#ea5fb1"
|
|
183
|
+
},
|
|
184
|
+
500: {
|
|
185
|
+
title: "Magenta 500",
|
|
186
|
+
hex: "#e5389e"
|
|
187
|
+
},
|
|
188
|
+
600: {
|
|
189
|
+
title: "Magenta 600",
|
|
190
|
+
hex: "#ba3082"
|
|
191
|
+
},
|
|
192
|
+
700: {
|
|
193
|
+
title: "Magenta 700",
|
|
194
|
+
hex: "#8f2866"
|
|
195
|
+
},
|
|
196
|
+
800: {
|
|
197
|
+
title: "Magenta 800",
|
|
198
|
+
hex: "#65204a"
|
|
199
|
+
},
|
|
200
|
+
900: {
|
|
201
|
+
title: "Magenta 900",
|
|
202
|
+
hex: "#3a182d"
|
|
203
|
+
},
|
|
204
|
+
950: {
|
|
205
|
+
title: "Magenta 950",
|
|
206
|
+
hex: "#25141f"
|
|
207
|
+
}
|
|
208
|
+
}, red = {
|
|
209
|
+
50: {
|
|
210
|
+
title: "Red 50",
|
|
211
|
+
hex: "#fdebea"
|
|
212
|
+
},
|
|
213
|
+
100: {
|
|
214
|
+
title: "Red 100",
|
|
215
|
+
hex: "#fcd8d5"
|
|
216
|
+
},
|
|
217
|
+
200: {
|
|
218
|
+
title: "Red 200",
|
|
219
|
+
hex: "#f9b1ab"
|
|
220
|
+
},
|
|
221
|
+
300: {
|
|
222
|
+
title: "Red 300",
|
|
223
|
+
hex: "#f68b82"
|
|
224
|
+
},
|
|
225
|
+
400: {
|
|
226
|
+
title: "Red 400",
|
|
227
|
+
hex: "#f36458"
|
|
228
|
+
},
|
|
229
|
+
500: {
|
|
230
|
+
title: "Red 500",
|
|
231
|
+
hex: "#f03e2f"
|
|
232
|
+
},
|
|
233
|
+
600: {
|
|
234
|
+
title: "Red 600",
|
|
235
|
+
hex: "#c33529"
|
|
236
|
+
},
|
|
237
|
+
700: {
|
|
238
|
+
title: "Red 700",
|
|
239
|
+
hex: "#962c23"
|
|
240
|
+
},
|
|
241
|
+
800: {
|
|
242
|
+
title: "Red 800",
|
|
243
|
+
hex: "#69231d"
|
|
244
|
+
},
|
|
245
|
+
900: {
|
|
246
|
+
title: "Red 900",
|
|
247
|
+
hex: "#3c1a17"
|
|
248
|
+
},
|
|
249
|
+
950: {
|
|
250
|
+
title: "Red 950",
|
|
251
|
+
hex: "#261514"
|
|
252
|
+
}
|
|
253
|
+
}, orange = {
|
|
254
|
+
50: {
|
|
255
|
+
title: "Orange 50",
|
|
256
|
+
hex: "#fef0e6"
|
|
257
|
+
},
|
|
258
|
+
100: {
|
|
259
|
+
title: "Orange 100",
|
|
260
|
+
hex: "#fee2ce"
|
|
261
|
+
},
|
|
262
|
+
200: {
|
|
263
|
+
title: "Orange 200",
|
|
264
|
+
hex: "#fdc59d"
|
|
265
|
+
},
|
|
266
|
+
300: {
|
|
267
|
+
title: "Orange 300",
|
|
268
|
+
hex: "#fca86d"
|
|
269
|
+
},
|
|
270
|
+
400: {
|
|
271
|
+
title: "Orange 400",
|
|
272
|
+
hex: "#fb8b3c"
|
|
273
|
+
},
|
|
274
|
+
500: {
|
|
275
|
+
title: "Orange 500",
|
|
276
|
+
hex: "#e57322"
|
|
277
|
+
},
|
|
278
|
+
600: {
|
|
279
|
+
title: "Orange 600",
|
|
280
|
+
hex: "#ba5f1f"
|
|
281
|
+
},
|
|
282
|
+
700: {
|
|
283
|
+
title: "Orange 700",
|
|
284
|
+
hex: "#904b1b"
|
|
285
|
+
},
|
|
286
|
+
800: {
|
|
287
|
+
title: "Orange 800",
|
|
288
|
+
hex: "#653818"
|
|
289
|
+
},
|
|
290
|
+
900: {
|
|
291
|
+
title: "Orange 900",
|
|
292
|
+
hex: "#3a2415"
|
|
293
|
+
},
|
|
294
|
+
950: {
|
|
295
|
+
title: "Orange 950",
|
|
296
|
+
hex: "#251a13"
|
|
297
|
+
}
|
|
298
|
+
}, yellow = {
|
|
299
|
+
50: {
|
|
300
|
+
title: "Yellow 50",
|
|
301
|
+
hex: "#fef7da"
|
|
302
|
+
},
|
|
303
|
+
100: {
|
|
304
|
+
title: "Yellow 100",
|
|
305
|
+
hex: "#fdefb6"
|
|
306
|
+
},
|
|
307
|
+
200: {
|
|
308
|
+
title: "Yellow 200",
|
|
309
|
+
hex: "#fcdf6d"
|
|
310
|
+
},
|
|
311
|
+
300: {
|
|
312
|
+
title: "Yellow 300",
|
|
313
|
+
hex: "#fbd024"
|
|
314
|
+
},
|
|
315
|
+
400: {
|
|
316
|
+
title: "Yellow 400",
|
|
317
|
+
hex: "#d9b421"
|
|
318
|
+
},
|
|
319
|
+
500: {
|
|
320
|
+
title: "Yellow 500",
|
|
321
|
+
hex: "#b7991e"
|
|
322
|
+
},
|
|
323
|
+
600: {
|
|
324
|
+
title: "Yellow 600",
|
|
325
|
+
hex: "#967e1c"
|
|
326
|
+
},
|
|
327
|
+
700: {
|
|
328
|
+
title: "Yellow 700",
|
|
329
|
+
hex: "#746219"
|
|
330
|
+
},
|
|
331
|
+
800: {
|
|
332
|
+
title: "Yellow 800",
|
|
333
|
+
hex: "#534717"
|
|
334
|
+
},
|
|
335
|
+
900: {
|
|
336
|
+
title: "Yellow 900",
|
|
337
|
+
hex: "#312c14"
|
|
338
|
+
},
|
|
339
|
+
950: {
|
|
340
|
+
title: "Yellow 950",
|
|
341
|
+
hex: "#201e13"
|
|
342
|
+
}
|
|
343
|
+
}, green = {
|
|
344
|
+
50: {
|
|
345
|
+
title: "Green 50",
|
|
346
|
+
hex: "#e7f9ed"
|
|
347
|
+
},
|
|
348
|
+
100: {
|
|
349
|
+
title: "Green 100",
|
|
350
|
+
hex: "#d0f4dc"
|
|
351
|
+
},
|
|
352
|
+
200: {
|
|
353
|
+
title: "Green 200",
|
|
354
|
+
hex: "#a1eaba"
|
|
355
|
+
},
|
|
356
|
+
300: {
|
|
357
|
+
title: "Green 300",
|
|
358
|
+
hex: "#72e097"
|
|
359
|
+
},
|
|
360
|
+
400: {
|
|
361
|
+
title: "Green 400",
|
|
362
|
+
hex: "#43d675"
|
|
363
|
+
},
|
|
364
|
+
500: {
|
|
365
|
+
title: "Green 500",
|
|
366
|
+
hex: "#3ab564"
|
|
367
|
+
},
|
|
368
|
+
600: {
|
|
369
|
+
title: "Green 600",
|
|
370
|
+
hex: "#329454"
|
|
371
|
+
},
|
|
372
|
+
700: {
|
|
373
|
+
title: "Green 700",
|
|
374
|
+
hex: "#297343"
|
|
375
|
+
},
|
|
376
|
+
800: {
|
|
377
|
+
title: "Green 800",
|
|
378
|
+
hex: "#215233"
|
|
379
|
+
},
|
|
380
|
+
900: {
|
|
381
|
+
title: "Green 900",
|
|
382
|
+
hex: "#183122"
|
|
383
|
+
},
|
|
384
|
+
950: {
|
|
385
|
+
title: "Green 950",
|
|
386
|
+
hex: "#14211a"
|
|
387
|
+
}
|
|
388
|
+
}, cyan = {
|
|
389
|
+
50: {
|
|
390
|
+
title: "Cyan 50",
|
|
391
|
+
hex: "#e3fafd"
|
|
392
|
+
},
|
|
393
|
+
100: {
|
|
394
|
+
title: "Cyan 100",
|
|
395
|
+
hex: "#c7f5fc"
|
|
396
|
+
},
|
|
397
|
+
200: {
|
|
398
|
+
title: "Cyan 200",
|
|
399
|
+
hex: "#90ecf9"
|
|
400
|
+
},
|
|
401
|
+
300: {
|
|
402
|
+
title: "Cyan 300",
|
|
403
|
+
hex: "#59e3f6"
|
|
404
|
+
},
|
|
405
|
+
400: {
|
|
406
|
+
title: "Cyan 400",
|
|
407
|
+
hex: "#22daf4"
|
|
408
|
+
},
|
|
409
|
+
500: {
|
|
410
|
+
title: "Cyan 500",
|
|
411
|
+
hex: "#1fb8ce"
|
|
412
|
+
},
|
|
413
|
+
600: {
|
|
414
|
+
title: "Cyan 600",
|
|
415
|
+
hex: "#1c97a8"
|
|
416
|
+
},
|
|
417
|
+
700: {
|
|
418
|
+
title: "Cyan 700",
|
|
419
|
+
hex: "#197583"
|
|
420
|
+
},
|
|
421
|
+
800: {
|
|
422
|
+
title: "Cyan 800",
|
|
423
|
+
hex: "#16545d"
|
|
424
|
+
},
|
|
425
|
+
900: {
|
|
426
|
+
title: "Cyan 900",
|
|
427
|
+
hex: "#133237"
|
|
428
|
+
},
|
|
429
|
+
950: {
|
|
430
|
+
title: "Cyan 950",
|
|
431
|
+
hex: "#112124"
|
|
432
|
+
}
|
|
433
|
+
}, lightest = white.hex.toLowerCase(), darkest = black.hex.toLowerCase(), defaultHues = {
|
|
434
|
+
default: {
|
|
435
|
+
lightest,
|
|
436
|
+
darkest,
|
|
437
|
+
mid: "#8690a0",
|
|
438
|
+
midPoint: 500
|
|
439
|
+
},
|
|
440
|
+
primary: {
|
|
441
|
+
lightest,
|
|
442
|
+
darkest,
|
|
443
|
+
mid: "#2276fc",
|
|
444
|
+
midPoint: 500
|
|
445
|
+
},
|
|
446
|
+
transparent: {
|
|
447
|
+
lightest,
|
|
448
|
+
darkest,
|
|
449
|
+
mid: "#8690a0",
|
|
450
|
+
midPoint: 500
|
|
451
|
+
},
|
|
452
|
+
positive: {
|
|
453
|
+
lightest,
|
|
454
|
+
darkest,
|
|
455
|
+
mid: "#43d675",
|
|
456
|
+
midPoint: 400
|
|
457
|
+
},
|
|
458
|
+
caution: {
|
|
459
|
+
lightest,
|
|
460
|
+
darkest,
|
|
461
|
+
mid: "#fbd024",
|
|
462
|
+
midPoint: 300
|
|
463
|
+
},
|
|
464
|
+
critical: {
|
|
465
|
+
lightest,
|
|
466
|
+
darkest,
|
|
467
|
+
mid: "#f03e2f",
|
|
468
|
+
midPoint: 500
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
/**
|
|
472
|
+
* Merges partial hues over the defaults, exactly like the hosted Themer
|
|
473
|
+
* service did. When a hue's `mid` color is customized without an explicit
|
|
474
|
+
* `midPoint`, the mid point resets to `500`.
|
|
475
|
+
*/
|
|
476
|
+
function applyHues(_hues, defaults = defaultHues) {
|
|
477
|
+
let hues = {
|
|
478
|
+
default: dropUndefined(_hues.default),
|
|
479
|
+
primary: dropUndefined(_hues.primary),
|
|
480
|
+
transparent: dropUndefined(_hues.transparent),
|
|
481
|
+
positive: dropUndefined(_hues.positive),
|
|
482
|
+
caution: dropUndefined(_hues.caution),
|
|
483
|
+
critical: dropUndefined(_hues.critical)
|
|
484
|
+
}, defaultMid = hues.default?.mid?.toLowerCase() || defaults.default.mid, primaryMid = hues.primary?.mid?.toLowerCase() || defaults.primary.mid, transparentMid = hues.transparent?.mid?.toLowerCase() || defaults.transparent.mid, positiveMid = hues.positive?.mid?.toLowerCase() || defaults.positive.mid, cautionMid = hues.caution?.mid?.toLowerCase() || defaults.caution.mid, criticalMid = hues.critical?.mid?.toLowerCase() || defaults.critical.mid;
|
|
485
|
+
return {
|
|
486
|
+
default: {
|
|
487
|
+
...defaults.default,
|
|
488
|
+
midPoint: defaultMid === defaults.default.mid ? defaults.default.midPoint : 500,
|
|
489
|
+
...hues.default,
|
|
490
|
+
mid: defaultMid
|
|
491
|
+
},
|
|
492
|
+
primary: {
|
|
493
|
+
...defaults.primary,
|
|
494
|
+
midPoint: primaryMid === defaults.primary.mid ? defaults.primary.midPoint : 500,
|
|
495
|
+
...hues.primary,
|
|
496
|
+
mid: primaryMid
|
|
497
|
+
},
|
|
498
|
+
transparent: {
|
|
499
|
+
...defaults.transparent,
|
|
500
|
+
midPoint: transparentMid === defaults.transparent.mid ? defaults.transparent.midPoint : 500,
|
|
501
|
+
...hues.transparent,
|
|
502
|
+
mid: transparentMid
|
|
503
|
+
},
|
|
504
|
+
positive: {
|
|
505
|
+
...defaults.positive,
|
|
506
|
+
midPoint: positiveMid === defaults.positive.mid ? defaults.positive.midPoint : 500,
|
|
507
|
+
...hues.positive,
|
|
508
|
+
mid: positiveMid
|
|
509
|
+
},
|
|
510
|
+
caution: {
|
|
511
|
+
...defaults.caution,
|
|
512
|
+
midPoint: cautionMid === defaults.caution.mid ? defaults.caution.midPoint : 500,
|
|
513
|
+
...hues.caution,
|
|
514
|
+
mid: cautionMid
|
|
515
|
+
},
|
|
516
|
+
critical: {
|
|
517
|
+
...defaults.critical,
|
|
518
|
+
midPoint: criticalMid === defaults.critical.mid ? defaults.critical.midPoint : 500,
|
|
519
|
+
...hues.critical,
|
|
520
|
+
mid: criticalMid
|
|
521
|
+
}
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const VALID_MID_POINTS = /* @__PURE__ */ new Set([
|
|
525
|
+
50,
|
|
526
|
+
100,
|
|
527
|
+
200,
|
|
528
|
+
300,
|
|
529
|
+
400,
|
|
530
|
+
500,
|
|
531
|
+
600,
|
|
532
|
+
700,
|
|
533
|
+
800,
|
|
534
|
+
900,
|
|
535
|
+
950
|
|
536
|
+
]);
|
|
537
|
+
/**
|
|
538
|
+
* Parses hues from the query of a hosted Themer service URL, exactly like
|
|
539
|
+
* `https://themer.sanity.build/api/hues` did — including its validation
|
|
540
|
+
* errors.
|
|
541
|
+
*/
|
|
542
|
+
function parseHuesFromSearchParams(searchParams) {
|
|
543
|
+
let lightest = searchParams.has("lightest") ? assertValidColor(`#${(searchParams.get("lightest") ?? "").toLowerCase()}`) : void 0, darkest = searchParams.get("darkest") ? assertValidColor(`#${(searchParams.get("darkest") ?? "").toLowerCase()}`) : void 0;
|
|
544
|
+
return {
|
|
545
|
+
default: dropUndefined(parseHue("default", searchParams, lightest, darkest)),
|
|
546
|
+
primary: dropUndefined(parseHue("primary", searchParams, lightest, darkest)),
|
|
547
|
+
transparent: dropUndefined(parseHue("transparent", searchParams, lightest, darkest)),
|
|
548
|
+
positive: dropUndefined(parseHue("positive", searchParams, lightest, darkest)),
|
|
549
|
+
caution: dropUndefined(parseHue("caution", searchParams, lightest, darkest)),
|
|
550
|
+
critical: dropUndefined(parseHue("critical", searchParams, lightest, darkest))
|
|
551
|
+
};
|
|
552
|
+
}
|
|
553
|
+
function parseHue(key, searchParams, defaultLightest, defaultDarkest) {
|
|
554
|
+
if (!searchParams.has(key)) return {
|
|
555
|
+
lightest: defaultLightest,
|
|
556
|
+
darkest: defaultDarkest
|
|
557
|
+
};
|
|
558
|
+
let input = (searchParams.get(key) ?? "").toLowerCase(), mid, midPoint, lightest, darkest, params = input.split(";");
|
|
559
|
+
if (params.length > 4) throw TypeError(`Invalid number of params for the ${key} hue, it should be 4 or less instead it's ${params.length}: ${JSON.stringify(params)}`);
|
|
560
|
+
for (let param of params) {
|
|
561
|
+
let maybeMid = `#${param}`, maybeMidPoint = roundMidPoint(Number(param));
|
|
562
|
+
switch (!0) {
|
|
563
|
+
case param === "": break;
|
|
564
|
+
case require_mix.t(maybeMid) && !mid:
|
|
565
|
+
mid = maybeMid;
|
|
566
|
+
break;
|
|
567
|
+
case !Number.isNaN(maybeMidPoint) && !midPoint:
|
|
568
|
+
midPoint = assertValidMidPoint(maybeMidPoint);
|
|
569
|
+
break;
|
|
570
|
+
case param.startsWith("lightest:") && !lightest:
|
|
571
|
+
lightest = assertValidColor(`#${param.replace(/^lightest:/, "")}`);
|
|
572
|
+
break;
|
|
573
|
+
case param.startsWith("darkest:") && !darkest:
|
|
574
|
+
darkest = assertValidColor(`#${param.replace(/^darkest:/, "")}`);
|
|
575
|
+
break;
|
|
576
|
+
case require_mix.t(maybeMid):
|
|
577
|
+
throwDuplicate(key, mid?.replace(/^#/, ""), param, input);
|
|
578
|
+
break;
|
|
579
|
+
case !Number.isNaN(maybeMidPoint):
|
|
580
|
+
throwDuplicate(key, midPoint, maybeMidPoint, input);
|
|
581
|
+
break;
|
|
582
|
+
case param.startsWith("lightest:"):
|
|
583
|
+
throwDuplicate(key, lightest?.replace(/^#/, "lightest:"), param, input);
|
|
584
|
+
break;
|
|
585
|
+
case param.startsWith("darkest:"):
|
|
586
|
+
throwDuplicate(key, darkest?.replace(/^#/, "darkest:"), param, input);
|
|
587
|
+
break;
|
|
588
|
+
default: throw TypeError(`Invalid param for the ${key} hue: ${param}`);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
return {
|
|
592
|
+
mid,
|
|
593
|
+
midPoint,
|
|
594
|
+
lightest: lightest ?? defaultLightest,
|
|
595
|
+
darkest: darkest ?? defaultDarkest
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function roundMidPoint(value) {
|
|
599
|
+
return value < 75 ? 50 : value > 925 ? 950 : Math.round(value / 100) * 100;
|
|
600
|
+
}
|
|
601
|
+
function throwDuplicate(key, a, b, input) {
|
|
602
|
+
throw TypeError(`Duplicate params detected. Remove at least ${a === b ? `one of the ${JSON.stringify(String(a))}` : `${JSON.stringify(String(a))} or ${JSON.stringify(String(b))}`} from the ${key} hue: ${JSON.stringify(input)}`);
|
|
603
|
+
}
|
|
604
|
+
function assertValidColor(input) {
|
|
605
|
+
if (require_mix.t(input)) return input;
|
|
606
|
+
throw TypeError(`Invalid color: ${input}`);
|
|
607
|
+
}
|
|
608
|
+
function assertValidMidPoint(input) {
|
|
609
|
+
if (isMidPoint(input)) return input;
|
|
610
|
+
throw TypeError(`Invalid midPoint: ${input}`);
|
|
611
|
+
}
|
|
612
|
+
function isMidPoint(input) {
|
|
613
|
+
return VALID_MID_POINTS.has(input);
|
|
614
|
+
}
|
|
615
|
+
function definePreset(slug, title, searchParams) {
|
|
616
|
+
return {
|
|
617
|
+
slug,
|
|
618
|
+
title,
|
|
619
|
+
searchParams,
|
|
620
|
+
hues: applyHues(parseHuesFromSearchParams(new URLSearchParams(searchParams)))
|
|
621
|
+
};
|
|
622
|
+
}
|
|
623
|
+
const defaultPreset = definePreset("default", "Studio v3", "lightest=fff&darkest=101112&default=8690a0;500&primary=2276fc;500&transparent=8690a0;500&positive=43d675;400&caution=fbd024;300&critical=f03e2f;500"), presets = [
|
|
624
|
+
defaultPreset,
|
|
625
|
+
definePreset("dew", "Dew", "default=5e63b4;600;lightest:fcfcfd;darkest:0d0d15&primary=d1a308;400;lightest:fcfcfd;darkest:0d0d15&transparent=6c6fa7;500;lightest:fcfcfd;darkest:0d0d15&positive=43D675;300;lightest:fcfcfd;darkest:0d0d15&caution=fb9f24;400;lightest:fcfcfd;darkest:0d0d15&critical=F03E2F;500;lightest:fcfcfd;darkest:0d0d15"),
|
|
626
|
+
definePreset("pink-synth", "Pink Synth", "lightest=f7f2f5&darkest=171721&default=8b6584&primary=ec4899&transparent=503a4c&positive=10b981&caution=fde047;300&critical=fe3459"),
|
|
627
|
+
definePreset("pixel-art", "Pixel Art", "default=57619c;600&primary=f10784&transparent=5b6498;600&positive=43d675;300&caution=fbd024;200&lightest=fcfcfd&darkest=0d0e15"),
|
|
628
|
+
definePreset("retro-colonial", "Retro Colonial", "default=8bb9b5;400&primary=fa7a78;400&transparent=8bb9b5;400&positive=43d675;300&caution=fbd024;200&critical=f02f53&lightest=fcfdfd&darkest=0d1515"),
|
|
629
|
+
definePreset("rosabel", "Rosabel", "default=9d8966&primary=ed2555;700&transparent=9d8966&positive=43d675;300&caution=fbd024;200&lightest=fdfdfc&darkest=15120d"),
|
|
630
|
+
definePreset("stereofidelic", "Stereofidelic", "default=678e9a&primary=f13009&transparent=678e9a&positive=43d675;300&caution=fbd024;200&critical=f02f35&lightest=fcfdfd&darkest=0e1315"),
|
|
631
|
+
definePreset("tw-cyan", "Tailwind Cyan", "default=677389;500;lightest:f9fafb;darkest:101728&primary=51b4d0;500;lightest:effefe;darkest:264d61&transparent=6b727f;500;lightest:f8fafb;darkest:131826&positive=55b785;500;lightest:eefdf5;darkest:214d3b&caution=e2b53e;500;lightest:fefbea;darkest:69411b&critical=e14f62;500;lightest:fdf2f2;darkest:7d2037"),
|
|
632
|
+
definePreset("verdant", "Verdant", "default=5c9199;500;lightest:fcfdfd;darkest:0d1415&primary=1cb485;400;lightest:fcfdfd;darkest:0d1415&transparent=5c9199;500;lightest:fcfdfd;darkest:0d1415&positive=43D675;300;lightest:fcfdfd;darkest:0d1415&caution=FBD024;200;lightest:fcfdfd;darkest:0d1415&critical=F03E2F;500;lightest:fcfdfd;darkest:0d1415")
|
|
633
|
+
];
|
|
634
|
+
/**
|
|
635
|
+
* Finds a preset by its slug, falling back to the default Studio preset for
|
|
636
|
+
* unknown slugs — the same behavior as the hosted Themer service.
|
|
637
|
+
*
|
|
638
|
+
* @public
|
|
639
|
+
*/
|
|
640
|
+
function getPreset(slug) {
|
|
641
|
+
let needle = slug?.toLowerCase();
|
|
642
|
+
return presets.find((preset) => preset.slug === needle) || defaultPreset;
|
|
643
|
+
}
|
|
644
|
+
/**
|
|
645
|
+
* Generates the tint ramp for each of the six hues, exactly like the hosted
|
|
646
|
+
* Themer service did.
|
|
647
|
+
*/
|
|
648
|
+
function createTonesFromHues(hues) {
|
|
649
|
+
return {
|
|
650
|
+
default: createTintsFromHue(hues.default, "Default"),
|
|
651
|
+
primary: createTintsFromHue(hues.primary, "Primary"),
|
|
652
|
+
transparent: createTintsFromHue(hues.transparent, "Transparent"),
|
|
653
|
+
positive: createTintsFromHue(hues.positive, "Positive"),
|
|
654
|
+
caution: createTintsFromHue(hues.caution, "Caution"),
|
|
655
|
+
critical: createTintsFromHue(hues.critical, "Critical")
|
|
656
|
+
};
|
|
657
|
+
}
|
|
658
|
+
function createTintsFromHue(hue, title) {
|
|
659
|
+
return _sanity_color.COLOR_TINTS.reduce((tints, tint) => (tints[tint] = {
|
|
660
|
+
title: `${title} ${tint}`,
|
|
661
|
+
hex: getColorHex(hue, tint)
|
|
662
|
+
}, tints), {});
|
|
663
|
+
}
|
|
664
|
+
function getColorHex(hue, tint) {
|
|
665
|
+
let tintNum = Number(tint), midPoint = hue.midPoint, darkSize = 1e3 - midPoint, lightPosition = tintNum / midPoint, darkPosition = (tintNum - midPoint) / darkSize;
|
|
666
|
+
return tintNum === midPoint ? hue.mid.toLowerCase() : tintNum < midPoint ? require_mix.n(lightPosition, hue.mid, hue.lightest) : require_mix.n(darkPosition, hue.darkest, hue.mid);
|
|
667
|
+
}
|
|
668
|
+
const NEUTRAL_TONES = /* @__PURE__ */ new Set(["default", "transparent"]), SPOT_TINTS = {
|
|
669
|
+
blue,
|
|
670
|
+
cyan,
|
|
671
|
+
gray,
|
|
672
|
+
green,
|
|
673
|
+
magenta,
|
|
674
|
+
orange,
|
|
675
|
+
purple,
|
|
676
|
+
red,
|
|
677
|
+
yellow
|
|
678
|
+
};
|
|
679
|
+
function getTint(key) {
|
|
680
|
+
let tints = SPOT_TINTS[key];
|
|
681
|
+
if (!tints) throw Error(`Unknown tint: ${key}`);
|
|
682
|
+
return tints;
|
|
683
|
+
}
|
|
684
|
+
const studioTheme = (0, _sanity_ui_theme.buildTheme)();
|
|
685
|
+
/**
|
|
686
|
+
* Generates a Studio theme from hues, producing the exact same colors as the
|
|
687
|
+
* hosted Themer service (themer.sanity.build). This is a port of its
|
|
688
|
+
* `themeFromHues` implementation:
|
|
689
|
+
* https://github.com/sanity-io/themer/blob/main/apps/v1/utils/themeFromHues.ts
|
|
690
|
+
*/
|
|
691
|
+
function themeFromHues(partialHues) {
|
|
692
|
+
function multiply(bg, fg) {
|
|
693
|
+
return (0, _sanity_ui_theme.rgbToHex)((0, _sanity_ui_theme.multiply)((0, _sanity_ui_theme.parseColor)(bg), (0, _sanity_ui_theme.parseColor)(fg)));
|
|
694
|
+
}
|
|
695
|
+
function screen(bg, fg) {
|
|
696
|
+
return (0, _sanity_ui_theme.rgbToHex)((0, _sanity_ui_theme.screen)((0, _sanity_ui_theme.parseColor)(bg), (0, _sanity_ui_theme.parseColor)(fg)));
|
|
697
|
+
}
|
|
698
|
+
let hues = applyHues(partialHues), black = {
|
|
699
|
+
title: "Black",
|
|
700
|
+
hex: hues.default.darkest
|
|
701
|
+
}, white = {
|
|
702
|
+
title: "white",
|
|
703
|
+
hex: hues.default.lightest
|
|
704
|
+
}, tones = createTonesFromHues(hues), focusRingHue = tones.primary, accentHue = tones.critical, linkHue = tones.primary, color = (0, _sanity_ui_theme.createColorTheme)({
|
|
705
|
+
base: ({ dark, name }) => {
|
|
706
|
+
if (name === "default") {
|
|
707
|
+
let skeletonFrom = dark ? tones.transparent[900].hex : tones.transparent[100].hex;
|
|
708
|
+
return {
|
|
709
|
+
fg: dark ? white.hex : black.hex,
|
|
710
|
+
bg: dark ? black.hex : white.hex,
|
|
711
|
+
border: tones.transparent[dark ? 800 : 200].hex,
|
|
712
|
+
focusRing: focusRingHue[500].hex,
|
|
713
|
+
shadow: {
|
|
714
|
+
outline: (0, _sanity_ui_theme.rgba)(tones.transparent[500].hex, .4),
|
|
715
|
+
umbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tones.transparent[500].hex, .2),
|
|
716
|
+
penumbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tones.transparent[500].hex, .14),
|
|
717
|
+
ambient: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tones.transparent[500].hex, .12)
|
|
718
|
+
},
|
|
719
|
+
skeleton: {
|
|
720
|
+
from: skeletonFrom,
|
|
721
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
}
|
|
725
|
+
if (name === "transparent") {
|
|
726
|
+
let tints = tones.default, skeletonFrom = tints[dark ? 800 : 200].hex;
|
|
727
|
+
return {
|
|
728
|
+
fg: tints[dark ? 100 : 900].hex,
|
|
729
|
+
bg: tints[dark ? 950 : 50].hex,
|
|
730
|
+
border: tints[dark ? 800 : 300].hex,
|
|
731
|
+
focusRing: focusRingHue[500].hex,
|
|
732
|
+
shadow: {
|
|
733
|
+
outline: (0, _sanity_ui_theme.rgba)(tints[500].hex, dark ? .2 : .4),
|
|
734
|
+
umbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .2),
|
|
735
|
+
penumbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .14),
|
|
736
|
+
ambient: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .12)
|
|
737
|
+
},
|
|
738
|
+
skeleton: {
|
|
739
|
+
from: skeletonFrom,
|
|
740
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
741
|
+
}
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
let tints = tones[name] || tones.default, skeletonFrom = tints[dark ? 800 : 200].hex;
|
|
745
|
+
return {
|
|
746
|
+
fg: tints[dark ? 100 : 900].hex,
|
|
747
|
+
bg: tints[dark ? 950 : 50].hex,
|
|
748
|
+
border: tints[dark ? 800 : 200].hex,
|
|
749
|
+
focusRing: tints[500].hex,
|
|
750
|
+
shadow: {
|
|
751
|
+
outline: (0, _sanity_ui_theme.rgba)(tints[500].hex, dark ? .2 : .4),
|
|
752
|
+
umbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .2),
|
|
753
|
+
penumbra: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .14),
|
|
754
|
+
ambient: (0, _sanity_ui_theme.rgba)(dark ? black.hex : tints[500].hex, .12)
|
|
755
|
+
},
|
|
756
|
+
skeleton: {
|
|
757
|
+
from: skeletonFrom,
|
|
758
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
759
|
+
}
|
|
760
|
+
};
|
|
761
|
+
},
|
|
762
|
+
solid: ({ base, dark, name, state, tone }) => {
|
|
763
|
+
let mix = dark ? screen : multiply, mix2 = dark ? multiply : screen, defaultTints = tones[name] || tones.default, isNeutral = NEUTRAL_TONES.has(name) && NEUTRAL_TONES.has(tone), tints = tones[tone === "default" ? name : tone] || defaultTints;
|
|
764
|
+
if (state === "disabled") {
|
|
765
|
+
tints = defaultTints;
|
|
766
|
+
let bg = mix(base.bg, tints[dark ? 800 : 200].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
767
|
+
return {
|
|
768
|
+
bg,
|
|
769
|
+
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
770
|
+
border: mix(base.bg, tints[dark ? 800 : 200].hex),
|
|
771
|
+
fg: mix(base.bg, dark ? black.hex : white.hex),
|
|
772
|
+
icon: mix(base.bg, dark ? black.hex : white.hex),
|
|
773
|
+
muted: { fg: mix(base.bg, tints[dark ? 950 : 50].hex) },
|
|
774
|
+
accent: { fg: mix(base.bg, tints[dark ? 950 : 50].hex) },
|
|
775
|
+
link: { fg: mix(base.bg, tints[dark ? 950 : 50].hex) },
|
|
776
|
+
code: {
|
|
777
|
+
bg,
|
|
778
|
+
fg: mix(base.bg, tints[dark ? 950 : 50].hex)
|
|
779
|
+
},
|
|
780
|
+
skeleton: {
|
|
781
|
+
from: skeletonFrom,
|
|
782
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
783
|
+
}
|
|
784
|
+
};
|
|
785
|
+
}
|
|
786
|
+
if (state === "hovered") {
|
|
787
|
+
let bg = mix(base.bg, tints[dark ? 300 : 600].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
788
|
+
return {
|
|
789
|
+
bg,
|
|
790
|
+
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
791
|
+
border: mix(base.bg, tints[dark ? 300 : 600].hex),
|
|
792
|
+
fg: mix(base.bg, dark ? black.hex : white.hex),
|
|
793
|
+
icon: mix(base.bg, dark ? black.hex : white.hex),
|
|
794
|
+
muted: { fg: mix(base.bg, tints[dark ? 800 : 200].hex) },
|
|
795
|
+
accent: { fg: mix2(bg, accentHue[dark ? 800 : 200].hex) },
|
|
796
|
+
link: { fg: mix2(bg, linkHue[dark ? 800 : 200].hex) },
|
|
797
|
+
code: {
|
|
798
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
799
|
+
fg: mix(base.bg, tints[dark ? 800 : 200].hex)
|
|
800
|
+
},
|
|
801
|
+
skeleton: {
|
|
802
|
+
from: skeletonFrom,
|
|
803
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
if (state === "pressed") {
|
|
808
|
+
let bg = mix(base.bg, tints[dark ? 200 : 800].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
809
|
+
return {
|
|
810
|
+
bg: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
811
|
+
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
812
|
+
border: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
813
|
+
fg: mix(base.bg, dark ? black.hex : white.hex),
|
|
814
|
+
icon: mix(base.bg, dark ? black.hex : white.hex),
|
|
815
|
+
muted: { fg: mix(base.bg, tints[dark ? 800 : 200].hex) },
|
|
816
|
+
accent: { fg: mix2(bg, accentHue[dark ? 800 : 200].hex) },
|
|
817
|
+
link: { fg: mix2(bg, linkHue[dark ? 800 : 200].hex) },
|
|
818
|
+
code: {
|
|
819
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
820
|
+
fg: mix(base.bg, tints[dark ? 800 : 200].hex)
|
|
821
|
+
},
|
|
822
|
+
skeleton: {
|
|
823
|
+
from: skeletonFrom,
|
|
824
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
825
|
+
}
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
if (state === "selected") {
|
|
829
|
+
isNeutral && (tints = tones.primary);
|
|
830
|
+
let bg = mix(base.bg, tints[dark ? 200 : 800].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
831
|
+
return {
|
|
832
|
+
bg,
|
|
833
|
+
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
834
|
+
border: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
835
|
+
fg: mix(base.bg, dark ? black.hex : white.hex),
|
|
836
|
+
icon: mix(base.bg, dark ? black.hex : white.hex),
|
|
837
|
+
muted: { fg: mix(base.bg, tints[dark ? 800 : 200].hex) },
|
|
838
|
+
accent: { fg: mix2(bg, accentHue[dark ? 800 : 200].hex) },
|
|
839
|
+
link: { fg: mix2(bg, linkHue[dark ? 800 : 200].hex) },
|
|
840
|
+
code: {
|
|
841
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
842
|
+
fg: mix(base.bg, tints[dark ? 800 : 200].hex)
|
|
843
|
+
},
|
|
844
|
+
skeleton: {
|
|
845
|
+
from: skeletonFrom,
|
|
846
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
let bg = mix(base.bg, tints[dark ? 400 : 500].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
851
|
+
return {
|
|
852
|
+
bg,
|
|
853
|
+
bg2: mix2(bg, tints[dark ? 50 : 950].hex),
|
|
854
|
+
border: mix(base.bg, tints[dark ? 400 : 500].hex),
|
|
855
|
+
fg: mix(base.bg, dark ? black.hex : white.hex),
|
|
856
|
+
icon: mix(base.bg, dark ? black.hex : white.hex),
|
|
857
|
+
muted: { fg: mix(base.bg, tints[dark ? 900 : 100].hex) },
|
|
858
|
+
accent: { fg: mix2(bg, accentHue[dark ? 900 : 100].hex) },
|
|
859
|
+
link: { fg: mix2(bg, linkHue[dark ? 900 : 100].hex) },
|
|
860
|
+
code: {
|
|
861
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
862
|
+
fg: mix(base.bg, tints[dark ? 900 : 100].hex)
|
|
863
|
+
},
|
|
864
|
+
skeleton: {
|
|
865
|
+
from: skeletonFrom,
|
|
866
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
867
|
+
}
|
|
868
|
+
};
|
|
869
|
+
},
|
|
870
|
+
muted: ({ base, dark, name, state, tone }) => {
|
|
871
|
+
let mix = dark ? screen : multiply, defaultTints = tones[name] || tones.default, isNeutral = NEUTRAL_TONES.has(name) && NEUTRAL_TONES.has(tone), tints = tones[tone === "default" ? name : tone] || defaultTints;
|
|
872
|
+
if (state === "disabled") {
|
|
873
|
+
tints = defaultTints;
|
|
874
|
+
let bg = base.bg, skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
875
|
+
return {
|
|
876
|
+
bg,
|
|
877
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
878
|
+
border: mix(bg, tints[dark ? 950 : 50].hex),
|
|
879
|
+
fg: mix(bg, tints[dark ? 800 : 200].hex),
|
|
880
|
+
icon: mix(bg, tints[dark ? 800 : 200].hex),
|
|
881
|
+
muted: { fg: mix(bg, tints[dark ? 900 : 100].hex) },
|
|
882
|
+
accent: { fg: mix(bg, tints[dark ? 900 : 100].hex) },
|
|
883
|
+
link: { fg: mix(bg, tints[dark ? 900 : 100].hex) },
|
|
884
|
+
code: {
|
|
885
|
+
bg,
|
|
886
|
+
fg: mix(bg, tints[dark ? 900 : 100].hex)
|
|
887
|
+
},
|
|
888
|
+
skeleton: {
|
|
889
|
+
from: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5),
|
|
890
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .25)
|
|
891
|
+
}
|
|
892
|
+
};
|
|
893
|
+
}
|
|
894
|
+
if (state === "hovered") {
|
|
895
|
+
isNeutral && (tints = tones.primary);
|
|
896
|
+
let bg = mix(base.bg, tints[dark ? 950 : 50].hex), skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
897
|
+
return {
|
|
898
|
+
bg,
|
|
899
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
900
|
+
border: mix(bg, tints[dark ? 900 : 100].hex),
|
|
901
|
+
fg: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
902
|
+
icon: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
903
|
+
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
904
|
+
accent: { fg: mix(base.bg, linkHue[dark ? 400 : 500].hex) },
|
|
905
|
+
link: { fg: mix(base.bg, linkHue[dark ? 400 : 600].hex) },
|
|
906
|
+
code: {
|
|
907
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
908
|
+
fg: mix(base.bg, tints[dark ? 400 : 600].hex)
|
|
909
|
+
},
|
|
910
|
+
skeleton: {
|
|
911
|
+
from: skeletonFrom,
|
|
912
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
913
|
+
}
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
if (state === "pressed") {
|
|
917
|
+
isNeutral && (tints = tones.primary);
|
|
918
|
+
let bg = mix(base.bg, tints[dark ? 900 : 100].hex), skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
919
|
+
return {
|
|
920
|
+
bg,
|
|
921
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
922
|
+
border: mix(bg, tints[dark ? 900 : 100].hex),
|
|
923
|
+
fg: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
924
|
+
icon: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
925
|
+
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
926
|
+
accent: { fg: mix(bg, accentHue[dark ? 400 : 500].hex) },
|
|
927
|
+
link: { fg: mix(bg, linkHue[dark ? 400 : 600].hex) },
|
|
928
|
+
code: {
|
|
929
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
930
|
+
fg: mix(base.bg, tints[dark ? 400 : 600].hex)
|
|
931
|
+
},
|
|
932
|
+
skeleton: {
|
|
933
|
+
from: skeletonFrom,
|
|
934
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
935
|
+
}
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
if (state === "selected") {
|
|
939
|
+
isNeutral && (tints = tones.primary);
|
|
940
|
+
let bg = mix(base.bg, tints[dark ? 900 : 100].hex), skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
941
|
+
return {
|
|
942
|
+
bg,
|
|
943
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
944
|
+
border: mix(bg, tints[dark ? 900 : 100].hex),
|
|
945
|
+
fg: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
946
|
+
icon: mix(base.bg, tints[dark ? 200 : 800].hex),
|
|
947
|
+
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
948
|
+
accent: { fg: mix(bg, accentHue[dark ? 400 : 500].hex) },
|
|
949
|
+
link: { fg: mix(bg, linkHue[dark ? 400 : 600].hex) },
|
|
950
|
+
code: {
|
|
951
|
+
bg: mix(bg, tints[dark ? 950 : 50].hex),
|
|
952
|
+
fg: mix(base.bg, tints[dark ? 400 : 600].hex)
|
|
953
|
+
},
|
|
954
|
+
skeleton: {
|
|
955
|
+
from: skeletonFrom,
|
|
956
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
}
|
|
960
|
+
let bg = base.bg, skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
961
|
+
return {
|
|
962
|
+
bg,
|
|
963
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
964
|
+
border: mix(bg, tints[dark ? 900 : 100].hex),
|
|
965
|
+
fg: mix(base.bg, tints[dark ? 300 : 700].hex),
|
|
966
|
+
icon: mix(base.bg, tints[dark ? 300 : 700].hex),
|
|
967
|
+
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
968
|
+
accent: { fg: mix(base.bg, accentHue[dark ? 400 : 500].hex) },
|
|
969
|
+
link: { fg: mix(base.bg, linkHue[dark ? 400 : 600].hex) },
|
|
970
|
+
code: {
|
|
971
|
+
bg: mix(base.bg, tints[dark ? 950 : 50].hex),
|
|
972
|
+
fg: mix(base.bg, tints[dark ? 400 : 600].hex)
|
|
973
|
+
},
|
|
974
|
+
skeleton: {
|
|
975
|
+
from: skeletonFrom,
|
|
976
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
},
|
|
980
|
+
button: ({ base, mode, muted, solid }) => mode === "bleed" ? {
|
|
981
|
+
enabled: {
|
|
982
|
+
...muted.enabled,
|
|
983
|
+
border: muted.enabled.bg
|
|
984
|
+
},
|
|
985
|
+
hovered: {
|
|
986
|
+
...muted.hovered,
|
|
987
|
+
border: muted.hovered.bg
|
|
988
|
+
},
|
|
989
|
+
pressed: {
|
|
990
|
+
...muted.pressed,
|
|
991
|
+
border: muted.pressed.bg
|
|
992
|
+
},
|
|
993
|
+
selected: {
|
|
994
|
+
...muted.selected,
|
|
995
|
+
border: muted.selected.bg
|
|
996
|
+
},
|
|
997
|
+
disabled: {
|
|
998
|
+
...muted.disabled,
|
|
999
|
+
border: muted.disabled.bg
|
|
1000
|
+
}
|
|
1001
|
+
} : mode === "ghost" ? {
|
|
1002
|
+
...solid,
|
|
1003
|
+
enabled: {
|
|
1004
|
+
...muted.enabled,
|
|
1005
|
+
border: base.border
|
|
1006
|
+
},
|
|
1007
|
+
disabled: muted.disabled
|
|
1008
|
+
} : solid,
|
|
1009
|
+
card: ({ base, dark, muted, name, solid, state }) => {
|
|
1010
|
+
if (state === "hovered") return muted[name].hovered;
|
|
1011
|
+
if (state === "disabled") return muted[name].disabled;
|
|
1012
|
+
let isNeutral = NEUTRAL_TONES.has(name), tints = tones[name] || tones.default, mix = dark ? screen : multiply;
|
|
1013
|
+
if (state === "pressed") return isNeutral ? muted.primary.pressed : muted[name].pressed;
|
|
1014
|
+
if (state === "selected") return isNeutral ? solid.primary.enabled : solid[name].enabled;
|
|
1015
|
+
let bg = base.bg, skeletonFrom = mix(base.bg, tints[dark ? 900 : 100].hex);
|
|
1016
|
+
return {
|
|
1017
|
+
bg,
|
|
1018
|
+
bg2: mix(bg, tints[dark ? 950 : 50].hex),
|
|
1019
|
+
fg: base.fg,
|
|
1020
|
+
icon: base.fg,
|
|
1021
|
+
border: base.border,
|
|
1022
|
+
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
1023
|
+
accent: { fg: mix(base.bg, red[dark ? 400 : 500].hex) },
|
|
1024
|
+
link: { fg: mix(base.bg, blue[dark ? 400 : 600].hex) },
|
|
1025
|
+
code: {
|
|
1026
|
+
bg: mix(base.bg, tints[dark ? 950 : 50].hex),
|
|
1027
|
+
fg: tints[dark ? 400 : 600].hex
|
|
1028
|
+
},
|
|
1029
|
+
skeleton: {
|
|
1030
|
+
from: skeletonFrom,
|
|
1031
|
+
to: (0, _sanity_ui_theme.rgba)(skeletonFrom, .5)
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
},
|
|
1035
|
+
input: ({ base, dark, mode, state }) => {
|
|
1036
|
+
let mix = dark ? screen : multiply;
|
|
1037
|
+
if (mode === "invalid") {
|
|
1038
|
+
let tints = tones.critical;
|
|
1039
|
+
return {
|
|
1040
|
+
bg: mix(base.bg, tints[dark ? 950 : 50].hex),
|
|
1041
|
+
bg2: mix(base.bg, tints[dark ? 800 : 200].hex),
|
|
1042
|
+
fg: mix(base.bg, tints[dark ? 400 : 600].hex),
|
|
1043
|
+
border: mix(base.bg, tints[dark ? 800 : 200].hex),
|
|
1044
|
+
placeholder: mix(base.bg, tints[dark ? 600 : 400].hex)
|
|
1045
|
+
};
|
|
1046
|
+
}
|
|
1047
|
+
return state === "hovered" ? {
|
|
1048
|
+
bg: base.bg,
|
|
1049
|
+
bg2: mix(base.bg, gray[dark ? 700 : 300].hex),
|
|
1050
|
+
fg: base.fg,
|
|
1051
|
+
border: mix(base.bg, gray[dark ? 700 : 300].hex),
|
|
1052
|
+
placeholder: mix(base.bg, gray[dark ? 600 : 400].hex)
|
|
1053
|
+
} : state === "disabled" ? {
|
|
1054
|
+
bg: mix(base.bg, gray[dark ? 950 : 50].hex),
|
|
1055
|
+
bg2: mix(base.bg, gray[dark ? 900 : 100].hex),
|
|
1056
|
+
fg: mix(base.bg, gray[dark ? 700 : 300].hex),
|
|
1057
|
+
border: mix(base.bg, gray[dark ? 900 : 100].hex),
|
|
1058
|
+
placeholder: mix(base.bg, gray[dark ? 800 : 200].hex)
|
|
1059
|
+
} : state === "readOnly" ? {
|
|
1060
|
+
bg: mix(base.bg, gray[dark ? 950 : 50].hex),
|
|
1061
|
+
bg2: mix(base.bg, gray[dark ? 800 : 200].hex),
|
|
1062
|
+
fg: mix(base.bg, gray[dark ? 200 : 800].hex),
|
|
1063
|
+
border: mix(base.bg, gray[dark ? 800 : 200].hex),
|
|
1064
|
+
placeholder: mix(base.bg, gray[dark ? 600 : 400].hex)
|
|
1065
|
+
} : {
|
|
1066
|
+
bg: base.bg,
|
|
1067
|
+
bg2: base.border,
|
|
1068
|
+
fg: base.fg,
|
|
1069
|
+
border: base.border,
|
|
1070
|
+
placeholder: mix(base.bg, gray[dark ? 600 : 400].hex)
|
|
1071
|
+
};
|
|
1072
|
+
},
|
|
1073
|
+
selectable: ({ base, muted, tone, solid, state }) => state === "enabled" ? {
|
|
1074
|
+
...muted[tone].enabled,
|
|
1075
|
+
bg: base.bg
|
|
1076
|
+
} : state === "pressed" ? tone === "default" ? muted.primary.pressed : muted[tone].pressed : state === "selected" ? tone === "default" ? solid.primary.enabled : solid[tone].enabled : state === "disabled" ? {
|
|
1077
|
+
...muted[tone].disabled,
|
|
1078
|
+
bg: base.bg
|
|
1079
|
+
} : muted[tone][state],
|
|
1080
|
+
spot: ({ base, dark, key }) => (dark ? screen : multiply)(base.bg, getTint(key)[dark ? 400 : 500].hex),
|
|
1081
|
+
syntax: ({ base, dark }) => {
|
|
1082
|
+
let mix = dark ? screen : multiply, mainShade = dark ? 400 : 600, secondaryShade = dark ? 600 : 400;
|
|
1083
|
+
return {
|
|
1084
|
+
atrule: mix(base.bg, purple[mainShade].hex),
|
|
1085
|
+
attrName: mix(base.bg, green[mainShade].hex),
|
|
1086
|
+
attrValue: mix(base.bg, yellow[mainShade].hex),
|
|
1087
|
+
attribute: mix(base.bg, yellow[mainShade].hex),
|
|
1088
|
+
boolean: mix(base.bg, purple[mainShade].hex),
|
|
1089
|
+
builtin: mix(base.bg, purple[mainShade].hex),
|
|
1090
|
+
cdata: mix(base.bg, yellow[mainShade].hex),
|
|
1091
|
+
char: mix(base.bg, yellow[mainShade].hex),
|
|
1092
|
+
class: mix(base.bg, orange[mainShade].hex),
|
|
1093
|
+
className: mix(base.bg, cyan[mainShade].hex),
|
|
1094
|
+
comment: mix(base.bg, gray[secondaryShade].hex),
|
|
1095
|
+
constant: mix(base.bg, purple[mainShade].hex),
|
|
1096
|
+
deleted: mix(base.bg, red[mainShade].hex),
|
|
1097
|
+
doctype: mix(base.bg, gray[secondaryShade].hex),
|
|
1098
|
+
entity: mix(base.bg, red[mainShade].hex),
|
|
1099
|
+
function: mix(base.bg, green[mainShade].hex),
|
|
1100
|
+
hexcode: mix(base.bg, blue[mainShade].hex),
|
|
1101
|
+
id: mix(base.bg, purple[mainShade].hex),
|
|
1102
|
+
important: mix(base.bg, purple[mainShade].hex),
|
|
1103
|
+
inserted: mix(base.bg, yellow[mainShade].hex),
|
|
1104
|
+
keyword: mix(base.bg, magenta[mainShade].hex),
|
|
1105
|
+
number: mix(base.bg, purple[mainShade].hex),
|
|
1106
|
+
operator: mix(base.bg, magenta[mainShade].hex),
|
|
1107
|
+
prolog: mix(base.bg, gray[secondaryShade].hex),
|
|
1108
|
+
property: mix(base.bg, blue[mainShade].hex),
|
|
1109
|
+
pseudoClass: mix(base.bg, yellow[mainShade].hex),
|
|
1110
|
+
pseudoElement: mix(base.bg, yellow[mainShade].hex),
|
|
1111
|
+
punctuation: mix(base.bg, gray[mainShade].hex),
|
|
1112
|
+
regex: mix(base.bg, blue[mainShade].hex),
|
|
1113
|
+
selector: mix(base.bg, red[mainShade].hex),
|
|
1114
|
+
string: mix(base.bg, yellow[mainShade].hex),
|
|
1115
|
+
symbol: mix(base.bg, purple[mainShade].hex),
|
|
1116
|
+
tag: mix(base.bg, red[mainShade].hex),
|
|
1117
|
+
unit: mix(base.bg, orange[mainShade].hex),
|
|
1118
|
+
url: mix(base.bg, red[mainShade].hex),
|
|
1119
|
+
variable: mix(base.bg, red[mainShade].hex)
|
|
1120
|
+
};
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
return {
|
|
1124
|
+
...studioTheme,
|
|
1125
|
+
color,
|
|
1126
|
+
__themer: !0,
|
|
1127
|
+
v2: void 0
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
/**
|
|
1131
|
+
* Generates a Studio theme from hues, producing the same colors as importing
|
|
1132
|
+
* the theme from the hosted Themer service (themer.sanity.build):
|
|
1133
|
+
*
|
|
1134
|
+
* ```ts
|
|
1135
|
+
* import {createTheme, hues} from '@sanity/themer/legacy'
|
|
1136
|
+
* import {defineConfig} from 'sanity'
|
|
1137
|
+
*
|
|
1138
|
+
* export default defineConfig({
|
|
1139
|
+
* theme: createTheme({...hues, primary: {...hues.primary, mid: '#22fca8'}}),
|
|
1140
|
+
* // ...rest of the config
|
|
1141
|
+
* })
|
|
1142
|
+
* ```
|
|
1143
|
+
*
|
|
1144
|
+
* @public
|
|
1145
|
+
*/
|
|
1146
|
+
function createTheme(hues = {}) {
|
|
1147
|
+
return themeFromHues(hues);
|
|
1148
|
+
}
|
|
1149
|
+
/**
|
|
1150
|
+
* Parses the hues encoded in a hosted Themer service URL, returning the exact
|
|
1151
|
+
* hues that `https://themer.sanity.build/api/hues` served for that query —
|
|
1152
|
+
* presets and overrides included.
|
|
1153
|
+
*
|
|
1154
|
+
* ```ts
|
|
1155
|
+
* import {createTheme, parseHuesFromUrl} from '@sanity/themer/legacy'
|
|
1156
|
+
*
|
|
1157
|
+
* const hues = parseHuesFromUrl(
|
|
1158
|
+
* 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8',
|
|
1159
|
+
* )
|
|
1160
|
+
* const theme = createTheme(hues)
|
|
1161
|
+
* ```
|
|
1162
|
+
*
|
|
1163
|
+
* @public
|
|
1164
|
+
*/
|
|
1165
|
+
function parseHuesFromUrl(url) {
|
|
1166
|
+
let { searchParams } = new URL(url, "https://themer.sanity.build/api/hues"), preset = getPreset(searchParams.get("preset"));
|
|
1167
|
+
return applyHues(parseHuesFromSearchParams(searchParams), preset.hues);
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* The one-line replacement for a theme imported from the hosted Themer
|
|
1171
|
+
* service — pass the URL that used to be imported:
|
|
1172
|
+
*
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* // Before:
|
|
1175
|
+
* // import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant'
|
|
1176
|
+
*
|
|
1177
|
+
* // After:
|
|
1178
|
+
* import {createThemeFromUrl} from '@sanity/themer/legacy'
|
|
1179
|
+
*
|
|
1180
|
+
* const theme = createThemeFromUrl(
|
|
1181
|
+
* 'https://themer.sanity.build/api/hues?preset=verdant',
|
|
1182
|
+
* )
|
|
1183
|
+
* ```
|
|
1184
|
+
*
|
|
1185
|
+
* @public
|
|
1186
|
+
*/
|
|
1187
|
+
function createThemeFromUrl(url) {
|
|
1188
|
+
return createTheme(parseHuesFromUrl(url));
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* The hues of the default Studio theme — the same `hues` export that
|
|
1192
|
+
* `https://themer.sanity.build/api/hues` served without any parameters.
|
|
1193
|
+
*
|
|
1194
|
+
* @public
|
|
1195
|
+
*/
|
|
1196
|
+
const hues = applyHues({}), theme = createTheme(hues);
|
|
1197
|
+
exports.createTheme = createTheme, exports.createThemeFromUrl = createThemeFromUrl, exports.getPreset = getPreset, exports.hues = hues, exports.parseHuesFromUrl = parseHuesFromUrl, exports.presets = presets, exports.theme = theme;
|
|
1198
|
+
|
|
1199
|
+
//# sourceMappingURL=legacy.cjs.map
|