@marianmeres/design-tokens 1.5.0 → 1.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/AGENTS.md CHANGED
@@ -55,7 +55,7 @@ Entry points:
55
55
  | --------------------------------------------- | --------------------------------------------------------------------------------------------------- |
56
56
  | `generateCssTokens(schema, prefix, options?)` | Generate token key-value pairs. Third arg: `GenerateOptions` object or `"light"`/`"dark"` shorthand |
57
57
  | `toCssString(tokens, selector?)` | Convert tokens to a CSS declaration block (groups by base color name) |
58
- | `generateThemeCss(schema, prefix, options?)` | Generate complete CSS for light + optional dark mode; supports `cssLayer` wrapping |
58
+ | `generateThemeCss(schema, prefix, options?)` | Generate complete CSS for light + optional dark mode; supports `cssLayer` wrapping and `prettierIgnore` pragma |
59
59
  | `hexToRgb(hex)` | Parse hex to `[r, g, b]` tuple |
60
60
  | `hexToRgbTriplet(hex)` | Convert hex to `"r, g, b"` string |
61
61
 
@@ -83,7 +83,7 @@ Entry points:
83
83
  | `SingleColor` | `string \| ColorValue` |
84
84
  | `GeneratedTokens` | `Record<string, string>` |
85
85
  | `GenerateOptions` | `{ mode?, deriveStates?, surfaceForegroundContrast? }` |
86
- | `GenerateThemeOptions` | `Omit<GenerateOptions, "mode"> & { cssLayer? }` |
86
+ | `GenerateThemeOptions` | `Omit<GenerateOptions, "mode"> & { cssLayer?, prettierIgnore? }` |
87
87
  | `RolePairedKey` | Required: `"background" \| "muted" \| "surface"` |
88
88
  | `RolePairedOptionalKey` | Optional: `"surface-1"` (all bundled themes ship it) |
89
89
 
package/API.md CHANGED
@@ -71,6 +71,7 @@ Generate complete CSS for a theme with light mode and optional dark mode.
71
71
  - `prefix` (`string`) — CSS variable prefix (trailing dash optional)
72
72
  - `options` (`GenerateThemeOptions`, optional) — Accepts all `GenerateOptions` (except `mode`, which is set per section) plus:
73
73
  - `cssLayer` (`string`, optional) — Wrap the output in `@layer {name} { ... }`. Useful for CSS cascade control.
74
+ - `prettierIgnore` (`boolean`, optional) — Prepend a `/* prettier-ignore */` comment so Prettier preserves the generated whitespace alignment when the output is written to a file that later gets formatted. Default: `false`.
74
75
 
75
76
  **Returns:** `string` — Complete CSS with `:root` for light and `:root.dark` for dark mode, optionally wrapped in `@layer`.
76
77
 
@@ -290,10 +291,11 @@ Options passed to `generateCssTokens`. See the function docs above for field mea
290
291
  ```typescript
291
292
  type GenerateThemeOptions = Omit<GenerateOptions, "mode"> & {
292
293
  cssLayer?: string;
294
+ prettierIgnore?: boolean;
293
295
  };
294
296
  ```
295
297
 
296
- Options passed to `generateThemeCss`. Omits `mode` (set automatically per section) and adds `cssLayer` for optional `@layer` wrapping.
298
+ Options passed to `generateThemeCss`. Omits `mode` (set automatically per section) and adds `cssLayer` for optional `@layer` wrapping plus `prettierIgnore` to prepend a `/* prettier-ignore */` pragma for build pipelines that pass the output through Prettier.
297
299
 
298
300
  ---
299
301
 
@@ -32,6 +32,15 @@ export type GenerateThemeOptions = Omit<GenerateOptions, "mode"> & {
32
32
  * Wrap the output in `@layer {name} { ... }`. Pass a layer name to enable.
33
33
  */
34
34
  cssLayer?: string;
35
+ /**
36
+ * Prepend a `/* prettier-ignore *\/` comment so Prettier preserves the
37
+ * generated whitespace alignment when the output is written to a file that
38
+ * later gets formatted. Has no runtime effect; only meaningful for build
39
+ * pipelines that pass the result through Prettier.
40
+ *
41
+ * @default false
42
+ */
43
+ prettierIgnore?: boolean;
35
44
  };
36
45
  /**
37
46
  * Generate CSS token key-value pairs from a {@link TokenSchema}.
package/dist/generate.js CHANGED
@@ -173,7 +173,7 @@ export function toCssString(tokens, selector = ":root") {
173
173
  * @param options - Generation + output options
174
174
  */
175
175
  export function generateThemeCss(schema, prefix, options = {}) {
176
- const { cssLayer, ...genOptions } = options;
176
+ const { cssLayer, prettierIgnore, ...genOptions } = options;
177
177
  let css = toCssString(generateCssTokens(schema.light, prefix, { ...genOptions, mode: "light" }));
178
178
  if (schema.dark) {
179
179
  css += "\n" +
@@ -186,5 +186,8 @@ export function generateThemeCss(schema, prefix, options = {}) {
186
186
  const indented = css.split("\n").map((l) => (l ? "\t" + l : l)).join("\n");
187
187
  css = `@layer ${cssLayer} {\n${indented}}\n`;
188
188
  }
189
+ if (prettierIgnore) {
190
+ css = "/* prettier-ignore */\n" + css;
191
+ }
189
192
  return css;
190
193
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/design-tokens",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",