@sanity/themer 0.3.15 → 0.3.16

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