@uniweb/theming 0.1.2 → 0.1.4
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/package.json +2 -2
- package/src/css-generator.js +24 -2
- package/src/index.js +1 -0
- package/src/section-overrides.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uniweb/theming",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Theming utilities for the Uniweb platform — shade generation, CSS generation, theme processing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"node": ">=20.19"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"vitest": "^
|
|
30
|
+
"vitest": "^4.1.7"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"test": "vitest run"
|
package/src/css-generator.js
CHANGED
|
@@ -396,13 +396,29 @@ function generateFontCSS(fonts = {}) {
|
|
|
396
396
|
}
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
+
// Theme token names reserved by the theming engine — foundation vars must not use these
|
|
400
|
+
const RESERVED_VAR_NAMES = new Set([
|
|
401
|
+
// Semantic color tokens
|
|
402
|
+
'section', 'card', 'muted', 'body', 'heading', 'subtle',
|
|
403
|
+
'border', 'ring', 'link', 'link-hover', 'accent',
|
|
404
|
+
// Action tokens
|
|
405
|
+
'primary', 'primary-foreground', 'primary-hover', 'primary-border',
|
|
406
|
+
'secondary', 'secondary-foreground', 'secondary-hover', 'secondary-border',
|
|
407
|
+
// Status tokens
|
|
408
|
+
'success', 'success-subtle', 'warning', 'warning-subtle',
|
|
409
|
+
'error', 'error-subtle', 'info', 'info-subtle',
|
|
410
|
+
])
|
|
411
|
+
|
|
412
|
+
// Palette shade pattern: primary-50, neutral-950, accent-300, etc.
|
|
413
|
+
const PALETTE_SHADE_RE = /^(primary|secondary|accent|neutral)-\d+$/
|
|
414
|
+
|
|
399
415
|
/**
|
|
400
416
|
* Generate foundation-specific CSS variables
|
|
401
417
|
*
|
|
402
418
|
* @param {Object} vars - Foundation variables from vars.js
|
|
403
419
|
* @returns {string} CSS variable declarations
|
|
404
420
|
*/
|
|
405
|
-
function generateFoundationVars(vars = {}) {
|
|
421
|
+
export function generateFoundationVars(vars = {}) {
|
|
406
422
|
if (!vars || Object.keys(vars).length === 0) {
|
|
407
423
|
return ''
|
|
408
424
|
}
|
|
@@ -410,9 +426,15 @@ function generateFoundationVars(vars = {}) {
|
|
|
410
426
|
const declarations = []
|
|
411
427
|
|
|
412
428
|
for (const [name, config] of Object.entries(vars)) {
|
|
429
|
+
if (RESERVED_VAR_NAMES.has(name) || PALETTE_SHADE_RE.test(name)) {
|
|
430
|
+
console.warn(
|
|
431
|
+
`Warning: Foundation var '${name}' collides with a theme token. ` +
|
|
432
|
+
`Rename it to avoid unexpected behavior (e.g., '${name}-value' or '${name}-size').`
|
|
433
|
+
)
|
|
434
|
+
}
|
|
413
435
|
const value = typeof config === 'object' ? config.default : config
|
|
414
436
|
if (value !== undefined) {
|
|
415
|
-
declarations.push(`
|
|
437
|
+
declarations.push(` --${name}: ${value};`)
|
|
416
438
|
}
|
|
417
439
|
}
|
|
418
440
|
|
package/src/index.js
CHANGED
package/src/section-overrides.js
CHANGED
|
@@ -86,7 +86,7 @@ function buildFoundationVars(styles) {
|
|
|
86
86
|
const vars = []
|
|
87
87
|
for (const [name, value] of Object.entries(styles)) {
|
|
88
88
|
if (value === '' || value == null || typeof value === 'object') continue
|
|
89
|
-
vars.push(`
|
|
89
|
+
vars.push(` --${name}: ${value};`)
|
|
90
90
|
}
|
|
91
91
|
return vars
|
|
92
92
|
}
|