Added mobile support
This commit is contained in:
23
src/app/(admin)/dashboard/_components/sidebar-client.tsx
Normal file
23
src/app/(admin)/dashboard/_components/sidebar-client.tsx
Normal file
@@ -0,0 +1,23 @@
|
||||
"use client"
|
||||
|
||||
import { SidebarTrigger } from "@/components/ui/sidebar"
|
||||
import { useIsMobile } from "@/hooks/use-mobile"
|
||||
import { ReactNode } from "react"
|
||||
|
||||
export function SidebarClient({ children }: { children: ReactNode }) {
|
||||
const isMobile = useIsMobile()
|
||||
|
||||
if (isMobile) {
|
||||
return (
|
||||
<div className="flex flex-col w-full">
|
||||
<div className="p-2 border-b flex items-center gap-1">
|
||||
<SidebarTrigger />
|
||||
<span className="text-xl">Linker</span>
|
||||
</div>
|
||||
<div className="flex-1 flex">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return children
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { SidebarProvider } from "@/components/ui/sidebar"
|
||||
import { ReactNode } from "react"
|
||||
import { DashboardSidebar } from "./_components/sidebar"
|
||||
import { SidebarClient } from "./_components/sidebar-client"
|
||||
|
||||
export default function DashboardLayout({
|
||||
children
|
||||
@@ -9,12 +10,14 @@ export default function DashboardLayout({
|
||||
}) {
|
||||
return (
|
||||
<SidebarProvider>
|
||||
<div className="min-h-screen flex w-full">
|
||||
<DashboardSidebar />
|
||||
<main className="flex-1 overflow-auto">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
<SidebarClient>
|
||||
<div className="min-h-screen flex w-full">
|
||||
<DashboardSidebar />
|
||||
<main className="flex-1 overflow-auto">
|
||||
{children}
|
||||
</main>
|
||||
</div>
|
||||
</SidebarClient>
|
||||
</SidebarProvider>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user