refactor: main layout
This commit is contained in:
@@ -161,7 +161,10 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS
|
|||||||
href={''}
|
href={''}
|
||||||
title={''}
|
title={''}
|
||||||
icon={<></>}>
|
icon={<></>}>
|
||||||
<NightModeSwitch checked={nightModeState} onClick={togglenightModeState} />
|
<NightModeSwitch
|
||||||
|
checked={nightModeState}
|
||||||
|
onClick={togglenightModeState}
|
||||||
|
/>
|
||||||
</SideMenuItem>
|
</SideMenuItem>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -1,39 +1,44 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useState } from 'react'
|
import React, { useEffect } from 'react'
|
||||||
import TopBar from '../topbar/TopBar'
|
import TopBar from '../topbar/TopBar'
|
||||||
import SideMenu from '../menu/SideMenu'
|
import SideMenu from '../menu/SideMenu'
|
||||||
import BottomNavBar from '../navigation/BottomNavBar'
|
import BottomNavBar from '../navigation/BottomNavBar'
|
||||||
|
import useToggle from '@/hooks/helpers/useToggle';
|
||||||
|
import { usePathname } from 'next/navigation';
|
||||||
|
|
||||||
type Props = {} & React.AllHTMLAttributes<HTMLBodyElementEventMap>
|
type Props = {} & React.AllHTMLAttributes<HTMLBodyElementEventMap>
|
||||||
|
|
||||||
function ClientMenuRouteWrapper({ children }: Props) {
|
function ClientMenuRouteWrapper({ children }: Props) {
|
||||||
const [profileDrop, setProfileDrop] = useState(false);
|
const { state: profileDrop, toggle: _toggleProfileDrop } = useToggle(false);
|
||||||
const [nightMode, setNightMode] = useState(false);
|
const { state: nightMode, toggle: _toggleNightMode } = useToggle(false);
|
||||||
const [menuState, setMenuState] = useState(false);
|
const { state: menuState, toggle: _toggleMenuState, set: setMenuState } = useToggle(false);
|
||||||
const [searchModal, setSearchModal] = useState(false);
|
const { state: searchModal, toggle: _toggleSearchModal } = useToggle(false);
|
||||||
|
|
||||||
const toggleProfileDrop = () => {
|
const toggleProfileDrop = () => {
|
||||||
setProfileDrop((state) => !state);
|
_toggleProfileDrop();
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleNightMode = () => {
|
const toggleNightMode = () => {
|
||||||
setNightMode((state) => !state);
|
_toggleNightMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleMenuState = () => {
|
const toggleMenuState = () => {
|
||||||
setMenuState((state) => !state);
|
_toggleMenuState();
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleSearchModal = () => {
|
const toggleSearchModal = () => {
|
||||||
setSearchModal((state) => !state);
|
_toggleSearchModal();
|
||||||
}
|
}
|
||||||
|
|
||||||
// const location = useRouter();
|
const location = usePathname();
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// setMenuState(false)
|
if (menuState) {
|
||||||
// }, [location])
|
setMenuState(false)
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [location])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="h-svh overflow-hidden pt-10 flex flex-col pb-4 xl:pt-12">
|
<div className="h-svh overflow-hidden pt-10 flex flex-col pb-4 xl:pt-12">
|
||||||
|
|||||||
Reference in New Issue
Block a user