@umoa/saascfm-css 0.1.2 → 0.2.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/README.md +2 -0
- package/dist/index.cjs +4 -5
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -5
- package/package.json +1 -1
- package/templates/js/saascfm-css/RULES.md +2 -0
- package/templates/ts/saascfm-css/RULES.md +2 -0
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ TypeScript only: add `"types": ["@umoa/saascfm-css/client"]` to `tsconfig.json`.
|
|
|
36
36
|
| `spacing` `layout` `typography` `cursor` `border` | `true` | turn a module off with `false` |
|
|
37
37
|
| `colorsModule` | none | your `PRIMITIVES` and `TOKENS` |
|
|
38
38
|
| `primitiveClasses` | `true` | `false` removes the `blue-500` / `bg-blue-500` classes |
|
|
39
|
+
| `primitiveVars` | `false` | `true` also writes every primitive as a CSS variable on `:root` (`--brand-500`), so `var(--brand-500)` works in your own CSS |
|
|
39
40
|
| `important` | `false` | `true` adds `!important` to every generated declaration |
|
|
40
41
|
| `exclude` | `[".colors.", ".tokens.", "primitives."]` | file paths containing these are not scanned, so your color definitions do not generate every class |
|
|
41
42
|
|
|
@@ -88,6 +89,7 @@ export const TOKENS = { 'text-brand': 'brand-500', 'bg-card': 'white' }
|
|
|
88
89
|
- `PRIMITIVES`: name → color. Each generates `name` (color), `bg-name`, `border-name`. `rgba`/`hsla` values generate the color class only.
|
|
89
90
|
- `TOKENS`: name → primitive name, or any CSS color. Each becomes `--name` on `:root`.
|
|
90
91
|
- Token names are yours. The first word decides the class: `text-*` → `color`, `bg-*` → `background-color`, `border-*` → `border-color`. Any other prefix (`nav-*`, `tabb-*`, `shadow-*`) is a CSS var only.
|
|
92
|
+
- Primitives are classes only by default. Set `primitiveVars: true` to also get a variable for each one (`--brand-500`). You do not need to spread `PRIMITIVES` into `TOKENS` for this. A token with the same name overrides the primitive's variable.
|
|
91
93
|
- Unknown primitive names print a warning and are skipped.
|
|
92
94
|
- `hl`, `hl-muted`, `vl` read `--border-default` / `--border-muted`, falling back to `currentColor`.
|
|
93
95
|
|
package/dist/index.cjs
CHANGED
|
@@ -369,11 +369,10 @@ function cssModule(options = {}) {
|
|
|
369
369
|
const primitives = colorsModule["PRIMITIVES"];
|
|
370
370
|
const useColor = !!(tokens || primitives);
|
|
371
371
|
if (useColor) {
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
}
|
|
372
|
+
const resolved = tokens ? resolveTokens(tokens, primitives ?? {}) : {};
|
|
373
|
+
const rootVars = { ...options.primitiveVars && primitives ? primitives : {}, ...resolved };
|
|
374
|
+
if (Object.keys(rootVars).length) COLOR_ROOT_VARS = generateRootVars(rootVars);
|
|
375
|
+
COLOR_RULES = buildColorUtilityRules(resolved);
|
|
377
376
|
if (primitives && options.primitiveClasses !== false) {
|
|
378
377
|
PRIMITIVE_COLOR_RULES = buildPrimitiveRules(primitives);
|
|
379
378
|
}
|
package/dist/index.d.cts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -335,11 +335,10 @@ function cssModule(options = {}) {
|
|
|
335
335
|
const primitives = colorsModule["PRIMITIVES"];
|
|
336
336
|
const useColor = !!(tokens || primitives);
|
|
337
337
|
if (useColor) {
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
}
|
|
338
|
+
const resolved = tokens ? resolveTokens(tokens, primitives ?? {}) : {};
|
|
339
|
+
const rootVars = { ...options.primitiveVars && primitives ? primitives : {}, ...resolved };
|
|
340
|
+
if (Object.keys(rootVars).length) COLOR_ROOT_VARS = generateRootVars(rootVars);
|
|
341
|
+
COLOR_RULES = buildColorUtilityRules(resolved);
|
|
343
342
|
if (primitives && options.primitiveClasses !== false) {
|
|
344
343
|
PRIMITIVE_COLOR_RULES = buildPrimitiveRules(primitives);
|
|
345
344
|
}
|
package/package.json
CHANGED
|
@@ -72,6 +72,8 @@ Each token becomes a CSS variable on `:root`. The first word of the name decides
|
|
|
72
72
|
</style>
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
Primitives are classes only. To also get a CSS variable for every primitive (`var(--brand-500)`), set `primitiveVars: true` in the plugin options. No change to the token files is needed.
|
|
76
|
+
|
|
75
77
|
A token value can be a primitive (`P['neutral-900']`), a primitive name as a string (`'neutral-900'`), or any CSS color or value (`'#fff'`, `'rgba(0,0,0,.4)'`, `'56px'`). A string that looks like a primitive name but doesn't exist prints a warning and is skipped.
|
|
76
78
|
|
|
77
79
|
### When to use which
|
|
@@ -72,6 +72,8 @@ Each token becomes a CSS variable on `:root`. The first word of the name decides
|
|
|
72
72
|
</style>
|
|
73
73
|
```
|
|
74
74
|
|
|
75
|
+
Primitives are classes only. To also get a CSS variable for every primitive (`var(--brand-500)`), set `primitiveVars: true` in the plugin options. No change to the token files is needed.
|
|
76
|
+
|
|
75
77
|
A token value can be a primitive (`P['neutral-900']`), a primitive name as a string (`'neutral-900'`), or any CSS color or value (`'#fff'`, `'rgba(0,0,0,.4)'`, `'56px'`). A string that looks like a primitive name but doesn't exist prints a warning and is skipped.
|
|
76
78
|
|
|
77
79
|
### When to use which
|