Browse Source

feat: Add sidebar close button

pull/367/head
Daniel 1 year ago
parent
commit
c2cdc92ae9
  1. 21
      src/components/Sidebar.tsx

21
src/components/Sidebar.tsx

@ -12,9 +12,12 @@ import {
MapIcon, MapIcon,
MessageSquareIcon, MessageSquareIcon,
SettingsIcon, SettingsIcon,
SidebarCloseIcon,
SidebarOpenIcon,
UsersIcon, UsersIcon,
ZapIcon, ZapIcon,
} from "lucide-react"; } from "lucide-react";
import { useState } from "react";
export interface SidebarProps { export interface SidebarProps {
children?: React.ReactNode; children?: React.ReactNode;
@ -25,6 +28,7 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
const myNode = nodes.get(hardware.myNodeNum); const myNode = nodes.get(hardware.myNodeNum);
const myMetadata = metadata.get(0); const myMetadata = metadata.get(0);
const { activePage, setActivePage, setDialogOpen } = useDevice(); const { activePage, setActivePage, setDialogOpen } = useDevice();
const [showSidebar, setShowSidebar] = useState<boolean>(true);
interface NavLink { interface NavLink {
name: string; name: string;
@ -60,7 +64,7 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
}, },
]; ];
return ( return showSidebar ? (
<div className="min-w-[280px] max-w-min flex-col overflow-y-auto border-r-[0.5px] border-slate-300 bg-transparent dark:border-slate-700"> <div className="min-w-[280px] max-w-min flex-col overflow-y-auto border-r-[0.5px] border-slate-300 bg-transparent dark:border-slate-700">
<div className="flex justify-between px-8 pt-6"> <div className="flex justify-between px-8 pt-6">
<div> <div>
@ -76,6 +80,12 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
> >
<EditIcon size={16} /> <EditIcon size={16} />
</button> </button>
<button
type="button"
onClick={() => setShowSidebar(false)}
>
<SidebarCloseIcon size={24} />
</button>
</div> </div>
<div className="px-8 pb-6"> <div className="px-8 pb-6">
<div className="flex items-center"> <div className="flex items-center">
@ -109,5 +119,14 @@ export const Sidebar = ({ children }: SidebarProps): JSX.Element => {
</SidebarSection> </SidebarSection>
{children} {children}
</div> </div>
) : (
<div className="px-1 pt-8">
<button
type="button"
onClick={() => setShowSidebar(true)}
>
<SidebarOpenIcon size={24} />
</button>
</div>
); );
}; };

Loading…
Cancel
Save