From 8a57d5d4afa3d27a8510ae8e7807bef9b42a7773 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Fri, 13 Oct 2023 02:23:32 -0400 Subject: [PATCH] refactor: third pass at CircularProgress --- .../lume/LumeDashboard/LumeDashboard.tsx | 46 +++---------------- 1 file changed, 6 insertions(+), 40 deletions(-) diff --git a/src/components/lume/LumeDashboard/LumeDashboard.tsx b/src/components/lume/LumeDashboard/LumeDashboard.tsx index d33e8c3..ffc28e1 100644 --- a/src/components/lume/LumeDashboard/LumeDashboard.tsx +++ b/src/components/lume/LumeDashboard/LumeDashboard.tsx @@ -118,16 +118,6 @@ const NetworkIndicator = ({ network }: { network: Network }) => { ); }; -function getTextDimensions( - fontSize: number, - ratios: { width: number; height: number }, -) { - const width = fontSize * ratios.width; - const height = fontSize * ratios.height; - - return { width, height }; -} - const CircularProgress = ({ chain, className, @@ -135,37 +125,13 @@ const CircularProgress = ({ chain: Network; className?: string; }) => { - const [fontRatio, setFontRatio] = useState({ - width: 0, - height: 0, - }); - useEffect(() => { - const testText = document.createElement("span"); - testText.style.fontSize = `${textSize}px`; - testText.style.position = "absolute"; - testText.style.left = "-9999px"; // This effectively hides the element - testText.textContent = "The quick brown fox jumps over the lazy dog"; - - document.body.appendChild(testText); - - const rect = testText.getBoundingClientRect(); - - setFontRatio({ - width: rect.width / textSize, - height: rect.height / textSize, - }); - - // Clean up after measurements - document.body.removeChild(testText); - }, []); - - const size = 55; + const size = 60; const progressWidth = 2; const circleWidth = 2; const radius = size / 2 - 10; const circumference = 2 * radius * Math.PI; const offset = circumference * ((100 - chain.sync) / 100); - const textSize = 11; + const fontSize = 15; return ( + style={{ transform: "rotate(90deg) translate(0px, -56px)" }}> {chain.sync}