@sanity/themer 0.0.0 → 0.1.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/README.md +9 -89
- package/dist/{legacy.cjs → defaults-DJtuhI2W.js} +94 -56
- package/dist/defaults-DJtuhI2W.js.map +1 -0
- package/dist/legacy.d.ts +8 -90
- package/dist/legacy.d.ts.map +1 -1
- package/dist/legacy.js +2 -1199
- package/dist/tool.d.ts +20 -13
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +682 -250
- package/dist/tool.js.map +1 -1
- package/dist/types-DfPLuLv0.d.ts +74 -0
- package/dist/types-DfPLuLv0.d.ts.map +1 -0
- package/package.json +22 -39
- package/dist/_chunks/mix.cjs +0 -52
- package/dist/_chunks/mix.cjs.map +0 -1
- package/dist/_chunks/mix.js +0 -42
- package/dist/_chunks/mix.js.map +0 -1
- package/dist/_chunks/presets.cjs +0 -215
- package/dist/_chunks/presets.cjs.map +0 -1
- package/dist/_chunks/presets.js +0 -201
- package/dist/_chunks/presets.js.map +0 -1
- package/dist/_chunks/types.d.cts +0 -26
- package/dist/_chunks/types.d.cts.map +0 -1
- package/dist/_chunks/types.d.ts +0 -26
- package/dist/_chunks/types.d.ts.map +0 -1
- package/dist/index.cjs +0 -3
- package/dist/index.d.cts +0 -63
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts +0 -63
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/legacy.cjs.map +0 -1
- package/dist/legacy.d.cts +0 -166
- package/dist/legacy.d.cts.map +0 -1
- package/dist/legacy.js.map +0 -1
- package/dist/tool.cjs +0 -407
- package/dist/tool.cjs.map +0 -1
- package/dist/tool.d.cts +0 -45
- package/dist/tool.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -1,105 +1,25 @@
|
|
|
1
1
|
# @sanity/themer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Recreate [Sanity Studio](https://www.sanity.io/studio) themes from the hosted Themer service locally.
|
|
4
4
|
|
|
5
|
-
This package is the npm migration path off the hosted Themer service ([themer.sanity.build](https://themer.sanity.build)) — the
|
|
5
|
+
This package is the npm migration path off the hosted Themer service ([themer.sanity.build](https://themer.sanity.build)) — the generator runs locally, so Studio configs no longer need to import modules from a hosted URL. The `@sanity/themer/legacy` subpath generates the exact same colors the service serves. There is no root export yet.
|
|
6
6
|
|
|
7
7
|
```sh
|
|
8
8
|
npm install @sanity/themer
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
## Usage
|
|
12
|
-
|
|
13
|
-
Generate a theme from a handful of colors:
|
|
14
|
-
|
|
15
|
-
```ts
|
|
16
|
-
// sanity.config.ts
|
|
17
|
-
import {createTheme} from '@sanity/themer'
|
|
18
|
-
import {defineConfig} from 'sanity'
|
|
19
|
-
|
|
20
|
-
export default defineConfig({
|
|
21
|
-
theme: createTheme({primary: '#2276fc'}),
|
|
22
|
-
// ...rest of the config
|
|
23
|
-
})
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
Every color is optional — omitted colors keep their default Sanity ramps:
|
|
27
|
-
|
|
28
|
-
| Color | Drives |
|
|
29
|
-
| ---------- | --------------------------------------- |
|
|
30
|
-
| `primary` | Buttons, focus rings, links, selections |
|
|
31
|
-
| `gray` | Neutral surfaces, borders and text |
|
|
32
|
-
| `positive` | Success accents |
|
|
33
|
-
| `caution` | Warning accents |
|
|
34
|
-
| `critical` | Errors and destructive actions |
|
|
35
|
-
| `lightest` | Light mode background |
|
|
36
|
-
| `darkest` | Dark mode background |
|
|
37
|
-
|
|
38
|
-
Preset themes are available from the `presets` export:
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
import {createTheme, presets} from '@sanity/themer'
|
|
42
|
-
|
|
43
|
-
const verdant = presets.find((preset) => preset.slug === 'verdant')
|
|
44
|
-
const theme = createTheme(verdant.colors)
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
For customization beyond colors, `themeConfigFromColors` maps colors to a [`@sanity/ui`](https://github.com/sanity-io/ui) `ThemeConfig` to pass to `buildTheme`:
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import {themeConfigFromColors} from '@sanity/themer'
|
|
51
|
-
import {buildTheme} from '@sanity/ui/theme'
|
|
52
|
-
|
|
53
|
-
const theme = buildTheme({
|
|
54
|
-
...themeConfigFromColors({primary: '#2276fc'}),
|
|
55
|
-
// ...other ThemeConfig properties
|
|
56
|
-
})
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
## The Studio tool
|
|
60
|
-
|
|
61
|
-
The `themerTool` plugin previews generated themes live on your own Studio:
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
// sanity.config.ts
|
|
65
|
-
import {themerTool} from '@sanity/themer/tool'
|
|
66
|
-
import {defineConfig} from 'sanity'
|
|
67
|
-
|
|
68
|
-
export default defineConfig({
|
|
69
|
-
plugins: [themerTool()],
|
|
70
|
-
// ...rest of the config
|
|
71
|
-
})
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
A color wheel toggle in the navbar opens the themer sidebar next to the active tool, so you can browse around the Studio while tweaking presets and colors. Toggle between light and dark mode with the regular appearance menu — the preview follows it. When the theme looks right, copy the generated `createTheme` snippet into the Studio config.
|
|
75
|
-
|
|
76
|
-
If the Studio is already themed, pass the same colors to the plugin so the sidebar starts editing from them:
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
import {createTheme} from '@sanity/themer'
|
|
80
|
-
import {themerTool} from '@sanity/themer/tool'
|
|
81
|
-
import {defineConfig} from 'sanity'
|
|
82
|
-
|
|
83
|
-
const colors = {primary: '#2276fc'}
|
|
84
|
-
|
|
85
|
-
export default defineConfig({
|
|
86
|
-
theme: createTheme(colors),
|
|
87
|
-
plugins: [themerTool({colors})],
|
|
88
|
-
})
|
|
89
|
-
```
|
|
90
|
-
|
|
91
11
|
## Migrating from themer.sanity.build
|
|
92
12
|
|
|
93
|
-
`@sanity/themer/legacy` generates the exact same colors as the hosted service, with the same `createTheme`, `hues` and `theme` exports that `https://themer.sanity.build/api/hues` served. Replace the URL import with `
|
|
13
|
+
`@sanity/themer/legacy` generates the exact same colors as the hosted service, with the same `createTheme`, `hues` and `theme` exports that `https://themer.sanity.build/api/hues` served. Replace the URL import with `buildThemeFromUrl` and the URL as a string:
|
|
94
14
|
|
|
95
15
|
```ts
|
|
96
16
|
// Before:
|
|
97
17
|
import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8'
|
|
98
18
|
|
|
99
19
|
// After:
|
|
100
|
-
import {
|
|
20
|
+
import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
101
21
|
|
|
102
|
-
const theme =
|
|
22
|
+
const theme = buildThemeFromUrl(
|
|
103
23
|
'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8',
|
|
104
24
|
)
|
|
105
25
|
```
|
|
@@ -121,17 +41,17 @@ export default defineConfig({
|
|
|
121
41
|
})
|
|
122
42
|
```
|
|
123
43
|
|
|
124
|
-
The hosted presets are
|
|
44
|
+
The hosted presets are addressed by query, exactly like the service:
|
|
125
45
|
|
|
126
46
|
```ts
|
|
127
|
-
import {
|
|
47
|
+
import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
128
48
|
|
|
129
|
-
const theme =
|
|
49
|
+
const theme = buildThemeFromUrl('?preset=verdant')
|
|
130
50
|
```
|
|
131
51
|
|
|
132
52
|
Once migrated, remove any `themer.d.ts` module declarations and `urlImports` config that the URL imports needed.
|
|
133
53
|
|
|
134
|
-
The
|
|
54
|
+
The generated theme carries no `__themer` flag, which is the one intentional difference from the hosted module. Sanity Studio uses that flag to throw away the fonts the hosted module bundled, because they had drifted from the Studio's own; here the fonts come from the `@sanity/ui` installed next to the Studio, so there is nothing to throw away.
|
|
135
55
|
|
|
136
56
|
## License
|
|
137
57
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
let _sanity_color = require("@sanity/color"), _sanity_ui_theme = require("@sanity/ui/theme");
|
|
1
|
+
import { buildTheme, createColorTheme, multiply, parseColor, rgbToHex, rgba, screen } from "@sanity/ui/theme";
|
|
2
|
+
import { COLOR_TINTS } from "@sanity/color";
|
|
4
3
|
/**
|
|
5
4
|
* Drops properties that are set to `undefined`, so that spreading the hue
|
|
6
5
|
* over defaults doesn't shadow them. The hosted Themer service used a
|
|
@@ -521,6 +520,45 @@ function applyHues(_hues, defaults = defaultHues) {
|
|
|
521
520
|
}
|
|
522
521
|
};
|
|
523
522
|
}
|
|
523
|
+
/**
|
|
524
|
+
* Color mixing that is byte-for-byte compatible with the `mix` function from
|
|
525
|
+
* `polished`, which the hosted Themer service (themer.sanity.build) used to
|
|
526
|
+
* interpolate hue tints. Only opaque hex colors are supported, which is all
|
|
527
|
+
* the theme generators ever pass.
|
|
528
|
+
*
|
|
529
|
+
* @internal
|
|
530
|
+
*/
|
|
531
|
+
function mix(weight, color, otherColor) {
|
|
532
|
+
if (weight === 0) return otherColor;
|
|
533
|
+
let [r1, g1, b1] = hexToRgb(color), [r2, g2, b2] = hexToRgb(otherColor), w2 = 1 - weight;
|
|
534
|
+
return reduceHex(`#${channelToHex(Math.floor(r1 * weight + r2 * w2))}${channelToHex(Math.floor(g1 * weight + g2 * w2))}${channelToHex(Math.floor(b1 * weight + b2 * w2))}`);
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Matches `#abc` and `#aabbcc` hex colors (the only formats the theme
|
|
538
|
+
* generators accept), same as the hosted Themer service did.
|
|
539
|
+
*
|
|
540
|
+
* @internal
|
|
541
|
+
*/
|
|
542
|
+
function isColor(input) {
|
|
543
|
+
return /^#(?:[0-9a-f]{3}){1,2}$/i.test(input);
|
|
544
|
+
}
|
|
545
|
+
function hexToRgb(color) {
|
|
546
|
+
if (!isColor(color)) throw TypeError(`Invalid color: ${JSON.stringify(color)} — expected a hex color`);
|
|
547
|
+
let hex = color.length === 4 ? `${color[1]}${color[1]}${color[2]}${color[2]}${color[3]}${color[3]}` : color.slice(1);
|
|
548
|
+
return [
|
|
549
|
+
parseInt(hex.slice(0, 2), 16),
|
|
550
|
+
parseInt(hex.slice(2, 4), 16),
|
|
551
|
+
parseInt(hex.slice(4, 6), 16)
|
|
552
|
+
];
|
|
553
|
+
}
|
|
554
|
+
function channelToHex(value) {
|
|
555
|
+
let hex = value.toString(16);
|
|
556
|
+
return hex.length === 1 ? `0${hex}` : hex;
|
|
557
|
+
}
|
|
558
|
+
/** Shortens `#aabbcc` to `#abc` when possible, same as `polished` does */
|
|
559
|
+
function reduceHex(hex) {
|
|
560
|
+
return hex[1] === hex[2] && hex[3] === hex[4] && hex[5] === hex[6] ? `#${hex[1]}${hex[3]}${hex[5]}` : hex;
|
|
561
|
+
}
|
|
524
562
|
const VALID_MID_POINTS = /* @__PURE__ */ new Set([
|
|
525
563
|
50,
|
|
526
564
|
100,
|
|
@@ -561,7 +599,7 @@ function parseHue(key, searchParams, defaultLightest, defaultDarkest) {
|
|
|
561
599
|
let maybeMid = `#${param}`, maybeMidPoint = roundMidPoint(Number(param));
|
|
562
600
|
switch (!0) {
|
|
563
601
|
case param === "": break;
|
|
564
|
-
case
|
|
602
|
+
case isColor(maybeMid) && !mid:
|
|
565
603
|
mid = maybeMid;
|
|
566
604
|
break;
|
|
567
605
|
case !Number.isNaN(maybeMidPoint) && !midPoint:
|
|
@@ -573,7 +611,7 @@ function parseHue(key, searchParams, defaultLightest, defaultDarkest) {
|
|
|
573
611
|
case param.startsWith("darkest:") && !darkest:
|
|
574
612
|
darkest = assertValidColor(`#${param.replace(/^darkest:/, "")}`);
|
|
575
613
|
break;
|
|
576
|
-
case
|
|
614
|
+
case isColor(maybeMid):
|
|
577
615
|
throwDuplicate(key, mid?.replace(/^#/, ""), param, input);
|
|
578
616
|
break;
|
|
579
617
|
case !Number.isNaN(maybeMidPoint):
|
|
@@ -602,7 +640,7 @@ function throwDuplicate(key, a, b, input) {
|
|
|
602
640
|
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
641
|
}
|
|
604
642
|
function assertValidColor(input) {
|
|
605
|
-
if (
|
|
643
|
+
if (isColor(input)) return input;
|
|
606
644
|
throw TypeError(`Invalid color: ${input}`);
|
|
607
645
|
}
|
|
608
646
|
function assertValidMidPoint(input) {
|
|
@@ -633,9 +671,10 @@ const defaultPreset = definePreset("default", "Studio v3", "lightest=fff&darkest
|
|
|
633
671
|
];
|
|
634
672
|
/**
|
|
635
673
|
* Finds a preset by its slug, falling back to the default Studio preset for
|
|
636
|
-
* unknown slugs — the
|
|
674
|
+
* unknown slugs — the behavior of the hosted Themer service's `?preset`
|
|
675
|
+
* param, which `parseHuesFromUrl` exposes.
|
|
637
676
|
*
|
|
638
|
-
* @
|
|
677
|
+
* @internal
|
|
639
678
|
*/
|
|
640
679
|
function getPreset(slug) {
|
|
641
680
|
let needle = slug?.toLowerCase();
|
|
@@ -656,14 +695,14 @@ function createTonesFromHues(hues) {
|
|
|
656
695
|
};
|
|
657
696
|
}
|
|
658
697
|
function createTintsFromHue(hue, title) {
|
|
659
|
-
return
|
|
698
|
+
return COLOR_TINTS.reduce((tints, tint) => (tints[tint] = {
|
|
660
699
|
title: `${title} ${tint}`,
|
|
661
700
|
hex: getColorHex(hue, tint)
|
|
662
701
|
}, tints), {});
|
|
663
702
|
}
|
|
664
703
|
function getColorHex(hue, tint) {
|
|
665
704
|
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 ?
|
|
705
|
+
return tintNum === midPoint ? hue.mid.toLowerCase() : tintNum < midPoint ? mix(lightPosition, hue.mid, hue.lightest) : mix(darkPosition, hue.darkest, hue.mid);
|
|
667
706
|
}
|
|
668
707
|
const NEUTRAL_TONES = /* @__PURE__ */ new Set(["default", "transparent"]), SPOT_TINTS = {
|
|
669
708
|
blue,
|
|
@@ -681,7 +720,7 @@ function getTint(key) {
|
|
|
681
720
|
if (!tints) throw Error(`Unknown tint: ${key}`);
|
|
682
721
|
return tints;
|
|
683
722
|
}
|
|
684
|
-
const
|
|
723
|
+
const defaultTheme = buildTheme();
|
|
685
724
|
/**
|
|
686
725
|
* Generates a Studio theme from hues, producing the exact same colors as the
|
|
687
726
|
* hosted Themer service (themer.sanity.build). This is a port of its
|
|
@@ -689,11 +728,11 @@ const studioTheme = (0, _sanity_ui_theme.buildTheme)();
|
|
|
689
728
|
* https://github.com/sanity-io/themer/blob/main/apps/v1/utils/themeFromHues.ts
|
|
690
729
|
*/
|
|
691
730
|
function themeFromHues(partialHues) {
|
|
692
|
-
function multiply(bg, fg) {
|
|
693
|
-
return
|
|
731
|
+
function multiply$1(bg, fg) {
|
|
732
|
+
return rgbToHex(multiply(parseColor(bg), parseColor(fg)));
|
|
694
733
|
}
|
|
695
|
-
function screen(bg, fg) {
|
|
696
|
-
return
|
|
734
|
+
function screen$1(bg, fg) {
|
|
735
|
+
return rgbToHex(screen(parseColor(bg), parseColor(fg)));
|
|
697
736
|
}
|
|
698
737
|
let hues = applyHues(partialHues), black = {
|
|
699
738
|
title: "Black",
|
|
@@ -701,7 +740,7 @@ function themeFromHues(partialHues) {
|
|
|
701
740
|
}, white = {
|
|
702
741
|
title: "white",
|
|
703
742
|
hex: hues.default.lightest
|
|
704
|
-
}, tones = createTonesFromHues(hues), focusRingHue = tones.primary, accentHue = tones.critical, linkHue = tones.primary, color =
|
|
743
|
+
}, tones = createTonesFromHues(hues), focusRingHue = tones.primary, accentHue = tones.critical, linkHue = tones.primary, color = createColorTheme({
|
|
705
744
|
base: ({ dark, name }) => {
|
|
706
745
|
if (name === "default") {
|
|
707
746
|
let skeletonFrom = dark ? tones.transparent[900].hex : tones.transparent[100].hex;
|
|
@@ -711,14 +750,14 @@ function themeFromHues(partialHues) {
|
|
|
711
750
|
border: tones.transparent[dark ? 800 : 200].hex,
|
|
712
751
|
focusRing: focusRingHue[500].hex,
|
|
713
752
|
shadow: {
|
|
714
|
-
outline:
|
|
715
|
-
umbra:
|
|
716
|
-
penumbra:
|
|
717
|
-
ambient:
|
|
753
|
+
outline: rgba(tones.transparent[500].hex, .4),
|
|
754
|
+
umbra: rgba(dark ? black.hex : tones.transparent[500].hex, .2),
|
|
755
|
+
penumbra: rgba(dark ? black.hex : tones.transparent[500].hex, .14),
|
|
756
|
+
ambient: rgba(dark ? black.hex : tones.transparent[500].hex, .12)
|
|
718
757
|
},
|
|
719
758
|
skeleton: {
|
|
720
759
|
from: skeletonFrom,
|
|
721
|
-
to:
|
|
760
|
+
to: rgba(skeletonFrom, .5)
|
|
722
761
|
}
|
|
723
762
|
};
|
|
724
763
|
}
|
|
@@ -730,14 +769,14 @@ function themeFromHues(partialHues) {
|
|
|
730
769
|
border: tints[dark ? 800 : 300].hex,
|
|
731
770
|
focusRing: focusRingHue[500].hex,
|
|
732
771
|
shadow: {
|
|
733
|
-
outline:
|
|
734
|
-
umbra:
|
|
735
|
-
penumbra:
|
|
736
|
-
ambient:
|
|
772
|
+
outline: rgba(tints[500].hex, dark ? .2 : .4),
|
|
773
|
+
umbra: rgba(dark ? black.hex : tints[500].hex, .2),
|
|
774
|
+
penumbra: rgba(dark ? black.hex : tints[500].hex, .14),
|
|
775
|
+
ambient: rgba(dark ? black.hex : tints[500].hex, .12)
|
|
737
776
|
},
|
|
738
777
|
skeleton: {
|
|
739
778
|
from: skeletonFrom,
|
|
740
|
-
to:
|
|
779
|
+
to: rgba(skeletonFrom, .5)
|
|
741
780
|
}
|
|
742
781
|
};
|
|
743
782
|
}
|
|
@@ -748,19 +787,19 @@ function themeFromHues(partialHues) {
|
|
|
748
787
|
border: tints[dark ? 800 : 200].hex,
|
|
749
788
|
focusRing: tints[500].hex,
|
|
750
789
|
shadow: {
|
|
751
|
-
outline:
|
|
752
|
-
umbra:
|
|
753
|
-
penumbra:
|
|
754
|
-
ambient:
|
|
790
|
+
outline: rgba(tints[500].hex, dark ? .2 : .4),
|
|
791
|
+
umbra: rgba(dark ? black.hex : tints[500].hex, .2),
|
|
792
|
+
penumbra: rgba(dark ? black.hex : tints[500].hex, .14),
|
|
793
|
+
ambient: rgba(dark ? black.hex : tints[500].hex, .12)
|
|
755
794
|
},
|
|
756
795
|
skeleton: {
|
|
757
796
|
from: skeletonFrom,
|
|
758
|
-
to:
|
|
797
|
+
to: rgba(skeletonFrom, .5)
|
|
759
798
|
}
|
|
760
799
|
};
|
|
761
800
|
},
|
|
762
801
|
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;
|
|
802
|
+
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;
|
|
764
803
|
if (state === "disabled") {
|
|
765
804
|
tints = defaultTints;
|
|
766
805
|
let bg = mix(base.bg, tints[dark ? 800 : 200].hex), skeletonFrom = mix2(bg, tints[dark ? 200 : 800].hex);
|
|
@@ -779,7 +818,7 @@ function themeFromHues(partialHues) {
|
|
|
779
818
|
},
|
|
780
819
|
skeleton: {
|
|
781
820
|
from: skeletonFrom,
|
|
782
|
-
to:
|
|
821
|
+
to: rgba(skeletonFrom, .5)
|
|
783
822
|
}
|
|
784
823
|
};
|
|
785
824
|
}
|
|
@@ -800,7 +839,7 @@ function themeFromHues(partialHues) {
|
|
|
800
839
|
},
|
|
801
840
|
skeleton: {
|
|
802
841
|
from: skeletonFrom,
|
|
803
|
-
to:
|
|
842
|
+
to: rgba(skeletonFrom, .5)
|
|
804
843
|
}
|
|
805
844
|
};
|
|
806
845
|
}
|
|
@@ -821,7 +860,7 @@ function themeFromHues(partialHues) {
|
|
|
821
860
|
},
|
|
822
861
|
skeleton: {
|
|
823
862
|
from: skeletonFrom,
|
|
824
|
-
to:
|
|
863
|
+
to: rgba(skeletonFrom, .5)
|
|
825
864
|
}
|
|
826
865
|
};
|
|
827
866
|
}
|
|
@@ -843,7 +882,7 @@ function themeFromHues(partialHues) {
|
|
|
843
882
|
},
|
|
844
883
|
skeleton: {
|
|
845
884
|
from: skeletonFrom,
|
|
846
|
-
to:
|
|
885
|
+
to: rgba(skeletonFrom, .5)
|
|
847
886
|
}
|
|
848
887
|
};
|
|
849
888
|
}
|
|
@@ -863,12 +902,12 @@ function themeFromHues(partialHues) {
|
|
|
863
902
|
},
|
|
864
903
|
skeleton: {
|
|
865
904
|
from: skeletonFrom,
|
|
866
|
-
to:
|
|
905
|
+
to: rgba(skeletonFrom, .5)
|
|
867
906
|
}
|
|
868
907
|
};
|
|
869
908
|
},
|
|
870
909
|
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;
|
|
910
|
+
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;
|
|
872
911
|
if (state === "disabled") {
|
|
873
912
|
tints = defaultTints;
|
|
874
913
|
let bg = base.bg, skeletonFrom = mix(bg, tints[dark ? 900 : 100].hex);
|
|
@@ -886,8 +925,8 @@ function themeFromHues(partialHues) {
|
|
|
886
925
|
fg: mix(bg, tints[dark ? 900 : 100].hex)
|
|
887
926
|
},
|
|
888
927
|
skeleton: {
|
|
889
|
-
from:
|
|
890
|
-
to:
|
|
928
|
+
from: rgba(skeletonFrom, .5),
|
|
929
|
+
to: rgba(skeletonFrom, .25)
|
|
891
930
|
}
|
|
892
931
|
};
|
|
893
932
|
}
|
|
@@ -909,7 +948,7 @@ function themeFromHues(partialHues) {
|
|
|
909
948
|
},
|
|
910
949
|
skeleton: {
|
|
911
950
|
from: skeletonFrom,
|
|
912
|
-
to:
|
|
951
|
+
to: rgba(skeletonFrom, .5)
|
|
913
952
|
}
|
|
914
953
|
};
|
|
915
954
|
}
|
|
@@ -931,7 +970,7 @@ function themeFromHues(partialHues) {
|
|
|
931
970
|
},
|
|
932
971
|
skeleton: {
|
|
933
972
|
from: skeletonFrom,
|
|
934
|
-
to:
|
|
973
|
+
to: rgba(skeletonFrom, .5)
|
|
935
974
|
}
|
|
936
975
|
};
|
|
937
976
|
}
|
|
@@ -953,7 +992,7 @@ function themeFromHues(partialHues) {
|
|
|
953
992
|
},
|
|
954
993
|
skeleton: {
|
|
955
994
|
from: skeletonFrom,
|
|
956
|
-
to:
|
|
995
|
+
to: rgba(skeletonFrom, .5)
|
|
957
996
|
}
|
|
958
997
|
};
|
|
959
998
|
}
|
|
@@ -973,7 +1012,7 @@ function themeFromHues(partialHues) {
|
|
|
973
1012
|
},
|
|
974
1013
|
skeleton: {
|
|
975
1014
|
from: skeletonFrom,
|
|
976
|
-
to:
|
|
1015
|
+
to: rgba(skeletonFrom, .5)
|
|
977
1016
|
}
|
|
978
1017
|
};
|
|
979
1018
|
},
|
|
@@ -1009,7 +1048,7 @@ function themeFromHues(partialHues) {
|
|
|
1009
1048
|
card: ({ base, dark, muted, name, solid, state }) => {
|
|
1010
1049
|
if (state === "hovered") return muted[name].hovered;
|
|
1011
1050
|
if (state === "disabled") return muted[name].disabled;
|
|
1012
|
-
let isNeutral = NEUTRAL_TONES.has(name), tints = tones[name] || tones.default, mix = dark ? screen : multiply;
|
|
1051
|
+
let isNeutral = NEUTRAL_TONES.has(name), tints = tones[name] || tones.default, mix = dark ? screen$1 : multiply$1;
|
|
1013
1052
|
if (state === "pressed") return isNeutral ? muted.primary.pressed : muted[name].pressed;
|
|
1014
1053
|
if (state === "selected") return isNeutral ? solid.primary.enabled : solid[name].enabled;
|
|
1015
1054
|
let bg = base.bg, skeletonFrom = mix(base.bg, tints[dark ? 900 : 100].hex);
|
|
@@ -1028,12 +1067,12 @@ function themeFromHues(partialHues) {
|
|
|
1028
1067
|
},
|
|
1029
1068
|
skeleton: {
|
|
1030
1069
|
from: skeletonFrom,
|
|
1031
|
-
to:
|
|
1070
|
+
to: rgba(skeletonFrom, .5)
|
|
1032
1071
|
}
|
|
1033
1072
|
};
|
|
1034
1073
|
},
|
|
1035
1074
|
input: ({ base, dark, mode, state }) => {
|
|
1036
|
-
let mix = dark ? screen : multiply;
|
|
1075
|
+
let mix = dark ? screen$1 : multiply$1;
|
|
1037
1076
|
if (mode === "invalid") {
|
|
1038
1077
|
let tints = tones.critical;
|
|
1039
1078
|
return {
|
|
@@ -1077,9 +1116,9 @@ function themeFromHues(partialHues) {
|
|
|
1077
1116
|
...muted[tone].disabled,
|
|
1078
1117
|
bg: base.bg
|
|
1079
1118
|
} : muted[tone][state],
|
|
1080
|
-
spot: ({ base, dark, key }) => (dark ? screen : multiply)(base.bg, getTint(key)[dark ? 400 : 500].hex),
|
|
1119
|
+
spot: ({ base, dark, key }) => (dark ? screen$1 : multiply$1)(base.bg, getTint(key)[dark ? 400 : 500].hex),
|
|
1081
1120
|
syntax: ({ base, dark }) => {
|
|
1082
|
-
let mix = dark ? screen : multiply, mainShade = dark ? 400 : 600, secondaryShade = dark ? 600 : 400;
|
|
1121
|
+
let mix = dark ? screen$1 : multiply$1, mainShade = dark ? 400 : 600, secondaryShade = dark ? 600 : 400;
|
|
1083
1122
|
return {
|
|
1084
1123
|
atrule: mix(base.bg, purple[mainShade].hex),
|
|
1085
1124
|
attrName: mix(base.bg, green[mainShade].hex),
|
|
@@ -1121,9 +1160,8 @@ function themeFromHues(partialHues) {
|
|
|
1121
1160
|
}
|
|
1122
1161
|
});
|
|
1123
1162
|
return {
|
|
1124
|
-
...
|
|
1163
|
+
...defaultTheme,
|
|
1125
1164
|
color,
|
|
1126
|
-
__themer: !0,
|
|
1127
1165
|
v2: void 0
|
|
1128
1166
|
};
|
|
1129
1167
|
}
|
|
@@ -1175,16 +1213,16 @@ function parseHuesFromUrl(url) {
|
|
|
1175
1213
|
* // import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant'
|
|
1176
1214
|
*
|
|
1177
1215
|
* // After:
|
|
1178
|
-
* import {
|
|
1216
|
+
* import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
1179
1217
|
*
|
|
1180
|
-
* const theme =
|
|
1218
|
+
* const theme = buildThemeFromUrl(
|
|
1181
1219
|
* 'https://themer.sanity.build/api/hues?preset=verdant',
|
|
1182
1220
|
* )
|
|
1183
1221
|
* ```
|
|
1184
1222
|
*
|
|
1185
1223
|
* @public
|
|
1186
1224
|
*/
|
|
1187
|
-
function
|
|
1225
|
+
function buildThemeFromUrl(url) {
|
|
1188
1226
|
return createTheme(parseHuesFromUrl(url));
|
|
1189
1227
|
}
|
|
1190
1228
|
/**
|
|
@@ -1194,6 +1232,6 @@ function createThemeFromUrl(url) {
|
|
|
1194
1232
|
* @public
|
|
1195
1233
|
*/
|
|
1196
1234
|
const hues = applyHues({}), theme = createTheme(hues);
|
|
1197
|
-
|
|
1235
|
+
export { parseHuesFromUrl as a, isColor as c, createTheme as i, applyHues as l, theme as n, createTonesFromHues as o, buildThemeFromUrl as r, presets as s, hues as t };
|
|
1198
1236
|
|
|
1199
|
-
//# sourceMappingURL=
|
|
1237
|
+
//# sourceMappingURL=defaults-DJtuhI2W.js.map
|