@vettvangur/design-system 2.0.68 → 2.0.70
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 +55 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3511,7 +3511,8 @@ async function renderTypography(tokens, config) {
|
|
|
3511
3511
|
return;
|
|
3512
3512
|
}
|
|
3513
3513
|
if (typeof value === 'number') {
|
|
3514
|
-
const
|
|
3514
|
+
const k = String(key);
|
|
3515
|
+
const v = value === 0 ? '0' : k.startsWith('text-') || k.startsWith('leading-') ? rem(value) : `${value}px`;
|
|
3515
3516
|
return ` --${key}: ${v};\n`;
|
|
3516
3517
|
}
|
|
3517
3518
|
return ` --${key}: ${String(value)};\n`; // already has units
|
|
@@ -3618,16 +3619,43 @@ function pickNumber(values, preferredMode) {
|
|
|
3618
3619
|
if (!values || typeof values !== 'object') {
|
|
3619
3620
|
return null;
|
|
3620
3621
|
}
|
|
3621
|
-
const
|
|
3622
|
-
|
|
3622
|
+
const parseNumberLike = v => {
|
|
3623
|
+
if (typeof v === 'number') {
|
|
3624
|
+
return Number.isFinite(v) ? v : null;
|
|
3625
|
+
}
|
|
3626
|
+
if (typeof v !== 'string') {
|
|
3627
|
+
return null;
|
|
3628
|
+
}
|
|
3629
|
+
|
|
3630
|
+
// Accept numeric strings and common px strings from Figma variables.
|
|
3631
|
+
// Examples: "2", "2px", "0px".
|
|
3632
|
+
const s = v.trim();
|
|
3633
|
+
if (!s) {
|
|
3634
|
+
return null;
|
|
3635
|
+
}
|
|
3636
|
+
|
|
3637
|
+
// Radius/spacing/border tokens are expected to be integer pixel values.
|
|
3638
|
+
// If decimals are present, keep behavior explicit by rejecting them.
|
|
3639
|
+
const m = /^-?\d+(?:px)?$/i.exec(s);
|
|
3640
|
+
if (!m) {
|
|
3641
|
+
return null;
|
|
3642
|
+
}
|
|
3643
|
+
const n = Number.parseInt(s.replace(/px$/i, ''), 10);
|
|
3644
|
+
return Number.isFinite(n) ? n : null;
|
|
3645
|
+
};
|
|
3646
|
+
const direct = parseNumberLike(values[preferredMode]);
|
|
3647
|
+
if (direct != null) {
|
|
3623
3648
|
return direct;
|
|
3624
3649
|
}
|
|
3625
3650
|
const normalizedPreferred = modeKey(preferredMode) ;
|
|
3626
|
-
if (normalizedPreferred
|
|
3627
|
-
|
|
3651
|
+
if (normalizedPreferred) {
|
|
3652
|
+
const n = parseNumberLike(values[normalizedPreferred]);
|
|
3653
|
+
if (n != null) {
|
|
3654
|
+
return n;
|
|
3655
|
+
}
|
|
3628
3656
|
}
|
|
3629
3657
|
const first = Object.values(values)[0];
|
|
3630
|
-
return
|
|
3658
|
+
return parseNumberLike(first);
|
|
3631
3659
|
}
|
|
3632
3660
|
|
|
3633
3661
|
/**
|
|
@@ -3685,14 +3713,14 @@ function ensureVar(lines, varName, value) {
|
|
|
3685
3713
|
*
|
|
3686
3714
|
* addRem(map, name, n)
|
|
3687
3715
|
*/
|
|
3688
|
-
function
|
|
3716
|
+
function addPx(map, name, n) {
|
|
3689
3717
|
if (n == null) {
|
|
3690
3718
|
return;
|
|
3691
3719
|
}
|
|
3692
3720
|
if (map.has(name)) {
|
|
3693
3721
|
return;
|
|
3694
3722
|
}
|
|
3695
|
-
map.set(name, n === 0 ? '0' :
|
|
3723
|
+
map.set(name, n === 0 ? '0' : `${n}px`);
|
|
3696
3724
|
}
|
|
3697
3725
|
|
|
3698
3726
|
/**
|
|
@@ -3716,7 +3744,7 @@ function generateSpacingCss(scales) {
|
|
|
3716
3744
|
if (v == null) {
|
|
3717
3745
|
continue;
|
|
3718
3746
|
}
|
|
3719
|
-
|
|
3747
|
+
addPx(map, `--spacing-${kebab$1(tokenKey)}`, v);
|
|
3720
3748
|
}
|
|
3721
3749
|
};
|
|
3722
3750
|
|
|
@@ -3732,7 +3760,7 @@ function generateSpacingCss(scales) {
|
|
|
3732
3760
|
continue;
|
|
3733
3761
|
}
|
|
3734
3762
|
const k = kebab$1(tokenKey).replace(/^scale-/, '');
|
|
3735
|
-
|
|
3763
|
+
addPx(map, `--spacing-vertical-${k}`, v);
|
|
3736
3764
|
}
|
|
3737
3765
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3738
3766
|
|
|
@@ -3766,7 +3794,7 @@ function generateBorderCss(scales) {
|
|
|
3766
3794
|
if (v == null) {
|
|
3767
3795
|
continue;
|
|
3768
3796
|
}
|
|
3769
|
-
|
|
3797
|
+
addPx(map, `--border-${kebab$1(tokenKey)}`, v);
|
|
3770
3798
|
}
|
|
3771
3799
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3772
3800
|
|
|
@@ -3801,6 +3829,7 @@ function generateRadiusCss(scales) {
|
|
|
3801
3829
|
const map = new Map();
|
|
3802
3830
|
let skippedManual = 0;
|
|
3803
3831
|
let skippedNull = 0;
|
|
3832
|
+
const skippedNullSample = [];
|
|
3804
3833
|
for (const [tokenKey, token] of Object.entries(input)) {
|
|
3805
3834
|
const k = kebab$1(tokenKey);
|
|
3806
3835
|
|
|
@@ -3812,19 +3841,31 @@ function generateRadiusCss(scales) {
|
|
|
3812
3841
|
const v = pickNumber(token?.values, 'Mode 1');
|
|
3813
3842
|
if (v == null) {
|
|
3814
3843
|
skippedNull++;
|
|
3844
|
+
if (debug && skippedNullSample.length < 8) {
|
|
3845
|
+
const values = token?.values && typeof token.values === 'object' ? token.values : null;
|
|
3846
|
+
skippedNullSample.push({
|
|
3847
|
+
key: tokenKey,
|
|
3848
|
+
type: token?.type ?? null,
|
|
3849
|
+
modes: values ? Object.keys(values).slice(0, 10) : [],
|
|
3850
|
+
valuesSample: values ? Object.fromEntries(Object.entries(values).slice(0, 3)) : null
|
|
3851
|
+
});
|
|
3852
|
+
}
|
|
3815
3853
|
continue;
|
|
3816
3854
|
}
|
|
3817
|
-
|
|
3855
|
+
addPx(map, `--radius-${k}`, v);
|
|
3818
3856
|
}
|
|
3819
3857
|
if (debug) {
|
|
3820
3858
|
console.log('[design-system] radius: emitted =', map.size, '| skipped(manual)=', skippedManual, '| skipped(null)=', skippedNull);
|
|
3859
|
+
if (skippedNullSample.length) {
|
|
3860
|
+
console.log('[design-system] radius: skipped(null) sample =', JSON.stringify(skippedNullSample, null, 2));
|
|
3861
|
+
}
|
|
3821
3862
|
}
|
|
3822
3863
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3823
3864
|
|
|
3824
3865
|
// manual required defaults
|
|
3825
3866
|
ensureVar(lines, '--radius-0', '0');
|
|
3826
3867
|
ensureVar(lines, '--radius-circle', '50%');
|
|
3827
|
-
ensureVar(lines, '--radius-rounded',
|
|
3868
|
+
ensureVar(lines, '--radius-rounded', '100px');
|
|
3828
3869
|
return `/* AUTO-GENERATED - DO NOT EDIT BY HAND */\n\n${renderTheme$1(lines)}`;
|
|
3829
3870
|
}
|
|
3830
3871
|
|
|
@@ -3975,7 +4016,7 @@ function effectToBoxShadow(effect) {
|
|
|
3975
4016
|
const color = rgbaFromColor(effect.color) ?? 'rgba(0 0 0 / 0.25)';
|
|
3976
4017
|
|
|
3977
4018
|
// "x y blur spread color"
|
|
3978
|
-
const len = n => n === 0 ? '0' :
|
|
4019
|
+
const len = n => n === 0 ? '0' : `${n}px`;
|
|
3979
4020
|
return `${len(x)} ${len(y)} ${len(blur)} ${len(spread)} ${color}`;
|
|
3980
4021
|
}
|
|
3981
4022
|
|