Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 730c161

Browse files
Merge pull request #339 from mousheng/improve_widthCalculator_and_heightCalculator
improve_widthCalculator_and_heightCalculator
2 parents 1974df2 + e9c5fcc commit 730c161

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

‎client/packages/lowcoder/src/comps/controls/styleControlConstants.tsx‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -945,45 +945,42 @@ export type CarouselStyleType = StyleConfigType<typeof CarouselStyle>;
945945
export type RichTextEditorStyleType = StyleConfigType<typeof RichTextEditorStyle>;
946946

947947
export function widthCalculator(margin: string) {
948-
const marginArr = margin?.trim().split(" ") || "";
948+
const marginArr = margin?.trim().replace(/\s+/g,' ').split(" ") || "";
949949
if (marginArr.length === 1) {
950950
return `calc(100% - ${
951-
parseInt(margin.replace(/[^\d.]/g, "")) * 2 + margin.replace(/[0-9]/g, "")
951+
parseInt(margin.replace(/[^\d.]/g, "")) * 2 +
952+
(margin.replace(/[0-9]/g, "") || "px")
952953
})`;
953954
} else if (marginArr.length === 2 || marginArr.length === 3) {
954955
return `calc(100% - ${
955956
parseInt(marginArr[1].replace(/[^\d.]/g, "")) * 2 +
956-
marginArr[1].replace(/[0-9]/g, "")
957+
(marginArr[1].replace(/[0-9]/g, "")||'px')
957958
})`;
958959
} else {
959960
return `calc(100% - ${
960961
parseInt(marginArr[1]?.replace(/[^\d.]/g, "") || "0") +
961-
marginArr[1]?.replace(/[0-9]/g, "" || "px")
962+
(marginArr[1]?.replace(/[0-9]/g, "") || "px")
962963
} - ${
963964
parseInt(marginArr[3]?.replace(/[^\d.]/g, "") || "0") +
964-
marginArr[3]?.replace(/[0-9]/g, "" || "px")
965+
(marginArr[3]?.replace(/[0-9]/g, "") || "px")
965966
})`;
966967
}
967968
}
968969

969970
export function heightCalculator(margin: string) {
970971
const marginArr = margin?.trim().split(" ") || "";
971-
if (marginArr.length === 1) {
972-
return `calc(100% - ${
973-
parseInt(margin.replace(/[^\d.]/g, "")) * 2 + margin.replace(/[0-9]/g, "")
974-
})`;
975-
} else if (marginArr.length === 2) {
972+
if (marginArr.length === 1 || marginArr.length === 2) {
976973
return `calc(100% - ${
977-
parseInt(marginArr[0].replace(/[^\d.]/g, "")) * 2 +
978-
marginArr[0].replace(/[0-9]/g, "")
974+
parseInt(marginArr[0].replace(/[^\d.]/g, "")) * 2 +
975+
(marginArr[0].replace(/[0-9]/g, "")||'px')
979976
})`;
980-
}else {
977+
}else if(marginArr.length>2){
981978
return `calc(100% - ${
982979
parseInt(marginArr[0]?.replace(/[^\d.]/g, "") || "0") +
983-
marginArr[0]?.replace(/[0-9]/g, "") || "px"
980+
(marginArr[0]?.replace(/[0-9]/g, "") || "px")
984981
} - ${
985982
parseInt(marginArr[2]?.replace(/[^\d.]/g, "") || "0") +
986-
marginArr[2]?.replace(/[0-9]/g, "") || "px"
983+
(marginArr[2]?.replace(/[0-9]/g, "") || "px")
987984
})`;
988985
}
989986
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /