@tenphi/glaze 0.9.1 → 0.9.3
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 +3 -3
- package/dist/index.cjs +8 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -3
- package/dist/index.d.mts +18 -3
- package/dist/index.mjs +8 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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>;
|
|
@@ -304,7 +319,7 @@ interface GlazeColorToken {
|
|
|
304
319
|
/**
|
|
305
320
|
* Export as a tasty style-to-state binding (no color name key).
|
|
306
321
|
* Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
|
|
307
|
-
* @see https://
|
|
322
|
+
* @see https://tasty.style/docs
|
|
308
323
|
*/
|
|
309
324
|
tasty(options?: GlazeTokenOptions): Record<string, string>;
|
|
310
325
|
/** Export as a flat JSON map (no color name key). */
|
|
@@ -348,7 +363,7 @@ interface GlazeTheme {
|
|
|
348
363
|
* Export as tasty style-to-state bindings.
|
|
349
364
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
350
365
|
* Spread into component styles or register as a recipe via `configure({ recipes })`.
|
|
351
|
-
* @see https://
|
|
366
|
+
* @see https://tasty.style/docs
|
|
352
367
|
*/
|
|
353
368
|
tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
|
|
354
369
|
/** Export as plain JSON. */
|
|
@@ -442,7 +457,7 @@ interface GlazePalette {
|
|
|
442
457
|
* Export all themes as tasty style-to-state bindings.
|
|
443
458
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
444
459
|
* Prefix defaults to `true`. Inherits the palette-level `primary`.
|
|
445
|
-
* @see https://
|
|
460
|
+
* @see https://tasty.style/docs
|
|
446
461
|
*/
|
|
447
462
|
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
448
463
|
/** Export all themes as plain JSON grouped by theme name. */
|
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>;
|
|
@@ -304,7 +319,7 @@ interface GlazeColorToken {
|
|
|
304
319
|
/**
|
|
305
320
|
* Export as a tasty style-to-state binding (no color name key).
|
|
306
321
|
* Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
|
|
307
|
-
* @see https://
|
|
322
|
+
* @see https://tasty.style/docs
|
|
308
323
|
*/
|
|
309
324
|
tasty(options?: GlazeTokenOptions): Record<string, string>;
|
|
310
325
|
/** Export as a flat JSON map (no color name key). */
|
|
@@ -348,7 +363,7 @@ interface GlazeTheme {
|
|
|
348
363
|
* Export as tasty style-to-state bindings.
|
|
349
364
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
350
365
|
* Spread into component styles or register as a recipe via `configure({ recipes })`.
|
|
351
|
-
* @see https://
|
|
366
|
+
* @see https://tasty.style/docs
|
|
352
367
|
*/
|
|
353
368
|
tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
|
|
354
369
|
/** Export as plain JSON. */
|
|
@@ -442,7 +457,7 @@ interface GlazePalette {
|
|
|
442
457
|
* Export all themes as tasty style-to-state bindings.
|
|
443
458
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
444
459
|
* Prefix defaults to `true`. Inherits the palette-level `primary`.
|
|
445
|
-
* @see https://
|
|
460
|
+
* @see https://tasty.style/docs
|
|
446
461
|
*/
|
|
447
462
|
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
448
463
|
/** Export all themes as plain JSON grouped by theme name. */
|
package/dist/index.mjs
CHANGED
|
@@ -618,7 +618,7 @@ function coarseScan(h, s, lo, hi, yBase, target, epsilon, maxIter) {
|
|
|
618
618
|
function findLightnessForContrast(options) {
|
|
619
619
|
const { hue, saturation, preferredLightness, baseLinearRgb, contrast: contrastInput, lightnessRange = [0, 1], epsilon = 1e-4, maxIterations = 14 } = options;
|
|
620
620
|
const target = resolveMinContrast(contrastInput);
|
|
621
|
-
const searchTarget = target * 1.
|
|
621
|
+
const searchTarget = target * 1.01;
|
|
622
622
|
const yBase = gamutClampedLuminance(baseLinearRgb);
|
|
623
623
|
const crPref = contrastRatioFromLuminance(cachedLuminance(hue, saturation, preferredLightness), yBase);
|
|
624
624
|
if (crPref >= searchTarget) return {
|
|
@@ -1413,10 +1413,14 @@ function createTheme(hue, saturation, initialColors) {
|
|
|
1413
1413
|
};
|
|
1414
1414
|
},
|
|
1415
1415
|
extend(options) {
|
|
1416
|
-
|
|
1417
|
-
|
|
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
|
-
} : { ...
|
|
1423
|
+
} : { ...inheritedColors });
|
|
1420
1424
|
},
|
|
1421
1425
|
resolve() {
|
|
1422
1426
|
return resolveAllColors(hue, saturation, colorDefs);
|