diff --git a/packages/ui/src/components/AppShell.tsx b/packages/ui/src/components/AppShell.tsx index 8f4cea16..56f328a5 100644 --- a/packages/ui/src/components/AppShell.tsx +++ b/packages/ui/src/components/AppShell.tsx @@ -1,5 +1,3 @@ -'use client'; - import * as React from 'react'; import { clsx } from 'clsx'; import { Menu, X } from 'lucide-react'; @@ -8,42 +6,6 @@ type ShellStyle = React.CSSProperties & { '--bl-app-sidebar-width'?: string; }; -type ShellMediaQueryList = { - matches: boolean; - addEventListener?: (type: 'change', listener: () => void) => void; - removeEventListener?: (type: 'change', listener: () => void) => void; - addListener?: (listener: () => void) => void; - removeListener?: (listener: () => void) => void; -}; - -function useDesktopShell() { - const [isDesktop, setIsDesktop] = React.useState(false); - - React.useEffect(() => { - const browser = globalThis as typeof globalThis & { - matchMedia?: (query: string) => ShellMediaQueryList; - }; - const media = browser.matchMedia?.('(min-width: 1024px)'); - - if (!media) { - return undefined; - } - - const sync = () => setIsDesktop(media.matches); - - sync(); - if (media.addEventListener && media.removeEventListener) { - media.addEventListener('change', sync); - return () => media.removeEventListener?.('change', sync); - } - - media.addListener?.(sync); - return () => media.removeListener?.(sync); - }, []); - - return isDesktop; -} - export interface AppShellProps extends React.HTMLAttributes { sidebarWidth?: number; } @@ -63,12 +25,55 @@ export function AppShell({ return (
+ {children}
); @@ -116,18 +121,12 @@ export function AppShellMobileToggle({ children, ...props }: AppShellMobileToggleProps) { - const isDesktop = useDesktopShell(); - - if (isDesktop) { - return null; - } - return (