@vettvangur/design-system 2.0.74 → 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.
Files changed (2) hide show
  1. package/dist/index.js +54 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3776,7 +3776,7 @@ function generateSpacingCss(scales) {
3776
3776
  const lines = Array.from(map.entries()).map(([k, v]) => ` ${k}: ${v};`);
3777
3777
 
3778
3778
  // manual required defaults
3779
- ensureVar(lines, '--spacing', '1px');
3779
+ ensureVar(lines, '--spacing', rem(1));
3780
3780
  ensureVar(lines, '--spacing-0', '0');
3781
3781
  ensureVar(lines, '--spacing-auto', 'auto');
3782
3782
  ensureVar(lines, '--spacing-full', '100%');
@@ -3981,12 +3981,49 @@ function rgbaFromColor(color) {
3981
3981
  const r = color?.rgba?.r;
3982
3982
  const g = color?.rgba?.g;
3983
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
+ };
3984
4018
  if ([r, g, b, a].every(v => typeof v === 'number')) {
3985
- const rr = Math.round(r * 255);
3986
- const gg = Math.round(g * 255);
3987
- const bb = Math.round(b * 255);
3988
- const aa = Math.max(0, Math.min(1, a));
3989
- return `rgba(${rr} ${gg} ${bb} / ${aa})`;
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
+ }
3990
4027
  }
3991
4028
  const hex = String(color?.hex ?? '').trim();
3992
4029
  // supports #RRGGBB or #RRGGBBAA
@@ -4000,7 +4037,10 @@ function rgbaFromColor(color) {
4000
4037
  const gg = parseInt(rgb.slice(2, 4), 16);
4001
4038
  const bb = parseInt(rgb.slice(4, 6), 16);
4002
4039
  const alpha = aa ? parseInt(aa, 16) / 255 : 1;
4003
- return `rgba(${rr} ${gg} ${bb} / ${alpha})`;
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})`;
4004
4044
  }
4005
4045
 
4006
4046
  /**
@@ -4340,7 +4380,13 @@ async function generateTailwind(config, projectType, typography, buttons, colors
4340
4380
  message(pc.yellow('-=[ tailwind ]=-'));
4341
4381
  await generateFontFamily(typography.families, config);
4342
4382
  await generateFontWeight(typography.weights, config);
4343
- await generateButtons$1(buttons, config);
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
+ }
4344
4390
  await generateBodies(typography.sizes, typography.lineHeights, config);
4345
4391
  await generateHeadlines(typography.sizes, typography.lineHeights, config);
4346
4392
  await generateTypography$1(typography.sizes, typography.lineHeights, config);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vettvangur/design-system",
3
- "version": "2.0.74",
3
+ "version": "2.0.76",
4
4
  "description": "",
5
5
  "access": "public",
6
6
  "type": "module",