@uniweb/theming 0.1.2 → 0.1.3

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uniweb/theming",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Theming utilities for the Uniweb platform — shade generation, CSS generation, theme processing",
5
5
  "type": "module",
6
6
  "exports": {
@@ -396,6 +396,22 @@ 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
  *
@@ -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(` --foundation-${name}: ${value};`)
437
+ declarations.push(` --${name}: ${value};`)
416
438
  }
417
439
  }
418
440
 
@@ -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(` --foundation-${name}: ${value};`)
89
+ vars.push(` --${name}: ${value};`)
90
90
  }
91
91
  return vars
92
92
  }