diff --git a/src/components/menu/SideMenu.tsx b/src/components/menu/SideMenu.tsx index bcd7978..da67898 100644 --- a/src/components/menu/SideMenu.tsx +++ b/src/components/menu/SideMenu.tsx @@ -1,6 +1,7 @@ 'use client'; -import React, { useMemo } from 'react' +import React, { useMemo, useRef } from 'react' +import { motion, PanInfo, Variants } from 'framer-motion'; import MenuItemType from './SideMenuItem' import SideMenuItem from './SideMenuItem'; import NotificationBellIcon from '../icons/NotificationBellIcon'; @@ -73,11 +74,43 @@ type Props = { function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeState }: Props) { const menuStateMemo = useMemo(() => menuState, [menuState]); + const closeRef: React.Ref | undefined = useRef(null); + + const variants: Variants = { + hidden: { + x: '100%', + }, + visible: { + x: 0, + transition: { + duration: 0.1, + ease: 'easeInOut', + }, + }, + }; + + const onDrag = (_event: MouseEvent | TouchEvent | PointerEvent, info: PanInfo) => { + if (info.offset.x > 100) { + if (closeRef.current) { + closeRef.current.click(); + } + } + } return ( -
- -
+ + { e.stopPropagation(); }} className={`fixed top-0 bottom-0 -right-full data-[isvisible=true]:right-0 transition-all duration-100 ease-in-out not-xl:!rounded-s-none overflow-clip bg-white w-[200px] h-dvh flex flex-col z-40`}> @@ -99,7 +132,7 @@ function SideMenu({ menuState, toggleMenuState, nightModeState, togglenightModeS }> -
+
)