@tenphi/glaze 0.9.0 → 0.9.2

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/index.d.cts CHANGED
@@ -133,6 +133,11 @@ interface RegularColorDef {
133
133
  * should not be combined (a console.warn is emitted).
134
134
  */
135
135
  opacity?: number;
136
+ /**
137
+ * Whether this color is inherited by child themes created via `extend()`.
138
+ * Default: true. Set to false to make this color local to the current theme.
139
+ */
140
+ inherit?: boolean;
136
141
  }
137
142
  /** Shadow tuning knobs. All values use the 0–1 scale (OKHSL). */
138
143
  interface ShadowTuning {
@@ -177,6 +182,11 @@ interface ShadowColorDef {
177
182
  intensity: HCPair<number>;
178
183
  /** Override default tuning. Merged field-by-field with global `shadowTuning`. */
179
184
  tuning?: ShadowTuning;
185
+ /**
186
+ * Whether this color is inherited by child themes created via `extend()`.
187
+ * Default: true. Set to false to make this color local to the current theme.
188
+ */
189
+ inherit?: boolean;
180
190
  }
181
191
  interface MixColorDef {
182
192
  type: 'mix';
@@ -211,6 +221,11 @@ interface MixColorDef {
211
221
  * Supports [normal, highContrast] pair.
212
222
  */
213
223
  contrast?: HCPair<MinContrast>;
224
+ /**
225
+ * Whether this color is inherited by child themes created via `extend()`.
226
+ * Default: true. Set to false to make this color local to the current theme.
227
+ */
228
+ inherit?: boolean;
214
229
  }
215
230
  type ColorDef = RegularColorDef | ShadowColorDef | MixColorDef;
216
231
  type ColorMap = Record<string, ColorDef>;
package/dist/index.d.mts CHANGED
@@ -133,6 +133,11 @@ interface RegularColorDef {
133
133
  * should not be combined (a console.warn is emitted).
134
134
  */
135
135
  opacity?: number;
136
+ /**
137
+ * Whether this color is inherited by child themes created via `extend()`.
138
+ * Default: true. Set to false to make this color local to the current theme.
139
+ */
140
+ inherit?: boolean;
136
141
  }
137
142
  /** Shadow tuning knobs. All values use the 0–1 scale (OKHSL). */
138
143
  interface ShadowTuning {
@@ -177,6 +182,11 @@ interface ShadowColorDef {
177
182
  intensity: HCPair<number>;
178
183
  /** Override default tuning. Merged field-by-field with global `shadowTuning`. */
179
184
  tuning?: ShadowTuning;
185
+ /**
186
+ * Whether this color is inherited by child themes created via `extend()`.
187
+ * Default: true. Set to false to make this color local to the current theme.
188
+ */
189
+ inherit?: boolean;
180
190
  }
181
191
  interface MixColorDef {
182
192
  type: 'mix';
@@ -211,6 +221,11 @@ interface MixColorDef {
211
221
  * Supports [normal, highContrast] pair.
212
222
  */
213
223
  contrast?: HCPair<MinContrast>;
224
+ /**
225
+ * Whether this color is inherited by child themes created via `extend()`.
226
+ * Default: true. Set to false to make this color local to the current theme.
227
+ */
228
+ inherit?: boolean;
214
229
  }
215
230
  type ColorDef = RegularColorDef | ShadowColorDef | MixColorDef;
216
231
  type ColorMap = Record<string, ColorDef>;
package/dist/index.mjs CHANGED
@@ -1413,10 +1413,14 @@ function createTheme(hue, saturation, initialColors) {
1413
1413
  };
1414
1414
  },
1415
1415
  extend(options) {
1416
- return createTheme(options.hue ?? hue, options.saturation ?? saturation, options.colors ? {
1417
- ...colorDefs,
1416
+ const newHue = options.hue ?? hue;
1417
+ const newSat = options.saturation ?? saturation;
1418
+ const inheritedColors = {};
1419
+ for (const [name, def] of Object.entries(colorDefs)) if (def.inherit !== false) inheritedColors[name] = def;
1420
+ return createTheme(newHue, newSat, options.colors ? {
1421
+ ...inheritedColors,
1418
1422
  ...options.colors
1419
- } : { ...colorDefs });
1423
+ } : { ...inheritedColors });
1420
1424
  },
1421
1425
  resolve() {
1422
1426
  return resolveAllColors(hue, saturation, colorDefs);