@vettvangur/design-system 2.0.60 → 2.0.62
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 +51 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1725,6 +1725,10 @@ function groupColors(variableSet, collectionKey = 'colour') {
|
|
|
1725
1725
|
* @generated
|
|
1726
1726
|
* @module design-system
|
|
1727
1727
|
*/
|
|
1728
|
+
function isFontFamilyKey(key) {
|
|
1729
|
+
// NOTE: accept historical typo "familiy" as well.
|
|
1730
|
+
return key.startsWith('font-family-') || key.startsWith('font-familiy-');
|
|
1731
|
+
}
|
|
1728
1732
|
|
|
1729
1733
|
/**
|
|
1730
1734
|
* Entries.
|
|
@@ -1759,6 +1763,15 @@ function groupTypography(variableSet) {
|
|
|
1759
1763
|
message('grouping typography...');
|
|
1760
1764
|
const col = variableSet.typography;
|
|
1761
1765
|
const toks = col?.tokens || {};
|
|
1766
|
+
if (process$1.env.DS_DEBUG) {
|
|
1767
|
+
const keys = Object.keys(toks);
|
|
1768
|
+
console.log('[design-system] typography: token count =', keys.length);
|
|
1769
|
+
if (keys.length) {
|
|
1770
|
+
console.log('[design-system] typography: token key sample =', keys.slice(0, 25).join(', '));
|
|
1771
|
+
const ff = keys.filter(k => isFontFamilyKey(k));
|
|
1772
|
+
console.log('[design-system] typography: font-family key sample =', ff.slice(0, 25).join(', '));
|
|
1773
|
+
}
|
|
1774
|
+
}
|
|
1762
1775
|
const out = {
|
|
1763
1776
|
families: {},
|
|
1764
1777
|
weights: {},
|
|
@@ -1767,7 +1780,7 @@ function groupTypography(variableSet) {
|
|
|
1767
1780
|
other: {}
|
|
1768
1781
|
};
|
|
1769
1782
|
for (const [key, token] of entries$1(toks)) {
|
|
1770
|
-
if (key
|
|
1783
|
+
if (isFontFamilyKey(key)) {
|
|
1771
1784
|
out.families[key] = token;
|
|
1772
1785
|
continue;
|
|
1773
1786
|
}
|
|
@@ -2103,6 +2116,10 @@ function normalizeFontKey(rawKey) {
|
|
|
2103
2116
|
if (rawKey.startsWith('font-family-')) {
|
|
2104
2117
|
return rawKey.replace(/^font-family-/, 'font-');
|
|
2105
2118
|
}
|
|
2119
|
+
// accept common typo
|
|
2120
|
+
if (rawKey.startsWith('font-familiy-')) {
|
|
2121
|
+
return rawKey.replace(/^font-familiy-/, 'font-');
|
|
2122
|
+
}
|
|
2106
2123
|
if (rawKey.startsWith('font-')) {
|
|
2107
2124
|
return rawKey;
|
|
2108
2125
|
}
|
|
@@ -2134,6 +2151,37 @@ function normalizeValuesKeys(values) {
|
|
|
2134
2151
|
}
|
|
2135
2152
|
return out;
|
|
2136
2153
|
}
|
|
2154
|
+
function escapeCssSingleQuotedString(value) {
|
|
2155
|
+
return String(value).replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
2156
|
+
}
|
|
2157
|
+
function formatFontFamilyValue(raw) {
|
|
2158
|
+
if (raw == null) {
|
|
2159
|
+
return raw;
|
|
2160
|
+
}
|
|
2161
|
+
const s = String(raw).trim();
|
|
2162
|
+
if (!s) {
|
|
2163
|
+
return null;
|
|
2164
|
+
}
|
|
2165
|
+
|
|
2166
|
+
// Allow comma-separated stacks and quote parts that would otherwise be parsed as separate identifiers.
|
|
2167
|
+
const parts = s.split(',').map(p => p.trim()).filter(Boolean);
|
|
2168
|
+
const formatted = parts.map(p => {
|
|
2169
|
+
// Keep CSS var() and already-quoted values.
|
|
2170
|
+
if (/^var\(/.test(p)) {
|
|
2171
|
+
return p;
|
|
2172
|
+
}
|
|
2173
|
+
if (p.startsWith("'") && p.endsWith("'") || p.startsWith('"') && p.endsWith('"')) {
|
|
2174
|
+
return p;
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2177
|
+
// Quote anything containing whitespace or special characters.
|
|
2178
|
+
if (/\s/.test(p) || /[^a-zA-Z0-9_-]/.test(p)) {
|
|
2179
|
+
return `'${escapeCssSingleQuotedString(p)}'`;
|
|
2180
|
+
}
|
|
2181
|
+
return p;
|
|
2182
|
+
});
|
|
2183
|
+
return formatted.join(', ');
|
|
2184
|
+
}
|
|
2137
2185
|
|
|
2138
2186
|
/**
|
|
2139
2187
|
* Generate font family.
|
|
@@ -2179,8 +2227,8 @@ async function generateFontFamily(variableSet, config) {
|
|
|
2179
2227
|
async function generateFile(variables, config) {
|
|
2180
2228
|
let css = `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n` + `@theme {\n`;
|
|
2181
2229
|
for (const [key, token] of Object.entries(variables || {})) {
|
|
2182
|
-
const mobile = token?.values?.mobile;
|
|
2183
|
-
const desktop = token?.values?.desktop;
|
|
2230
|
+
const mobile = formatFontFamilyValue(token?.values?.mobile);
|
|
2231
|
+
const desktop = formatFontFamilyValue(token?.values?.desktop);
|
|
2184
2232
|
if (mobile != null) {
|
|
2185
2233
|
css += ` --${key}: ${mobile};\n`;
|
|
2186
2234
|
}
|