Skip to content

Commit c7134e1

Browse files
committed
Conslidate border.
1 parent 2160662 commit c7134e1

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

packages/backend/src/html/htmlDefaultBuilder.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,24 @@ export class HtmlDefaultBuilder {
8181
const color = htmlColorFromFills(node.strokes);
8282
const borderStyle = node.dashPattern.length > 0 ? "dotted" : "solid";
8383

84+
const consolidateBorders = (border: number): string =>
85+
[`${sliceNum(border)}px`, color, borderStyle].filter((d) => d).join(" ");
86+
8487
if ("all" in commonBorder) {
8588
if (commonBorder.all === 0) {
8689
return this;
8790
}
8891
const weight = commonBorder.all;
8992
this.addStyles(
90-
formatWithJSX(
91-
"border",
92-
this.isJSX,
93-
[`${sliceNum(weight)}px`, color, borderStyle]
94-
.filter((d) => d)
95-
.join(" ")
96-
)
93+
formatWithJSX("border", this.isJSX, consolidateBorders(weight))
9794
);
9895
} else {
9996
if (commonBorder.left !== 0) {
10097
this.addStyles(
10198
formatWithJSX(
10299
"border-left",
103100
this.isJSX,
104-
`${sliceNum(commonBorder.left)}px ${color} ${borderStyle}`
101+
consolidateBorders(commonBorder.left)
105102
)
106103
);
107104
}
@@ -110,7 +107,7 @@ export class HtmlDefaultBuilder {
110107
formatWithJSX(
111108
"border-top",
112109
this.isJSX,
113-
`${sliceNum(commonBorder.top)}px ${color} ${borderStyle}`
110+
consolidateBorders(commonBorder.top)
114111
)
115112
);
116113
}
@@ -119,7 +116,7 @@ export class HtmlDefaultBuilder {
119116
formatWithJSX(
120117
"border-right",
121118
this.isJSX,
122-
`${sliceNum(commonBorder.right)}px ${color} ${borderStyle}`
119+
consolidateBorders(commonBorder.right)
123120
)
124121
);
125122
}
@@ -128,7 +125,7 @@ export class HtmlDefaultBuilder {
128125
formatWithJSX(
129126
"border-bottom",
130127
this.isJSX,
131-
`${sliceNum(commonBorder.bottom)}px ${color} ${borderStyle}`
128+
consolidateBorders(commonBorder.bottom)
132129
)
133130
);
134131
}

0 commit comments

Comments
 (0)