@vettvangur/design-system 2.0.63 → 2.0.65
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 +34 -5
- 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
|
});
|
|
@@ -2276,7 +2303,9 @@ async function generateFile(variables, config) {
|
|
|
2276
2303
|
if (mobile != null) {
|
|
2277
2304
|
css += ` --${key}: ${mobile};\n`;
|
|
2278
2305
|
}
|
|
2279
|
-
|
|
2306
|
+
|
|
2307
|
+
// Keep the -desktop key if a desktop mode exists, even if it matches mobile.
|
|
2308
|
+
if (desktop != null) {
|
|
2280
2309
|
css += ` --${key}-desktop: ${desktop};\n`;
|
|
2281
2310
|
}
|
|
2282
2311
|
}
|
|
@@ -3117,7 +3146,7 @@ function needsDesktopLine$1(values) {
|
|
|
3117
3146
|
if (!values) {
|
|
3118
3147
|
return false;
|
|
3119
3148
|
}
|
|
3120
|
-
return values.desktop !== values.mobile;
|
|
3149
|
+
return values.desktop != null && values.desktop !== values.mobile;
|
|
3121
3150
|
}
|
|
3122
3151
|
|
|
3123
3152
|
/**
|
|
@@ -3293,7 +3322,7 @@ function needsDesktopLine(values) {
|
|
|
3293
3322
|
if (!values) {
|
|
3294
3323
|
return false;
|
|
3295
3324
|
}
|
|
3296
|
-
return values.desktop !== values.mobile;
|
|
3325
|
+
return values.desktop != null && values.desktop !== values.mobile;
|
|
3297
3326
|
}
|
|
3298
3327
|
|
|
3299
3328
|
/**
|