diff --git a/index.html b/index.html index a0446ae..104eb4d 100644 --- a/index.html +++ b/index.html @@ -48,6 +48,7 @@ ? "dark" : "light"; document.documentElement.dataset.theme = t; + document.documentElement.dataset.loading = "1"; })(); diff --git a/src/index.css b/src/index.css index a890b8f..64fb634 100644 --- a/src/index.css +++ b/src/index.css @@ -3,6 +3,10 @@ @import "@fontsource/poppins/latin-700.css"; @import "tailwindcss"; +html[data-loading] #root { + visibility: hidden; +} + @theme { /* Layout */ --color-surface: #f3f1e9; diff --git a/src/layout/main.layout.tsx b/src/layout/main.layout.tsx index 7bce954..2b135b9 100644 --- a/src/layout/main.layout.tsx +++ b/src/layout/main.layout.tsx @@ -35,12 +35,22 @@ export function MainLayout({ children }: MainLayoutProps) { const { theme, toggle } = useTheme(); const handleResize = useCallback(() => { - setLayout(computeLayout()); + setLayout((prev) => { + const next = computeLayout(); + if ( + prev.tileSize === next.tileSize && + prev.dims.rows === next.dims.rows && + prev.dims.cols === next.dims.cols + ) { + return prev; + } + return next; + }); }, []); useLayoutEffect(() => { + delete document.documentElement.dataset.loading; window.addEventListener("resize", handleResize); - handleResize(); return () => window.removeEventListener("resize", handleResize); }, [handleResize]);