@vettvangur/design-system 2.0.63 → 2.0.64
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/dist/index.js +29 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2182,6 +2182,29 @@ function maybeCollapseToBaseFont(raw, {
|
|
|
2182
2182
|
}
|
|
2183
2183
|
return raw;
|
|
2184
2184
|
}
|
|
2185
|
+
function normalizeBaseFontValue(raw, {
|
|
2186
|
+
baseFamily
|
|
2187
|
+
}) {
|
|
2188
|
+
// For the base token itself, prefer emitting the canonical family name.
|
|
2189
|
+
// Example: "Sharp Grotesk Book 19" -> "Sharp Grotesk".
|
|
2190
|
+
const v = String(raw ?? '').trim();
|
|
2191
|
+
if (!v || !baseFamily) {
|
|
2192
|
+
return raw;
|
|
2193
|
+
}
|
|
2194
|
+
|
|
2195
|
+
// Avoid changing var() or multi-stack definitions.
|
|
2196
|
+
if (/^var\(/.test(v) || v.includes(',')) {
|
|
2197
|
+
return raw;
|
|
2198
|
+
}
|
|
2199
|
+
const base = String(baseFamily).trim();
|
|
2200
|
+
if (!base) {
|
|
2201
|
+
return raw;
|
|
2202
|
+
}
|
|
2203
|
+
if (v === base || v.startsWith(`${base} `)) {
|
|
2204
|
+
return base;
|
|
2205
|
+
}
|
|
2206
|
+
return raw;
|
|
2207
|
+
}
|
|
2185
2208
|
function formatFontFamilyValue(raw) {
|
|
2186
2209
|
if (raw == null) {
|
|
2187
2210
|
return raw;
|
|
@@ -2263,11 +2286,15 @@ async function generateFile(variables, config) {
|
|
|
2263
2286
|
const baseMobileRaw = baseTokenKey ? variables?.[baseTokenKey]?.values?.mobile : null;
|
|
2264
2287
|
const baseFamily = baseMobileRaw ? splitFontStack(baseMobileRaw)[0] : null;
|
|
2265
2288
|
for (const [key, token] of Object.entries(variables || {})) {
|
|
2266
|
-
const mobileRaw = key === baseTokenKey ?
|
|
2289
|
+
const mobileRaw = key === baseTokenKey ? normalizeBaseFontValue(token?.values?.mobile, {
|
|
2290
|
+
baseFamily
|
|
2291
|
+
}) : maybeCollapseToBaseFont(token?.values?.mobile, {
|
|
2267
2292
|
baseTokenKey,
|
|
2268
2293
|
baseFamily
|
|
2269
2294
|
});
|
|
2270
|
-
const desktopRaw = key === baseTokenKey ?
|
|
2295
|
+
const desktopRaw = key === baseTokenKey ? normalizeBaseFontValue(token?.values?.desktop, {
|
|
2296
|
+
baseFamily
|
|
2297
|
+
}) : maybeCollapseToBaseFont(token?.values?.desktop, {
|
|
2271
2298
|
baseTokenKey,
|
|
2272
2299
|
baseFamily
|
|
2273
2300
|
});
|