Skip to content

Commit

Permalink
rename isNavOpened
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Oct 12, 2023
1 parent 090b555 commit 65e707e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions components/header/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import { forwardRef } from 'react'
import s from './header.module.scss'

export const Header = forwardRef((_, ref) => {
const [navIsOpened, setNavIsOpened] = useStore(
({ navIsOpened, setNavIsOpened }) => [navIsOpened, setNavIsOpened],
const [isNavOpened, setIsNavOpened] = useStore(
({ isNavOpened, setIsNavOpened }) => [isNavOpened, setIsNavOpened],
)

return (
Expand All @@ -16,7 +16,7 @@ export const Header = forwardRef((_, ref) => {
<div className={cn('layout-block', s.head)}>
<button
onClick={() => {
setNavIsOpened(!navIsOpened)
setIsNavOpened(!isNavOpened)
}}
>
menu
Expand Down
8 changes: 4 additions & 4 deletions components/navigation/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { useEffect } from 'react'
import s from './navigation.module.scss'

export function Navigation() {
const [navIsOpened, setNavIsOpened] = useStore(
({ navIsOpened, setNavIsOpened }) => [navIsOpened, setNavIsOpened],
const [isNavOpened, setIsNavOpened] = useStore(
({ isNavOpened, setIsNavOpened }) => [isNavOpened, setIsNavOpened],
)

const router = useRouter()

useEffect(() => {
function onRouteChange() {
setNavIsOpened(false)
setIsNavOpened(false)
}

router.events.on('routeChangeStart', onRouteChange)
Expand All @@ -26,7 +26,7 @@ export function Navigation() {
}, [])

return (
<Lenis className={cn(s.navigation, !navIsOpened && s.closed)}>
<Lenis className={cn(s.navigation, !isNavOpened && s.closed)}>
<div className={s.content}>
<Link href="/">home</Link>
<Link href="/contact">contact</Link>
Expand Down
4 changes: 2 additions & 2 deletions libs/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { createWithEqualityFn } from 'zustand/traditional'

export const useStore = createWithEqualityFn(
(set) => ({
navIsOpened: false,
setNavIsOpened: (value) => set({ navIsOpened: value }),
isNavOpened: false,
setIsNavOpened: (value) => set({ isNavOpened: value }),
}),
shallow,
)
6 changes: 3 additions & 3 deletions pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,15 @@ function MyApp({ Component, pageProps }) {
const lenis = useLenis(ScrollTrigger.update)
useEffect(ScrollTrigger.refresh, [lenis])

const navIsOpened = useStore(({ navIsOpened }) => navIsOpened)
const isNavOpened = useStore(({ isNavOpened }) => isNavOpened)

useEffect(() => {
if (navIsOpened) {
if (isNavOpened) {
lenis?.stop()
} else {
lenis?.start()
}
}, [lenis, navIsOpened])
}, [lenis, isNavOpened])

return (
<>
Expand Down

1 comment on commit 65e707e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"⚡️ Lighthouse report for the changes in this commit:

🟠 Performance: 64
🟢 Accessibility: 97
🟢 Best practices: 100
🟠 SEO: 75
🔴 PWA: 30

Lighthouse ran on https://astro-satus-lyenorvrb-studio-freight.vercel.app/"

Please sign in to comment.