Close menu on selection (mobile only)
This commit is contained in:
parent
89fdd955fe
commit
dca61e1459
1 changed files with 10 additions and 0 deletions
|
|
@ -24,6 +24,7 @@ import {
|
||||||
import { fonts } from "@link-stack/ui";
|
import { fonts } from "@link-stack/ui";
|
||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
import LinkLogo from "public/link-logo-small.png";
|
import LinkLogo from "public/link-logo-small.png";
|
||||||
|
import { usePathname } from 'next/navigation';
|
||||||
|
|
||||||
interface InternalLayoutProps extends PropsWithChildren {
|
interface InternalLayoutProps extends PropsWithChildren {
|
||||||
setupModeActive: boolean;
|
setupModeActive: boolean;
|
||||||
|
|
@ -44,6 +45,15 @@ export const InternalLayout: FC<InternalLayoutProps> = ({
|
||||||
const [openWidth, setOpenWidth] = useState<number>(0);
|
const [openWidth, setOpenWidth] = useState<number>(0);
|
||||||
const [closedWidth, setClosedWidth] = useState<number>(0);
|
const [closedWidth, setClosedWidth] = useState<number>(0);
|
||||||
|
|
||||||
|
const pathname = usePathname();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
// On mobile, close menu when stuff is selected
|
||||||
|
if (mobile) {
|
||||||
|
setOpen(false);
|
||||||
|
}
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setClosedWidth(mobile ? 0 : 70);
|
setClosedWidth(mobile ? 0 : 70);
|
||||||
setOpenWidth(270);
|
setOpenWidth(270);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue