@vettvangur/design-system 2.0.73 → 2.0.76
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 +61 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2669,8 +2669,13 @@ const renderApplyLine = (prefix, token, indent = ' ') => {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
if (prefix === 'border') {
|
|
2671
2671
|
// Tailwind border color utilities are always `border-{token}`.
|
|
2672
|
-
//
|
|
2673
|
-
|
|
2672
|
+
// Our color keys are grouped (e.g. `border-default`), so border colors should always apply as
|
|
2673
|
+
// `border-border-*`. If the token already starts with `border-`, keep it; otherwise namespace it.
|
|
2674
|
+
const t = token.startsWith('border-') ? token : `border-${token}`;
|
|
2675
|
+
if (process$1.env.DS_DEBUG) {
|
|
2676
|
+
console.log('[design-system] button-variants: border token =', token, '=>', `border-${t}`);
|
|
2677
|
+
}
|
|
2678
|
+
return `${indent}@apply border-${t};\n`;
|
|
2674
2679
|
}
|
|
2675
2680
|
return `${indent}@apply ${prefix}-${token};\n`;
|
|
2676
2681
|
};
|
|
@@ -3771,7 +3776,7 @@ function generateSpacingCss(scales) {
|
|
|
3771
3776
|
const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
|
|
3772
3777
|
|
|
3773
3778
|
// manual required defaults
|
|
3774
|
-
ensureVar(lines, '--spacing',
|
|
3779
|
+
ensureVar(lines, '--spacing', rem(1));
|
|
3775
3780
|
ensureVar(lines, '--spacing-0', '0');
|
|
3776
3781
|
ensureVar(lines, '--spacing-auto', 'auto');
|
|
3777
3782
|
ensureVar(lines, '--spacing-full', '100%');
|
|
@@ -3976,12 +3981,49 @@ function rgbaFromColor(color) {
|
|
|
3976
3981
|
const r = color?.rgba?.r;
|
|
3977
3982
|
const g = color?.rgba?.g;
|
|
3978
3983
|
const b = color?.rgba?.b;
|
|
3984
|
+
const normalizeRgbChannel = v => {
|
|
3985
|
+
if (typeof v !== 'number' || Number.isNaN(v)) {
|
|
3986
|
+
return null;
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
// Figma typically gives channels in 0..1, but some token sources provide 0..255.
|
|
3990
|
+
if (v >= 0 && v <= 1) {
|
|
3991
|
+
return Math.round(v * 255);
|
|
3992
|
+
}
|
|
3993
|
+
|
|
3994
|
+
// Handle 16-bit channels (0..65535) defensively.
|
|
3995
|
+
if (v > 255 && v <= 65535) {
|
|
3996
|
+
return Math.round(Math.max(0, Math.min(255, v / 257)));
|
|
3997
|
+
}
|
|
3998
|
+
return Math.round(Math.max(0, Math.min(255, v)));
|
|
3999
|
+
};
|
|
4000
|
+
const normalizeAlpha = v => {
|
|
4001
|
+
if (typeof v !== 'number' || Number.isNaN(v)) {
|
|
4002
|
+
return null;
|
|
4003
|
+
}
|
|
4004
|
+
|
|
4005
|
+
// Common cases: 0..1, percent (0..100), or 0..255.
|
|
4006
|
+
let a = v;
|
|
4007
|
+
if (a > 1 && a <= 100) {
|
|
4008
|
+
a /= 100;
|
|
4009
|
+
} else if (a > 100 && a <= 255) {
|
|
4010
|
+
a /= 255;
|
|
4011
|
+
}
|
|
4012
|
+
a = Math.max(0, Math.min(1, a));
|
|
4013
|
+
|
|
4014
|
+
// Avoid long float tails from upstream values.
|
|
4015
|
+
const rounded = Number(a.toFixed(4));
|
|
4016
|
+
return String(rounded);
|
|
4017
|
+
};
|
|
3979
4018
|
if ([r, g, b, a].every(v => typeof v === 'number')) {
|
|
3980
|
-
const rr =
|
|
3981
|
-
const gg =
|
|
3982
|
-
const bb =
|
|
3983
|
-
const aa =
|
|
3984
|
-
|
|
4019
|
+
const rr = normalizeRgbChannel(r);
|
|
4020
|
+
const gg = normalizeRgbChannel(g);
|
|
4021
|
+
const bb = normalizeRgbChannel(b);
|
|
4022
|
+
const aa = normalizeAlpha(a);
|
|
4023
|
+
if ([rr, gg, bb, aa].every(v => v != null)) {
|
|
4024
|
+
// Use legacy comma-separated rgba() for maximum tool compatibility.
|
|
4025
|
+
return `rgba(${rr}, ${gg}, ${bb}, ${aa})`;
|
|
4026
|
+
}
|
|
3985
4027
|
}
|
|
3986
4028
|
const hex = String(color?.hex ?? '').trim();
|
|
3987
4029
|
// supports #RRGGBB or #RRGGBBAA
|
|
@@ -3995,7 +4037,10 @@ function rgbaFromColor(color) {
|
|
|
3995
4037
|
const gg = parseInt(rgb.slice(2, 4), 16);
|
|
3996
4038
|
const bb = parseInt(rgb.slice(4, 6), 16);
|
|
3997
4039
|
const alpha = aa ? parseInt(aa, 16) / 255 : 1;
|
|
3998
|
-
|
|
4040
|
+
const alphaStr = String(Number(Math.max(0, Math.min(1, alpha)).toFixed(4)));
|
|
4041
|
+
|
|
4042
|
+
// Use legacy comma-separated rgba() for maximum tool compatibility.
|
|
4043
|
+
return `rgba(${rr}, ${gg}, ${bb}, ${alphaStr})`;
|
|
3999
4044
|
}
|
|
4000
4045
|
|
|
4001
4046
|
/**
|
|
@@ -4335,7 +4380,13 @@ async function generateTailwind(config, projectType, typography, buttons, colors
|
|
|
4335
4380
|
message(pc.yellow('-=[ tailwind ]=-'));
|
|
4336
4381
|
await generateFontFamily(typography.families, config);
|
|
4337
4382
|
await generateFontWeight(typography.weights, config);
|
|
4338
|
-
|
|
4383
|
+
const skipButtonVariants = process.env.DS_SKIP_BUTTON_VARIANTS === '1' || process.env.DS_SKIP_BUTTON_VARIANTS === 'true' || config?.raw?.generators?.tailwind?.buttonVariants === false || config?.raw?.generators?.tailwind?.buttons === false;
|
|
4384
|
+
const enableButtonVariants = process.env.DS_ENABLE_BUTTON_VARIANTS === '1' || process.env.DS_ENABLE_BUTTON_VARIANTS === 'true' || config?.raw?.generators?.tailwind?.buttonVariants === true || config?.raw?.generators?.tailwind?.buttons === true;
|
|
4385
|
+
if (skipButtonVariants || !enableButtonVariants) {
|
|
4386
|
+
message('skipping tailwind button variants generator');
|
|
4387
|
+
} else {
|
|
4388
|
+
await generateButtons$1(buttons, config);
|
|
4389
|
+
}
|
|
4339
4390
|
await generateBodies(typography.sizes, typography.lineHeights, config);
|
|
4340
4391
|
await generateHeadlines(typography.sizes, typography.lineHeights, config);
|
|
4341
4392
|
await generateTypography$1(typography.sizes, typography.lineHeights, config);
|