mirror of
https://github.com/ershisan99/DevToysWeb.git
synced 2025-12-17 04:59:23 +00:00
feat: add a toggle for sidebar
This commit is contained in:
24
components/client-layout.tsx
Normal file
24
components/client-layout.tsx
Normal file
@@ -0,0 +1,24 @@
|
||||
"use client";
|
||||
|
||||
import React, { PropsWithChildren } from "react";
|
||||
|
||||
import { cn } from "@/lib/style";
|
||||
import { SidebarStatus, useSidebarStatus } from "@/contexts/sidebar";
|
||||
|
||||
export function ClientLayout({ children }: PropsWithChildren) {
|
||||
const sidebarStatus = useSidebarStatus();
|
||||
const isOpen = sidebarStatus === SidebarStatus.Open;
|
||||
const isClosed = sidebarStatus === SidebarStatus.Closed;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
"grid h-full grid-rows-[3.5rem_1fr] transition-all",
|
||||
isOpen && "grid-cols-[18rem_1fr]",
|
||||
isClosed && "grid-cols-[0_1fr]"
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user