@tenphi/glaze 0.0.0-snapshot.c8281e2 → 0.0.0-snapshot.cdd8acc
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 +140 -38
- package/dist/index.cjs +315 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +137 -27
- package/dist/index.d.mts +137 -27
- package/dist/index.mjs +314 -52
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
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>;
|
|
@@ -242,6 +257,13 @@ interface GlazeConfig {
|
|
|
242
257
|
darkLightness?: [number, number];
|
|
243
258
|
/** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
|
|
244
259
|
darkDesaturation?: number;
|
|
260
|
+
/**
|
|
261
|
+
* Möbius beta for dark auto-inversion (0–1).
|
|
262
|
+
* Lower values expand subtle near-white distinctions in dark mode.
|
|
263
|
+
* Set to 1 for linear (legacy) behavior. Default: 0.5.
|
|
264
|
+
* Accepts [normal, highContrast] pair for separate HC tuning.
|
|
265
|
+
*/
|
|
266
|
+
darkCurve?: HCPair<number>;
|
|
245
267
|
/** State alias names for token export. */
|
|
246
268
|
states?: {
|
|
247
269
|
dark?: string;
|
|
@@ -256,6 +278,7 @@ interface GlazeConfigResolved {
|
|
|
256
278
|
lightLightness: [number, number];
|
|
257
279
|
darkLightness: [number, number];
|
|
258
280
|
darkDesaturation: number;
|
|
281
|
+
darkCurve: HCPair<number>;
|
|
259
282
|
states: {
|
|
260
283
|
dark: string;
|
|
261
284
|
highContrast: string;
|
|
@@ -279,7 +302,7 @@ interface GlazeShadowInput {
|
|
|
279
302
|
intensity: number;
|
|
280
303
|
tuning?: ShadowTuning;
|
|
281
304
|
}
|
|
282
|
-
/** Input for `glaze.color()`
|
|
305
|
+
/** Input for the structured `glaze.color()` overload. */
|
|
283
306
|
interface GlazeColorInput {
|
|
284
307
|
hue: number;
|
|
285
308
|
saturation: number;
|
|
@@ -287,6 +310,65 @@ interface GlazeColorInput {
|
|
|
287
310
|
saturationFactor?: number;
|
|
288
311
|
mode?: AdaptationMode;
|
|
289
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Any single-color input form accepted by the value-shorthand
|
|
315
|
+
* overload of `glaze.color()`.
|
|
316
|
+
*
|
|
317
|
+
* Strings cover hex (`#rgb` / `#rrggbb`) and the four CSS color
|
|
318
|
+
* functions Glaze itself emits: `rgb()`, `hsl()`, `okhsl()`, `oklch()`.
|
|
319
|
+
* The OKHSL object form `{ h, s, l }` matches Glaze's native shape
|
|
320
|
+
* (h: 0–360, s/l: 0–1). The tuple form is `[r, g, b]` in 0–255,
|
|
321
|
+
* matching `glaze.fromRgb`'s range.
|
|
322
|
+
*/
|
|
323
|
+
type GlazeColorValue = string | OkhslColor | [number, number, number];
|
|
324
|
+
/** Optional overrides for `glaze.color(value, overrides?)`. */
|
|
325
|
+
interface GlazeColorOverrides {
|
|
326
|
+
/**
|
|
327
|
+
* Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
|
|
328
|
+
* to the extracted (or overridden) seed hue — same semantics as
|
|
329
|
+
* `RegularColorDef.hue`.
|
|
330
|
+
*/
|
|
331
|
+
hue?: number | RelativeValue;
|
|
332
|
+
/** Override seed saturation (0–100). Default: extracted from value. */
|
|
333
|
+
saturation?: number;
|
|
334
|
+
/**
|
|
335
|
+
* Override lightness. Number is absolute (0–100); `'+N'`/`'-N'` is
|
|
336
|
+
* relative to the resolved `base` color's lightness — and therefore
|
|
337
|
+
* requires `base`. Supports HCPair for high-contrast.
|
|
338
|
+
*/
|
|
339
|
+
lightness?: HCPair<number | RelativeValue>;
|
|
340
|
+
/** Saturation multiplier on the seed (0–1). Default: 1. */
|
|
341
|
+
saturationFactor?: number;
|
|
342
|
+
/** Adaptation mode. Default: 'auto'. */
|
|
343
|
+
mode?: AdaptationMode;
|
|
344
|
+
/**
|
|
345
|
+
* Optional base color the result is computed against. Accepts any
|
|
346
|
+
* `GlazeColorValue` (hex, color function, OKHSL object, RGB tuple).
|
|
347
|
+
* Required when using relative `lightness` or `contrast`.
|
|
348
|
+
*/
|
|
349
|
+
base?: GlazeColorValue;
|
|
350
|
+
/**
|
|
351
|
+
* WCAG contrast floor against the resolved `base`. Requires `base`.
|
|
352
|
+
* Same shape as `RegularColorDef.contrast`.
|
|
353
|
+
*/
|
|
354
|
+
contrast?: HCPair<MinContrast>;
|
|
355
|
+
}
|
|
356
|
+
/** Options for `GlazeColorToken.css()`. */
|
|
357
|
+
interface GlazeColorCssOptions {
|
|
358
|
+
/**
|
|
359
|
+
* Custom property base name (without leading `--`). Required.
|
|
360
|
+
* Becomes the variable identifier in the output, e.g.
|
|
361
|
+
* `name: 'brand'` → `--brand-color: …`.
|
|
362
|
+
*/
|
|
363
|
+
name: string;
|
|
364
|
+
/** Output color format. Default: 'rgb' (matches `theme.css` default). */
|
|
365
|
+
format?: GlazeColorFormat;
|
|
366
|
+
/**
|
|
367
|
+
* Suffix appended to the name. Default: '-color' (matches
|
|
368
|
+
* `theme.css` default).
|
|
369
|
+
*/
|
|
370
|
+
suffix?: string;
|
|
371
|
+
}
|
|
290
372
|
/** Return type for `glaze.color()`. */
|
|
291
373
|
interface GlazeColorToken {
|
|
292
374
|
/** Resolve the color across all scheme variants. */
|
|
@@ -296,11 +378,13 @@ interface GlazeColorToken {
|
|
|
296
378
|
/**
|
|
297
379
|
* Export as a tasty style-to-state binding (no color name key).
|
|
298
380
|
* Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
|
|
299
|
-
* @see https://
|
|
381
|
+
* @see https://tasty.style/docs
|
|
300
382
|
*/
|
|
301
383
|
tasty(options?: GlazeTokenOptions): Record<string, string>;
|
|
302
384
|
/** Export as a flat JSON map (no color name key). */
|
|
303
385
|
json(options?: GlazeJsonOptions): Record<string, string>;
|
|
386
|
+
/** Export as CSS custom property declarations grouped by scheme variant. */
|
|
387
|
+
css(options: GlazeColorCssOptions): GlazeCssResult;
|
|
304
388
|
}
|
|
305
389
|
interface GlazeTheme {
|
|
306
390
|
/** The hue seed (0–360). */
|
|
@@ -340,7 +424,7 @@ interface GlazeTheme {
|
|
|
340
424
|
* Export as tasty style-to-state bindings.
|
|
341
425
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
342
426
|
* Spread into component styles or register as a recipe via `configure({ recipes })`.
|
|
343
|
-
* @see https://
|
|
427
|
+
* @see https://tasty.style/docs
|
|
344
428
|
*/
|
|
345
429
|
tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
|
|
346
430
|
/** Export as plain JSON. */
|
|
@@ -385,35 +469,47 @@ interface GlazeCssResult {
|
|
|
385
469
|
lightContrast: string;
|
|
386
470
|
darkContrast: string;
|
|
387
471
|
}
|
|
388
|
-
/** Options
|
|
389
|
-
interface
|
|
390
|
-
/**
|
|
391
|
-
* Prefix mode. `true` uses `"<themeName>-"`, or provide a custom map.
|
|
392
|
-
* Defaults to `true` for palette export methods.
|
|
393
|
-
* Set to `false` explicitly to disable prefixing (last-write-wins on collisions).
|
|
394
|
-
*/
|
|
395
|
-
prefix?: boolean | Record<string, string>;
|
|
472
|
+
/** Options for `glaze.palette()` creation. */
|
|
473
|
+
interface GlazePaletteOptions {
|
|
396
474
|
/**
|
|
397
475
|
* Name of the primary theme. The primary theme's tokens are duplicated
|
|
398
|
-
* without prefix, providing convenient short aliases
|
|
399
|
-
* prefixed versions.
|
|
476
|
+
* without prefix in all exports, providing convenient short aliases
|
|
477
|
+
* alongside the prefixed versions. Can be overridden per-export.
|
|
400
478
|
*
|
|
401
479
|
* @example
|
|
402
480
|
* ```ts
|
|
403
|
-
* palette.
|
|
481
|
+
* const palette = glaze.palette({ brand, accent }, { primary: 'brand' });
|
|
482
|
+
* palette.tokens()
|
|
404
483
|
* // → { light: { 'brand-surface': '...', 'surface': '...', 'accent-surface': '...' } }
|
|
405
484
|
* ```
|
|
406
485
|
*/
|
|
407
486
|
primary?: string;
|
|
408
487
|
}
|
|
488
|
+
/** Options shared by palette `tokens()`, `tasty()`, and `css()` exports. */
|
|
489
|
+
interface GlazePaletteExportOptions {
|
|
490
|
+
/**
|
|
491
|
+
* Prefix mode. `true` uses `"<themeName>-"`, or provide a custom map.
|
|
492
|
+
* Defaults to `true` for palette export methods.
|
|
493
|
+
* Set to `false` explicitly to disable prefixing. Colliding keys
|
|
494
|
+
* produce a console.warn and the first-written value wins.
|
|
495
|
+
*/
|
|
496
|
+
prefix?: boolean | Record<string, string>;
|
|
497
|
+
/**
|
|
498
|
+
* Override the palette-level primary theme for this export.
|
|
499
|
+
* Pass a theme name to set/change the primary, or `false` to disable it.
|
|
500
|
+
* When omitted, inherits the palette-level `primary`.
|
|
501
|
+
*/
|
|
502
|
+
primary?: string | false;
|
|
503
|
+
}
|
|
409
504
|
interface GlazePalette {
|
|
410
505
|
/**
|
|
411
506
|
* Export all themes as a flat token map grouped by scheme variant.
|
|
412
507
|
* Prefix defaults to `true` — all tokens are prefixed with the theme name.
|
|
413
|
-
*
|
|
508
|
+
* Inherits the palette-level `primary`; override per-call or pass `false` to disable.
|
|
414
509
|
*
|
|
415
510
|
* ```ts
|
|
416
|
-
* palette.
|
|
511
|
+
* const palette = glaze.palette({ brand, accent }, { primary: 'brand' });
|
|
512
|
+
* palette.tokens()
|
|
417
513
|
* // → { light: { 'brand-surface': '...', 'surface': '...', 'accent-surface': '...' } }
|
|
418
514
|
* ```
|
|
419
515
|
*/
|
|
@@ -421,12 +517,10 @@ interface GlazePalette {
|
|
|
421
517
|
/**
|
|
422
518
|
* Export all themes as tasty style-to-state bindings.
|
|
423
519
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
424
|
-
* Prefix defaults to `true`.
|
|
425
|
-
* @see https://
|
|
520
|
+
* Prefix defaults to `true`. Inherits the palette-level `primary`.
|
|
521
|
+
* @see https://tasty.style/docs
|
|
426
522
|
*/
|
|
427
|
-
tasty(options?: GlazeTokenOptions &
|
|
428
|
-
primary?: string;
|
|
429
|
-
}): Record<string, Record<string, string>>;
|
|
523
|
+
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
430
524
|
/** Export all themes as plain JSON grouped by theme name. */
|
|
431
525
|
json(options?: GlazeJsonOptions & {
|
|
432
526
|
prefix?: boolean | Record<string, string>;
|
|
@@ -453,18 +547,19 @@ declare function glaze(hueOrOptions: number | {
|
|
|
453
547
|
}, saturation?: number): GlazeTheme;
|
|
454
548
|
declare namespace glaze {
|
|
455
549
|
var configure: (config: GlazeConfig) => void;
|
|
456
|
-
var palette: (themes: PaletteInput) => {
|
|
550
|
+
var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => {
|
|
457
551
|
tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
458
|
-
tasty(options?: GlazeTokenOptions &
|
|
459
|
-
primary?: string;
|
|
460
|
-
}): Record<string, Record<string, string>>;
|
|
552
|
+
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
461
553
|
json(options?: GlazeJsonOptions & {
|
|
462
554
|
prefix?: boolean | Record<string, string>;
|
|
463
555
|
}): Record<string, Record<string, Record<string, string>>>;
|
|
464
556
|
css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
|
|
465
557
|
};
|
|
466
558
|
var from: (data: GlazeThemeExport) => GlazeTheme;
|
|
467
|
-
var color:
|
|
559
|
+
var color: {
|
|
560
|
+
(input: GlazeColorInput): GlazeColorToken;
|
|
561
|
+
(value: GlazeColorValue, options?: GlazeColorOverrides): GlazeColorToken;
|
|
562
|
+
};
|
|
468
563
|
var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
|
|
469
564
|
var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
|
|
470
565
|
var fromHex: (hex: string) => GlazeTheme;
|
|
@@ -481,6 +576,7 @@ declare namespace glaze {
|
|
|
481
576
|
* computation for WCAG 2 contrast calculations, and multi-format output
|
|
482
577
|
* (okhsl, rgb, hsl, oklch).
|
|
483
578
|
*/
|
|
579
|
+
type Vec3 = [number, number, number];
|
|
484
580
|
/**
|
|
485
581
|
* Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLab [L, a, b].
|
|
486
582
|
*/
|
|
@@ -509,11 +605,25 @@ declare function okhslToSrgb(h: number, s: number, l: number): [number, number,
|
|
|
509
605
|
* This avoids over/under-estimating luminance for out-of-gamut OKHSL colors.
|
|
510
606
|
*/
|
|
511
607
|
declare function gamutClampedLuminance(linearRgb: [number, number, number]): number;
|
|
608
|
+
/**
|
|
609
|
+
* Convert OKLab to OKHSL.
|
|
610
|
+
* Input: [L, a, b] where L: 0–1, a/b: roughly -0.5 to 0.5.
|
|
611
|
+
* Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
|
|
612
|
+
*/
|
|
613
|
+
declare const oklabToOkhsl: (lab: Vec3) => Vec3;
|
|
512
614
|
/**
|
|
513
615
|
* Convert gamma-encoded sRGB (0–1 per channel) to OKHSL.
|
|
514
616
|
* Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
|
|
515
617
|
*/
|
|
516
618
|
declare function srgbToOkhsl(rgb: [number, number, number]): [number, number, number];
|
|
619
|
+
/**
|
|
620
|
+
* Convert CSS HSL (sRGB-based) to gamma-encoded sRGB [r, g, b] in 0–1 range.
|
|
621
|
+
* h: 0–360, s: 0–1, l: 0–1.
|
|
622
|
+
*
|
|
623
|
+
* Note: CSS HSL is not the same as OKHSL — it's HSL in the sRGB color space.
|
|
624
|
+
* Use this when parsing `hsl(...)` strings before passing to `srgbToOkhsl`.
|
|
625
|
+
*/
|
|
626
|
+
declare function hslToSrgb(h: number, s: number, l: number): [number, number, number];
|
|
517
627
|
/**
|
|
518
628
|
* Parse a hex color string (#rgb or #rrggbb) to sRGB [r, g, b] in 0–1 range.
|
|
519
629
|
* Returns null if the string is not a valid hex color.
|
|
@@ -541,5 +651,5 @@ declare function formatHsl(h: number, s: number, l: number): string;
|
|
|
541
651
|
*/
|
|
542
652
|
declare function formatOklch(h: number, s: number, l: number): string;
|
|
543
653
|
//#endregion
|
|
544
|
-
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorToken, type GlazeConfig, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type MinContrast, type MixColorDef, type OkhslColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, parseHex, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
654
|
+
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorOverrides, type GlazeColorToken, type GlazeColorValue, type GlazeConfig, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type MinContrast, type MixColorDef, type OkhslColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, hslToSrgb, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, oklabToOkhsl, parseHex, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
545
655
|
//# sourceMappingURL=index.d.cts.map
|
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>;
|
|
@@ -242,6 +257,13 @@ interface GlazeConfig {
|
|
|
242
257
|
darkLightness?: [number, number];
|
|
243
258
|
/** Saturation reduction factor for dark scheme (0–1). Default: 0.1. */
|
|
244
259
|
darkDesaturation?: number;
|
|
260
|
+
/**
|
|
261
|
+
* Möbius beta for dark auto-inversion (0–1).
|
|
262
|
+
* Lower values expand subtle near-white distinctions in dark mode.
|
|
263
|
+
* Set to 1 for linear (legacy) behavior. Default: 0.5.
|
|
264
|
+
* Accepts [normal, highContrast] pair for separate HC tuning.
|
|
265
|
+
*/
|
|
266
|
+
darkCurve?: HCPair<number>;
|
|
245
267
|
/** State alias names for token export. */
|
|
246
268
|
states?: {
|
|
247
269
|
dark?: string;
|
|
@@ -256,6 +278,7 @@ interface GlazeConfigResolved {
|
|
|
256
278
|
lightLightness: [number, number];
|
|
257
279
|
darkLightness: [number, number];
|
|
258
280
|
darkDesaturation: number;
|
|
281
|
+
darkCurve: HCPair<number>;
|
|
259
282
|
states: {
|
|
260
283
|
dark: string;
|
|
261
284
|
highContrast: string;
|
|
@@ -279,7 +302,7 @@ interface GlazeShadowInput {
|
|
|
279
302
|
intensity: number;
|
|
280
303
|
tuning?: ShadowTuning;
|
|
281
304
|
}
|
|
282
|
-
/** Input for `glaze.color()`
|
|
305
|
+
/** Input for the structured `glaze.color()` overload. */
|
|
283
306
|
interface GlazeColorInput {
|
|
284
307
|
hue: number;
|
|
285
308
|
saturation: number;
|
|
@@ -287,6 +310,65 @@ interface GlazeColorInput {
|
|
|
287
310
|
saturationFactor?: number;
|
|
288
311
|
mode?: AdaptationMode;
|
|
289
312
|
}
|
|
313
|
+
/**
|
|
314
|
+
* Any single-color input form accepted by the value-shorthand
|
|
315
|
+
* overload of `glaze.color()`.
|
|
316
|
+
*
|
|
317
|
+
* Strings cover hex (`#rgb` / `#rrggbb`) and the four CSS color
|
|
318
|
+
* functions Glaze itself emits: `rgb()`, `hsl()`, `okhsl()`, `oklch()`.
|
|
319
|
+
* The OKHSL object form `{ h, s, l }` matches Glaze's native shape
|
|
320
|
+
* (h: 0–360, s/l: 0–1). The tuple form is `[r, g, b]` in 0–255,
|
|
321
|
+
* matching `glaze.fromRgb`'s range.
|
|
322
|
+
*/
|
|
323
|
+
type GlazeColorValue = string | OkhslColor | [number, number, number];
|
|
324
|
+
/** Optional overrides for `glaze.color(value, overrides?)`. */
|
|
325
|
+
interface GlazeColorOverrides {
|
|
326
|
+
/**
|
|
327
|
+
* Override hue. Number is absolute (0–360); `'+N'`/`'-N'` is relative
|
|
328
|
+
* to the extracted (or overridden) seed hue — same semantics as
|
|
329
|
+
* `RegularColorDef.hue`.
|
|
330
|
+
*/
|
|
331
|
+
hue?: number | RelativeValue;
|
|
332
|
+
/** Override seed saturation (0–100). Default: extracted from value. */
|
|
333
|
+
saturation?: number;
|
|
334
|
+
/**
|
|
335
|
+
* Override lightness. Number is absolute (0–100); `'+N'`/`'-N'` is
|
|
336
|
+
* relative to the resolved `base` color's lightness — and therefore
|
|
337
|
+
* requires `base`. Supports HCPair for high-contrast.
|
|
338
|
+
*/
|
|
339
|
+
lightness?: HCPair<number | RelativeValue>;
|
|
340
|
+
/** Saturation multiplier on the seed (0–1). Default: 1. */
|
|
341
|
+
saturationFactor?: number;
|
|
342
|
+
/** Adaptation mode. Default: 'auto'. */
|
|
343
|
+
mode?: AdaptationMode;
|
|
344
|
+
/**
|
|
345
|
+
* Optional base color the result is computed against. Accepts any
|
|
346
|
+
* `GlazeColorValue` (hex, color function, OKHSL object, RGB tuple).
|
|
347
|
+
* Required when using relative `lightness` or `contrast`.
|
|
348
|
+
*/
|
|
349
|
+
base?: GlazeColorValue;
|
|
350
|
+
/**
|
|
351
|
+
* WCAG contrast floor against the resolved `base`. Requires `base`.
|
|
352
|
+
* Same shape as `RegularColorDef.contrast`.
|
|
353
|
+
*/
|
|
354
|
+
contrast?: HCPair<MinContrast>;
|
|
355
|
+
}
|
|
356
|
+
/** Options for `GlazeColorToken.css()`. */
|
|
357
|
+
interface GlazeColorCssOptions {
|
|
358
|
+
/**
|
|
359
|
+
* Custom property base name (without leading `--`). Required.
|
|
360
|
+
* Becomes the variable identifier in the output, e.g.
|
|
361
|
+
* `name: 'brand'` → `--brand-color: …`.
|
|
362
|
+
*/
|
|
363
|
+
name: string;
|
|
364
|
+
/** Output color format. Default: 'rgb' (matches `theme.css` default). */
|
|
365
|
+
format?: GlazeColorFormat;
|
|
366
|
+
/**
|
|
367
|
+
* Suffix appended to the name. Default: '-color' (matches
|
|
368
|
+
* `theme.css` default).
|
|
369
|
+
*/
|
|
370
|
+
suffix?: string;
|
|
371
|
+
}
|
|
290
372
|
/** Return type for `glaze.color()`. */
|
|
291
373
|
interface GlazeColorToken {
|
|
292
374
|
/** Resolve the color across all scheme variants. */
|
|
@@ -296,11 +378,13 @@ interface GlazeColorToken {
|
|
|
296
378
|
/**
|
|
297
379
|
* Export as a tasty style-to-state binding (no color name key).
|
|
298
380
|
* Uses `#name` keys and state aliases (`''`, `@dark`, etc.).
|
|
299
|
-
* @see https://
|
|
381
|
+
* @see https://tasty.style/docs
|
|
300
382
|
*/
|
|
301
383
|
tasty(options?: GlazeTokenOptions): Record<string, string>;
|
|
302
384
|
/** Export as a flat JSON map (no color name key). */
|
|
303
385
|
json(options?: GlazeJsonOptions): Record<string, string>;
|
|
386
|
+
/** Export as CSS custom property declarations grouped by scheme variant. */
|
|
387
|
+
css(options: GlazeColorCssOptions): GlazeCssResult;
|
|
304
388
|
}
|
|
305
389
|
interface GlazeTheme {
|
|
306
390
|
/** The hue seed (0–360). */
|
|
@@ -340,7 +424,7 @@ interface GlazeTheme {
|
|
|
340
424
|
* Export as tasty style-to-state bindings.
|
|
341
425
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
342
426
|
* Spread into component styles or register as a recipe via `configure({ recipes })`.
|
|
343
|
-
* @see https://
|
|
427
|
+
* @see https://tasty.style/docs
|
|
344
428
|
*/
|
|
345
429
|
tasty(options?: GlazeTokenOptions): Record<string, Record<string, string>>;
|
|
346
430
|
/** Export as plain JSON. */
|
|
@@ -385,35 +469,47 @@ interface GlazeCssResult {
|
|
|
385
469
|
lightContrast: string;
|
|
386
470
|
darkContrast: string;
|
|
387
471
|
}
|
|
388
|
-
/** Options
|
|
389
|
-
interface
|
|
390
|
-
/**
|
|
391
|
-
* Prefix mode. `true` uses `"<themeName>-"`, or provide a custom map.
|
|
392
|
-
* Defaults to `true` for palette export methods.
|
|
393
|
-
* Set to `false` explicitly to disable prefixing (last-write-wins on collisions).
|
|
394
|
-
*/
|
|
395
|
-
prefix?: boolean | Record<string, string>;
|
|
472
|
+
/** Options for `glaze.palette()` creation. */
|
|
473
|
+
interface GlazePaletteOptions {
|
|
396
474
|
/**
|
|
397
475
|
* Name of the primary theme. The primary theme's tokens are duplicated
|
|
398
|
-
* without prefix, providing convenient short aliases
|
|
399
|
-
* prefixed versions.
|
|
476
|
+
* without prefix in all exports, providing convenient short aliases
|
|
477
|
+
* alongside the prefixed versions. Can be overridden per-export.
|
|
400
478
|
*
|
|
401
479
|
* @example
|
|
402
480
|
* ```ts
|
|
403
|
-
* palette.
|
|
481
|
+
* const palette = glaze.palette({ brand, accent }, { primary: 'brand' });
|
|
482
|
+
* palette.tokens()
|
|
404
483
|
* // → { light: { 'brand-surface': '...', 'surface': '...', 'accent-surface': '...' } }
|
|
405
484
|
* ```
|
|
406
485
|
*/
|
|
407
486
|
primary?: string;
|
|
408
487
|
}
|
|
488
|
+
/** Options shared by palette `tokens()`, `tasty()`, and `css()` exports. */
|
|
489
|
+
interface GlazePaletteExportOptions {
|
|
490
|
+
/**
|
|
491
|
+
* Prefix mode. `true` uses `"<themeName>-"`, or provide a custom map.
|
|
492
|
+
* Defaults to `true` for palette export methods.
|
|
493
|
+
* Set to `false` explicitly to disable prefixing. Colliding keys
|
|
494
|
+
* produce a console.warn and the first-written value wins.
|
|
495
|
+
*/
|
|
496
|
+
prefix?: boolean | Record<string, string>;
|
|
497
|
+
/**
|
|
498
|
+
* Override the palette-level primary theme for this export.
|
|
499
|
+
* Pass a theme name to set/change the primary, or `false` to disable it.
|
|
500
|
+
* When omitted, inherits the palette-level `primary`.
|
|
501
|
+
*/
|
|
502
|
+
primary?: string | false;
|
|
503
|
+
}
|
|
409
504
|
interface GlazePalette {
|
|
410
505
|
/**
|
|
411
506
|
* Export all themes as a flat token map grouped by scheme variant.
|
|
412
507
|
* Prefix defaults to `true` — all tokens are prefixed with the theme name.
|
|
413
|
-
*
|
|
508
|
+
* Inherits the palette-level `primary`; override per-call or pass `false` to disable.
|
|
414
509
|
*
|
|
415
510
|
* ```ts
|
|
416
|
-
* palette.
|
|
511
|
+
* const palette = glaze.palette({ brand, accent }, { primary: 'brand' });
|
|
512
|
+
* palette.tokens()
|
|
417
513
|
* // → { light: { 'brand-surface': '...', 'surface': '...', 'accent-surface': '...' } }
|
|
418
514
|
* ```
|
|
419
515
|
*/
|
|
@@ -421,12 +517,10 @@ interface GlazePalette {
|
|
|
421
517
|
/**
|
|
422
518
|
* Export all themes as tasty style-to-state bindings.
|
|
423
519
|
* Uses `#name` color token keys and state aliases (`''`, `@dark`, etc.).
|
|
424
|
-
* Prefix defaults to `true`.
|
|
425
|
-
* @see https://
|
|
520
|
+
* Prefix defaults to `true`. Inherits the palette-level `primary`.
|
|
521
|
+
* @see https://tasty.style/docs
|
|
426
522
|
*/
|
|
427
|
-
tasty(options?: GlazeTokenOptions &
|
|
428
|
-
primary?: string;
|
|
429
|
-
}): Record<string, Record<string, string>>;
|
|
523
|
+
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
430
524
|
/** Export all themes as plain JSON grouped by theme name. */
|
|
431
525
|
json(options?: GlazeJsonOptions & {
|
|
432
526
|
prefix?: boolean | Record<string, string>;
|
|
@@ -453,18 +547,19 @@ declare function glaze(hueOrOptions: number | {
|
|
|
453
547
|
}, saturation?: number): GlazeTheme;
|
|
454
548
|
declare namespace glaze {
|
|
455
549
|
var configure: (config: GlazeConfig) => void;
|
|
456
|
-
var palette: (themes: PaletteInput) => {
|
|
550
|
+
var palette: (themes: PaletteInput, options?: GlazePaletteOptions) => {
|
|
457
551
|
tokens(options?: GlazeJsonOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
458
|
-
tasty(options?: GlazeTokenOptions &
|
|
459
|
-
primary?: string;
|
|
460
|
-
}): Record<string, Record<string, string>>;
|
|
552
|
+
tasty(options?: GlazeTokenOptions & GlazePaletteExportOptions): Record<string, Record<string, string>>;
|
|
461
553
|
json(options?: GlazeJsonOptions & {
|
|
462
554
|
prefix?: boolean | Record<string, string>;
|
|
463
555
|
}): Record<string, Record<string, Record<string, string>>>;
|
|
464
556
|
css(options?: GlazeCssOptions & GlazePaletteExportOptions): GlazeCssResult;
|
|
465
557
|
};
|
|
466
558
|
var from: (data: GlazeThemeExport) => GlazeTheme;
|
|
467
|
-
var color:
|
|
559
|
+
var color: {
|
|
560
|
+
(input: GlazeColorInput): GlazeColorToken;
|
|
561
|
+
(value: GlazeColorValue, options?: GlazeColorOverrides): GlazeColorToken;
|
|
562
|
+
};
|
|
468
563
|
var shadow: (input: GlazeShadowInput) => ResolvedColorVariant;
|
|
469
564
|
var format: (variant: ResolvedColorVariant, colorFormat?: GlazeColorFormat) => string;
|
|
470
565
|
var fromHex: (hex: string) => GlazeTheme;
|
|
@@ -481,6 +576,7 @@ declare namespace glaze {
|
|
|
481
576
|
* computation for WCAG 2 contrast calculations, and multi-format output
|
|
482
577
|
* (okhsl, rgb, hsl, oklch).
|
|
483
578
|
*/
|
|
579
|
+
type Vec3 = [number, number, number];
|
|
484
580
|
/**
|
|
485
581
|
* Convert OKHSL (h: 0–360, s: 0–1, l: 0–1) to OKLab [L, a, b].
|
|
486
582
|
*/
|
|
@@ -509,11 +605,25 @@ declare function okhslToSrgb(h: number, s: number, l: number): [number, number,
|
|
|
509
605
|
* This avoids over/under-estimating luminance for out-of-gamut OKHSL colors.
|
|
510
606
|
*/
|
|
511
607
|
declare function gamutClampedLuminance(linearRgb: [number, number, number]): number;
|
|
608
|
+
/**
|
|
609
|
+
* Convert OKLab to OKHSL.
|
|
610
|
+
* Input: [L, a, b] where L: 0–1, a/b: roughly -0.5 to 0.5.
|
|
611
|
+
* Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
|
|
612
|
+
*/
|
|
613
|
+
declare const oklabToOkhsl: (lab: Vec3) => Vec3;
|
|
512
614
|
/**
|
|
513
615
|
* Convert gamma-encoded sRGB (0–1 per channel) to OKHSL.
|
|
514
616
|
* Returns [h, s, l] where h: 0–360, s: 0–1, l: 0–1.
|
|
515
617
|
*/
|
|
516
618
|
declare function srgbToOkhsl(rgb: [number, number, number]): [number, number, number];
|
|
619
|
+
/**
|
|
620
|
+
* Convert CSS HSL (sRGB-based) to gamma-encoded sRGB [r, g, b] in 0–1 range.
|
|
621
|
+
* h: 0–360, s: 0–1, l: 0–1.
|
|
622
|
+
*
|
|
623
|
+
* Note: CSS HSL is not the same as OKHSL — it's HSL in the sRGB color space.
|
|
624
|
+
* Use this when parsing `hsl(...)` strings before passing to `srgbToOkhsl`.
|
|
625
|
+
*/
|
|
626
|
+
declare function hslToSrgb(h: number, s: number, l: number): [number, number, number];
|
|
517
627
|
/**
|
|
518
628
|
* Parse a hex color string (#rgb or #rrggbb) to sRGB [r, g, b] in 0–1 range.
|
|
519
629
|
* Returns null if the string is not a valid hex color.
|
|
@@ -541,5 +651,5 @@ declare function formatHsl(h: number, s: number, l: number): string;
|
|
|
541
651
|
*/
|
|
542
652
|
declare function formatOklch(h: number, s: number, l: number): string;
|
|
543
653
|
//#endregion
|
|
544
|
-
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorFormat, type GlazeColorInput, type GlazeColorToken, type GlazeConfig, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type MinContrast, type MixColorDef, type OkhslColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, parseHex, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
654
|
+
export { type AdaptationMode, type ColorDef, type ColorMap, type ContrastPreset, type FindLightnessForContrastOptions, type FindLightnessForContrastResult, type FindValueForMixContrastOptions, type FindValueForMixContrastResult, type GlazeColorCssOptions, type GlazeColorFormat, type GlazeColorInput, type GlazeColorOverrides, type GlazeColorToken, type GlazeColorValue, type GlazeConfig, type GlazeCssOptions, type GlazeCssResult, type GlazeExtendOptions, type GlazeJsonOptions, type GlazeOutputModes, type GlazePalette, type GlazePaletteExportOptions, type GlazePaletteOptions, type GlazeShadowInput, type GlazeTheme, type GlazeThemeExport, type GlazeTokenOptions, type HCPair, type HexColor, type MinContrast, type MixColorDef, type OkhslColor, type RegularColorDef, type RelativeValue, type ResolvedColor, type ResolvedColorVariant, type ShadowColorDef, type ShadowTuning, contrastRatioFromLuminance, findLightnessForContrast, findValueForMixContrast, formatHsl, formatOkhsl, formatOklch, formatRgb, gamutClampedLuminance, glaze, hslToSrgb, okhslToLinearSrgb, okhslToOklab, okhslToSrgb, oklabToOkhsl, parseHex, relativeLuminanceFromLinearRgb, resolveMinContrast, srgbToOkhsl };
|
|
545
655
|
//# sourceMappingURL=index.d.mts.map
|