@calibrate-ds/generator-react 0.1.88 → 0.1.90
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.
|
@@ -102,8 +102,21 @@ export function generateComponentCss(component, lookup) {
|
|
|
102
102
|
}
|
|
103
103
|
}
|
|
104
104
|
if (component.styleMetadata) {
|
|
105
|
+
// B-2: multiple style slots can map to the same CSS property (e.g. `text`,
|
|
106
|
+
// `fill`, `iconColor` all → `color`). Emitting each produced a DUPLICATE
|
|
107
|
+
// declaration (invalid/confusing). Track emitted properties; first slot wins.
|
|
108
|
+
const emittedProps = new Set();
|
|
105
109
|
for (const [key, val] of Object.entries(component.styleMetadata)) {
|
|
106
110
|
const cssProperty = CSS_PROPERTY_MAP[key] || normalizeCssVarName(key);
|
|
111
|
+
if (emittedProps.has(cssProperty))
|
|
112
|
+
continue;
|
|
113
|
+
emittedProps.add(cssProperty);
|
|
114
|
+
// B-2: `border` is a shorthand and needs `width style` before the color —
|
|
115
|
+
// a bare `border: <color>` (or `border: var(--x, #hex)`) is invalid and the
|
|
116
|
+
// whole declaration is dropped, leaving no border. The styleMetadata border
|
|
117
|
+
// slot only carries the stroke color, so wrap every border value in
|
|
118
|
+
// `1px solid`. Applies to BOTH the token-bound path below and the raw path.
|
|
119
|
+
const asBorder = (valueExpr) => ` border: 1px solid ${valueExpr};\n`;
|
|
107
120
|
// T3: token-bound color/style — emit var(--ptb-collection-token, raw-hex) with hex fallback.
|
|
108
121
|
// tv.cssVar is the canonical var name from getPTBTokenVariableName (collection-aware).
|
|
109
122
|
if (val !== null && typeof val === "object" && "token" in val) {
|
|
@@ -112,19 +125,19 @@ export function generateComponentCss(component, lookup) {
|
|
|
112
125
|
// cssVar. Fabricating `--ptb-${token}` (no collection tier) produces a
|
|
113
126
|
// reference that does not exist in tokens.css. When cssVar is absent, emit
|
|
114
127
|
// the concrete resolved value directly.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
128
|
+
const valueExpr = tv.cssVar
|
|
129
|
+
? `var(${tv.cssVar}, ${typeof tv.value === "number" ? `${tv.value}px` : tv.value})`
|
|
130
|
+
: `${tv.value}`;
|
|
131
|
+
cssContent += cssProperty === "border"
|
|
132
|
+
? asBorder(valueExpr)
|
|
133
|
+
: ` ${cssProperty}: ${valueExpr};\n`;
|
|
122
134
|
continue;
|
|
123
135
|
}
|
|
124
136
|
// Token alias reference: `{token.path}` → CSS custom property
|
|
125
137
|
if (typeof val === "string" && val.startsWith("{") && val.endsWith("}")) {
|
|
126
138
|
const tokenAlias = val.slice(1, -1);
|
|
127
|
-
|
|
139
|
+
const aliasVar = `var(--ptb-${normalizeCssVarName(tokenAlias)})`;
|
|
140
|
+
cssContent += cssProperty === "border" ? asBorder(aliasVar) : ` ${cssProperty}: ${aliasVar};\n`;
|
|
128
141
|
continue;
|
|
129
142
|
}
|
|
130
143
|
// Fixed pixel dimensions on root containers produce non-responsive layouts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calibrate-ds/generator-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.90",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"react": "^19.0.0",
|
|
38
|
-
"@calibrate-ds/
|
|
39
|
-
"@calibrate-ds/
|
|
38
|
+
"@calibrate-ds/shared-types": "^0.1.90",
|
|
39
|
+
"@calibrate-ds/core": "^0.1.90"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"typescript": "^5.7.3",
|