From 758cb6a9f036f0dc2af436b57012dc08e87d4479 Mon Sep 17 00:00:00 2001 From: Neshura Date: Fri, 9 Dec 2022 18:29:47 +0100 Subject: [PATCH] Various changes Removed debug logging, implemented Issue #7 --- components/sidebar.tsx | 58 ++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/components/sidebar.tsx b/components/sidebar.tsx index ccf3a7f..35386ec 100644 --- a/components/sidebar.tsx +++ b/components/sidebar.tsx @@ -15,37 +15,51 @@ function stopPropagation(e: any) { const Sidebar = () => { const isMobile = useWindowSize(); - console.log(isMobile); // DEBUG const router = useRouter(); - const [active, setActive] = useState(!isMobile); - const { maps, isLoading, isError } = useNavbar(); - + const [active, setActive] = useState(isMobile); + const { maps, isLoading, isError }:{ maps: ReadyOrNotMap[], isLoading: boolean, isError: boolean} = useNavbar(); - if (isError) { return (
) } + if(typeof(isMobile) === "boolean" && typeof(active) === "undefined") { + setActive(!isMobile); + } + + if (isError) { + return ( + <> +
+
+ + ) + } else if (isLoading) { return ( -
- -
+ <> +
+ +
+
+ ) } else { - // > is a placeholder return ( -
setActive(!active)}> - -
- {active" : "<" }/> + <> +
setActive(!active)}> + +
+ {active" : "<"} /> +
-
+
+ ); } }