@bamboocss/token-dictionary 1.57.5 → 1.57.6

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.cjs CHANGED
@@ -40,7 +40,7 @@ const isCompositeGradient = (0, ts_pattern.isMatching)({
40
40
  placement: ts_pattern.P.union(ts_pattern.P.string, ts_pattern.P.number),
41
41
  stops: ts_pattern.P.union(ts_pattern.P.array(ts_pattern.P.string), ts_pattern.P.array({
42
42
  color: ts_pattern.P.string,
43
- position: ts_pattern.P.number
43
+ position: ts_pattern.P.union(ts_pattern.P.number, ts_pattern.P.string)
44
44
  }))
45
45
  });
46
46
  const isCompositeBorder = (0, ts_pattern.isMatching)({
@@ -585,6 +585,12 @@ const gradientAngle = (name, type, placement) => {
585
585
  if (type === "conic" || type === "repeating-conic") return `from ${placement}deg`;
586
586
  throw new _bamboocss_shared.BambooError("INVALID_TOKEN", `The ${type} gradient \`${name}\` has a numeric \`placement\`, and only a linear or conic gradient takes an angle. Place a ${type} gradient with a shape and a position, like \`'circle at top'\`.`);
587
587
  };
588
+ /**
589
+ * Where a stop sits along the gradient. A number is a percentage of it, as a design tool places a
590
+ * stop: `position: 100` is the end of the gradient however long it is, where `100px` ended it a
591
+ * hundred pixels in and filled the rest with the last color. A string is written as it is, `'40px'`.
592
+ */
593
+ const gradientStopPosition = (position) => (0, _bamboocss_shared.isString)(position) ? position : `${position}%`;
588
594
  const transforms = [
589
595
  transformShadow,
590
596
  {
@@ -597,7 +603,7 @@ const transforms = [
597
603
  const rawStops = stops.map((stop) => {
598
604
  if ((0, _bamboocss_shared.isString)(stop)) return stop;
599
605
  const { color, position } = stop;
600
- return `${color} ${position}px`;
606
+ return `${color} ${gradientStopPosition(position)}`;
601
607
  });
602
608
  return `${type}-gradient(${typeof placement === "number" ? gradientAngle(token.name, type, placement) : placement}, ${rawStops.join(", ")})`;
603
609
  }
package/dist/index.mjs CHANGED
@@ -16,7 +16,7 @@ const isCompositeGradient = isMatching({
16
16
  placement: P.union(P.string, P.number),
17
17
  stops: P.union(P.array(P.string), P.array({
18
18
  color: P.string,
19
- position: P.number
19
+ position: P.union(P.number, P.string)
20
20
  }))
21
21
  });
22
22
  const isCompositeBorder = isMatching({
@@ -561,6 +561,12 @@ const gradientAngle = (name, type, placement) => {
561
561
  if (type === "conic" || type === "repeating-conic") return `from ${placement}deg`;
562
562
  throw new BambooError("INVALID_TOKEN", `The ${type} gradient \`${name}\` has a numeric \`placement\`, and only a linear or conic gradient takes an angle. Place a ${type} gradient with a shape and a position, like \`'circle at top'\`.`);
563
563
  };
564
+ /**
565
+ * Where a stop sits along the gradient. A number is a percentage of it, as a design tool places a
566
+ * stop: `position: 100` is the end of the gradient however long it is, where `100px` ended it a
567
+ * hundred pixels in and filled the rest with the last color. A string is written as it is, `'40px'`.
568
+ */
569
+ const gradientStopPosition = (position) => isString(position) ? position : `${position}%`;
564
570
  const transforms = [
565
571
  transformShadow,
566
572
  {
@@ -573,7 +579,7 @@ const transforms = [
573
579
  const rawStops = stops.map((stop) => {
574
580
  if (isString(stop)) return stop;
575
581
  const { color, position } = stop;
576
- return `${color} ${position}px`;
582
+ return `${color} ${gradientStopPosition(position)}`;
577
583
  });
578
584
  return `${type}-gradient(${typeof placement === "number" ? gradientAngle(token.name, type, placement) : placement}, ${rawStops.join(", ")})`;
579
585
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bamboocss/token-dictionary",
3
- "version": "1.57.5",
3
+ "version": "1.57.6",
4
4
  "description": "Common error messages for css bamboo",
5
5
  "homepage": "https://bamboocss.com",
6
6
  "license": "MIT",
@@ -35,9 +35,9 @@
35
35
  "dependencies": {
36
36
  "picomatch": "4.0.5",
37
37
  "ts-pattern": "5.9.0",
38
- "@bamboocss/logger": "^1.57.5",
39
- "@bamboocss/types": "1.57.5",
40
- "@bamboocss/shared": "1.57.5"
38
+ "@bamboocss/logger": "^1.57.6",
39
+ "@bamboocss/shared": "1.57.6",
40
+ "@bamboocss/types": "1.57.6"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/picomatch": "4.0.2"