hextimator 0.5.0 → 0.5.1
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 +6 -2
- package/README.md +76 -12
- package/dist/{HextimatePaletteBuilder-C8I05ZmB.d.ts → HextimatePaletteBuilder-BY1EjhFs.d.ts} +1 -1
- package/dist/chunk-JODPLAXA.js +183 -0
- package/dist/{chunk-HCVIQY7G.js → chunk-RAI6L6AN.js} +0 -175
- package/dist/index-C2l4fSiA.d.ts +79 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.js +4 -2
- package/dist/presets.d.ts +2 -0
- package/dist/presets.js +16 -0
- package/dist/react.d.ts +1 -1
- package/dist/react.js +2 -1
- package/package.json +19 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
## 0.5.
|
|
1
|
+
## 0.5.1 (Latest)
|
|
2
2
|
|
|
3
|
-
- [#
|
|
3
|
+
- [#110](https://github.com/fgrgic/hextimator/pull/110): Add ./presets as a dedicated subpath export so `import { tinted } from 'hextimator/presets'` works
|
|
4
|
+
|
|
5
|
+
## 0.5.0
|
|
6
|
+
|
|
7
|
+
- [#108](https://github.com/fgrgic/hextimator/pull/108) **Breaking.** `.format({ as: "css" })` and `.format({ as: "tailwind-css" })` now return a ready-to-paste stylesheet **string** instead of a `{ light, dark }` map of CSS variable objects. Both themes are combined into one output and wrapped for dark mode according to the new `darkMode` option.
|
|
4
8
|
|
|
5
9
|
```ts
|
|
6
10
|
// Before (0.4)
|
package/README.md
CHANGED
|
@@ -6,15 +6,45 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Per-tenant themes from a single one brand color: Runtime theming for B2B2C and white-label apps.
|
|
10
10
|
|
|
11
|
-
Your customers pick a brand color. Your app looks good. Every time. No manual tuning, no edge cases where "that shade of yellow" breaks your UI.
|
|
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.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- **Every color just works** — perceptually uniform colors with OKLCH means that electric blue looks as balanced as muted olive.
|
|
15
|
-
- **Accessible by default** — every foreground meets AAA contrast against its background, light and dark mode included.
|
|
13
|
+
Ship multi-tenant apps without the design overhead:
|
|
16
14
|
|
|
17
|
-
**
|
|
15
|
+
- **Every color just works**. Perceptually uniform colors with OKLCH means that electric blue looks as balanced as muted olive.
|
|
16
|
+
- **Accessible by default**. Every foreground meets AAA contrast against its background, light and dark mode included.
|
|
17
|
+
|
|
18
|
+
Try it in the playground: **[hextimator.com](https://hextimator.com)**
|
|
19
|
+
|
|
20
|
+
## Why `hextimator` exists
|
|
21
|
+
|
|
22
|
+
You're building a B2B, a B2B2C, or a white-label app. Every tenant wants their own brand color in the app. The options today are:
|
|
23
|
+
|
|
24
|
+
1. **Let customers pick any hex.** It works until a partner's _legal-pad yellow_ renders your buttons unreadable, and their _cheeto dust tangerine_ toast makes it indistinguishable from a warning.
|
|
25
|
+
2. **Constrain them to a curated palette.** Now you need to tell a paying customer that their brand color isn't allowed. Or spend hours adjusting all the other colors by hand to make the theme somewhat work.
|
|
26
|
+
|
|
27
|
+
Hextimator is option 3. One color in, whole theme out. You get accent, semantic roles, light/dark palette, every foreground guaranteed to meet WCAG contrast against its background. Every time. Even for that yellow.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { hextimate } from "hextimator";
|
|
31
|
+
|
|
32
|
+
const tenantTheme = hextimate(tenant.brandColor).format({ as: "css" });
|
|
33
|
+
|
|
34
|
+
document.getElementById("tenant-theme").textContent = tenantTheme;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That's the integration. Swap the color, the theme regenerates at runtime, and the UI stays readable.
|
|
38
|
+
|
|
39
|
+
Using React? Even easier:
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<HextimatorProvider defaultColor={tenant.brandColor}>
|
|
43
|
+
<App />
|
|
44
|
+
</HextimatorProvider>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See full React integration guide [here](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md).
|
|
18
48
|
|
|
19
49
|
## Installation
|
|
20
50
|
|
|
@@ -24,20 +54,38 @@ Add to your project:
|
|
|
24
54
|
npm i hextimator
|
|
25
55
|
```
|
|
26
56
|
|
|
27
|
-
|
|
57
|
+
**Using tailwind?**
|
|
58
|
+
make sure to include
|
|
28
59
|
|
|
29
|
-
```
|
|
30
|
-
|
|
60
|
+
```css
|
|
61
|
+
@import "hextimator/tailwind.css";
|
|
31
62
|
```
|
|
32
63
|
|
|
64
|
+
in your `index.css`
|
|
65
|
+
|
|
33
66
|
## Quick start
|
|
34
67
|
|
|
68
|
+
```bash
|
|
69
|
+
npm install hextimator
|
|
70
|
+
```
|
|
71
|
+
|
|
35
72
|
```typescript
|
|
36
73
|
import { hextimate } from "hextimator";
|
|
37
74
|
|
|
38
|
-
const theme = hextimate("#
|
|
75
|
+
const theme = hextimate("#6A5ACD").format();
|
|
76
|
+
// theme.light / theme.dark each contain your full theme tokens
|
|
39
77
|
```
|
|
40
78
|
|
|
79
|
+
### Multi-tenant app with React
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
<HextimatorProvider defaultColor={tenant.brandColor}>
|
|
83
|
+
<App />
|
|
84
|
+
</HextimatorProvider>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
See full React integration guide [here](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md).
|
|
88
|
+
|
|
41
89
|
### With presets
|
|
42
90
|
|
|
43
91
|
Presets are partial or full themes. You can chain them together, [extend them](#extending-presets), or not use them at all. They provide a starting point: whether for a specific framework or a particular style:
|
|
@@ -116,7 +164,7 @@ hextimate("#F11732").format({
|
|
|
116
164
|
const myPreset: HextimatePreset = {
|
|
117
165
|
format: {
|
|
118
166
|
excludeRoles: ["warning"],
|
|
119
|
-
excludeVariants: ["
|
|
167
|
+
excludeVariants: ["weak"],
|
|
120
168
|
},
|
|
121
169
|
};
|
|
122
170
|
```
|
|
@@ -152,7 +200,7 @@ All formats return `{ light: { ... }, dark: { ... } }`.
|
|
|
152
200
|
|
|
153
201
|
Besides hex, **`hextimate`** accepts CSS color strings, RGB tuples, and numeric `0xRRGGBB`—anything **`parseColor`** understands.
|
|
154
202
|
|
|
155
|
-
> **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control.
|
|
203
|
+
> **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control. You can always add an opacity modifier later if you wish (e.g. `base-accent-weak/20` in tailwind).
|
|
156
204
|
|
|
157
205
|
Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**, **`.preset()`**, **`.fork()`**, **`.simulate()` / `.adaptFor()`**, and anything else in [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) or [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md).
|
|
158
206
|
|
|
@@ -175,6 +223,22 @@ const color = parseColor("rgb(255, 102, 102)");
|
|
|
175
223
|
const oklch = convertColor(color, "oklch");
|
|
176
224
|
```
|
|
177
225
|
|
|
226
|
+
## CLI
|
|
227
|
+
|
|
228
|
+
Quickly get one-off themes from the terminal:
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
npx hextimate "#ff6677";
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Get the full help running:
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
npx hextimate -h
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
> Note: `hextimate` and `hextimator` are the same CLI; pick whichever you like typing.
|
|
241
|
+
|
|
178
242
|
## React
|
|
179
243
|
|
|
180
244
|
Import from `hextimator/react`:
|
package/dist/{HextimatePaletteBuilder-C8I05ZmB.d.ts → HextimatePaletteBuilder-BY1EjhFs.d.ts}
RENAMED
|
@@ -576,4 +576,4 @@ declare class HextimatePaletteBuilder {
|
|
|
576
576
|
private resolvedOptions;
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
export { type Color as C, type DerivedToken as D, type FlatTokenMap as F,
|
|
579
|
+
export { type Color as C, type DerivedToken as D, type FlatTokenMap as F, HextimatePaletteBuilder as H, type NestedTokenMap as N, type OKLCH as O, type ThemeAdjustments as T, type VariantPlacement as V, type CVDType as a, type ColorSpace as b, type ColorInSpace as c, type ColorInput as d, type FormatResult as e, type HextimateFormatOptions as f, type HextimateOptions as g, type HextimatePreset as h, type HextimateResult as i, type HextimateStyleOptions as j, type TokenValue as k };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/presets/index.ts
|
|
8
|
+
var presets_exports = {};
|
|
9
|
+
__export(presets_exports, {
|
|
10
|
+
bold: () => bold,
|
|
11
|
+
mui: () => mui,
|
|
12
|
+
muted: () => muted,
|
|
13
|
+
shadcn: () => shadcn,
|
|
14
|
+
tinted: () => tinted,
|
|
15
|
+
vibrant: () => vibrant
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/presets/bold.ts
|
|
19
|
+
var bold = {
|
|
20
|
+
style: {
|
|
21
|
+
light: { lightness: 0.5 },
|
|
22
|
+
dark: { lightness: 0.8 },
|
|
23
|
+
baseMaxChroma: 0.06,
|
|
24
|
+
foregroundMaxChroma: 0.02
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/presets/mui.ts
|
|
29
|
+
var mui = {
|
|
30
|
+
roles: [
|
|
31
|
+
{ name: "info", color: "#0288d1" },
|
|
32
|
+
{ name: "secondary", color: { from: "accent", hue: 180 } }
|
|
33
|
+
],
|
|
34
|
+
tokens: [
|
|
35
|
+
// background
|
|
36
|
+
{ name: "background-default", value: { from: "base" } },
|
|
37
|
+
{
|
|
38
|
+
name: "background-paper",
|
|
39
|
+
value: { from: "base", emphasis: -0.025 }
|
|
40
|
+
},
|
|
41
|
+
// text
|
|
42
|
+
{ name: "text-primary", value: { from: "base.foreground" } },
|
|
43
|
+
{
|
|
44
|
+
name: "text-secondary",
|
|
45
|
+
value: { from: "base.foreground", emphasis: -0.2 }
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "text-disabled",
|
|
49
|
+
value: { from: "base.foreground", emphasis: -0.4 }
|
|
50
|
+
},
|
|
51
|
+
// divider
|
|
52
|
+
{ name: "divider", value: { from: "base", emphasis: 0.12 } },
|
|
53
|
+
// action tokens
|
|
54
|
+
{ name: "action-hover", value: { from: "base", emphasis: 0.04 } },
|
|
55
|
+
{ name: "action-selected", value: { from: "base", emphasis: 0.08 } },
|
|
56
|
+
{ name: "action-disabled", value: { from: "base", emphasis: 0.15 } },
|
|
57
|
+
{
|
|
58
|
+
name: "action-disabledBackground",
|
|
59
|
+
value: { from: "base", emphasis: 0.06 }
|
|
60
|
+
},
|
|
61
|
+
{ name: "action-focus", value: { from: "base", emphasis: 0.06 } }
|
|
62
|
+
],
|
|
63
|
+
format: {
|
|
64
|
+
as: "object",
|
|
65
|
+
colors: "hex",
|
|
66
|
+
separator: "-",
|
|
67
|
+
roleNames: {
|
|
68
|
+
accent: "primary",
|
|
69
|
+
negative: "error",
|
|
70
|
+
positive: "success"
|
|
71
|
+
},
|
|
72
|
+
variantNames: {
|
|
73
|
+
DEFAULT: "main",
|
|
74
|
+
weak: "light",
|
|
75
|
+
strong: "dark",
|
|
76
|
+
foreground: "contrastText"
|
|
77
|
+
},
|
|
78
|
+
excludeRoles: ["base"]
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/presets/muted.ts
|
|
83
|
+
var muted = {
|
|
84
|
+
style: {
|
|
85
|
+
light: { maxChroma: 0.08 },
|
|
86
|
+
dark: { maxChroma: 0.07 },
|
|
87
|
+
baseMaxChroma: 5e-3,
|
|
88
|
+
foregroundMaxChroma: 5e-3
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/presets/shadcn.ts
|
|
93
|
+
var shadcn = {
|
|
94
|
+
tokens: [
|
|
95
|
+
// shadcn uses bare --foreground (not --background-foreground)
|
|
96
|
+
{ name: "foreground", value: { from: "base.foreground" } },
|
|
97
|
+
// card / popover — same as background
|
|
98
|
+
{ name: "card", value: { from: "base" } },
|
|
99
|
+
{ name: "card-foreground", value: { from: "base.foreground" } },
|
|
100
|
+
{ name: "popover", value: { from: "base" } },
|
|
101
|
+
{ name: "popover-foreground", value: { from: "base.foreground" } },
|
|
102
|
+
// secondary — subtle contrast from background
|
|
103
|
+
{ name: "secondary", value: { from: "base" } },
|
|
104
|
+
{ name: "secondary-foreground", value: { from: "base.foreground" } },
|
|
105
|
+
// muted — similar to secondary, but with dimmer foreground
|
|
106
|
+
{ name: "muted", value: { from: "base" } },
|
|
107
|
+
{
|
|
108
|
+
name: "muted-foreground",
|
|
109
|
+
value: {
|
|
110
|
+
from: "base.foreground",
|
|
111
|
+
emphasis: -0.25
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
115
|
+
{ name: "accent", value: { from: "base" } },
|
|
116
|
+
{ name: "accent-foreground", value: { from: "base.foreground" } },
|
|
117
|
+
// border / input
|
|
118
|
+
{
|
|
119
|
+
name: "border",
|
|
120
|
+
value: { from: "base", emphasis: 0.8 }
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "input",
|
|
124
|
+
value: {
|
|
125
|
+
from: "base",
|
|
126
|
+
emphasis: 0.8
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
// ring — uses the brand/primary color
|
|
130
|
+
{ name: "ring", value: { from: "accent" } },
|
|
131
|
+
// chart tokens colors use brand/priamry color
|
|
132
|
+
{ name: "chart-1", value: { from: "accent" } },
|
|
133
|
+
{ name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
|
|
134
|
+
{ name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
|
|
135
|
+
{ name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
|
|
136
|
+
{ name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
|
|
137
|
+
],
|
|
138
|
+
format: {
|
|
139
|
+
as: "css",
|
|
140
|
+
colors: "oklch",
|
|
141
|
+
roleNames: {
|
|
142
|
+
base: "background",
|
|
143
|
+
accent: "primary",
|
|
144
|
+
negative: "destructive",
|
|
145
|
+
positive: "success"
|
|
146
|
+
},
|
|
147
|
+
variantNames: {
|
|
148
|
+
foreground: "foreground"
|
|
149
|
+
},
|
|
150
|
+
excludeRoles: ["warning"],
|
|
151
|
+
excludeVariants: ["strong", "weak"]
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/presets/tinted.ts
|
|
156
|
+
var tinted = {
|
|
157
|
+
style: {
|
|
158
|
+
baseMaxChroma: 0.05,
|
|
159
|
+
baseHueShift: 0,
|
|
160
|
+
foregroundMaxChroma: 0.015
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/presets/vibrant.ts
|
|
165
|
+
var vibrant = {
|
|
166
|
+
style: {
|
|
167
|
+
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
168
|
+
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
169
|
+
hueShift: 5,
|
|
170
|
+
baseHueShift: 180,
|
|
171
|
+
baseMaxChroma: 0.08
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
bold,
|
|
177
|
+
mui,
|
|
178
|
+
muted,
|
|
179
|
+
shadcn,
|
|
180
|
+
tinted,
|
|
181
|
+
vibrant,
|
|
182
|
+
presets_exports
|
|
183
|
+
};
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/convert/matrices.ts
|
|
8
2
|
var M1 = [
|
|
9
3
|
[0.4122214708, 0.5363325363, 0.0514459929],
|
|
@@ -2092,174 +2086,6 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2092
2086
|
}
|
|
2093
2087
|
};
|
|
2094
2088
|
|
|
2095
|
-
// src/presets/index.ts
|
|
2096
|
-
var presets_exports = {};
|
|
2097
|
-
__export(presets_exports, {
|
|
2098
|
-
bold: () => bold,
|
|
2099
|
-
mui: () => mui,
|
|
2100
|
-
muted: () => muted,
|
|
2101
|
-
shadcn: () => shadcn,
|
|
2102
|
-
tinted: () => tinted,
|
|
2103
|
-
vibrant: () => vibrant
|
|
2104
|
-
});
|
|
2105
|
-
|
|
2106
|
-
// src/presets/bold.ts
|
|
2107
|
-
var bold = {
|
|
2108
|
-
style: {
|
|
2109
|
-
light: { lightness: 0.5 },
|
|
2110
|
-
dark: { lightness: 0.8 },
|
|
2111
|
-
baseMaxChroma: 0.06,
|
|
2112
|
-
foregroundMaxChroma: 0.02
|
|
2113
|
-
}
|
|
2114
|
-
};
|
|
2115
|
-
|
|
2116
|
-
// src/presets/mui.ts
|
|
2117
|
-
var mui = {
|
|
2118
|
-
roles: [
|
|
2119
|
-
{ name: "info", color: "#0288d1" },
|
|
2120
|
-
{ name: "secondary", color: { from: "accent", hue: 180 } }
|
|
2121
|
-
],
|
|
2122
|
-
tokens: [
|
|
2123
|
-
// background
|
|
2124
|
-
{ name: "background-default", value: { from: "base" } },
|
|
2125
|
-
{
|
|
2126
|
-
name: "background-paper",
|
|
2127
|
-
value: { from: "base", emphasis: -0.025 }
|
|
2128
|
-
},
|
|
2129
|
-
// text
|
|
2130
|
-
{ name: "text-primary", value: { from: "base.foreground" } },
|
|
2131
|
-
{
|
|
2132
|
-
name: "text-secondary",
|
|
2133
|
-
value: { from: "base.foreground", emphasis: -0.2 }
|
|
2134
|
-
},
|
|
2135
|
-
{
|
|
2136
|
-
name: "text-disabled",
|
|
2137
|
-
value: { from: "base.foreground", emphasis: -0.4 }
|
|
2138
|
-
},
|
|
2139
|
-
// divider
|
|
2140
|
-
{ name: "divider", value: { from: "base", emphasis: 0.12 } },
|
|
2141
|
-
// action tokens
|
|
2142
|
-
{ name: "action-hover", value: { from: "base", emphasis: 0.04 } },
|
|
2143
|
-
{ name: "action-selected", value: { from: "base", emphasis: 0.08 } },
|
|
2144
|
-
{ name: "action-disabled", value: { from: "base", emphasis: 0.15 } },
|
|
2145
|
-
{
|
|
2146
|
-
name: "action-disabledBackground",
|
|
2147
|
-
value: { from: "base", emphasis: 0.06 }
|
|
2148
|
-
},
|
|
2149
|
-
{ name: "action-focus", value: { from: "base", emphasis: 0.06 } }
|
|
2150
|
-
],
|
|
2151
|
-
format: {
|
|
2152
|
-
as: "object",
|
|
2153
|
-
colors: "hex",
|
|
2154
|
-
separator: "-",
|
|
2155
|
-
roleNames: {
|
|
2156
|
-
accent: "primary",
|
|
2157
|
-
negative: "error",
|
|
2158
|
-
positive: "success"
|
|
2159
|
-
},
|
|
2160
|
-
variantNames: {
|
|
2161
|
-
DEFAULT: "main",
|
|
2162
|
-
weak: "light",
|
|
2163
|
-
strong: "dark",
|
|
2164
|
-
foreground: "contrastText"
|
|
2165
|
-
},
|
|
2166
|
-
excludeRoles: ["base"]
|
|
2167
|
-
}
|
|
2168
|
-
};
|
|
2169
|
-
|
|
2170
|
-
// src/presets/muted.ts
|
|
2171
|
-
var muted = {
|
|
2172
|
-
style: {
|
|
2173
|
-
light: { maxChroma: 0.08 },
|
|
2174
|
-
dark: { maxChroma: 0.07 },
|
|
2175
|
-
baseMaxChroma: 5e-3,
|
|
2176
|
-
foregroundMaxChroma: 5e-3
|
|
2177
|
-
}
|
|
2178
|
-
};
|
|
2179
|
-
|
|
2180
|
-
// src/presets/shadcn.ts
|
|
2181
|
-
var shadcn = {
|
|
2182
|
-
tokens: [
|
|
2183
|
-
// shadcn uses bare --foreground (not --background-foreground)
|
|
2184
|
-
{ name: "foreground", value: { from: "base.foreground" } },
|
|
2185
|
-
// card / popover — same as background
|
|
2186
|
-
{ name: "card", value: { from: "base" } },
|
|
2187
|
-
{ name: "card-foreground", value: { from: "base.foreground" } },
|
|
2188
|
-
{ name: "popover", value: { from: "base" } },
|
|
2189
|
-
{ name: "popover-foreground", value: { from: "base.foreground" } },
|
|
2190
|
-
// secondary — subtle contrast from background
|
|
2191
|
-
{ name: "secondary", value: { from: "base" } },
|
|
2192
|
-
{ name: "secondary-foreground", value: { from: "base.foreground" } },
|
|
2193
|
-
// muted — similar to secondary, but with dimmer foreground
|
|
2194
|
-
{ name: "muted", value: { from: "base" } },
|
|
2195
|
-
{
|
|
2196
|
-
name: "muted-foreground",
|
|
2197
|
-
value: {
|
|
2198
|
-
from: "base.foreground",
|
|
2199
|
-
emphasis: -0.25
|
|
2200
|
-
}
|
|
2201
|
-
},
|
|
2202
|
-
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
2203
|
-
{ name: "accent", value: { from: "base" } },
|
|
2204
|
-
{ name: "accent-foreground", value: { from: "base.foreground" } },
|
|
2205
|
-
// border / input
|
|
2206
|
-
{
|
|
2207
|
-
name: "border",
|
|
2208
|
-
value: { from: "base", emphasis: 0.8 }
|
|
2209
|
-
},
|
|
2210
|
-
{
|
|
2211
|
-
name: "input",
|
|
2212
|
-
value: {
|
|
2213
|
-
from: "base",
|
|
2214
|
-
emphasis: 0.8
|
|
2215
|
-
}
|
|
2216
|
-
},
|
|
2217
|
-
// ring — uses the brand/primary color
|
|
2218
|
-
{ name: "ring", value: { from: "accent" } },
|
|
2219
|
-
// chart tokens colors use brand/priamry color
|
|
2220
|
-
{ name: "chart-1", value: { from: "accent" } },
|
|
2221
|
-
{ name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
|
|
2222
|
-
{ name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
|
|
2223
|
-
{ name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
|
|
2224
|
-
{ name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
|
|
2225
|
-
],
|
|
2226
|
-
format: {
|
|
2227
|
-
as: "css",
|
|
2228
|
-
colors: "oklch",
|
|
2229
|
-
roleNames: {
|
|
2230
|
-
base: "background",
|
|
2231
|
-
accent: "primary",
|
|
2232
|
-
negative: "destructive",
|
|
2233
|
-
positive: "success"
|
|
2234
|
-
},
|
|
2235
|
-
variantNames: {
|
|
2236
|
-
foreground: "foreground"
|
|
2237
|
-
},
|
|
2238
|
-
excludeRoles: ["warning"],
|
|
2239
|
-
excludeVariants: ["strong", "weak"]
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
|
|
2243
|
-
// src/presets/tinted.ts
|
|
2244
|
-
var tinted = {
|
|
2245
|
-
style: {
|
|
2246
|
-
baseMaxChroma: 0.05,
|
|
2247
|
-
baseHueShift: 0,
|
|
2248
|
-
foregroundMaxChroma: 0.015
|
|
2249
|
-
}
|
|
2250
|
-
};
|
|
2251
|
-
|
|
2252
|
-
// src/presets/vibrant.ts
|
|
2253
|
-
var vibrant = {
|
|
2254
|
-
style: {
|
|
2255
|
-
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
2256
|
-
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
2257
|
-
hueShift: 5,
|
|
2258
|
-
baseHueShift: 180,
|
|
2259
|
-
baseMaxChroma: 0.08
|
|
2260
|
-
}
|
|
2261
|
-
};
|
|
2262
|
-
|
|
2263
2089
|
// src/index.ts
|
|
2264
2090
|
var HextimateError = class extends Error {
|
|
2265
2091
|
constructor(input, message) {
|
|
@@ -2289,7 +2115,6 @@ export {
|
|
|
2289
2115
|
daltonizeColor,
|
|
2290
2116
|
simulateColor,
|
|
2291
2117
|
HextimatePaletteBuilder,
|
|
2292
|
-
presets_exports,
|
|
2293
2118
|
HextimateError,
|
|
2294
2119
|
hextimate
|
|
2295
2120
|
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { h as HextimatePreset } from './HextimatePaletteBuilder-BY1EjhFs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Darker accents on light themes, lighter accents on dark themes.
|
|
5
|
+
* Higher chroma for neutrals.
|
|
6
|
+
*/
|
|
7
|
+
declare const bold: HextimatePreset;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Preset for Material UI (MUI) projects.
|
|
11
|
+
*
|
|
12
|
+
* Generates palette tokens matching MUI's theme structure:
|
|
13
|
+
* `primary`, `secondary`, `error`, `warning`, `info`, `success` —
|
|
14
|
+
* each with `main`, `light`, `dark`, and `contrastText` variants.
|
|
15
|
+
*
|
|
16
|
+
* Also generates `background` (`default`, `paper`), `text` (`primary`,
|
|
17
|
+
* `secondary`, `disabled`), `divider`, and `action` tokens.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to `object` format for use with `createTheme()`. Override with
|
|
20
|
+
* `.format({ as: 'css' })` for MUI's CSS variables mode.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { hextimate, presets } from 'hextimator';
|
|
24
|
+
* import { createTheme } from '@mui/material/styles';
|
|
25
|
+
*
|
|
26
|
+
* const palette = hextimate('#6366F1')
|
|
27
|
+
* .preset(presets.mui)
|
|
28
|
+
* .format();
|
|
29
|
+
*
|
|
30
|
+
* const theme = createTheme({ palette: palette.light });
|
|
31
|
+
*/
|
|
32
|
+
declare const mui: HextimatePreset;
|
|
33
|
+
|
|
34
|
+
/** Desaturated, restrained palette. Low chroma across the board. */
|
|
35
|
+
declare const muted: HextimatePreset;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Preset for shadcn/ui projects.
|
|
39
|
+
*
|
|
40
|
+
* Generates all CSS variables that shadcn/ui components expect:
|
|
41
|
+
* `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`,
|
|
42
|
+
* `--accent`, `--destructive`, `--card`, `--popover`, `--border`, `--input`, `--ring`,
|
|
43
|
+
* plus their `-foreground` counterparts.
|
|
44
|
+
*
|
|
45
|
+
* Defaults to `oklch` color format (modern shadcn). Override with
|
|
46
|
+
* `.format({ colors: 'hsl-raw' })` for older shadcn setups.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { hextimate, presets } from 'hextimator';
|
|
50
|
+
*
|
|
51
|
+
* const theme = hextimate('#6366F1')
|
|
52
|
+
* .preset(presets.shadcn)
|
|
53
|
+
* .format();
|
|
54
|
+
*
|
|
55
|
+
* // Use with React hook:
|
|
56
|
+
* const palette = useHextimator('#6366F1', {
|
|
57
|
+
* configure: (b) => b.preset(presets.shadcn),
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
declare const shadcn: HextimatePreset;
|
|
61
|
+
|
|
62
|
+
/** Neutrals pick up the accent hue for a cohesive, branded feel. */
|
|
63
|
+
declare const tinted: HextimatePreset;
|
|
64
|
+
|
|
65
|
+
/** High-saturation palette. Colors that pop. */
|
|
66
|
+
declare const vibrant: HextimatePreset;
|
|
67
|
+
|
|
68
|
+
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
69
|
+
declare const index_bold: typeof bold;
|
|
70
|
+
declare const index_mui: typeof mui;
|
|
71
|
+
declare const index_muted: typeof muted;
|
|
72
|
+
declare const index_shadcn: typeof shadcn;
|
|
73
|
+
declare const index_tinted: typeof tinted;
|
|
74
|
+
declare const index_vibrant: typeof vibrant;
|
|
75
|
+
declare namespace index {
|
|
76
|
+
export { index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { muted as a, bold as b, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap,
|
|
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-BY1EjhFs.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BY1EjhFs.js';
|
|
3
|
+
export { i as presets } from './index-C2l4fSiA.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
|
@@ -63,82 +64,6 @@ declare function convert<S extends ColorSpace>(color: Color, to: S): ColorInSpac
|
|
|
63
64
|
*/
|
|
64
65
|
declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* Darker accents on light themes, lighter accents on dark themes.
|
|
68
|
-
* Higher chroma for neutrals.
|
|
69
|
-
*/
|
|
70
|
-
declare const bold: HextimatePreset;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Preset for Material UI (MUI) projects.
|
|
74
|
-
*
|
|
75
|
-
* Generates palette tokens matching MUI's theme structure:
|
|
76
|
-
* `primary`, `secondary`, `error`, `warning`, `info`, `success` —
|
|
77
|
-
* each with `main`, `light`, `dark`, and `contrastText` variants.
|
|
78
|
-
*
|
|
79
|
-
* Also generates `background` (`default`, `paper`), `text` (`primary`,
|
|
80
|
-
* `secondary`, `disabled`), `divider`, and `action` tokens.
|
|
81
|
-
*
|
|
82
|
-
* Defaults to `object` format for use with `createTheme()`. Override with
|
|
83
|
-
* `.format({ as: 'css' })` for MUI's CSS variables mode.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* import { hextimate, presets } from 'hextimator';
|
|
87
|
-
* import { createTheme } from '@mui/material/styles';
|
|
88
|
-
*
|
|
89
|
-
* const palette = hextimate('#6366F1')
|
|
90
|
-
* .preset(presets.mui)
|
|
91
|
-
* .format();
|
|
92
|
-
*
|
|
93
|
-
* const theme = createTheme({ palette: palette.light });
|
|
94
|
-
*/
|
|
95
|
-
declare const mui: HextimatePreset;
|
|
96
|
-
|
|
97
|
-
/** Desaturated, restrained palette. Low chroma across the board. */
|
|
98
|
-
declare const muted: HextimatePreset;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Preset for shadcn/ui projects.
|
|
102
|
-
*
|
|
103
|
-
* Generates all CSS variables that shadcn/ui components expect:
|
|
104
|
-
* `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`,
|
|
105
|
-
* `--accent`, `--destructive`, `--card`, `--popover`, `--border`, `--input`, `--ring`,
|
|
106
|
-
* plus their `-foreground` counterparts.
|
|
107
|
-
*
|
|
108
|
-
* Defaults to `oklch` color format (modern shadcn). Override with
|
|
109
|
-
* `.format({ colors: 'hsl-raw' })` for older shadcn setups.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* import { hextimate, presets } from 'hextimator';
|
|
113
|
-
*
|
|
114
|
-
* const theme = hextimate('#6366F1')
|
|
115
|
-
* .preset(presets.shadcn)
|
|
116
|
-
* .format();
|
|
117
|
-
*
|
|
118
|
-
* // Use with React hook:
|
|
119
|
-
* const palette = useHextimator('#6366F1', {
|
|
120
|
-
* configure: (b) => b.preset(presets.shadcn),
|
|
121
|
-
* });
|
|
122
|
-
*/
|
|
123
|
-
declare const shadcn: HextimatePreset;
|
|
124
|
-
|
|
125
|
-
/** Neutrals pick up the accent hue for a cohesive, branded feel. */
|
|
126
|
-
declare const tinted: HextimatePreset;
|
|
127
|
-
|
|
128
|
-
/** High-saturation palette. Colors that pop. */
|
|
129
|
-
declare const vibrant: HextimatePreset;
|
|
130
|
-
|
|
131
|
-
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
132
|
-
declare const index_bold: typeof bold;
|
|
133
|
-
declare const index_mui: typeof mui;
|
|
134
|
-
declare const index_muted: typeof muted;
|
|
135
|
-
declare const index_shadcn: typeof shadcn;
|
|
136
|
-
declare const index_tinted: typeof tinted;
|
|
137
|
-
declare const index_vibrant: typeof vibrant;
|
|
138
|
-
declare namespace index {
|
|
139
|
-
export { index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
67
|
/** Thrown when `hextimate()` fails to parse or generate a palette from the given input. */
|
|
143
68
|
declare class HextimateError extends Error {
|
|
144
69
|
readonly input: ColorInput;
|
|
@@ -162,4 +87,4 @@ declare class HextimateError extends Error {
|
|
|
162
87
|
*/
|
|
163
88
|
declare function hextimate(color: ColorInput): HextimatePaletteBuilder;
|
|
164
89
|
|
|
165
|
-
export { CVDType, HextimateError, HextimatePaletteBuilder,
|
|
90
|
+
export { CVDType, HextimateError, HextimatePaletteBuilder, convert as convertColor, daltonizeColor, hextimate, parse as parseColor, simulateColor };
|
package/dist/index.js
CHANGED
|
@@ -5,9 +5,11 @@ import {
|
|
|
5
5
|
daltonizeColor,
|
|
6
6
|
hextimate,
|
|
7
7
|
parse,
|
|
8
|
-
presets_exports,
|
|
9
8
|
simulateColor
|
|
10
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-RAI6L6AN.js";
|
|
10
|
+
import {
|
|
11
|
+
presets_exports
|
|
12
|
+
} from "./chunk-JODPLAXA.js";
|
|
11
13
|
export {
|
|
12
14
|
HextimateError,
|
|
13
15
|
HextimatePaletteBuilder,
|
package/dist/presets.js
ADDED
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { j as HextimateStyleOptions,
|
|
1
|
+
import { j as HextimateStyleOptions, h as HextimatePreset, H as HextimatePaletteBuilder, i as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-BY1EjhFs.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
package/package.json
CHANGED
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hextimator",
|
|
3
|
-
"version": "0.5.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.5.1",
|
|
4
|
+
"description": "Runtime theming for multi-tenant apps: per-tenant branded themes from a single brand color, with WCAG contrast guarantees.",
|
|
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",
|
|
6
18
|
"color",
|
|
7
19
|
"palette",
|
|
8
20
|
"generator",
|
|
9
21
|
"creator",
|
|
10
22
|
"oklch",
|
|
11
|
-
"rgb",
|
|
12
|
-
"rgb2oklch",
|
|
13
23
|
"theme",
|
|
14
24
|
"design-tokens",
|
|
15
25
|
"dark-mode",
|
|
16
|
-
"wcag",
|
|
17
26
|
"accessibility",
|
|
18
27
|
"contrast",
|
|
19
28
|
"brand-color",
|
|
20
|
-
"
|
|
21
|
-
"tailwind-theme",
|
|
22
|
-
"runtime-theming",
|
|
23
|
-
"multi-tenant"
|
|
29
|
+
"tailwind-theme"
|
|
24
30
|
],
|
|
25
31
|
"homepage": "https://hextimator.com",
|
|
26
32
|
"bugs": {
|
|
@@ -51,6 +57,10 @@
|
|
|
51
57
|
"types": "./dist/react.d.ts",
|
|
52
58
|
"import": "./dist/react.js"
|
|
53
59
|
},
|
|
60
|
+
"./presets": {
|
|
61
|
+
"types": "./dist/presets.d.ts",
|
|
62
|
+
"import": "./dist/presets.js"
|
|
63
|
+
},
|
|
54
64
|
"./cli": "./dist/cli.js",
|
|
55
65
|
"./tailwind.css": "./tailwind.css",
|
|
56
66
|
"./fallback.css": "./fallback.css"
|