@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/README.md CHANGED
@@ -63,51 +63,16 @@ If the Studio already uses a `buildTheme` theme, pass the same options so the to
63
63
 
64
64
  ## Migrating from themer.sanity.build
65
65
 
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.
66
+ The npm migration path off the hosted Themer service ([themer.sanity.build](https://themer.sanity.build)) is [`@sanity/themer-legacy`](https://www.npmjs.com/package/@sanity/themer-legacy): the exact same generator, running locally.
67
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:
68
+ `@sanity/themer/legacy` still works as a deprecated re-export of that package until `@sanity/themer@1.0` removes it; import from `@sanity/themer-legacy` instead. Migrating a hosted URL import looks like this:
69
69
 
70
- ```ts
71
- // Before:
72
- import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8'
73
-
74
- // After:
75
- import {buildThemeFromUrl} from '@sanity/themer/legacy'
76
-
77
- const theme = buildThemeFromUrl(
78
- 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8',
79
- )
80
- ```
81
-
82
- Configs that used `createTheme` and `hues` from the URL import work the same way with `parseHuesFromUrl`:
83
-
84
- ```ts
85
- // Before:
86
- // import {createTheme, hues} from 'https://themer.sanity.build/api/hues?preset=verdant'
87
-
88
- // After:
89
- import {createTheme, parseHuesFromUrl} from '@sanity/themer/legacy'
90
-
91
- const hues = parseHuesFromUrl('https://themer.sanity.build/api/hues?preset=verdant')
92
-
93
- export default defineConfig({
94
- theme: createTheme({...hues, primary: {...hues.primary, mid: '#22fca8'}}),
95
- // ...rest of the config
96
- })
97
- ```
98
-
99
- The hosted presets are addressed by query, exactly like the service:
100
-
101
- ```ts
102
- import {buildThemeFromUrl} from '@sanity/themer/legacy'
103
-
104
- const theme = buildThemeFromUrl('?preset=verdant')
70
+ ```diff
71
+ -import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8'
72
+ +import {buildThemeFromUrl} from '@sanity/themer-legacy'
73
+ +const theme = buildThemeFromUrl('https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8')
105
74
  ```
106
75
 
107
- Once migrated, remove any `themer.d.ts` module declarations and `urlImports` config that the URL imports needed.
108
-
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.
110
-
111
76
  ## License
112
77
 
113
78
  MIT © Sanity.io — see [LICENSE](https://github.com/sanity-io/ui/blob/main/LICENSE)
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as buildTheme, r as buildPalette, t as presets } from "./presets-DWzYcsLg.js";
1
+ import { n as buildTheme, r as buildPalette, t as presets } from "./presets-By3s-D-S.js";
2
2
  export { buildPalette, buildTheme, presets };
package/dist/legacy.d.ts CHANGED
@@ -1,155 +1,80 @@
1
- import { RootTheme } from "@sanity/ui/theme";
1
+ import * as themerLegacy from "@sanity/themer-legacy";
2
2
  /**
3
- * The tint (between 50 and 950) that a `Hue`'s `mid` color is placed at.
4
- *
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`.
5
6
  * @public
6
7
  */
7
- type HueMidPoint = 50 | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900 | 950;
8
+ export declare const buildThemeFromUrl: typeof themerLegacy.buildThemeFromUrl;
8
9
  /**
9
- * A single hue configuration, matching the hosted Themer service
10
- * (themer.sanity.build) hue format.
11
- *
10
+ * @deprecated Import `createTheme` from `@sanity/themer-legacy` instead.
11
+ * `@sanity/themer/legacy` re-exports it unchanged for now and will be removed
12
+ * in `@sanity/themer@1.0`.
12
13
  * @public
13
14
  */
14
- interface Hue {
15
- /** The mid color of the hue's tint ramp, as a hex color */
16
- mid: string;
17
- /** The tint that `mid` is placed at — the rest of the ramp is interpolated */
18
- midPoint: HueMidPoint;
19
- /** The hex color that the ramp's lightest end interpolates towards */
20
- lightest: string;
21
- /** The hex color that the ramp's darkest end interpolates towards */
22
- darkest: string;
23
- }
15
+ export declare const createTheme: typeof themerLegacy.createTheme;
24
16
  /**
25
- * The six hues a legacy Themer theme is generated from.
26
- *
17
+ * @deprecated Import `parseHuesFromUrl` from `@sanity/themer-legacy` instead.
18
+ * `@sanity/themer/legacy` re-exports it unchanged for now and will be removed
19
+ * in `@sanity/themer@1.0`.
27
20
  * @public
28
21
  */
29
- interface Hues {
30
- default: Hue;
31
- transparent: Hue;
32
- primary: Hue;
33
- positive: Hue;
34
- caution: Hue;
35
- critical: Hue;
36
- }
22
+ export declare const parseHuesFromUrl: typeof themerLegacy.parseHuesFromUrl;
37
23
  /**
38
- * `Hues` where every hue, and every property of each hue, is optional.
39
- * Omitted properties fall back to the default Studio theme hues.
40
- *
24
+ * @deprecated Import `hues` from `@sanity/themer-legacy` instead.
25
+ * `@sanity/themer/legacy` re-exports it unchanged for now and will be removed
26
+ * in `@sanity/themer@1.0`.
41
27
  * @public
42
28
  */
43
- type PartialHues = { [TKey in keyof Hues]?: Partial<Hues[TKey]>; };
29
+ export declare const hues: typeof themerLegacy.hues;
44
30
  /**
45
- * A theme generated by `createTheme`, compatible with the `theme` property in
46
- * a Sanity Studio `defineConfig`.
47
- *
31
+ * @deprecated Import `theme` from `@sanity/themer-legacy` instead.
32
+ * `@sanity/themer/legacy` re-exports it unchanged for now and will be removed
33
+ * in `@sanity/themer@1.0`.
48
34
  * @public
49
35
  */
50
- type LegacyTheme = RootTheme & {
51
- /**
52
- * Set to `undefined` so that `@sanity/ui` derives the v2 theme internally
53
- * from the generated colors.
54
- */
55
- v2: undefined;
56
- };
36
+ export declare const theme: typeof themerLegacy.theme;
57
37
  /**
58
- * A preset theme, carried over from the hosted Themer service.
59
- *
38
+ * @deprecated Import `presets` from `@sanity/themer-legacy` instead.
39
+ * `@sanity/themer/legacy` re-exports it unchanged for now and will be removed
40
+ * in `@sanity/themer@1.0`.
60
41
  * @public
61
42
  */
62
- interface ThemePreset {
63
- slug: string;
64
- title: string;
65
- /**
66
- * The canonical search params for this preset — the same query that
67
- * `https://themer.sanity.build/api/hues` served the preset for.
68
- */
69
- searchParams: string;
70
- /** The preset's resolved hues, ready to pass to `createTheme` */
71
- hues: Hues;
72
- }
43
+ export declare const presets: typeof themerLegacy.presets;
73
44
  /**
74
- * Generates a Studio theme from hues, producing the same colors as importing
75
- * the theme from the hosted Themer service (themer.sanity.build):
76
- *
77
- * ```ts
78
- * import {createTheme, hues} from '@sanity/themer/legacy'
79
- * import {defineConfig} from 'sanity'
80
- *
81
- * export default defineConfig({
82
- * theme: createTheme({...hues, primary: {...hues.primary, mid: '#22fca8'}}),
83
- * // ...rest of the config
84
- * })
85
- * ```
86
- *
45
+ * @deprecated Import `Hue` from `@sanity/themer-legacy` instead.
46
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
87
47
  * @public
88
48
  */
89
- export declare function createTheme(hues?: PartialHues): LegacyTheme;
49
+ export type Hue = themerLegacy.Hue;
90
50
  /**
91
- * Parses the hues encoded in a hosted Themer service URL, returning the exact
92
- * hues that `https://themer.sanity.build/api/hues` served for that query —
93
- * presets and overrides included.
94
- *
95
- * ```ts
96
- * import {createTheme, parseHuesFromUrl} from '@sanity/themer/legacy'
97
- *
98
- * const hues = parseHuesFromUrl(
99
- * 'https://themer.sanity.build/api/hues?preset=verdant&primary=22fca8',
100
- * )
101
- * const theme = createTheme(hues)
102
- * ```
103
- *
51
+ * @deprecated Import `HueMidPoint` from `@sanity/themer-legacy` instead.
52
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
104
53
  * @public
105
54
  */
106
- export declare function parseHuesFromUrl(url: string | URL): Hues;
55
+ export type HueMidPoint = themerLegacy.HueMidPoint;
107
56
  /**
108
- * The one-line replacement for a theme imported from the hosted Themer
109
- * service — pass the URL that used to be imported:
110
- *
111
- * ```ts
112
- * // Before:
113
- * // import {theme} from 'https://themer.sanity.build/api/hues?preset=verdant'
114
- *
115
- * // After:
116
- * import {buildThemeFromUrl} from '@sanity/themer/legacy'
117
- *
118
- * const theme = buildThemeFromUrl(
119
- * 'https://themer.sanity.build/api/hues?preset=verdant',
120
- * )
121
- * ```
122
- *
57
+ * @deprecated Import `Hues` from `@sanity/themer-legacy` instead.
58
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
123
59
  * @public
124
60
  */
125
- export declare function buildThemeFromUrl(url: string | URL): LegacyTheme;
61
+ export type Hues = themerLegacy.Hues;
126
62
  /**
127
- * The hues of the default Studio theme — the same `hues` export that
128
- * `https://themer.sanity.build/api/hues` served without any parameters.
129
- *
63
+ * @deprecated Import `LegacyTheme` from `@sanity/themer-legacy` instead.
64
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
130
65
  * @public
131
66
  */
132
- export declare const hues: Hues;
67
+ export type LegacyTheme = themerLegacy.LegacyTheme;
133
68
  /**
134
- * The default Studio theme — the same `theme` export that
135
- * `https://themer.sanity.build/api/hues` served without any parameters.
136
- *
69
+ * @deprecated Import `PartialHues` from `@sanity/themer-legacy` instead.
70
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
137
71
  * @public
138
72
  */
139
- export declare const theme: LegacyTheme;
73
+ export type PartialHues = themerLegacy.PartialHues;
140
74
  /**
141
- * The preset themes of the hosted Themer service (themer.sanity.build), with
142
- * the same slugs and hues:
143
- *
144
- * ```ts
145
- * import {createTheme, presets} from '@sanity/themer/legacy'
146
- *
147
- * const verdant = presets.find((preset) => preset.slug === 'verdant')
148
- * const theme = createTheme(verdant.hues)
149
- * ```
150
- *
75
+ * @deprecated Import `ThemePreset` from `@sanity/themer-legacy` instead.
76
+ * `@sanity/themer/legacy` will be removed in `@sanity/themer@1.0`.
151
77
  * @public
152
78
  */
153
- export declare const presets: ThemePreset[];
154
- export type { Hue, HueMidPoint, Hues, LegacyTheme, PartialHues, ThemePreset };
79
+ export type ThemePreset = themerLegacy.ThemePreset;
155
80
  //# sourceMappingURL=legacy.d.ts.map
@@ -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;;;;;;;UAQe;EACf;EACA;;;;;EAKA;;EAEA,MAAM;;;;;;;;;;;;;;;;;;wBCtDQ,YAAY,OAAM,cAAmB;;;;;;;;;;;;;;;;;wBAoBrC,iBAAiB,cAAc,MAAM;;;;;;;;;;;;;;;;;;;wBAyBrC,kBAAkB,cAAc,MAAM;;;;;;;qBCzDzC,MAAM;;;;;;;qBAQN,OAAO;;;;;;;;;;;;;;qBCcP,SAAS"}
1
+ {"version":3,"file":"legacy.d.ts","names":[],"sources":["../src/legacy/index.ts"],"mappings":";;;;;;;qBAYa,0BAA0B,aAAa;;;;;;;qBASvC,oBAAoB,aAAa;;;;;;;qBAQjC,yBAAyB,aAAa;;;;;;;qBAQtC,aAAa,aAAa;;;;;;;qBAQ1B,cAAc,aAAa;;;;;;;qBAQ3B,gBAAgB,aAAa;;;;;;YAO9B,MAAM,aAAa;;;;;;YAOnB,cAAc,aAAa;;;;;;YAO3B,OAAO,aAAa;;;;;;YAOpB,cAAc,aAAa;;;;;;YAO3B,cAAc,aAAa;;;;;;YAO3B,cAAc,aAAa"}