hextimator 0.12.0 → 0.12.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.
Files changed (4) hide show
  1. package/CHANGELOG.md +17 -3
  2. package/README.md +60 -20
  3. package/dist/cli.js +22 -18
  4. package/package.json +12 -25
package/CHANGELOG.md CHANGED
@@ -1,10 +1,24 @@
1
+ ## 0.12.2
2
+
3
+ ### Patch Changes
4
+
5
+ - [#159](https://github.com/fgrgic/hextimator/pull/159) [`6155be2`](https://github.com/fgrgic/hextimator/commit/6155be275afd33bd653bba9db9eac48ab4a83053) Thanks [@fgrgic](https://github.com/fgrgic)! - docs: refresh README and package description
6
+
7
+ ## 0.12.1
8
+
9
+ ### Patch Changes
10
+
11
+ - [#152](https://github.com/fgrgic/hextimator/pull/152) [`5de9e29`](https://github.com/fgrgic/hextimator/commit/5de9e2933cf57f2f323aa283c6eea15678665edc) Thanks [@fgrgic](https://github.com/fgrgic)! - trims the keywords of the package
12
+
13
+ - [#157](https://github.com/fgrgic/hextimator/pull/157) [`0fe89fa`](https://github.com/fgrgic/hextimator/commit/0fe89fa52a472f271b649360abeac6f2cbd80ffd) Thanks [@fgrgic](https://github.com/fgrgic)! - Fix `-f json` double-encoding in the CLI. With the default `--theme both`, the `light` and `dark` values were emitted as escaped JSON strings nested inside JSON, breaking `jq` pipelines. The CLI now emits a single, correctly-encoded JSON document with `light`/`dark` as real objects.
14
+
1
15
  ## 0.12.0
2
16
 
3
17
  ### Minor Changes
4
18
 
5
19
  - [#150](https://github.com/fgrgic/hextimator/pull/150) [`b7800b9`](https://github.com/fgrgic/hextimator/commit/b7800b9fac32fe3ef245f60ed39c954c63e73785) Thanks [@fgrgic](https://github.com/fgrgic)! - Adds foreground anchored variants
6
20
 
7
- You can add a new variant from foreground now. By default it will be the one that has the lowest still in rangecontrast ratio with its surface.
21
+ You can add a new variant from foreground now. By default it will be the one that has the lowest still in-range contrast ratio with its surface.
8
22
 
9
23
  The generation logic can also be overwritten by providing custom `emphasis` value (e.g. `emphasis: -0.1`)
10
24
 
@@ -16,7 +30,7 @@
16
30
 
17
31
  - [#142](https://github.com/fgrgic/hextimator/pull/142) [`95875bf`](https://github.com/fgrgic/hextimator/commit/95875bf4889c2120626cad00cfe54c6ea8f6b9dc) Thanks [@fgrgic](https://github.com/fgrgic)! - Widens the default POSITIVE_RANGE to be [120, 180].
18
32
 
19
- The previous range was to limiting so you could get an accent color that is green, and a positive color that is a whole other green that doesn't match.
33
+ The previous range was too limiting so you could get an accent color that is green, and a positive color that is a whole other green that doesn't match.
20
34
 
21
35
  Technically it changes the algorithm so it's a breaking change, but it's a minor change that should improve the color generation algorithm.
22
36
 
@@ -38,7 +52,7 @@
38
52
 
39
53
  ### Minor Changes
40
54
 
41
- - [#127](https://github.com/fgrgic/hextimator/pull/127) [`d0bbf5a`](https://github.com/fgrgic/hextimator/commit/d0bbf5a41ba303c18228057baf9b4ba6dfb016cd) Thanks [@fgrgic](https://github.com/fgrgic)! - - **Breaking.**: Lightness of the theme is derived from the input color's lightness by default. To pin down exact lightness, provide `light.baseLightness`, and/or `dark.baseLIghtness`
55
+ - [#127](https://github.com/fgrgic/hextimator/pull/127) [`d0bbf5a`](https://github.com/fgrgic/hextimator/commit/d0bbf5a41ba303c18228057baf9b4ba6dfb016cd) Thanks [@fgrgic](https://github.com/fgrgic)! - - **Breaking.**: Lightness of the theme is derived from the input color's lightness by default. To pin down exact lightness, provide `light.baseLightness`, and/or `dark.baseLightness`
42
56
 
43
57
  - Exposes `baseLightnessRange` at the top level and under `light` / `dark` to bound OKLCH **L** for accent and semantic anchors. Defaults: light `[0.4, 0.9]`, dark `[0.2, 0.8]`. CLI: `--base-lightness-range`, `--light-base-lightness-range`, `--dark-base-lightness-range`.
44
58
 
package/README.md CHANGED
@@ -1,25 +1,45 @@
1
1
  # hextimator
2
2
 
3
3
  <p align="center">
4
- <picture>
5
- <img src="https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/assets/gh-cover.webp?raw=true" alt="hextimator" width="500">
6
- </picture>
4
+ <img src="https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/assets/gh-cover.gif?raw=true" alt="hextimator" width="600">
7
5
  </p>
6
+ <p>
7
+ <a href="https://www.npmjs.com/package/hextimator"><img src="https://img.shields.io/npm/v/hextimator" alt="npm version"></a>
8
+ <a href="https://github.com/fgrgic/hextimator/actions/workflows/test.yml"><img src="https://img.shields.io/github/actions/workflow/status/fgrgic/hextimator/test.yml?branch=main" alt="CI status"></a>
9
+ <a href="https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/LICENSE.md"><img src="https://img.shields.io/npm/l/hextimator" alt="license"></a>
10
+ <a href="https://bundlejs.com/?q=hextimator&treeshake=[{hextimate}]"><img src="https://img.shields.io/bundlejs/size/hextimator" alt="bundle size"></a>
11
+ </p>
12
+
13
+ Runtime theming for multi-tenant apps.
8
14
 
9
- Per-tenant themes from a single brand color: Runtime theming for B2B2C and white-label apps.
15
+ Your customers pick a brand color. Your app looks good every time. No per-customer design reviews. No manual tuning. Yellow does not break your UI.
10
16
 
11
- Your customers pick a brand color. Your app looks good. Every time. No per-customer design reviews, no manual tuning, no edge cases where "that shade of yellow" breaks your UI.
17
+ Each call takes under a millisecond (~0.4ms [^perf]). Same color and options always produce the same tokens. Run it on the request path. Cache it if you want.
12
18
 
13
- Try it in the playground: **[hextimator.com](https://hextimator.com)**
19
+ ~12 kB min+gzip. Zero dependencies.
20
+
21
+ Try it: **[hextimator.com](https://hextimator.com)**
14
22
 
15
23
  ## Why `hextimator` exists
16
24
 
17
- You are shipping a B2B, B2B2C, or white-label app. Every tenant brings their own brand color. The options today are:
25
+ You ship a B2B, B2B2C, or white-label app. Every tenant brings a brand color. Your choices today:
26
+
27
+ - **Let them pick any hex.** Legal-pad yellow buttons become unreadable. Cheeto tangerine toasts look like your warning state.
28
+ - **Curate a palette.** You tell a paying customer their brand color is not allowed.
18
29
 
19
- - **Let them pick any hex**. Now legal-pad yellow buttons become unreadable; cheeto tangerine toasts look identical to your warning state.
20
- - **Curate a palette**. Now you are telling a paying customer their brand color is not allowed.
30
+ hextimator is the third option. **One color in, whole theme out.** Light and dark. Semantic roles and surfaces. Foregrounds meet WCAG contrast by default (AAA unless you opt down). Even yellow.
21
31
 
22
- hextimator is option three. **One color in, whole theme out.** Light and dark. Semantic roles and surfaces. Foregrounds tuned against their backgrounds for WCAG contrast by default (AAA targets unless you opt down). Even for yellow.
32
+ ## How it compares
33
+
34
+ hextimator is not the first palette generator. It targets one job the others skip: arbitrary brand colors at runtime.
35
+
36
+ - **[Adobe Leonardo](https://leonardocolor.io)** Contrast-driven scales with manual control. Designers build palettes ahead of time. No runtime API for arbitrary hex, semantic roles, or dark mode.
37
+ - **[Material dynamic color](https://github.com/material-foundation/material-color-utilities)** Full theming from one seed color. Battle-tested on Android. Output follows Material's token scheme. Hard to use outside Material-shaped UIs.
38
+ - **[Radix Colors](https://www.radix-ui.com/colors)** Hand-tuned scales with strong semantics. Fixed curated set. Does not generate themes from arbitrary input.
39
+ - **[tints.dev](https://tints.dev) / [uicolors.app](https://uicolors.app)** Quick Tailwind shade scales from one color. Build-time only. No semantic roles, contrast guarantees, dark theme, or library API.
40
+ - **[culori](https://culorijs.org) / [chroma.js](https://gka.github.io/chroma.js/)** Color math and conversions. You build a generator with these. They are not generators.
41
+
42
+ Hand-crafting one brand's design system? Several of these beat hextimator. Color comes from user input (tenants, white-label customers, CMS authors)? That is hextimator's job.
23
43
 
24
44
  ## Installation
25
45
 
@@ -27,7 +47,7 @@ hextimator is option three. **One color in, whole theme out.** Light and dark. S
27
47
  npm i hextimator
28
48
  ```
29
49
 
30
- **Tailwind v4:** import `hextimator/tailwind.css` in your CSS entry (see [Tailwind](docs/tailwind.md)).
50
+ **Tailwind v4:** import `hextimator/tailwind.css` in your CSS entry (see [Tailwind](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/tailwind.md)).
31
51
 
32
52
  ## 30-second integration
33
53
 
@@ -37,9 +57,9 @@ import { hextimate } from "hextimator";
37
57
  const css = hextimate("#C0FFEE").format({ as: "css" });
38
58
  ```
39
59
 
40
- `hextimate` turns one color into theme output. After that you decide how it ships: inline `<style>`, a `.css` file, a template partial, an edge cache, or something else. Prefer tokens over a stylesheet: `format({ as: 'object' })`
60
+ `hextimate` turns one color into a theme. You choose how to ship it: inline `<style>`, a `.css` file, a template partial, an edge cache, or something else. For tokens instead of a stylesheet, use `format({ as: 'object' })`.
41
61
 
42
- Pure computation; no DOM. SSR-friendly by default.
62
+ No DOM. Pure computation. Works with SSR.
43
63
 
44
64
  ### React (SSR-safe)
45
65
 
@@ -49,11 +69,11 @@ import { HextimatorStyle } from "hextimator/react";
49
69
  <HextimatorStyle color={"#0FF1CE"} />;
50
70
  ```
51
71
 
52
- Place it in your layout `<head>`. It renders a `<style>` node during server render (no `useEffect`, no FOUC from missing variables when paired with static HTML). Full API and dark-mode strategies: [React](docs/react.md).
72
+ Put it in your layout `<head>`. Server render writes a `<style>` node. No `useEffect`. No FOUC when you pair it with static HTML. API and dark mode: [React](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md).
53
73
 
54
74
  ### CLI (and AI agents)
55
75
 
56
- Stable entry point for tooling: same engine as the library, flags for presets and format.
76
+ Same engine as the library. Flags for presets and format.
57
77
 
58
78
  ```bash
59
79
  npx hextimator '#BADA55' --preset shadcn # framework-shaped tokens
@@ -72,16 +92,16 @@ npx hextimator '#BADA55' --preset bold
72
92
  | negative | DEFAULT, strong, weak, foreground |
73
93
  | caution | DEFAULT, strong, weak, foreground |
74
94
 
75
- Plus **`brand-exact`** (your input color, unmodified) and **`brand-exact-foreground`**.
95
+ Plus **`brand-exact`** (your input color, unchanged) and **`brand-exact-foreground`**.
76
96
 
77
97
  ## Customization and reference
78
98
 
79
- - [Customization](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/customization.md): style and format options reference
99
+ - [Customization](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/customization.md): style and format options
80
100
  - [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md): `addRole`, `addVariant`, `addToken`
81
- - [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md): drop-in configs for shadcn/ui, or create your own
101
+ - [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md): shadcn/ui configs and custom presets
82
102
  - [Multiple themes](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/multiple-themes.md): dynamic theming and `.fork()`
83
103
  - [React](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md): hook, `HextimatorStyle`, provider, scoped themes, dark mode
84
- - [Tailwind CSS v4](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/tailwind.md): setup and usage with Tailwind
104
+ - [Tailwind CSS v4](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/tailwind.md): setup and usage
85
105
 
86
106
  ### Also
87
107
 
@@ -89,6 +109,26 @@ Plus **`brand-exact`** (your input color, unmodified) and **`brand-exact-foregro
89
109
  - [Examples](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/examples.md)
90
110
  - [Migration](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md)
91
111
 
112
+ ## Contrast methodology
113
+
114
+ WCAG 2.x contrast ratios. AAA by default. Opt down with `minContrastRatio`. Audits and compliance tooling still measure this way.
115
+
116
+ APCA is the perceptual model in draft WCAG 3. Better for a lot of UI. Not what pass/fail checks ask for yet. Optional support is planned when WCAG 3 settles.
117
+
118
+ ## Stability
119
+
120
+ The API follows strict semver. Builder methods, options, formats, CLI flags, and token names only break in majors, with notes in migration.md.
121
+
122
+ Generated color values are a separate contract. Output is fully deterministic: same version, same color, same options, same tokens. The algorithm itself may improve in minors (wider hue ranges, better anchors), which changes the exact values a theme produces. Every such change is flagged in the changelog with how to opt back into the old behavior.
123
+
124
+ In practice:
125
+
126
+ - Pin an exact version if you cache or snapshot generated output.
127
+ - Patches only change generated values to fix bugs.
128
+ - Contrast guarantees hold across all releases. Whatever changes, foregrounds meet your configured minimum against their backgrounds.
129
+
92
130
  ## Contributing
93
131
 
94
- Issues and PRs are welcome at [github.com/fgrgic/hextimator](https://github.com/fgrgic/hextimator/issues).
132
+ Open issues and PRs at [github.com/fgrgic/hextimator](https://github.com/fgrgic/hextimator/issues).
133
+
134
+ [^perf]: Measured on Apple Silicon M2 Max with Bun. Ballpark only. Your hardware and runtime will differ.
package/dist/cli.js CHANGED
@@ -2858,7 +2858,9 @@ function run() {
2858
2858
  const preset = AVAILABLE_PRESETS[name];
2859
2859
  if (!preset) {
2860
2860
  console.error(
2861
- `Error: unknown preset "${name}". Available: ${Object.keys(AVAILABLE_PRESETS).join(", ")}`
2861
+ `Error: unknown preset "${name}". Available: ${Object.keys(
2862
+ AVAILABLE_PRESETS
2863
+ ).join(", ")}`
2862
2864
  );
2863
2865
  process.exit(1);
2864
2866
  }
@@ -2961,18 +2963,7 @@ function run() {
2961
2963
  if (values.selector) {
2962
2964
  formatOptions.selector = values.selector;
2963
2965
  }
2964
- const result = builder.format(formatOptions);
2965
- const themeFilter = values.theme;
2966
- let output;
2967
- if (typeof result === "string") {
2968
- output = result;
2969
- } else if (themeFilter === "light") {
2970
- output = serialize(result.light);
2971
- } else if (themeFilter === "dark") {
2972
- output = serialize(result.dark);
2973
- } else {
2974
- output = serialize({ light: result.light, dark: result.dark });
2975
- }
2966
+ const output = renderOutput(builder, formatOptions, values.theme);
2976
2967
  if (values.output) {
2977
2968
  writeFileSync(values.output, `${output}
2978
2969
  `);
@@ -2980,13 +2971,26 @@ function run() {
2980
2971
  console.log(output);
2981
2972
  }
2982
2973
  }
2974
+ function renderOutput(builder, formatOptions, themeFilter) {
2975
+ if (formatOptions.as === "json") formatOptions.as = "object";
2976
+ const result = builder.format(formatOptions);
2977
+ if (typeof result === "string") return result;
2978
+ if (themeFilter === "light") return serialize(result.light);
2979
+ if (themeFilter === "dark") return serialize(result.dark);
2980
+ return serialize({ light: result.light, dark: result.dark });
2981
+ }
2983
2982
  function serialize(value) {
2984
2983
  if (typeof value === "string") return value;
2985
2984
  return JSON.stringify(value, null, 2);
2986
2985
  }
2987
- try {
2988
- run();
2989
- } catch (err) {
2990
- console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
2991
- process.exit(1);
2986
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
2987
+ try {
2988
+ run();
2989
+ } catch (err) {
2990
+ console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
2991
+ process.exit(1);
2992
+ }
2992
2993
  }
2994
+ export {
2995
+ renderOutput
2996
+ };
package/package.json CHANGED
@@ -1,32 +1,18 @@
1
1
  {
2
2
  "name": "hextimator",
3
- "version": "0.12.0",
4
- "description": "Runtime theming for multi-tenant apps: per-tenant branded themes from a single brand color, with WCAG contrast guarantees.",
3
+ "version": "0.12.2",
4
+ "description": "Runtime theming for multi-tenant apps.",
5
5
  "keywords": [
6
- "runtime-theming",
7
- "multi-tenant",
8
- "per-tenant",
9
- "wcag",
10
- "b2b2c",
11
- "b2b",
12
- "saas-theming",
13
- "white-label",
14
- "no-code",
15
- "cms",
16
- "design-system",
17
- "multi-brand",
18
- "color",
19
- "palette",
20
- "generator",
21
- "creator",
22
- "oklch",
23
- "theme",
6
+ "color-palette",
7
+ "palette-generator",
24
8
  "design-tokens",
25
- "dark-mode",
26
- "accessibility",
9
+ "theme",
10
+ "oklch",
11
+ "wcag",
27
12
  "contrast",
28
- "brand-color",
29
- "tailwind-theme"
13
+ "multi-tenant",
14
+ "runtime-theming",
15
+ "tailwind"
30
16
  ],
31
17
  "homepage": "https://hextimator.com",
32
18
  "bugs": {
@@ -34,7 +20,8 @@
34
20
  },
35
21
  "repository": {
36
22
  "type": "git",
37
- "url": "git+https://github.com/fgrgic/hextimator.git"
23
+ "url": "git+https://github.com/fgrgic/hextimator.git",
24
+ "directory": "packages/hextimator"
38
25
  },
39
26
  "license": "MIT",
40
27
  "engines": {