@vettvangur/design-system 2.0.23 → 2.0.24
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 +27 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1540,12 +1540,12 @@ function pickHex(values, preferredMode) {
|
|
|
1540
1540
|
if (!values || typeof values !== 'object') {
|
|
1541
1541
|
return null;
|
|
1542
1542
|
}
|
|
1543
|
-
if (values[preferredMode]?.hex) {
|
|
1543
|
+
if (preferredMode && values[preferredMode]?.hex) {
|
|
1544
1544
|
return values[preferredMode].hex;
|
|
1545
1545
|
}
|
|
1546
1546
|
|
|
1547
1547
|
// if already normalized upstream
|
|
1548
|
-
if (values[modeKey$1(preferredMode)]?.hex) {
|
|
1548
|
+
if (preferredMode && values[modeKey$1(preferredMode)]?.hex) {
|
|
1549
1549
|
return values[modeKey$1(preferredMode)].hex;
|
|
1550
1550
|
}
|
|
1551
1551
|
|
|
@@ -1553,25 +1553,19 @@ function pickHex(values, preferredMode) {
|
|
|
1553
1553
|
const first = Object.values(values)[0];
|
|
1554
1554
|
return first?.hex ?? null;
|
|
1555
1555
|
}
|
|
1556
|
-
function collectColorVars(variableSet
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
}
|
|
1569
|
-
varName: '--color-umbraco-blue',
|
|
1570
|
-
hex: '#283a97'
|
|
1571
|
-
}, {
|
|
1572
|
-
varName: '--color-umbraco-pink',
|
|
1573
|
-
hex: '#f5c1bc'
|
|
1574
|
-
}];
|
|
1556
|
+
function collectColorVars(variableSet, {
|
|
1557
|
+
includeDefaults = false,
|
|
1558
|
+
preferredMode = 'Mode 1'
|
|
1559
|
+
} = {}) {
|
|
1560
|
+
const map = new Map();
|
|
1561
|
+
if (includeDefaults) {
|
|
1562
|
+
// Optional legacy colors (kept for backwards compatibility)
|
|
1563
|
+
map.set('--color-transparent', 'transparent');
|
|
1564
|
+
map.set('--color-white', '#fff');
|
|
1565
|
+
map.set('--color-black', '#111');
|
|
1566
|
+
map.set('--color-umbraco-blue', '#283a97');
|
|
1567
|
+
map.set('--color-umbraco-pink', '#f5c1bc');
|
|
1568
|
+
}
|
|
1575
1569
|
for (const [groupKey, group] of Object.entries(variableSet ?? {})) {
|
|
1576
1570
|
if (!group || typeof group !== 'object') {
|
|
1577
1571
|
continue;
|
|
@@ -1580,20 +1574,18 @@ function collectColorVars(variableSet) {
|
|
|
1580
1574
|
if (!token || token.type !== 'COLOR') {
|
|
1581
1575
|
continue;
|
|
1582
1576
|
}
|
|
1583
|
-
|
|
1584
|
-
// Prefer "Mode 1" if present, else fallback to first mode
|
|
1585
|
-
const hex = pickHex(token.values, 'Mode 1');
|
|
1577
|
+
const hex = pickHex(token.values, preferredMode);
|
|
1586
1578
|
if (!hex) {
|
|
1587
1579
|
continue;
|
|
1588
1580
|
}
|
|
1589
1581
|
const varName = `--color-${kebab$2(groupKey)}-${kebab$2(tokenKey)}`;
|
|
1590
|
-
|
|
1591
|
-
varName,
|
|
1592
|
-
hex
|
|
1593
|
-
});
|
|
1582
|
+
map.set(varName, hex);
|
|
1594
1583
|
}
|
|
1595
1584
|
}
|
|
1596
|
-
return
|
|
1585
|
+
return Array.from(map, ([varName, hex]) => ({
|
|
1586
|
+
varName,
|
|
1587
|
+
hex
|
|
1588
|
+
}));
|
|
1597
1589
|
}
|
|
1598
1590
|
function renderColors(vars) {
|
|
1599
1591
|
const lines = vars.map(v => ` ${v.varName}: ${v.hex};`);
|
|
@@ -1601,7 +1593,12 @@ function renderColors(vars) {
|
|
|
1601
1593
|
}
|
|
1602
1594
|
async function generateColors$1(variableSet, config) {
|
|
1603
1595
|
message('generating colors...');
|
|
1604
|
-
const
|
|
1596
|
+
const includeDefaults = config?.raw?.colors?.includeDefaults ?? false;
|
|
1597
|
+
const preferredMode = config?.raw?.colors?.preferredMode ?? 'Mode 1';
|
|
1598
|
+
const vars = collectColorVars(variableSet, {
|
|
1599
|
+
includeDefaults,
|
|
1600
|
+
preferredMode
|
|
1601
|
+
});
|
|
1605
1602
|
const css = '/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n' + renderColors(vars);
|
|
1606
1603
|
const outPath = path.join(config.paths.styles, 'config', 'color.css');
|
|
1607
1604
|
await fs$1.writeFile(outPath, css, 'utf8');
|