Skip to content

Commit 88913c2

Browse files
authored
fix: refactor htmlShadow function to handle multiple shadow effects (#245)
1 parent c2581aa commit 88913c2

1 file changed

Lines changed: 25 additions & 20 deletions

File tree

packages/backend/src/html/builderImpl/htmlShadow.ts

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,34 @@ export const htmlShadow = (node: BlendMixin): string => {
1616
);
1717
// simple shadow from tailwind
1818
if (shadowEffects.length > 0) {
19-
const shadow = shadowEffects[0];
20-
let x = 0;
21-
let y = 0;
22-
let blur = 0;
23-
let spread = "";
24-
let inner = "";
25-
let color = "";
19+
const shadows: string[] = [];
2620

27-
if (shadow.type === "DROP_SHADOW" || shadow.type === "INNER_SHADOW") {
28-
x = shadow.offset.x;
29-
y = shadow.offset.y;
30-
blur = shadow.radius;
31-
spread = shadow.spread ? `${shadow.spread}px ` : "";
32-
inner = shadow.type === "INNER_SHADOW" ? " inset" : "";
33-
color = htmlColor(shadow.color, shadow.color.a);
34-
} else if (shadow.type === "LAYER_BLUR") {
35-
x = shadow.radius;
36-
y = shadow.radius;
37-
blur = shadow.radius;
38-
}
21+
shadowEffects.forEach((shadow) => {
22+
let x = 0;
23+
let y = 0;
24+
let blur = 0;
25+
let spread = "";
26+
let inner = "";
27+
let color = "";
28+
29+
if (shadow.type === "DROP_SHADOW" || shadow.type === "INNER_SHADOW") {
30+
x = shadow.offset.x;
31+
y = shadow.offset.y;
32+
blur = shadow.radius;
33+
spread = shadow.spread ? `${shadow.spread}px ` : "";
34+
inner = shadow.type === "INNER_SHADOW" ? " inset" : "";
35+
color = htmlColor(shadow.color, shadow.color.a);
36+
} else if (shadow.type === "LAYER_BLUR") {
37+
x = shadow.radius;
38+
y = shadow.radius;
39+
blur = shadow.radius;
40+
}
41+
42+
shadows.push(`${x}px ${y}px ${blur}px ${spread}${color}${inner}`);
43+
});
3944

4045
// Return box-shadow in the desired format
41-
return `${x}px ${y}px ${blur}px ${spread}${color}${inner}`;
46+
return shadows.join(", ");
4247
}
4348
}
4449
return "";

0 commit comments

Comments
 (0)