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 { SidebarProvider } from "@/components/ui/sidebar"
|
||||||
import { ReactNode } from "react"
|
import { ReactNode } from "react"
|
||||||
import { DashboardSidebar } from "./_components/sidebar"
|
import { DashboardSidebar } from "./_components/sidebar"
|
||||||
|
import { SidebarClient } from "./_components/sidebar-client"
|
||||||
|
|
||||||
export default function DashboardLayout({
|
export default function DashboardLayout({
|
||||||
children
|
children
|
||||||
@@ -9,12 +10,14 @@ export default function DashboardLayout({
|
|||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<SidebarProvider>
|
<SidebarProvider>
|
||||||
|
<SidebarClient>
|
||||||
<div className="min-h-screen flex w-full">
|
<div className="min-h-screen flex w-full">
|
||||||
<DashboardSidebar />
|
<DashboardSidebar />
|
||||||
<main className="flex-1 overflow-auto">
|
<main className="flex-1 overflow-auto">
|
||||||
{children}
|
{children}
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
</SidebarClient>
|
||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user