From bb34e8139e1d53607d29672560ea7d1e73793bf5 Mon Sep 17 00:00:00 2001 From: Kit Loong Date: Mon, 24 Jun 2024 21:23:56 +0800 Subject: [PATCH] Simplify sidebar toggle --- .../Layout/Dashboard/Header/Header.tsx | 2 +- .../Dashboard/Header/HeaderSidebarToggler.tsx | 31 ++++---------- .../Layout/Dashboard/Sidebar/Sidebar.tsx | 13 +----- .../Layout/Dashboard/SidebarProvider.tsx | 9 +--- src/styles/layout/_sidebar.scss | 41 +++++++++++++------ 5 files changed, 39 insertions(+), 57 deletions(-) diff --git a/src/components/Layout/Dashboard/Header/Header.tsx b/src/components/Layout/Dashboard/Header/Header.tsx index d62156d..1dafda0 100644 --- a/src/components/Layout/Dashboard/Header/Header.tsx +++ b/src/components/Layout/Dashboard/Header/Header.tsx @@ -9,7 +9,7 @@ import Breadcrumb from '@/components/Layout/Dashboard/Breadcrumb/Breadcrumb' export default function Header() { return (
- + diff --git a/src/components/Layout/Dashboard/Header/HeaderSidebarToggler.tsx b/src/components/Layout/Dashboard/Header/HeaderSidebarToggler.tsx index 9dbb893..1de5726 100644 --- a/src/components/Layout/Dashboard/Header/HeaderSidebarToggler.tsx +++ b/src/components/Layout/Dashboard/Header/HeaderSidebarToggler.tsx @@ -8,35 +8,20 @@ import { faBars } from '@fortawesome/free-solid-svg-icons' export default function HeaderSidebarToggler() { const { showSidebarState: [isShowSidebar, setIsShowSidebar], - showSidebarMdState: [isShowSidebarMd, setIsShowSidebarMd], } = useSidebar() const toggleSidebar = () => { setIsShowSidebar(!isShowSidebar) } - const toggleSidebarMd = () => { - setIsShowSidebarMd(!isShowSidebarMd) - } - return ( - <> - - - + ) } diff --git a/src/components/Layout/Dashboard/Sidebar/Sidebar.tsx b/src/components/Layout/Dashboard/Sidebar/Sidebar.tsx index 598d8e8..7ec5540 100644 --- a/src/components/Layout/Dashboard/Sidebar/Sidebar.tsx +++ b/src/components/Layout/Dashboard/Sidebar/Sidebar.tsx @@ -10,10 +10,7 @@ import { useSidebar } from '@/components/Layout/Dashboard/SidebarProvider' export default function Sidebar({ children }: { children: React.ReactNode }) { const [isNarrow, setIsNarrow] = useState(false) - const { - showSidebarState: [isShowSidebar], - showSidebarMdState: [isShowSidebarMd, setIsShowSidebarMd], - } = useSidebar() + const { showSidebarState: [isShowSidebar] } = useSidebar() const toggleIsNarrow = () => { const newValue = !isNarrow @@ -28,19 +25,11 @@ export default function Sidebar({ children }: { children: React.ReactNode }) { } }, [setIsNarrow]) - // On first time load only - useEffect(() => { - if (localStorage.getItem('isShowSidebarMd')) { - setIsShowSidebarMd(localStorage.getItem('isShowSidebarMd') === 'true') - } - }, [setIsShowSidebarMd]) - return (