hextimator 0.14.0 → 0.14.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/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.14.2
2
+
3
+ ### Patch Changes
4
+
5
+ - [#180](https://github.com/fgrgic/hextimator/pull/180) [`4783af1`](https://github.com/fgrgic/hextimator/commit/4783af1270f6e8104a7fb8b902caf4410276cf27) Thanks [@fgrgic](https://github.com/fgrgic)! - Adds missing foreground-weak variant to llms.txt
6
+
7
+ ## 0.14.1
8
+
9
+ ### Patch Changes
10
+
11
+ - [#177](https://github.com/fgrgic/hextimator/pull/177) [`e035074`](https://github.com/fgrgic/hextimator/commit/e03507480239b98b4eb9aed6116487f69cf10d01) Thanks [@fgrgic](https://github.com/fgrgic)! - Wrong dist shipped with previous version, shipping correct one in this
12
+
1
13
  ## 0.14.0
2
14
 
3
15
  ### Minor Changes
@@ -317,7 +317,7 @@ type FormatResult = FlatTokenMap | NestedTokenMap | string;
317
317
  interface HextimatePreset {
318
318
  /** Style options (contrast, hue shifts, lightness, chroma). Applied before roles/variants/tokens. */
319
319
  style?: HextimateStyleOptions;
320
- /** Extra roles to add to the palette (each generates DEFAULT, strong, weak, foreground variants). */
320
+ /** Extra roles to add to the palette (each generates DEFAULT, strong, weak, foreground, foreground-weak variants). */
321
321
  roles?: Array<{
322
322
  name: string;
323
323
  color: ColorInput | DerivedToken;
@@ -149,7 +149,7 @@ var shadcn = {
149
149
  foreground: "foreground"
150
150
  },
151
151
  excludeRoles: ["caution"],
152
- excludeVariants: ["strong", "weak"]
152
+ excludeVariants: ["strong", "weak", "foreground-weak"]
153
153
  }
154
154
  };
155
155
 
@@ -726,12 +726,7 @@ function adaptPalette(palette, type, severity = 1) {
726
726
  const result = {};
727
727
  for (const role of Object.keys(palette)) {
728
728
  const scale = palette[role];
729
- const newScale = {
730
- DEFAULT: scale.DEFAULT,
731
- strong: scale.strong,
732
- weak: scale.weak,
733
- foreground: scale.foreground
734
- };
729
+ const newScale = {};
735
730
  for (const variant of Object.keys(scale)) {
736
731
  newScale[variant] = daltonizeColor(parse(scale[variant]), type, severity);
737
732
  }
@@ -757,12 +752,7 @@ function simulatePalette(palette, type, severity = 1) {
757
752
  const result = {};
758
753
  for (const role of Object.keys(palette)) {
759
754
  const scale = palette[role];
760
- const newScale = {
761
- DEFAULT: scale.DEFAULT,
762
- strong: scale.strong,
763
- weak: scale.weak,
764
- foreground: scale.foreground
765
- };
755
+ const newScale = {};
766
756
  for (const variant of Object.keys(scale)) {
767
757
  newScale[variant] = simulateColor(parse(scale[variant]), type, severity);
768
758
  }
@@ -1384,13 +1374,27 @@ function expandColorToScale(color, themeType, options) {
1384
1374
  contrastTarget,
1385
1375
  skipSurfaceCap
1386
1376
  );
1377
+ const foregroundWeakColorOKLCH = computeSoftestForeground(
1378
+ foregroundColorOKLCH,
1379
+ normalizedColorOKLCH,
1380
+ contrastTarget
1381
+ );
1387
1382
  return {
1388
1383
  DEFAULT: { ...normalizedColorOKLCH },
1389
1384
  strong: { ...strongColorOKLCH },
1390
1385
  weak: { ...weakColorOKLCH },
1391
- foreground: { ...foregroundColorOKLCH }
1386
+ foreground: { ...foregroundColorOKLCH },
1387
+ "foreground-weak": { ...foregroundWeakColorOKLCH }
1392
1388
  };
1393
1389
  }
1390
+ function computeSoftestForeground(foreground, base, contrastTarget) {
1391
+ const boundaryL = findContrastBoundaryLightness(
1392
+ foreground,
1393
+ base,
1394
+ contrastTarget
1395
+ );
1396
+ return { ...foreground, l: boundaryL ?? foreground.l };
1397
+ }
1394
1398
  var warnedLegacyLightness = false;
1395
1399
  function normalizeBaseLightnessRange(custom) {
1396
1400
  let lo = Number(custom[0]);
@@ -2092,21 +2096,19 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2092
2096
  return;
2093
2097
  }
2094
2098
  if (edge === "foreground") {
2095
- const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + 0.15;
2099
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2096
2100
  for (const palette of [this.lightPalette, this.darkPalette]) {
2097
2101
  for (const role of Object.keys(palette)) {
2098
2102
  const scale = palette[role];
2099
- const foreground = convert(parse(scale.foreground), "oklch");
2100
- const boundaryL = findContrastBoundaryLightness(
2101
- parse(scale.foreground),
2102
- parse(scale.DEFAULT),
2103
+ const soft = computeSoftestForeground(
2104
+ convert(parse(scale.foreground), "oklch"),
2105
+ convert(parse(scale.DEFAULT), "oklch"),
2103
2106
  contrastTarget
2104
2107
  );
2105
2108
  scale[name] = {
2106
- ...foreground,
2107
- l: boundaryL ?? foreground.l,
2108
- c: Math.max(0, foreground.c + chromaOffset),
2109
- h: wrapHue(foreground.h + hueOffset)
2109
+ ...soft,
2110
+ c: Math.max(0, soft.c + chromaOffset),
2111
+ h: wrapHue(soft.h + hueOffset)
2110
2112
  };
2111
2113
  }
2112
2114
  }
@@ -2386,7 +2388,7 @@ Did you mean addToken("${suggestion}") to change the palette?`
2386
2388
  const rawShift = this.options.hueShift ?? 0;
2387
2389
  const clampedShift = clampHueShift(rawShift, totalVariants);
2388
2390
  const hueShiftPerStep = isStrongSide ? clampedShift : -clampedShift;
2389
- const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + 0.15;
2391
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2390
2392
  for (const role of Object.keys(this.lightPalette)) {
2391
2393
  for (const [palette, themeType] of [
2392
2394
  [this.lightPalette, "light"],
package/dist/cli.js CHANGED
@@ -734,12 +734,7 @@ function adaptPalette(palette, type, severity = 1) {
734
734
  const result = {};
735
735
  for (const role of Object.keys(palette)) {
736
736
  const scale = palette[role];
737
- const newScale = {
738
- DEFAULT: scale.DEFAULT,
739
- strong: scale.strong,
740
- weak: scale.weak,
741
- foreground: scale.foreground
742
- };
737
+ const newScale = {};
743
738
  for (const variant of Object.keys(scale)) {
744
739
  newScale[variant] = daltonizeColor(parse(scale[variant]), type, severity);
745
740
  }
@@ -765,12 +760,7 @@ function simulatePalette(palette, type, severity = 1) {
765
760
  const result = {};
766
761
  for (const role of Object.keys(palette)) {
767
762
  const scale = palette[role];
768
- const newScale = {
769
- DEFAULT: scale.DEFAULT,
770
- strong: scale.strong,
771
- weak: scale.weak,
772
- foreground: scale.foreground
773
- };
763
+ const newScale = {};
774
764
  for (const variant of Object.keys(scale)) {
775
765
  newScale[variant] = simulateColor(parse(scale[variant]), type, severity);
776
766
  }
@@ -1392,13 +1382,27 @@ function expandColorToScale(color, themeType, options) {
1392
1382
  contrastTarget,
1393
1383
  skipSurfaceCap
1394
1384
  );
1385
+ const foregroundWeakColorOKLCH = computeSoftestForeground(
1386
+ foregroundColorOKLCH,
1387
+ normalizedColorOKLCH,
1388
+ contrastTarget
1389
+ );
1395
1390
  return {
1396
1391
  DEFAULT: { ...normalizedColorOKLCH },
1397
1392
  strong: { ...strongColorOKLCH },
1398
1393
  weak: { ...weakColorOKLCH },
1399
- foreground: { ...foregroundColorOKLCH }
1394
+ foreground: { ...foregroundColorOKLCH },
1395
+ "foreground-weak": { ...foregroundWeakColorOKLCH }
1400
1396
  };
1401
1397
  }
1398
+ function computeSoftestForeground(foreground, base, contrastTarget) {
1399
+ const boundaryL = findContrastBoundaryLightness(
1400
+ foreground,
1401
+ base,
1402
+ contrastTarget
1403
+ );
1404
+ return { ...foreground, l: boundaryL ?? foreground.l };
1405
+ }
1402
1406
  var warnedLegacyLightness = false;
1403
1407
  function normalizeBaseLightnessRange(custom) {
1404
1408
  let lo = Number(custom[0]);
@@ -2100,21 +2104,19 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
2100
2104
  return;
2101
2105
  }
2102
2106
  if (edge === "foreground") {
2103
- const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + 0.15;
2107
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2104
2108
  for (const palette of [this.lightPalette, this.darkPalette]) {
2105
2109
  for (const role of Object.keys(palette)) {
2106
2110
  const scale = palette[role];
2107
- const foreground = convert(parse(scale.foreground), "oklch");
2108
- const boundaryL = findContrastBoundaryLightness(
2109
- parse(scale.foreground),
2110
- parse(scale.DEFAULT),
2111
+ const soft = computeSoftestForeground(
2112
+ convert(parse(scale.foreground), "oklch"),
2113
+ convert(parse(scale.DEFAULT), "oklch"),
2111
2114
  contrastTarget
2112
2115
  );
2113
2116
  scale[name] = {
2114
- ...foreground,
2115
- l: boundaryL ?? foreground.l,
2116
- c: Math.max(0, foreground.c + chromaOffset),
2117
- h: wrapHue(foreground.h + hueOffset)
2117
+ ...soft,
2118
+ c: Math.max(0, soft.c + chromaOffset),
2119
+ h: wrapHue(soft.h + hueOffset)
2118
2120
  };
2119
2121
  }
2120
2122
  }
@@ -2394,7 +2396,7 @@ Did you mean addToken("${suggestion}") to change the palette?`
2394
2396
  const rawShift = this.options.hueShift ?? 0;
2395
2397
  const clampedShift = clampHueShift(rawShift, totalVariants);
2396
2398
  const hueShiftPerStep = isStrongSide ? clampedShift : -clampedShift;
2397
- const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + 0.15;
2399
+ const contrastTarget = resolveContrastRatio(this.options.minContrastRatio) + CONTRAST_MARGIN;
2398
2400
  for (const role of Object.keys(this.lightPalette)) {
2399
2401
  for (const [palette, themeType] of [
2400
2402
  [this.lightPalette, "light"],
@@ -2691,7 +2693,7 @@ var shadcn = {
2691
2693
  foreground: "foreground"
2692
2694
  },
2693
2695
  excludeRoles: ["caution"],
2694
- excludeVariants: ["strong", "weak"]
2696
+ excludeVariants: ["strong", "weak", "foreground-weak"]
2695
2697
  }
2696
2698
  };
2697
2699
 
@@ -1,4 +1,4 @@
1
- import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
1
+ import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-CPmTYcEY.js';
2
2
 
3
3
  /**
4
4
  * Darker accents on light themes, lighter accents on dark themes.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
2
- export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BsQOgUcZ.js';
3
- export { H as HextimateConfig, f as fromConfig, i as presets } from './index-CA19MMV4.js';
1
+ import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-CPmTYcEY.js';
2
+ export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-CPmTYcEY.js';
3
+ export { H as HextimateConfig, f as fromConfig, i as presets } from './index-An21acU4.js';
4
4
 
5
5
  /**
6
6
  * Daltonize a color for a specific type of color vision deficiency (CVD).
package/dist/index.js CHANGED
@@ -7,10 +7,10 @@ import {
7
7
  hextimate,
8
8
  parse,
9
9
  simulateColor
10
- } from "./chunk-V4RWDZQM.js";
10
+ } from "./chunk-FEOOTCAG.js";
11
11
  import {
12
12
  presets_exports
13
- } from "./chunk-TEZ2I4CJ.js";
13
+ } from "./chunk-23UBW2KU.js";
14
14
  export {
15
15
  HextimateError,
16
16
  HextimatePaletteBuilder,
package/dist/presets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { H as HextimateConfig, b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-CA19MMV4.js';
2
- export { g as HextimatePreset } from './HextimatePaletteBuilder-BsQOgUcZ.js';
1
+ export { H as HextimateConfig, b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-An21acU4.js';
2
+ export { g as HextimatePreset } from './HextimatePaletteBuilder-CPmTYcEY.js';
package/dist/presets.js CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  shadcn,
6
6
  tinted,
7
7
  vibrant
8
- } from "./chunk-TEZ2I4CJ.js";
8
+ } from "./chunk-23UBW2KU.js";
9
9
  export {
10
10
  bold,
11
11
  mui,
package/dist/react.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-BsQOgUcZ.js';
1
+ import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-CPmTYcEY.js';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
  import { PropsWithChildren, RefObject, CSSProperties, ReactNode } from 'react';
4
4
 
package/dist/react.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  hextimate
3
- } from "./chunk-V4RWDZQM.js";
4
- import "./chunk-TEZ2I4CJ.js";
3
+ } from "./chunk-FEOOTCAG.js";
4
+ import "./chunk-23UBW2KU.js";
5
5
 
6
6
  // src/react/hextimator-provider.tsx
7
7
  import {
package/llms.txt CHANGED
@@ -82,7 +82,7 @@ const sheet = hextimate("#6366f1").format({ as: "css", colors: "oklch" });
82
82
  |------|------|
83
83
  | `.preset(p)` | Apply preset(s); call multiple times, later wins on conflicts |
84
84
  | `.style(partial)` | Merge `HextimateStyleOptions` (contrast, surfaces, semantics, etc.) |
85
- | `.addRole(name, color)` | New role with default / strong / weak / foreground |
85
+ | `.addRole(name, color)` | New role with default / strong / weak / foreground / foreground-weak |
86
86
  | `.addVariant(name, placement)` | Extra lightness step on every role |
87
87
  | `.addToken(name, value)` | Standalone derived token |
88
88
  | `.fork(color?)` | Clone for another brand / tenant |
@@ -104,7 +104,7 @@ const sheet = hextimate("#6366f1").format({ as: "css", colors: "oklch" });
104
104
 
105
105
  ### Default token grid
106
106
 
107
- Roles: `surface`, `accent`, `positive`, `negative`, `caution`. Variants: default (no suffix), `strong`, `weak`, `foreground`. Plus `brand-exact` and `brand-exact-foreground`.
107
+ Roles: `surface`, `accent`, `positive`, `negative`, `caution`. Variants: default (no suffix), `strong`, `weak`, `foreground`, `foreground-weak` (softest text that still meets the contrast target vs DEFAULT). Plus `brand-exact` and `brand-exact-foreground`.
108
108
 
109
109
  ### Utilities
110
110
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hextimator",
3
- "version": "0.14.0",
3
+ "version": "0.14.2",
4
4
  "description": "Runtime theming for multi-tenant apps.",
5
5
  "keywords": [
6
6
  "color-palette",