@webstudio-is/css-engine 0.40.0 → 0.41.0

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.
@@ -67,13 +67,14 @@ const toValue = (value, options = defaultOptions) => {
67
67
  return `rgba(${value.r}, ${value.g}, ${value.b}, ${value.alpha})`;
68
68
  }
69
69
  if (value.type === "image") {
70
- return value.value.map(
71
- (imageAsset) => `url(${imageAsset.value.path}) /* id=${imageAsset.value.id} */`
72
- ).join(", ");
70
+ return `url(${value.value.value.path}) /* id=${value.value.value.id} */`;
73
71
  }
74
72
  if (value.type === "unparsed") {
75
73
  return value.value;
76
74
  }
75
+ if (value.type === "layers") {
76
+ return value.value.map((v) => toValue(v, options)).join(",");
77
+ }
77
78
  assertUnreachable(value, `Unknown value type`);
78
79
  throw new Error("Unknown value type");
79
80
  };
@@ -44,13 +44,14 @@ const toValue = (value, options = defaultOptions) => {
44
44
  return `rgba(${value.r}, ${value.g}, ${value.b}, ${value.alpha})`;
45
45
  }
46
46
  if (value.type === "image") {
47
- return value.value.map(
48
- (imageAsset) => `url(${imageAsset.value.path}) /* id=${imageAsset.value.id} */`
49
- ).join(", ");
47
+ return `url(${value.value.value.path}) /* id=${value.value.value.id} */`;
50
48
  }
51
49
  if (value.type === "unparsed") {
52
50
  return value.value;
53
51
  }
52
+ if (value.type === "layers") {
53
+ return value.value.map((v) => toValue(v, options)).join(",");
54
+ }
54
55
  assertUnreachable(value, `Unknown value type`);
55
56
  throw new Error("Unknown value type");
56
57
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webstudio-is/css-engine",
3
- "version": "0.40.0",
3
+ "version": "0.41.0",
4
4
  "description": "CSS Renderer for Webstudio",
5
5
  "author": "Webstudio <github@webstudio.is>",
6
6
  "homepage": "https://webstudio.is",
@@ -9,7 +9,7 @@
9
9
  "hyphenate-style-name": "^1.0.4",
10
10
  "react": "^17.0.2",
11
11
  "react-dom": "^17.0.2",
12
- "@webstudio-is/fonts": "^0.40.0"
12
+ "@webstudio-is/fonts": "^0.41.0"
13
13
  },
14
14
  "devDependencies": {
15
15
  "@jest/globals": "^29.3.1",
@@ -21,7 +21,7 @@
21
21
  "@types/react-dom": "^17.0.9",
22
22
  "jest": "^29.3.1",
23
23
  "typescript": "4.9.5",
24
- "@webstudio-is/css-data": "^0.40.0",
24
+ "@webstudio-is/css-data": "^0.41.0",
25
25
  "@webstudio-is/jest-config": "^1.0.2",
26
26
  "@webstudio-is/scripts": "^0.0.0",
27
27
  "@webstudio-is/storybook-config": "^0.0.0",
@@ -64,4 +64,40 @@ describe("Convert WS CSS Values to native CSS strings", () => {
64
64
  );
65
65
  expect(value).toBe("Courier New");
66
66
  });
67
+
68
+ test("array", () => {
69
+ const value = toValue({
70
+ type: "layers",
71
+ value: [
72
+ {
73
+ type: "keyword",
74
+ value: "auto",
75
+ },
76
+ { type: "unit", value: 10, unit: "px" },
77
+ { type: "unparsed", value: "calc(10px)" },
78
+ {
79
+ type: "image",
80
+ value: {
81
+ type: "asset",
82
+ value: {
83
+ type: "image",
84
+ path: "foo.png",
85
+
86
+ id: "1234567890",
87
+ projectId: "",
88
+ format: "",
89
+ size: 1212,
90
+ name: "img",
91
+ description: "",
92
+ location: "REMOTE",
93
+ createdAt: "",
94
+ meta: { width: 1, height: 2 },
95
+ },
96
+ },
97
+ },
98
+ ],
99
+ });
100
+
101
+ expect(value).toBe("auto,10px,calc(10px),url(foo.png) /* id=1234567890 */");
102
+ });
67
103
  });
@@ -63,18 +63,17 @@ export const toValue = (
63
63
 
64
64
  if (value.type === "image") {
65
65
  // @todo image-set
66
- return value.value
67
- .map(
68
- (imageAsset) =>
69
- `url(${imageAsset.value.path}) /* id=${imageAsset.value.id} */`
70
- )
71
- .join(", ");
66
+ return `url(${value.value.value.path}) /* id=${value.value.value.id} */`;
72
67
  }
73
68
 
74
69
  if (value.type === "unparsed") {
75
70
  return value.value;
76
71
  }
77
72
 
73
+ if (value.type === "layers") {
74
+ return value.value.map((v) => toValue(v, options)).join(",");
75
+ }
76
+
78
77
  // Will give ts error in case of missing type
79
78
  assertUnreachable(value, `Unknown value type`);
80
79