material-theme-builder 3.3.0 → 5.0.0

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/dist/react.js CHANGED
@@ -3988,8 +3988,8 @@ function buildShadcnAliases(ctx) {
3988
3988
  const lines = Object.entries(toShadcnAliasVars(ctx.prefix)).map(
3989
3989
  ([name, value]) => `--${name}: ${value};`
3990
3990
  );
3991
- return `:root,
3992
- .dark {
3991
+ return `:root:root,
3992
+ .dark.dark {
3993
3993
  ${lines.join("\n ")}
3994
3994
  }
3995
3995
  `;
@@ -4166,6 +4166,9 @@ function assertHexInputs(source, cores, customColors) {
4166
4166
  (color, i) => assertHexColor(`customColors[${i}].hex`, color.hex)
4167
4167
  );
4168
4168
  }
4169
+ function optionalHex(hex) {
4170
+ return hex?.trim() || void 0;
4171
+ }
4169
4172
  var STANDARD_TONES = [
4170
4173
  0,
4171
4174
  4,
@@ -4334,16 +4337,20 @@ function builder(hexSource, {
4334
4337
  customColors: hexCustomColors = DEFAULT_CUSTOM_COLORS,
4335
4338
  prefix = DEFAULT_PREFIX
4336
4339
  } = {}) {
4337
- assertHexInputs(
4338
- hexSource,
4339
- { primary, secondary, tertiary, error, neutral, neutralVariant },
4340
- hexCustomColors
4341
- );
4340
+ const cores = {
4341
+ primary: optionalHex(primary),
4342
+ secondary: optionalHex(secondary),
4343
+ tertiary: optionalHex(tertiary),
4344
+ error: optionalHex(error),
4345
+ neutral: optionalHex(neutral),
4346
+ neutralVariant: optionalHex(neutralVariant)
4347
+ };
4348
+ assertHexInputs(hexSource, cores, hexCustomColors);
4342
4349
  const sourceArgb = argbFromHex2(hexSource);
4343
4350
  const sourceHct = Hct2.fromInt(sourceArgb);
4344
- const effectiveSource = primary || hexSource;
4351
+ const effectiveSource = cores.primary || hexSource;
4345
4352
  const effectiveSourceArgb = argbFromHex2(effectiveSource);
4346
- const effectiveSourceForHarmonization = primary ? argbFromHex2(primary) : sourceArgb;
4353
+ const effectiveSourceForHarmonization = cores.primary ? argbFromHex2(cores.primary) : sourceArgb;
4347
4354
  const SchemeClass = schemesMap[scheme];
4348
4355
  const primaryHct = Hct2.fromInt(effectiveSourceArgb);
4349
4356
  const baseScheme = new SchemeClass(primaryHct, false, contrast);
@@ -4351,32 +4358,32 @@ function builder(hexSource, {
4351
4358
  // Core colors (hex may be undefined)
4352
4359
  {
4353
4360
  name: "primary",
4354
- hex: primary,
4361
+ hex: cores.primary,
4355
4362
  core: true,
4356
4363
  chromaSource: "primary"
4357
4364
  },
4358
4365
  {
4359
4366
  name: "secondary",
4360
- hex: secondary,
4367
+ hex: cores.secondary,
4361
4368
  core: true,
4362
4369
  chromaSource: "primary"
4363
4370
  },
4364
4371
  {
4365
4372
  name: "tertiary",
4366
- hex: tertiary,
4373
+ hex: cores.tertiary,
4367
4374
  core: true,
4368
4375
  chromaSource: "primary"
4369
4376
  },
4370
- { name: "error", hex: error, core: true, chromaSource: "primary" },
4377
+ { name: "error", hex: cores.error, core: true, chromaSource: "primary" },
4371
4378
  {
4372
4379
  name: "neutral",
4373
- hex: neutral,
4380
+ hex: cores.neutral,
4374
4381
  core: true,
4375
4382
  chromaSource: "neutral"
4376
4383
  },
4377
4384
  {
4378
4385
  name: "neutralVariant",
4379
- hex: neutralVariant,
4386
+ hex: cores.neutralVariant,
4380
4387
  core: true,
4381
4388
  chromaSource: "neutralVariant"
4382
4389
  },
@@ -4492,7 +4499,7 @@ function builder(hexSource, {
4492
4499
  }
4493
4500
 
4494
4501
  // src/ExportButton.tsx
4495
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
4502
+ import { jsx as jsx2 } from "react/jsx-runtime";
4496
4503
  function ExportButton({ config }) {
4497
4504
  const handleExport = () => {
4498
4505
  try {
@@ -4526,24 +4533,16 @@ function ExportButton({ config }) {
4526
4533
  onClick: handleExport,
4527
4534
  title: "Export Figma Tokens",
4528
4535
  "aria-label": "Export Figma Tokens",
4529
- className: "fixed z-50 bottom-6 right-6",
4530
- children: /* @__PURE__ */ jsxs(
4536
+ children: /* @__PURE__ */ jsx2(
4531
4537
  "svg",
4532
4538
  {
4533
4539
  xmlns: "http://www.w3.org/2000/svg",
4534
4540
  width: "24",
4535
4541
  height: "24",
4536
4542
  viewBox: "0 0 24 24",
4537
- fill: "none",
4538
- stroke: "currentColor",
4539
- strokeWidth: "2",
4540
- strokeLinecap: "round",
4541
- strokeLinejoin: "round",
4542
- children: [
4543
- /* @__PURE__ */ jsx2("path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }),
4544
- /* @__PURE__ */ jsx2("polyline", { points: "7 10 12 15 17 10" }),
4545
- /* @__PURE__ */ jsx2("line", { x1: "12", y1: "15", x2: "12", y2: "3" })
4546
- ]
4543
+ fill: "currentColor",
4544
+ "aria-hidden": true,
4545
+ children: /* @__PURE__ */ jsx2("path", { d: "M8 24a4 4 0 0 1-4-4 4 4 0 0 1 4-4h4v4a4 4 0 0 1-4 4Zm0-6.5A2.5 2.5 0 0 0 5.5 20 2.5 2.5 0 0 0 8 22.5 2.5 2.5 0 0 0 10.5 20v-2.5H8ZM8 16a4 4 0 0 1-4-4 4 4 0 0 1 4-4h4v8H8Zm0-6.5A2.5 2.5 0 0 0 5.5 12 2.5 2.5 0 0 0 8 14.5h2.5v-5H8ZM8 8a4 4 0 0 1-4-4 4 4 0 0 1 4-4h4v8H8Zm0-6.5A2.5 2.5 0 0 0 5.5 4 2.5 2.5 0 0 0 8 6.5h2.5v-5H8Zm8 6.5h-4V0h4a4 4 0 0 1 4 4 4 4 0 0 1-4 4Zm-2.5-1.5H16A2.5 2.5 0 0 0 18.5 4 2.5 2.5 0 0 0 16 1.5h-2.5v5ZM16 16a4 4 0 0 1-4-4 4 4 0 0 1 4-4 4 4 0 0 1 4 4 4 4 0 0 1-4 4Zm0-6.5a2.5 2.5 0 0 0-2.5 2.5 2.5 2.5 0 0 0 2.5 2.5 2.5 2.5 0 0 0 2.5-2.5A2.5 2.5 0 0 0 16 9.5Z" })
4547
4546
  }
4548
4547
  )
4549
4548
  }
@@ -4574,7 +4573,7 @@ var createRequiredContext = () => {
4574
4573
  };
4575
4574
 
4576
4575
  // src/Mtb.context.tsx
4577
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
4576
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
4578
4577
  var [useMtb, Provider, MtbContext] = createRequiredContext();
4579
4578
  var MtbProvider = ({
4580
4579
  styleId: styleId2,
@@ -4640,7 +4639,7 @@ var MtbProvider = ({
4640
4639
  figmaVariables
4641
4640
  ]
4642
4641
  );
4643
- return /* @__PURE__ */ jsxs2(Provider, { value, children: [
4642
+ return /* @__PURE__ */ jsxs(Provider, { value, children: [
4644
4643
  /* @__PURE__ */ jsx3("style", { id: styleId2, dangerouslySetInnerHTML: { __html: css } }),
4645
4644
  children
4646
4645
  ] });
package/dist/shadcn.css CHANGED
@@ -2,13 +2,13 @@
2
2
  * Generated by `scripts/generate.mjs` -- do not edit.
3
3
  *
4
4
  * Points shadcn's variables at the M3 custom properties `<Mtb>` emits, so
5
- * shadcn components follow the theme above them in the tree. Import it after
6
- * shadcn's own `:root` and `.dark` blocks, which it has to override -- or
7
- * skip the ordering question entirely and install `registry-item.json` with
8
- * `shadcn add`, which writes the same mapping into those blocks in place.
5
+ * shadcn components follow the theme above them in the tree. Import it with
6
+ * your other imports: the selectors are doubled, so it outranks shadcn's own
7
+ * `:root` and `.dark` wherever it lands. Or install `registry-item.json`
8
+ * with `shadcn add`, which writes the same mapping into those blocks.
9
9
  */
10
- :root,
11
- .dark {
10
+ :root:root,
11
+ .dark.dark {
12
12
  --background: var(--md-sys-color-surface);
13
13
  --foreground: var(--md-sys-color-on-surface);
14
14
  --card: var(--md-sys-color-surface-container-low);
@@ -38,8 +38,8 @@ declare function mtbColors({ customColors, prefix, }?: {
38
38
  prefix?: string;
39
39
  }): Record<string, string>;
40
40
  /**
41
- * Tailwind v4 plugin — the `@theme inline` block of
42
- * `material-theme-builder/tailwind.css`, minus the copy-paste.
41
+ * Tailwind v4 plugin — the whole M3 vocabulary as theme colors, from one line
42
+ * of CSS.
43
43
  *
44
44
  * ```css
45
45
  * @import "tailwindcss";
@@ -49,22 +49,22 @@ declare function mtbColors({ customColors, prefix, }?: {
49
49
  * ```
50
50
  *
51
51
  * Colors declared through a plugin's `theme` are inlined by Tailwind — the
52
- * utility resolves straight to `var(--md-sys-color-primary)` and no
53
- * `--color-*` indirection is emitted — which is what the stylesheet's
54
- * `@theme inline` was there to get. That indirection is not cosmetic: a
52
+ * utility resolves straight to `var(--md-sys-color-primary)`, with no
53
+ * `--color-*` in between. That indirection is not cosmetic: a
55
54
  * `--color-primary: var(--md-sys-color-primary)` declared on `:root` resolves
56
55
  * once, against `:root`, so a nested `<Mtb>` re-declaring the M3 properties
57
56
  * would not reach the utilities.
58
57
  *
59
- * Unlike the stylesheet, custom colors need no hand-written block: name them
60
- * in the options and their four scheme roles plus eleven shades come with them.
58
+ * Custom colors need no hand-written block either: name them in the options
59
+ * and their four scheme roles plus eleven shades come with them — which is
60
+ * what no shipped stylesheet, knowing nothing of your config, could do. That
61
+ * is why this replaced the `tailwind.css` the package used to ship.
61
62
  *
62
- * One thing the stylesheet does that this cannot: theme values a plugin
63
- * contributes are defaults, so an `@theme` block in the consumer's own CSS
64
- * wins over them whatever the order — where a later `@import` of the
65
- * stylesheet would have won. Only colliding names are affected, and against
66
- * shadcn there are exactly three (`background`, `primary`, `secondary`), which
67
- * a three-line `@theme inline` of one's own hands back. See the README.
63
+ * The one thing to know: theme values a plugin contributes are defaults, so an
64
+ * `@theme` block in the consumer's own CSS wins over them whatever the order.
65
+ * Only colliding names are affected, and against shadcn there are exactly
66
+ * three — `background`, `primary`, `secondary` — which `shadcn.css` points
67
+ * back at M3 anyway. See the README.
68
68
  *
69
69
  * @see https://tailwindcss.com/docs/functions-and-directives#plugin-directive
70
70
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "material-theme-builder",
3
- "version": "3.3.0",
3
+ "version": "5.0.0",
4
4
  "description": "m3 color-system for JS/TS ecosystem",
5
5
  "keywords": [
6
6
  "react",
@@ -21,7 +21,6 @@
21
21
  "import": "./dist/tailwind-plugin.js",
22
22
  "default": "./dist/tailwind-plugin.js"
23
23
  },
24
- "./tailwind.css": "./dist/tailwind.css",
25
24
  "./shadcn.css": "./dist/shadcn.css",
26
25
  "./registry-item.json": "./dist/registry-item.json"
27
26
  },
@@ -56,6 +55,7 @@
56
55
  "@fontsource-variable/inter": "^5.3.0",
57
56
  "@storybook/addon-docs": "^10.1.11",
58
57
  "@storybook/addon-themes": "^10.1.11",
58
+ "@storybook/icons": "^2.1.0",
59
59
  "@storybook/react-vite": "^10.1.11",
60
60
  "@tailwindcss/postcss": "^4.1.18",
61
61
  "@tanstack/react-table": "^9.1.2",
@@ -141,6 +141,7 @@
141
141
  "build-storybook": "pnpm run build && storybook build",
142
142
  "build-figma": "vite build --config figma-plugin/vite.config.ts && tsup --config figma-plugin/tsup.config.ts",
143
143
  "chromatic": "chromatic --project-token $CHROMATIC_PROJECT_TOKEN",
144
- "changeset": "pnpm exec changeset"
144
+ "changeset": "pnpm exec changeset",
145
+ "dev": "pnpm run storybook"
145
146
  }
146
147
  }
package/dist/tailwind.css DELETED
@@ -1,145 +0,0 @@
1
- /*
2
- * Generated by `scripts/generate.mjs` -- do not edit.
3
- *
4
- * Custom colors are not in here: they depend on your config, so they come from
5
- * the plugin instead.
6
- *
7
- * @plugin "material-theme-builder/tailwind" {
8
- * custom-colors: myCustomColor1, myCustomColor2;
9
- * }
10
- */
11
- @theme inline {
12
- --color-background: var(--md-sys-color-background);
13
- --color-error: var(--md-sys-color-error);
14
- --color-error-container: var(--md-sys-color-error-container);
15
- --color-inverse-on-surface: var(--md-sys-color-inverse-on-surface);
16
- --color-inverse-primary: var(--md-sys-color-inverse-primary);
17
- --color-inverse-surface: var(--md-sys-color-inverse-surface);
18
- --color-on-background: var(--md-sys-color-on-background);
19
- --color-on-error: var(--md-sys-color-on-error);
20
- --color-on-error-container: var(--md-sys-color-on-error-container);
21
- --color-on-primary: var(--md-sys-color-on-primary);
22
- --color-on-primary-container: var(--md-sys-color-on-primary-container);
23
- --color-on-primary-fixed: var(--md-sys-color-on-primary-fixed);
24
- --color-on-primary-fixed-variant: var(
25
- --md-sys-color-on-primary-fixed-variant
26
- );
27
- --color-on-secondary: var(--md-sys-color-on-secondary);
28
- --color-on-secondary-container: var(--md-sys-color-on-secondary-container);
29
- --color-on-secondary-fixed: var(--md-sys-color-on-secondary-fixed);
30
- --color-on-secondary-fixed-variant: var(
31
- --md-sys-color-on-secondary-fixed-variant
32
- );
33
- --color-on-surface: var(--md-sys-color-on-surface);
34
- --color-on-surface-variant: var(--md-sys-color-on-surface-variant);
35
- --color-on-tertiary: var(--md-sys-color-on-tertiary);
36
- --color-on-tertiary-container: var(--md-sys-color-on-tertiary-container);
37
- --color-on-tertiary-fixed: var(--md-sys-color-on-tertiary-fixed);
38
- --color-on-tertiary-fixed-variant: var(
39
- --md-sys-color-on-tertiary-fixed-variant
40
- );
41
- --color-outline: var(--md-sys-color-outline);
42
- --color-outline-variant: var(--md-sys-color-outline-variant);
43
- --color-primary: var(--md-sys-color-primary);
44
- --color-primary-container: var(--md-sys-color-primary-container);
45
- --color-primary-fixed: var(--md-sys-color-primary-fixed);
46
- --color-primary-fixed-dim: var(--md-sys-color-primary-fixed-dim);
47
- --color-scrim: var(--md-sys-color-scrim);
48
- --color-secondary: var(--md-sys-color-secondary);
49
- --color-secondary-container: var(--md-sys-color-secondary-container);
50
- --color-secondary-fixed: var(--md-sys-color-secondary-fixed);
51
- --color-secondary-fixed-dim: var(--md-sys-color-secondary-fixed-dim);
52
- --color-shadow: var(--md-sys-color-shadow);
53
- --color-surface: var(--md-sys-color-surface);
54
- --color-surface-bright: var(--md-sys-color-surface-bright);
55
- --color-surface-container: var(--md-sys-color-surface-container);
56
- --color-surface-container-high: var(--md-sys-color-surface-container-high);
57
- --color-surface-container-highest: var(
58
- --md-sys-color-surface-container-highest
59
- );
60
- --color-surface-container-low: var(--md-sys-color-surface-container-low);
61
- --color-surface-container-lowest: var(
62
- --md-sys-color-surface-container-lowest
63
- );
64
- --color-surface-dim: var(--md-sys-color-surface-dim);
65
- --color-surface-tint: var(--md-sys-color-surface-tint);
66
- --color-surface-variant: var(--md-sys-color-surface-variant);
67
- --color-tertiary: var(--md-sys-color-tertiary);
68
- --color-tertiary-container: var(--md-sys-color-tertiary-container);
69
- --color-tertiary-fixed: var(--md-sys-color-tertiary-fixed);
70
- --color-tertiary-fixed-dim: var(--md-sys-color-tertiary-fixed-dim);
71
-
72
- /* Shades */
73
-
74
- --color-primary-50: var(--md-ref-palette-primary-95);
75
- --color-primary-100: var(--md-ref-palette-primary-90);
76
- --color-primary-200: var(--md-ref-palette-primary-80);
77
- --color-primary-300: var(--md-ref-palette-primary-70);
78
- --color-primary-400: var(--md-ref-palette-primary-60);
79
- --color-primary-500: var(--md-ref-palette-primary-50);
80
- --color-primary-600: var(--md-ref-palette-primary-40);
81
- --color-primary-700: var(--md-ref-palette-primary-30);
82
- --color-primary-800: var(--md-ref-palette-primary-20);
83
- --color-primary-900: var(--md-ref-palette-primary-10);
84
- --color-primary-950: var(--md-ref-palette-primary-5);
85
-
86
- --color-secondary-50: var(--md-ref-palette-secondary-95);
87
- --color-secondary-100: var(--md-ref-palette-secondary-90);
88
- --color-secondary-200: var(--md-ref-palette-secondary-80);
89
- --color-secondary-300: var(--md-ref-palette-secondary-70);
90
- --color-secondary-400: var(--md-ref-palette-secondary-60);
91
- --color-secondary-500: var(--md-ref-palette-secondary-50);
92
- --color-secondary-600: var(--md-ref-palette-secondary-40);
93
- --color-secondary-700: var(--md-ref-palette-secondary-30);
94
- --color-secondary-800: var(--md-ref-palette-secondary-20);
95
- --color-secondary-900: var(--md-ref-palette-secondary-10);
96
- --color-secondary-950: var(--md-ref-palette-secondary-5);
97
-
98
- --color-tertiary-50: var(--md-ref-palette-tertiary-95);
99
- --color-tertiary-100: var(--md-ref-palette-tertiary-90);
100
- --color-tertiary-200: var(--md-ref-palette-tertiary-80);
101
- --color-tertiary-300: var(--md-ref-palette-tertiary-70);
102
- --color-tertiary-400: var(--md-ref-palette-tertiary-60);
103
- --color-tertiary-500: var(--md-ref-palette-tertiary-50);
104
- --color-tertiary-600: var(--md-ref-palette-tertiary-40);
105
- --color-tertiary-700: var(--md-ref-palette-tertiary-30);
106
- --color-tertiary-800: var(--md-ref-palette-tertiary-20);
107
- --color-tertiary-900: var(--md-ref-palette-tertiary-10);
108
- --color-tertiary-950: var(--md-ref-palette-tertiary-5);
109
-
110
- --color-error-50: var(--md-ref-palette-error-95);
111
- --color-error-100: var(--md-ref-palette-error-90);
112
- --color-error-200: var(--md-ref-palette-error-80);
113
- --color-error-300: var(--md-ref-palette-error-70);
114
- --color-error-400: var(--md-ref-palette-error-60);
115
- --color-error-500: var(--md-ref-palette-error-50);
116
- --color-error-600: var(--md-ref-palette-error-40);
117
- --color-error-700: var(--md-ref-palette-error-30);
118
- --color-error-800: var(--md-ref-palette-error-20);
119
- --color-error-900: var(--md-ref-palette-error-10);
120
- --color-error-950: var(--md-ref-palette-error-5);
121
-
122
- --color-neutral-50: var(--md-ref-palette-neutral-95);
123
- --color-neutral-100: var(--md-ref-palette-neutral-90);
124
- --color-neutral-200: var(--md-ref-palette-neutral-80);
125
- --color-neutral-300: var(--md-ref-palette-neutral-70);
126
- --color-neutral-400: var(--md-ref-palette-neutral-60);
127
- --color-neutral-500: var(--md-ref-palette-neutral-50);
128
- --color-neutral-600: var(--md-ref-palette-neutral-40);
129
- --color-neutral-700: var(--md-ref-palette-neutral-30);
130
- --color-neutral-800: var(--md-ref-palette-neutral-20);
131
- --color-neutral-900: var(--md-ref-palette-neutral-10);
132
- --color-neutral-950: var(--md-ref-palette-neutral-5);
133
-
134
- --color-neutral-variant-50: var(--md-ref-palette-neutral-variant-95);
135
- --color-neutral-variant-100: var(--md-ref-palette-neutral-variant-90);
136
- --color-neutral-variant-200: var(--md-ref-palette-neutral-variant-80);
137
- --color-neutral-variant-300: var(--md-ref-palette-neutral-variant-70);
138
- --color-neutral-variant-400: var(--md-ref-palette-neutral-variant-60);
139
- --color-neutral-variant-500: var(--md-ref-palette-neutral-variant-50);
140
- --color-neutral-variant-600: var(--md-ref-palette-neutral-variant-40);
141
- --color-neutral-variant-700: var(--md-ref-palette-neutral-variant-30);
142
- --color-neutral-variant-800: var(--md-ref-palette-neutral-variant-20);
143
- --color-neutral-variant-900: var(--md-ref-palette-neutral-variant-10);
144
- --color-neutral-variant-950: var(--md-ref-palette-neutral-variant-5);
145
- }