@sanity/themer 0.0.0 → 0.2.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 +33 -58
- package/dist/index.d.ts +51 -23
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/legacy.d.ts +7 -18
- package/dist/legacy.d.ts.map +1 -1
- package/dist/legacy.js +39 -39
- package/dist/legacy.js.map +1 -1
- package/dist/{_chunks/mix.js → mix-BfV6_Ke4.js} +1 -1
- package/dist/mix-BfV6_Ke4.js.map +1 -0
- package/dist/options-BaqJJgRs.d.ts +59 -0
- package/dist/options-BaqJJgRs.d.ts.map +1 -0
- package/dist/presets-DWzYcsLg.js +375 -0
- package/dist/presets-DWzYcsLg.js.map +1 -0
- package/dist/tool.d.ts +22 -15
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +608 -282
- package/dist/tool.js.map +1 -1
- package/package.json +24 -39
- package/dist/_chunks/mix.cjs +0 -52
- package/dist/_chunks/mix.cjs.map +0 -1
- 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/legacy.cjs +0 -1199
- package/dist/legacy.cjs.map +0 -1
- package/dist/legacy.d.cts +0 -166
- package/dist/legacy.d.cts.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,8 +1,6 @@
|
|
|
1
1
|
# @sanity/themer
|
|
2
2
|
|
|
3
|
-
Generate [Sanity Studio](https://www.sanity.io/studio) themes
|
|
4
|
-
|
|
5
|
-
This package is the npm migration path off the hosted Themer service ([themer.sanity.build](https://themer.sanity.build)) — the generators run locally, so Studio configs no longer need to import modules from a hosted URL.
|
|
3
|
+
Generate [Sanity Studio](https://www.sanity.io/studio) themes from a handful of colors.
|
|
6
4
|
|
|
7
5
|
```sh
|
|
8
6
|
npm install @sanity/themer
|
|
@@ -10,58 +8,48 @@ npm install @sanity/themer
|
|
|
10
8
|
|
|
11
9
|
## Usage
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
`buildTheme` builds the same type of theme as `buildTheme` from `@sanity/ui/theme` — ready for the `theme` property of a Studio config — but takes colors instead of design tokens. Under the hood it only swaps out the color palette that `@sanity/ui/theme` otherwise fills with [`@sanity/color`](https://www.sanity.io/docs/color):
|
|
14
12
|
|
|
15
13
|
```ts
|
|
16
|
-
|
|
17
|
-
import {createTheme} from '@sanity/themer'
|
|
14
|
+
import {buildTheme} from '@sanity/themer'
|
|
18
15
|
import {defineConfig} from 'sanity'
|
|
19
16
|
|
|
17
|
+
export const theme = buildTheme({
|
|
18
|
+
accent: '#f00', // required
|
|
19
|
+
text: '#727892', // optional
|
|
20
|
+
background: {dark: '#0d0e12', light: '#ffffff'}, // optional
|
|
21
|
+
contrast: 85, // optional, 15–100
|
|
22
|
+
})
|
|
23
|
+
|
|
20
24
|
export default defineConfig({
|
|
21
|
-
theme
|
|
25
|
+
theme,
|
|
22
26
|
// ...rest of the config
|
|
23
27
|
})
|
|
24
28
|
```
|
|
25
29
|
|
|
26
|
-
|
|
30
|
+
- `accent` replaces the `blue` scale of the palette, which Sanity UI uses for primary buttons, focus rings and links.
|
|
31
|
+
- `text` replaces the `gray` scale — text, icons, borders and neutral surfaces. When omitted it is derived from `accent`: a mostly desaturated version of it, the way the stock gray carries a hint of the stock blue.
|
|
32
|
+
- `background.dark` replaces `black` and `background.light` replaces `white` — the backgrounds of the two color schemes that every other color blends onto.
|
|
33
|
+
- `contrast` controls how strongly text and borders separate from the accent. The default `85` uses the text color as-is; `100` removes its tint entirely (a high contrast scheme with no mixing of text and accent), and lower values blend more and more of the accent into the text scale, giving text and borders more color.
|
|
27
34
|
|
|
28
|
-
|
|
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 |
|
|
35
|
+
A few ground rules keep the generated palette usable: the accent and text colors cannot be too dark or too light (they would mess with the rest of their scales), `background.dark` is made darker until it has enough contrast with both of them (it can never be lighter than either), and `background.light` can never be darker than either.
|
|
37
36
|
|
|
38
|
-
|
|
37
|
+
Called with the stock colors — like `text` and `background` in the example — the generated colors match `buildTheme()` from `@sanity/ui/theme` with no options exactly.
|
|
39
38
|
|
|
40
|
-
|
|
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`:
|
|
39
|
+
`buildPalette` returns the generated `@sanity/color`-shaped palette without building a theme from it, and `presets` ships the hosted Themer service presets translated to `buildTheme` options:
|
|
48
40
|
|
|
49
41
|
```ts
|
|
50
|
-
import {
|
|
51
|
-
import {buildTheme} from '@sanity/ui/theme'
|
|
42
|
+
import {buildTheme, presets} from '@sanity/themer'
|
|
52
43
|
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
// ...other ThemeConfig properties
|
|
56
|
-
})
|
|
44
|
+
const verdant = presets.find((preset) => preset.slug === 'verdant')
|
|
45
|
+
const theme = buildTheme(verdant.options)
|
|
57
46
|
```
|
|
58
47
|
|
|
59
|
-
##
|
|
48
|
+
## Studio tool
|
|
60
49
|
|
|
61
|
-
|
|
50
|
+
`@sanity/themer/tool` adds a themer sidebar to the Studio for these themes: presets, accent/text/background pickers and a contrast slider preview a `buildTheme` theme live on the whole Studio, plus the snippet to make it permanent:
|
|
62
51
|
|
|
63
52
|
```ts
|
|
64
|
-
// sanity.config.ts
|
|
65
53
|
import {themerTool} from '@sanity/themer/tool'
|
|
66
54
|
import {defineConfig} from 'sanity'
|
|
67
55
|
|
|
@@ -71,35 +59,22 @@ export default defineConfig({
|
|
|
71
59
|
})
|
|
72
60
|
```
|
|
73
61
|
|
|
74
|
-
|
|
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
|
-
```
|
|
62
|
+
If the Studio already uses a `buildTheme` theme, pass the same options so the tool starts editing from them: `themerTool({config: {accent: '#1cb485'}})`.
|
|
90
63
|
|
|
91
64
|
## Migrating from themer.sanity.build
|
|
92
65
|
|
|
93
|
-
|
|
66
|
+
This package is also 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.
|
|
67
|
+
|
|
68
|
+
`@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
69
|
|
|
95
70
|
```ts
|
|
96
71
|
// Before:
|
|
97
72
|
import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8'
|
|
98
73
|
|
|
99
74
|
// After:
|
|
100
|
-
import {
|
|
75
|
+
import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
101
76
|
|
|
102
|
-
const theme =
|
|
77
|
+
const theme = buildThemeFromUrl(
|
|
103
78
|
'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8',
|
|
104
79
|
)
|
|
105
80
|
```
|
|
@@ -121,17 +96,17 @@ export default defineConfig({
|
|
|
121
96
|
})
|
|
122
97
|
```
|
|
123
98
|
|
|
124
|
-
The hosted presets are
|
|
99
|
+
The hosted presets are addressed by query, exactly like the service:
|
|
125
100
|
|
|
126
101
|
```ts
|
|
127
|
-
import {
|
|
102
|
+
import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
128
103
|
|
|
129
|
-
const theme =
|
|
104
|
+
const theme = buildThemeFromUrl('?preset=verdant')
|
|
130
105
|
```
|
|
131
106
|
|
|
132
107
|
Once migrated, remove any `themer.d.ts` module declarations and `urlImports` config that the URL imports needed.
|
|
133
108
|
|
|
134
|
-
The
|
|
109
|
+
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
110
|
|
|
136
111
|
## License
|
|
137
112
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,63 +1,91 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import {
|
|
1
|
+
import { t as BuildThemeOptions } from "./options-BaqJJgRs.js";
|
|
2
|
+
import { ColorHueKey, ColorTintKey } from "@sanity/color";
|
|
3
|
+
import { RootTheme } from "@sanity/ui/theme";
|
|
3
4
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
5
|
+
* The color palette generated by {@link buildPalette}: the `palette` config
|
|
6
|
+
* of `buildTheme` from `@sanity/ui/theme`, with every color as a hex string.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
10
|
+
type GeneratedColorPalette = {
|
|
11
|
+
black: string;
|
|
12
|
+
white: string;
|
|
13
|
+
} & Record<ColorHueKey, Record<ColorTintKey, string>>;
|
|
14
|
+
/**
|
|
15
|
+
* Generates a Sanity UI color palette from the theme options: the accent
|
|
16
|
+
* color replaces the `blue` scale, the text color the `gray` scale, and the
|
|
17
|
+
* backgrounds replace `black` and `white`. All other hues keep their stock
|
|
18
|
+
* `@sanity/color` values. Called with the stock colors, it returns the stock
|
|
19
|
+
* palette byte-for-byte.
|
|
6
20
|
*
|
|
7
21
|
* ```ts
|
|
8
|
-
* import {
|
|
9
|
-
* import {buildTheme} from '@sanity/ui/theme'
|
|
22
|
+
* import {buildPalette} from '@sanity/themer'
|
|
10
23
|
*
|
|
11
|
-
* const
|
|
12
|
-
* ...themeConfigFromColors({primary: '#2276fc'}),
|
|
13
|
-
* // ...other ThemeConfig properties
|
|
14
|
-
* })
|
|
24
|
+
* const palette = buildPalette({accent: '#556bfc'})
|
|
15
25
|
* ```
|
|
16
26
|
*
|
|
17
27
|
* @public
|
|
18
28
|
*/
|
|
19
|
-
declare function
|
|
29
|
+
declare function buildPalette(options: BuildThemeOptions): GeneratedColorPalette;
|
|
20
30
|
/**
|
|
21
|
-
* Generates a
|
|
31
|
+
* Generates a Studio theme from a handful of colors, by replacing the color
|
|
32
|
+
* palette that the `buildTheme` from `@sanity/ui/theme` otherwise fills with
|
|
33
|
+
* `@sanity/color`: the accent color replaces the `blue` scale (primary
|
|
34
|
+
* buttons, focus rings, links), the optional text color the `gray` scale
|
|
35
|
+
* (text, icons, borders), and the optional backgrounds replace `black` and
|
|
36
|
+
* `white`. The result is the same type of theme that `@sanity/ui/theme`
|
|
37
|
+
* builds, ready for the `theme` property of a Studio config.
|
|
22
38
|
*
|
|
23
39
|
* ```ts
|
|
24
|
-
* import {
|
|
40
|
+
* import {buildTheme} from '@sanity/themer'
|
|
25
41
|
* import {defineConfig} from 'sanity'
|
|
26
42
|
*
|
|
43
|
+
* export const theme = buildTheme({
|
|
44
|
+
* accent: '#556bfc',
|
|
45
|
+
* text: '#727892', // optional — derived from `accent` when omitted
|
|
46
|
+
* background: {dark: '#0d0e12', light: '#ffffff'}, // optional
|
|
47
|
+
* contrast: 85, // optional, 15–100
|
|
48
|
+
* })
|
|
49
|
+
*
|
|
27
50
|
* export default defineConfig({
|
|
28
|
-
* theme
|
|
51
|
+
* theme,
|
|
29
52
|
* // ...rest of the config
|
|
30
53
|
* })
|
|
31
54
|
* ```
|
|
32
55
|
*
|
|
33
|
-
*
|
|
56
|
+
* Called with the stock colors — like the example — it returns the exact
|
|
57
|
+
* same colors as `buildTheme()` from `@sanity/ui/theme` with no options.
|
|
34
58
|
*
|
|
35
59
|
* @public
|
|
36
60
|
*/
|
|
37
|
-
declare function
|
|
61
|
+
declare function buildTheme(options: BuildThemeOptions): RootTheme;
|
|
38
62
|
/**
|
|
39
|
-
* A named set of
|
|
63
|
+
* A preset theme: a named set of {@link BuildThemeOptions} ready to pass to
|
|
64
|
+
* `buildTheme`.
|
|
40
65
|
*
|
|
41
66
|
* @public
|
|
42
67
|
*/
|
|
43
68
|
interface ThemePreset {
|
|
44
69
|
slug: string;
|
|
45
70
|
title: string;
|
|
46
|
-
|
|
71
|
+
/** The preset's theme options, ready to pass to `buildTheme` */
|
|
72
|
+
options: BuildThemeOptions;
|
|
47
73
|
}
|
|
48
74
|
/**
|
|
49
|
-
* Preset themes
|
|
50
|
-
* (themer.sanity.build)
|
|
75
|
+
* Preset themes for `buildTheme`, carried over from the hosted Themer service
|
|
76
|
+
* (themer.sanity.build) presets: each one maps the legacy preset's primary
|
|
77
|
+
* hue to `accent`, its default hue to `text` and its lightest/darkest colors
|
|
78
|
+
* to the backgrounds.
|
|
51
79
|
*
|
|
52
80
|
* ```ts
|
|
53
|
-
* import {
|
|
81
|
+
* import {buildTheme, presets} from '@sanity/themer'
|
|
54
82
|
*
|
|
55
83
|
* const verdant = presets.find((preset) => preset.slug === 'verdant')
|
|
56
|
-
* const theme =
|
|
84
|
+
* const theme = buildTheme(verdant.options)
|
|
57
85
|
* ```
|
|
58
86
|
*
|
|
59
87
|
* @public
|
|
60
88
|
*/
|
|
61
89
|
declare const presets: ThemePreset[];
|
|
62
|
-
export {
|
|
90
|
+
export { type BuildThemeOptions, type GeneratedColorPalette, type ThemePreset, buildPalette, buildTheme, presets };
|
|
63
91
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/theme/buildPalette.ts","../src/theme/buildTheme.ts","../src/theme/presets.ts"],"mappings":";;;;;;;;;KAqCY;EAAyB;EAAe;IAAiB,OACnE,aACA,OAAO;;;;;;;;;;;;;;;;iBAkBO,aAAa,SAAS,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBCrB1C,WAAW,SAAS,oBAAoB;;;;;;;UC5BvC;EACf;EACA;;EAEA,SAAS;;;;;;;;;;;;;;;;;cAkBE,SAAS"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
export {
|
|
1
|
+
import { n as buildTheme, r as buildPalette, t as presets } from "./presets-DWzYcsLg.js";
|
|
2
|
+
export { buildPalette, buildTheme, presets };
|
package/dist/legacy.d.ts
CHANGED
|
@@ -48,11 +48,6 @@ type PartialHues = { [TKey in keyof Hues]?: Partial<Hues[TKey]>; };
|
|
|
48
48
|
* @public
|
|
49
49
|
*/
|
|
50
50
|
type LegacyTheme = RootTheme & {
|
|
51
|
-
/**
|
|
52
|
-
* Marks the theme as generated by Themer, which Sanity Studio detects to
|
|
53
|
-
* reconcile fonts and other non-color attributes.
|
|
54
|
-
*/
|
|
55
|
-
__themer: true;
|
|
56
51
|
/**
|
|
57
52
|
* Set to `undefined` so that `@sanity/ui` derives the v2 theme internally
|
|
58
53
|
* from the generated colors.
|
|
@@ -118,16 +113,16 @@ declare function parseHuesFromUrl(url: string | URL): Hues;
|
|
|
118
113
|
* // import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant'
|
|
119
114
|
*
|
|
120
115
|
* // After:
|
|
121
|
-
* import {
|
|
116
|
+
* import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
122
117
|
*
|
|
123
|
-
* const theme =
|
|
118
|
+
* const theme = buildThemeFromUrl(
|
|
124
119
|
* 'https://themer.sanity.build/api/hues?preset=verdant',
|
|
125
120
|
* )
|
|
126
121
|
* ```
|
|
127
122
|
*
|
|
128
123
|
* @public
|
|
129
124
|
*/
|
|
130
|
-
declare function
|
|
125
|
+
declare function buildThemeFromUrl(url: string | URL): LegacyTheme;
|
|
131
126
|
/**
|
|
132
127
|
* The hues of the default Studio theme — the same `hues` export that
|
|
133
128
|
* `https://themer.sanity.build/api/hues` served without any parameters.
|
|
@@ -147,20 +142,14 @@ declare const theme: LegacyTheme;
|
|
|
147
142
|
* the same slugs and hues:
|
|
148
143
|
*
|
|
149
144
|
* ```ts
|
|
150
|
-
* import {createTheme,
|
|
145
|
+
* import {createTheme, presets} from '@sanity/themer/legacy'
|
|
151
146
|
*
|
|
152
|
-
* const
|
|
147
|
+
* const verdant = presets.find((preset) => preset.slug === 'verdant')
|
|
148
|
+
* const theme = createTheme(verdant.hues)
|
|
153
149
|
* ```
|
|
154
150
|
*
|
|
155
151
|
* @public
|
|
156
152
|
*/
|
|
157
153
|
declare const presets: ThemePreset[];
|
|
158
|
-
|
|
159
|
-
* Finds a preset by its slug, falling back to the default Studio preset for
|
|
160
|
-
* unknown slugs — the same behavior as the hosted Themer service.
|
|
161
|
-
*
|
|
162
|
-
* @public
|
|
163
|
-
*/
|
|
164
|
-
declare function getPreset(slug: string | null | undefined): ThemePreset;
|
|
165
|
-
export { type Hue, type HueMidPoint, type Hues, type LegacyTheme, type PartialHues, type ThemePreset, createTheme, createThemeFromUrl, getPreset, hues, parseHuesFromUrl, presets, theme };
|
|
154
|
+
export { type Hue, type HueMidPoint, type Hues, type LegacyTheme, type PartialHues, type ThemePreset, buildThemeFromUrl, createTheme, hues, parseHuesFromUrl, presets, theme };
|
|
166
155
|
//# sourceMappingURL=legacy.d.ts.map
|
package/dist/legacy.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"legacy.d.ts","names":[],"sources":["../src/legacy/types.ts","../src/legacy/createTheme.ts","../src/legacy/defaults.ts","../src/legacy/presets.ts"],"mappings":";;;;;;KAOY;;;;;;;UAQK;;EAEf;;EAEA,UAAU;;EAEV;;EAEA;;;;;;;UAQe;EACf,SAAS;EACT,aAAa;EACb,SAAS;EACT,UAAU;EACV,SAAS;EACT,UAAU;;;;;;;;KASA,iBAAgB,cAAc,QAAQ,QAAQ,KAAK;;;;;;;KAQnD,cAAc;;;;;EAKxB
|
|
1
|
+
{"version":3,"file":"legacy.d.ts","names":[],"sources":["../src/legacy/types.ts","../src/legacy/createTheme.ts","../src/legacy/defaults.ts","../src/legacy/presets.ts"],"mappings":";;;;;;KAOY;;;;;;;UAQK;;EAEf;;EAEA,UAAU;;EAEV;;EAEA;;;;;;;UAQe;EACf,SAAS;EACT,aAAa;EACb,SAAS;EACT,UAAU;EACV,SAAS;EACT,UAAU;;;;;;;;KASA,iBAAgB,cAAc,QAAQ,QAAQ,KAAK;;;;;;;KAQnD,cAAc;;;;;EAKxB;;;;;;;UAQe;EACf;EACA;;;;;EAKA;;EAEA,MAAM;;;;;;;;;;;;;;;;;;iBCtDQ,YAAY,OAAM,cAAmB;;;;;;;;;;;;;;;;;iBAoBrC,iBAAiB,cAAc,MAAM;;;;;;;;;;;;;;;;;;;iBAyBrC,kBAAkB,cAAc,MAAM;;;;;;;cCzDzC,MAAM;;;;;;;cAQN,OAAO;;;;;;;;;;;;;;cCcP,SAAS"}
|
package/dist/legacy.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as mix, t as isColor } from "./
|
|
1
|
+
import { n as mix, t as isColor } from "./mix-BfV6_Ke4.js";
|
|
2
2
|
import { COLOR_TINTS } from "@sanity/color";
|
|
3
3
|
import { buildTheme, createColorTheme, multiply, parseColor, rgbToHex, rgba, screen } from "@sanity/ui/theme";
|
|
4
4
|
/**
|
|
@@ -19,13 +19,13 @@ function dropUndefined(hue) {
|
|
|
19
19
|
* here without changing generated themes.
|
|
20
20
|
*/
|
|
21
21
|
/** @internal */
|
|
22
|
-
const black = {
|
|
22
|
+
const black$1 = {
|
|
23
23
|
title: "Black",
|
|
24
24
|
hex: "#101112"
|
|
25
|
-
}, white = {
|
|
25
|
+
}, white$1 = {
|
|
26
26
|
title: "White",
|
|
27
27
|
hex: "#fff"
|
|
28
|
-
}, gray = {
|
|
28
|
+
}, gray$1 = {
|
|
29
29
|
50: {
|
|
30
30
|
title: "Gray 50",
|
|
31
31
|
hex: "#f2f3f5"
|
|
@@ -70,7 +70,7 @@ const black = {
|
|
|
70
70
|
title: "Gray 950",
|
|
71
71
|
hex: "#1b1d20"
|
|
72
72
|
}
|
|
73
|
-
}, blue = {
|
|
73
|
+
}, blue$1 = {
|
|
74
74
|
50: {
|
|
75
75
|
title: "Blue 50",
|
|
76
76
|
hex: "#e8f1fe"
|
|
@@ -430,7 +430,7 @@ const black = {
|
|
|
430
430
|
title: "Cyan 950",
|
|
431
431
|
hex: "#112124"
|
|
432
432
|
}
|
|
433
|
-
}, lightest = white.hex.toLowerCase(), darkest = black.hex.toLowerCase(), defaultHues = {
|
|
433
|
+
}, lightest = white$1.hex.toLowerCase(), darkest = black$1.hex.toLowerCase(), defaultHues = {
|
|
434
434
|
default: {
|
|
435
435
|
lightest,
|
|
436
436
|
darkest,
|
|
@@ -633,9 +633,10 @@ const defaultPreset = definePreset("default", "Studio v3", "lightest=fff&darkest
|
|
|
633
633
|
];
|
|
634
634
|
/**
|
|
635
635
|
* Finds a preset by its slug, falling back to the default Studio preset for
|
|
636
|
-
* unknown slugs — the
|
|
636
|
+
* unknown slugs — the behavior of the hosted Themer service's `?preset`
|
|
637
|
+
* param, which `parseHuesFromUrl` exposes.
|
|
637
638
|
*
|
|
638
|
-
* @
|
|
639
|
+
* @internal
|
|
639
640
|
*/
|
|
640
641
|
function getPreset(slug) {
|
|
641
642
|
let needle = slug?.toLowerCase();
|
|
@@ -666,9 +667,9 @@ function getColorHex(hue, tint) {
|
|
|
666
667
|
return tintNum === midPoint ? hue.mid.toLowerCase() : tintNum < midPoint ? mix(lightPosition, hue.mid, hue.lightest) : mix(darkPosition, hue.darkest, hue.mid);
|
|
667
668
|
}
|
|
668
669
|
const NEUTRAL_TONES = /* @__PURE__ */ new Set(["default", "transparent"]), SPOT_TINTS = {
|
|
669
|
-
blue,
|
|
670
|
+
blue: blue$1,
|
|
670
671
|
cyan,
|
|
671
|
-
gray,
|
|
672
|
+
gray: gray$1,
|
|
672
673
|
green,
|
|
673
674
|
magenta,
|
|
674
675
|
orange,
|
|
@@ -681,7 +682,7 @@ function getTint(key) {
|
|
|
681
682
|
if (!tints) throw Error(`Unknown tint: ${key}`);
|
|
682
683
|
return tints;
|
|
683
684
|
}
|
|
684
|
-
const
|
|
685
|
+
const defaultTheme = buildTheme();
|
|
685
686
|
/**
|
|
686
687
|
* Generates a Studio theme from hues, producing the exact same colors as the
|
|
687
688
|
* hosted Themer service (themer.sanity.build). This is a port of its
|
|
@@ -1021,7 +1022,7 @@ function themeFromHues(partialHues) {
|
|
|
1021
1022
|
border: base.border,
|
|
1022
1023
|
muted: { fg: mix(base.bg, tints[dark ? 400 : 600].hex) },
|
|
1023
1024
|
accent: { fg: mix(base.bg, red[dark ? 400 : 500].hex) },
|
|
1024
|
-
link: { fg: mix(base.bg, blue[dark ? 400 : 600].hex) },
|
|
1025
|
+
link: { fg: mix(base.bg, blue$1[dark ? 400 : 600].hex) },
|
|
1025
1026
|
code: {
|
|
1026
1027
|
bg: mix(base.bg, tints[dark ? 950 : 50].hex),
|
|
1027
1028
|
fg: tints[dark ? 400 : 600].hex
|
|
@@ -1046,28 +1047,28 @@ function themeFromHues(partialHues) {
|
|
|
1046
1047
|
}
|
|
1047
1048
|
return state === "hovered" ? {
|
|
1048
1049
|
bg: base.bg,
|
|
1049
|
-
bg2: mix(base.bg, gray[dark ? 700 : 300].hex),
|
|
1050
|
+
bg2: mix(base.bg, gray$1[dark ? 700 : 300].hex),
|
|
1050
1051
|
fg: base.fg,
|
|
1051
|
-
border: mix(base.bg, gray[dark ? 700 : 300].hex),
|
|
1052
|
-
placeholder: mix(base.bg, gray[dark ? 600 : 400].hex)
|
|
1052
|
+
border: mix(base.bg, gray$1[dark ? 700 : 300].hex),
|
|
1053
|
+
placeholder: mix(base.bg, gray$1[dark ? 600 : 400].hex)
|
|
1053
1054
|
} : 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)
|
|
1055
|
+
bg: mix(base.bg, gray$1[dark ? 950 : 50].hex),
|
|
1056
|
+
bg2: mix(base.bg, gray$1[dark ? 900 : 100].hex),
|
|
1057
|
+
fg: mix(base.bg, gray$1[dark ? 700 : 300].hex),
|
|
1058
|
+
border: mix(base.bg, gray$1[dark ? 900 : 100].hex),
|
|
1059
|
+
placeholder: mix(base.bg, gray$1[dark ? 800 : 200].hex)
|
|
1059
1060
|
} : 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)
|
|
1061
|
+
bg: mix(base.bg, gray$1[dark ? 950 : 50].hex),
|
|
1062
|
+
bg2: mix(base.bg, gray$1[dark ? 800 : 200].hex),
|
|
1063
|
+
fg: mix(base.bg, gray$1[dark ? 200 : 800].hex),
|
|
1064
|
+
border: mix(base.bg, gray$1[dark ? 800 : 200].hex),
|
|
1065
|
+
placeholder: mix(base.bg, gray$1[dark ? 600 : 400].hex)
|
|
1065
1066
|
} : {
|
|
1066
1067
|
bg: base.bg,
|
|
1067
1068
|
bg2: base.border,
|
|
1068
1069
|
fg: base.fg,
|
|
1069
1070
|
border: base.border,
|
|
1070
|
-
placeholder: mix(base.bg, gray[dark ? 600 : 400].hex)
|
|
1071
|
+
placeholder: mix(base.bg, gray$1[dark ? 600 : 400].hex)
|
|
1071
1072
|
};
|
|
1072
1073
|
},
|
|
1073
1074
|
selectable: ({ base, muted, tone, solid, state }) => state === "enabled" ? {
|
|
@@ -1091,25 +1092,25 @@ function themeFromHues(partialHues) {
|
|
|
1091
1092
|
char: mix(base.bg, yellow[mainShade].hex),
|
|
1092
1093
|
class: mix(base.bg, orange[mainShade].hex),
|
|
1093
1094
|
className: mix(base.bg, cyan[mainShade].hex),
|
|
1094
|
-
comment: mix(base.bg, gray[secondaryShade].hex),
|
|
1095
|
+
comment: mix(base.bg, gray$1[secondaryShade].hex),
|
|
1095
1096
|
constant: mix(base.bg, purple[mainShade].hex),
|
|
1096
1097
|
deleted: mix(base.bg, red[mainShade].hex),
|
|
1097
|
-
doctype: mix(base.bg, gray[secondaryShade].hex),
|
|
1098
|
+
doctype: mix(base.bg, gray$1[secondaryShade].hex),
|
|
1098
1099
|
entity: mix(base.bg, red[mainShade].hex),
|
|
1099
1100
|
function: mix(base.bg, green[mainShade].hex),
|
|
1100
|
-
hexcode: mix(base.bg, blue[mainShade].hex),
|
|
1101
|
+
hexcode: mix(base.bg, blue$1[mainShade].hex),
|
|
1101
1102
|
id: mix(base.bg, purple[mainShade].hex),
|
|
1102
1103
|
important: mix(base.bg, purple[mainShade].hex),
|
|
1103
1104
|
inserted: mix(base.bg, yellow[mainShade].hex),
|
|
1104
1105
|
keyword: mix(base.bg, magenta[mainShade].hex),
|
|
1105
1106
|
number: mix(base.bg, purple[mainShade].hex),
|
|
1106
1107
|
operator: mix(base.bg, magenta[mainShade].hex),
|
|
1107
|
-
prolog: mix(base.bg, gray[secondaryShade].hex),
|
|
1108
|
-
property: mix(base.bg, blue[mainShade].hex),
|
|
1108
|
+
prolog: mix(base.bg, gray$1[secondaryShade].hex),
|
|
1109
|
+
property: mix(base.bg, blue$1[mainShade].hex),
|
|
1109
1110
|
pseudoClass: mix(base.bg, yellow[mainShade].hex),
|
|
1110
1111
|
pseudoElement: mix(base.bg, yellow[mainShade].hex),
|
|
1111
|
-
punctuation: mix(base.bg, gray[mainShade].hex),
|
|
1112
|
-
regex: mix(base.bg, blue[mainShade].hex),
|
|
1112
|
+
punctuation: mix(base.bg, gray$1[mainShade].hex),
|
|
1113
|
+
regex: mix(base.bg, blue$1[mainShade].hex),
|
|
1113
1114
|
selector: mix(base.bg, red[mainShade].hex),
|
|
1114
1115
|
string: mix(base.bg, yellow[mainShade].hex),
|
|
1115
1116
|
symbol: mix(base.bg, purple[mainShade].hex),
|
|
@@ -1121,9 +1122,8 @@ function themeFromHues(partialHues) {
|
|
|
1121
1122
|
}
|
|
1122
1123
|
});
|
|
1123
1124
|
return {
|
|
1124
|
-
...
|
|
1125
|
+
...defaultTheme,
|
|
1125
1126
|
color,
|
|
1126
|
-
__themer: !0,
|
|
1127
1127
|
v2: void 0
|
|
1128
1128
|
};
|
|
1129
1129
|
}
|
|
@@ -1175,16 +1175,16 @@ function parseHuesFromUrl(url) {
|
|
|
1175
1175
|
* // import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant'
|
|
1176
1176
|
*
|
|
1177
1177
|
* // After:
|
|
1178
|
-
* import {
|
|
1178
|
+
* import {buildThemeFromUrl} from '@sanity/themer/legacy'
|
|
1179
1179
|
*
|
|
1180
|
-
* const theme =
|
|
1180
|
+
* const theme = buildThemeFromUrl(
|
|
1181
1181
|
* 'https://themer.sanity.build/api/hues?preset=verdant',
|
|
1182
1182
|
* )
|
|
1183
1183
|
* ```
|
|
1184
1184
|
*
|
|
1185
1185
|
* @public
|
|
1186
1186
|
*/
|
|
1187
|
-
function
|
|
1187
|
+
function buildThemeFromUrl(url) {
|
|
1188
1188
|
return createTheme(parseHuesFromUrl(url));
|
|
1189
1189
|
}
|
|
1190
1190
|
/**
|
|
@@ -1194,6 +1194,6 @@ function createThemeFromUrl(url) {
|
|
|
1194
1194
|
* @public
|
|
1195
1195
|
*/
|
|
1196
1196
|
const hues = applyHues({}), theme = createTheme(hues);
|
|
1197
|
-
export {
|
|
1197
|
+
export { buildThemeFromUrl, createTheme, hues, parseHuesFromUrl, presets, theme };
|
|
1198
1198
|
|
|
1199
1199
|
//# sourceMappingURL=legacy.js.map
|