diff --git a/src/components/Art.tsx b/src/components/Art.tsx index dc78c8b..dfb5527 100644 --- a/src/components/Art.tsx +++ b/src/components/Art.tsx @@ -9,6 +9,9 @@ interface AsciiArtComponentProps { const AsciiArtComponent: Component = (props) => { const [asciiArt, setAsciiArt] = createSignal(""); const [scale, setScale] = createSignal(1); + const [windowWidth, setWindowWidth] = createSignal( + typeof window !== "undefined" ? window.innerWidth : 1024, + ); const imageToAscii = ( img: HTMLImageElement, @@ -46,46 +49,63 @@ const AsciiArtComponent: Component = (props) => { }; onMount(() => { - const img = new Image(); - img.src = props.imagePath; - img.onload = () => { - setAsciiArt( - imageToAscii(img, props.maxWidth ?? 500, props.maxHeight ?? 1000), - ); - }; - - const handleResize = () => { - setScale(window.devicePixelRatio || 1); - }; + // Only run client-side code if window is available + if (typeof window !== "undefined") { + const img = new Image(); + img.src = props.imagePath; + img.onload = () => { + setAsciiArt( + imageToAscii(img, props.maxWidth ?? 500, props.maxHeight ?? 1000), + ); + }; - handleResize(); + const handleResize = () => { + setScale(window.devicePixelRatio || 1); + setWindowWidth(window.innerWidth); + }; - window.addEventListener("resize", handleResize); - window.addEventListener("zoom", handleResize); + handleResize(); + window.addEventListener("resize", handleResize); + window.addEventListener("zoom", handleResize); - onCleanup(() => { - window.removeEventListener("resize", handleResize); - window.removeEventListener("zoom", handleResize); - }); + onCleanup(() => { + window.removeEventListener("resize", handleResize); + window.removeEventListener("zoom", handleResize); + }); + } }); + // Responsive font sizing logic + const calculateFontSize = () => { + const width = windowWidth(); + if (width < 640) { + return `${2.3 / scale()}px`; + } else if (width < 768) { + return `${2.4 / scale()}px`; + } + return `${2.5 / scale()}px`; + }; + return (
         {asciiArt()}
diff --git a/src/routes/index.tsx b/src/routes/index.tsx
index 6e8553c..62b9717 100644
--- a/src/routes/index.tsx
+++ b/src/routes/index.tsx
@@ -3,29 +3,42 @@ import Art from "../components/Art";
 export default function Home() {
   return (
     
-
+
logo

Flora

-

Flora is a team of developers aiming to create practical and useful solutions for real problems.

+

+ Flora is a team of developers aiming to create practical and useful + solutions for real problems. +

Our current projects:{" "}
orchid - +
{" "} and{" "}
aster - +
{"."}

- Founded by nam and rex. Follow us on GitHub. + Founded by nam and{" "} + rex. Follow us on{" "} + GitHub.