Fixed visual bug at Import Flows modal cards
This commit is contained in:
parent
d89e4bc985
commit
41b6a2c6fe
3 changed files with 61 additions and 91 deletions
|
|
@ -24,7 +24,7 @@ export default function ButtonBox({
|
||||||
}) {
|
}) {
|
||||||
let bigCircle: string;
|
let bigCircle: string;
|
||||||
let smallCircle: string;
|
let smallCircle: string;
|
||||||
let minTitleFontSize: number;
|
let titleFontSize: string;
|
||||||
let descriptionFontSize: string;
|
let descriptionFontSize: string;
|
||||||
let padding: string;
|
let padding: string;
|
||||||
let marginTop: string;
|
let marginTop: string;
|
||||||
|
|
@ -32,88 +32,48 @@ export default function ButtonBox({
|
||||||
let width: string;
|
let width: string;
|
||||||
let textHeight: number;
|
let textHeight: number;
|
||||||
let textWidth: number;
|
let textWidth: number;
|
||||||
const [truncate, setTruncate] = useState<boolean>(false);
|
|
||||||
switch (size) {
|
switch (size) {
|
||||||
case "small":
|
case "small":
|
||||||
bigCircle = "h-12 w-12";
|
bigCircle = "h-12 w-12";
|
||||||
smallCircle = "h-8 w-8";
|
smallCircle = "h-8 w-8";
|
||||||
minTitleFontSize =9;
|
titleFontSize = "text-sm";
|
||||||
descriptionFontSize = "text-xs";
|
descriptionFontSize = "text-xs";
|
||||||
padding = "p-2 py-3";
|
padding = "p-2 py-3";
|
||||||
marginTop = "mt-2";
|
marginTop = "mt-2";
|
||||||
height = "h-36";
|
height = "h-36";
|
||||||
textHeight = 70;
|
width = "w-32";
|
||||||
textWidth = 40;
|
break;
|
||||||
width = "w-32";
|
case "medium":
|
||||||
break;
|
bigCircle = "h-16 w-16";
|
||||||
case "medium":
|
smallCircle = "h-12 w-12";
|
||||||
bigCircle = "h-16 w-16";
|
titleFontSize = "text-base";
|
||||||
smallCircle = "h-12 w-12";
|
descriptionFontSize = "text-sm";
|
||||||
minTitleFontSize = 11;
|
padding = "p-4 py-5";
|
||||||
descriptionFontSize = "text-sm";
|
marginTop = "mt-3";
|
||||||
padding = "p-4 py-5";
|
height = "h-44";
|
||||||
marginTop = "mt-3";
|
width = "w-36";
|
||||||
textHeight = 112;
|
break;
|
||||||
textWidth = 162;
|
case "big":
|
||||||
height = "h-44";
|
bigCircle = "h-20 w-20";
|
||||||
width = "w-36";
|
smallCircle = "h-16 w-16";
|
||||||
break;
|
titleFontSize = "text-lg";
|
||||||
case "big":
|
descriptionFontSize = "text-sm";
|
||||||
bigCircle = "h-20 w-20";
|
padding = "p-8 py-10";
|
||||||
smallCircle = "h-16 w-16";
|
marginTop = "mt-6";
|
||||||
minTitleFontSize = 12;
|
height = "h-56";
|
||||||
descriptionFontSize = "text-sm";
|
width = "w-44";
|
||||||
padding = "p-8 py-10";
|
break;
|
||||||
marginTop = "mt-6";
|
default:
|
||||||
height = "h-56";
|
bigCircle = "h-20 w-20";
|
||||||
width = "w-44";
|
smallCircle = "h-16 w-16";
|
||||||
break;
|
titleFontSize = "text-lg";
|
||||||
default:
|
descriptionFontSize = "text-sm";
|
||||||
bigCircle = "h-20 w-20";
|
padding = "p-8 py-10";
|
||||||
smallCircle = "h-16 w-16";
|
marginTop = "mt-6";
|
||||||
minTitleFontSize = 12;
|
height = "h-56";
|
||||||
descriptionFontSize = "text-sm";
|
width = "w-44";
|
||||||
padding = "p-8 py-10";
|
break;
|
||||||
marginTop = "mt-6";
|
|
||||||
height = "h-56";
|
|
||||||
width = "w-44";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [fontSize, setFontSize] = useState<number>(16); // Initial font size value
|
|
||||||
|
|
||||||
const titleRef = useRef<HTMLHeadingElement>(null);
|
|
||||||
const parentDivRef = useRef<HTMLDivElement>(null);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
const textElement = titleRef.current;
|
|
||||||
const parentDivElement = parentDivRef.current;
|
|
||||||
|
|
||||||
if (!textElement || !parentDivElement) return;
|
|
||||||
|
|
||||||
const parentDivHeight = parentDivElement.offsetHeight;
|
|
||||||
const parentDivWidth = parentDivElement.offsetWidth;
|
|
||||||
let textElementHeight = textElement.scrollHeight;
|
|
||||||
let textElementWidth = textElement.scrollWidth;
|
|
||||||
|
|
||||||
if (textElementHeight > parentDivHeight || textElementWidth > parentDivWidth && fontSize > minTitleFontSize) {
|
|
||||||
let newFontSize = fontSize;
|
|
||||||
|
|
||||||
while (textElementHeight > parentDivHeight || textElementWidth > parentDivWidth) {
|
|
||||||
newFontSize -= 1;
|
|
||||||
textElement.style.fontSize = `${newFontSize}px`;
|
|
||||||
textElementHeight = textElement.scrollHeight;
|
|
||||||
textElementWidth = textElement.scrollWidth;
|
|
||||||
}
|
|
||||||
if(newFontSize <= minTitleFontSize){
|
|
||||||
setTruncate(true);
|
|
||||||
setFontSize(minTitleFontSize);
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
setFontSize(newFontSize);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}, [title, size, fontSize]);
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -136,15 +96,17 @@ export default function ButtonBox({
|
||||||
<div className={textColor}>{icon}</div>
|
<div className={textColor}>{icon}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div ref={parentDivRef} className="w-full h-1/2 mt-auto">
|
<div className="w-full mt-auto mb-auto">
|
||||||
<div
|
<h3
|
||||||
ref={titleRef}
|
className={classNames(
|
||||||
className={classNames(truncate?"truncate":"",
|
"w-full font-semibold break-words text-white dark:text-white/80 truncate-multiline",
|
||||||
" font-semibold text-white h-full dark:text-white/80",
|
titleFontSize,
|
||||||
)} >
|
marginTop
|
||||||
{title}
|
)}
|
||||||
</div>
|
>
|
||||||
</div>
|
{title}
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,7 @@ export default function ImportModal() {
|
||||||
!loadingExamples &&
|
!loadingExamples &&
|
||||||
examples.map((example, index) => {
|
examples.map((example, index) => {
|
||||||
return (
|
return (
|
||||||
<div id="index">
|
<div key={index}>
|
||||||
{" "}
|
{" "}
|
||||||
<ButtonBox
|
<ButtonBox
|
||||||
size="small"
|
size="small"
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,14 @@ module.exports = {
|
||||||
display: "none",
|
display: "none",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
".truncate-multiline": {
|
||||||
|
"display": "-webkit-box",
|
||||||
|
"-webkit-line-clamp": "3", /* Change this number to the number of lines you want to show */
|
||||||
|
"-webkit-box-orient": "vertical",
|
||||||
|
"overflow": "hidden",
|
||||||
|
"text-overflow": "ellipsis",
|
||||||
|
},
|
||||||
|
|
||||||
".arrow-hide": {
|
".arrow-hide": {
|
||||||
"&::-webkit-inner-spin-button": {
|
"&::-webkit-inner-spin-button": {
|
||||||
"-webkit-appearance": "none",
|
"-webkit-appearance": "none",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue