diff --git a/src/layouts/dashboard/layout.tsx b/src/layouts/dashboard/layout.tsx index 2b8f0fcb2..de62b93a4 100644 --- a/src/layouts/dashboard/layout.tsx +++ b/src/layouts/dashboard/layout.tsx @@ -7,6 +7,13 @@ import Main from './main'; // import Header from './header'; import NavMini from './nav-mini'; import NavVertical from './nav-vertical'; +import {useState} from "react"; +import {NAV} from "@src/layouts/config-layout.ts"; +import Stack from "@mui/material/Stack"; +import { + IconChevronLeft, + IconChevronRight +} from "@tabler/icons-react"; // ---------------------------------------------------------------------- @@ -16,7 +23,17 @@ type Props = { export default function DashboardLayout({ children }: Props) { const nav = useBoolean(); - + const [sidebarWidth, setSidebarWidth ] = useState(NAV.W_VERTICAL); // State to control LoginModal visibility + const [triggerPosition, setTriggerPosition ] = useState(NAV.W_MINI + NAV.W_VERTICAL ); // State to control LoginModal visibility + const toggleSidebarWidth = () => { + if (sidebarWidth === NAV.W_VERTICAL) { + setSidebarWidth(NAV.W_MINI); + setTriggerPosition(NAV.W_MINI *2 - 1); + } else { + setSidebarWidth(NAV.W_VERTICAL); + setTriggerPosition(NAV.W_MINI + NAV.W_VERTICAL - 1); + } + }; return ( <> {/*
*/} @@ -28,8 +45,41 @@ export default function DashboardLayout({ children }: Props) { flexDirection: { xs: 'column', md: 'row' }, }} > + `dashed 1px ${theme.palette.divider}`, + borderTop: (theme) => `dashed 1px ${theme.palette.divider}`, + borderBottom: (theme) => `dashed 1px ${theme.palette.divider}`, + transition: 'all 0.7s ease', + position: 'fixed', + top: '7px', + left: triggerPosition, + cursor: 'pointer', + zIndex: 20, + }}> + + + { + sidebarWidth === NAV.W_VERTICAL ? ( + + ) : ( + ) + } + + + - +
{children}
diff --git a/src/layouts/dashboard/nav-vertical.tsx b/src/layouts/dashboard/nav-vertical.tsx index 7f3e58b7f..dfc3bcb93 100644 --- a/src/layouts/dashboard/nav-vertical.tsx +++ b/src/layouts/dashboard/nav-vertical.tsx @@ -22,27 +22,23 @@ import { useNavData } from './config-navigation'; // LAYOUT IMPORTS import { NAV } from '../config-layout'; import { AccountPopover, NotificationsPopover, Searchbar } from '../_common'; -import { - IconLayoutSidebarLeftCollapse, - IconLayoutSidebarRightCollapse, -} from '@tabler/icons-react'; - // ---------------------------------------------------------------------- type Props = { openNav: boolean; onCloseNav: VoidFunction; + sidebarWidth: number; }; // ---------------------------------------------------------------------- -export default function NavVertical({ openNav, onCloseNav }: Props) { +export default function NavVertical({ openNav, onCloseNav, sidebarWidth}: Props) { const pathname = usePathname(); const lgUp = useResponsive('up', 'lg'); const navData = useNavData(); const { authenticated, loading } = useAuth(); // Use the AuthProvider to check authentication const [loginModalOpen, setLoginModalOpen] = useState(false); // State to control LoginModal visibility - const [sidebarWidth, setSidebarWidth ] = useState(NAV.W_VERTICAL); // State to control LoginModal visibility + useEffect(() => { if (openNav) { @@ -59,13 +55,6 @@ export default function NavVertical({ openNav, onCloseNav }: Props) { setLoginModalOpen(false); }; - const toggleSidebarWidth = () => { - if (sidebarWidth === NAV.W_VERTICAL) { - setSidebarWidth(NAV.W_MINI); - } else { - setSidebarWidth(NAV.W_VERTICAL); - } - }; const renderContent = ( {/*Add a icon to make collapsible the sidebar*/} - - - - { - sidebarWidth === NAV.W_VERTICAL ? ( - - ) : ( - ) - } - - - + @@ -178,9 +138,10 @@ export default function NavVertical({ openNav, onCloseNav }: Props) { {lgUp ? ( `dashed 1px ${theme.palette.divider}`, }} >