diff --git a/src/app.tsx b/src/app.tsx index eaf5de0..fce6b23 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -5,9 +5,7 @@ import { ErrorBoundary, onMount, onCleanup, - Suspense, - Show, - createSignal + Suspense } from "solid-js"; import "./app.css"; import { LeftBar, RightBar } from "./components/Bars"; @@ -20,56 +18,30 @@ import { createWindowWidth, isMobile } from "~/lib/resize-utils"; function AppLayout(props: { children: any }) { const { - leftBarSize, - rightBarSize, - setCenterWidth, - centerWidth, leftBarVisible, rightBarVisible, setLeftBarVisible, - setRightBarVisible, - barsInitialized + setRightBarVisible } = useBars(); let lastScrollY = 0; const SCROLL_THRESHOLD = 75; - // Track if we're on the client (hydrated) - starts false on server - const [isClient, setIsClient] = createSignal(false); - // Use onMount to avoid hydration issues - window operations are client-only onMount(() => { - setIsClient(true); const windowWidth = createWindowWidth(); createEffect(() => { - const handleResize = () => { - const currentIsMobile = isMobile(windowWidth()); + const currentIsMobile = isMobile(windowWidth()); - // Show bars when switching to desktop - if (!currentIsMobile) { - setLeftBarVisible(true); - setRightBarVisible(true); - } - - // On mobile, leftBarSize() is always 0 (overlay mode) - const newWidth = window.innerWidth - leftBarSize() - rightBarSize(); - setCenterWidth(newWidth); - }; - - // Call immediately and whenever dependencies change - handleResize(); + // Show bars when switching to desktop + if (!currentIsMobile) { + setLeftBarVisible(true); + setRightBarVisible(true); + } }); }); - // Recalculate when bar sizes change (visibility or actual resize) - createEffect(() => { - if (typeof window === "undefined") return; - // On mobile, leftBarSize() is always 0 (overlay mode) - const newWidth = window.innerWidth - leftBarSize() - rightBarSize(); - setCenterWidth(newWidth); - }); - // Auto-hide on scroll (mobile only) onMount(() => { const windowWidth = createWindowWidth(); @@ -194,40 +166,20 @@ function AppLayout(props: { children: any }) { <>
- } - > -
- -
- }> - {props.children} - +
+ +
+ }>{props.children}
- +
diff --git a/src/components/Bars.tsx b/src/components/Bars.tsx index 2efd0c6..f6c78ff 100644 --- a/src/components/Bars.tsx +++ b/src/components/Bars.tsx @@ -170,10 +170,8 @@ export function RightBarContent() { } export function LeftBar() { - const { setLeftBarSize, leftBarSize, leftBarVisible, setLeftBarVisible } = - useBars(); + const { leftBarSize, leftBarVisible, setLeftBarVisible } = useBars(); let ref: HTMLDivElement | undefined; - let actualWidth = 0; const [recentPosts, setRecentPosts] = createSignal( undefined @@ -208,21 +206,6 @@ export function LeftBar() { setIsMounted(true); if (ref) { - const updateSize = () => { - actualWidth = ref?.offsetWidth || 0; - setLeftBarSize(leftBarVisible() ? actualWidth : 0); - }; - - updateSize(); - - const resizeObserver = new ResizeObserver((entries) => { - requestAnimationFrame(() => { - actualWidth = ref?.offsetWidth || 0; - setLeftBarSize(leftBarVisible() ? actualWidth : 0); - }); - }); - resizeObserver.observe(ref); - // Focus trap for accessibility on mobile const handleKeyDown = (e: KeyboardEvent) => { const isMobile = window.innerWidth < 768; @@ -260,7 +243,6 @@ export function LeftBar() { ref.addEventListener("keydown", handleKeyDown); onCleanup(() => { - resizeObserver.disconnect(); ref?.removeEventListener("keydown", handleKeyDown); }); } @@ -303,10 +285,6 @@ export function LeftBar() { }, 0); }); - createEffect(() => { - setLeftBarSize(leftBarVisible() ? actualWidth : 0); - }); - return (