@@ -89,9 +89,7 @@ function SidebarProvider({
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Helper to toggle the sidebar.
|
// Helper to toggle the sidebar.
|
||||||
const toggleSidebar = React.useCallback(() => {
|
const toggleSidebar = () => setOpen((open) => !open);
|
||||||
return isMobile ? setOpenMobile((open) => !open) : setOpen((open) => !open)
|
|
||||||
}, [isMobile, setOpen, setOpenMobile])
|
|
||||||
|
|
||||||
// Adds a keyboard shortcut to toggle the sidebar.
|
// Adds a keyboard shortcut to toggle the sidebar.
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
@@ -157,13 +155,15 @@ function Sidebar({
|
|||||||
collapsible = "offcanvas",
|
collapsible = "offcanvas",
|
||||||
className,
|
className,
|
||||||
children,
|
children,
|
||||||
|
forceSheet = false,
|
||||||
...props
|
...props
|
||||||
}: React.ComponentProps<"div"> & {
|
}: React.ComponentProps<"div"> & {
|
||||||
side?: "left" | "right"
|
side?: "left" | "right"
|
||||||
variant?: "sidebar" | "floating" | "inset"
|
variant?: "sidebar" | "floating" | "inset"
|
||||||
collapsible?: "offcanvas" | "icon" | "none"
|
collapsible?: "offcanvas" | "icon" | "none",
|
||||||
|
forceSheet?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { isMobile, state, openMobile, setOpenMobile } = useSidebar()
|
const { isMobile, state, open, setOpen } = useSidebar()
|
||||||
|
|
||||||
if (collapsible === "none") {
|
if (collapsible === "none") {
|
||||||
return (
|
return (
|
||||||
@@ -180,14 +180,14 @@ function Sidebar({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isMobile) {
|
if (isMobile || forceSheet) {
|
||||||
return (
|
return (
|
||||||
<Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
|
<Sheet open={open} onOpenChange={setOpen} {...props}>
|
||||||
<SheetContent
|
<SheetContent
|
||||||
data-sidebar="sidebar"
|
data-sidebar="sidebar"
|
||||||
data-slot="sidebar"
|
data-slot="sidebar"
|
||||||
data-mobile="true"
|
data-mobile="true"
|
||||||
className="bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden"
|
className="bg-sidebar text-sidebar-foreground rounded-br-2xl rounded-tr-2xl w-(--sidebar-width) p-0 [&>button]:hidden"
|
||||||
style={
|
style={
|
||||||
{
|
{
|
||||||
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
"--sidebar-width": SIDEBAR_WIDTH_MOBILE,
|
||||||
|
|||||||
@@ -33,9 +33,10 @@ export default function Layout() {
|
|||||||
<SideBar />
|
<SideBar />
|
||||||
<div className="flex flex-col w-full h-full">
|
<div className="flex flex-col w-full h-full">
|
||||||
{ authData ? <Header /> : null}
|
{ authData ? <Header /> : null}
|
||||||
{/* <Header /> */}
|
<div className="w-full h-full p-2.5">
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</SidebarProvider>
|
</SidebarProvider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,13 +2,53 @@ import { Label } from '@/components/ui/label';
|
|||||||
import { SidebarTrigger } from '@/components/ui/sidebar';
|
import { SidebarTrigger } from '@/components/ui/sidebar';
|
||||||
import { Separator } from '@/components/ui/separator';
|
import { Separator } from '@/components/ui/separator';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { useAuthStore } from '@/store/authStore';
|
||||||
|
import { LogOutIcon } from 'lucide-react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { PageRouting } from '@/const/PageRouting';
|
||||||
|
|
||||||
export default function Header() {
|
export default function Header() {
|
||||||
|
const navigate = useNavigate();
|
||||||
|
const { logout } = useAuthStore();
|
||||||
|
|
||||||
|
const handleClickLogoutButton = () => {
|
||||||
|
logout();
|
||||||
|
navigate(PageRouting["LOGIN"].path);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className="flex shrink-0 items-center gap-2 border-b px-4 w-full h-12">
|
<header className="w-full flex shrink-0 flex-row justify-between items-center border-b px-4 h-12">
|
||||||
|
<div className="flex flex-row gap-2 items-center">
|
||||||
<SidebarTrigger className="-ml-1" />
|
<SidebarTrigger className="-ml-1" />
|
||||||
<Separator orientation="vertical" className="mr-2 data-[orientation=vertical]:h-4" />
|
<Separator orientation="vertical" className="mr-2 data-[orientation=vertical]:h-4" />
|
||||||
<Label>{import.meta.env.BASE_URL}</Label>
|
<Label>{import.meta.env.BASE_URL}</Label>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Button
|
||||||
|
className={`
|
||||||
|
group flex items-center justify-start
|
||||||
|
pr-2 pl-2 border border-red-500 bg-white
|
||||||
|
transition-all duration-150
|
||||||
|
w-10 hover:w-25 hover:bg-red-500
|
||||||
|
overflow-hidden rounded-md
|
||||||
|
`}
|
||||||
|
type="button"
|
||||||
|
onClick={handleClickLogoutButton}
|
||||||
|
>
|
||||||
|
<LogOutIcon
|
||||||
|
className="text-red-500 transition-colors duration-150 group-hover:text-white"
|
||||||
|
/>
|
||||||
|
<span className="
|
||||||
|
text-red-500 group-hover:text-white
|
||||||
|
opacity-0 scale-1
|
||||||
|
transition-all duration-150
|
||||||
|
group-hover:opacity-100 group-hover:scale-100
|
||||||
|
">
|
||||||
|
로그아웃
|
||||||
|
</span>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</header>
|
</header>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
|
|
||||||
export default function SideBar() {
|
export default function SideBar() {
|
||||||
return (
|
return (
|
||||||
<Sidebar>
|
<Sidebar forceSheet={true}>
|
||||||
|
|
||||||
</Sidebar>
|
</Sidebar>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user