Skip to content

Commit

Permalink
close sidebar on change page
Browse files Browse the repository at this point in the history
  • Loading branch information
LooLzzz committed Sep 2, 2024
1 parent 89e2139 commit 780bbd0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Button, Code, Divider, Drawer, DrawerProps, NavLink, NavLinkProps, Stack, Switch, Text, Title, useMantineColorScheme } from '@mantine/core'
import { Link, LinkProps, useMatchRoute } from '@tanstack/react-router'
import { Link, LinkProps, useLocation, useMatchRoute } from '@tanstack/react-router'
import { useEffect } from 'react'

import { MoonStarsIcon, SunIcon } from '@/assets'
import { useSwipe, useWordleStore } from '@/hooks'
Expand Down Expand Up @@ -34,16 +35,21 @@ const Sidebar = ({ opened, onClose, ...props }: SidebarProps) => {
state.resetStore,
state.time,
])
const location = useLocation()
const { colorScheme, toggleColorScheme } = useMantineColorScheme()

const handleResetStore = () => {
resetStore()
onClose()
}

useSwipe({
left: onClose
})

const handleResetStore = () => {
resetStore()
useEffect(() => {
onClose()
}
}, [location])

return (
<Drawer
Expand Down

0 comments on commit 780bbd0

Please sign in to comment.