From a3808770a04935b469a6fad9528b82e0d4237913 Mon Sep 17 00:00:00 2001 From: Edgard Zavarezzi Date: Wed, 2 Oct 2024 18:30:37 -0400 Subject: [PATCH] chore: cleanup --- package.json | 2 +- plopfile.js | 2 +- src/components/Layout/Layout.tsx | 19 +++++++------------ .../ScreenIntro/ScreenIntro.controller.tsx | 17 +++++++++++++---- .../ScreenIntro/ScreenIntro.view.tsx | 4 +++- src/hooks/use-transition-presence.ts | 6 +++--- src/pages/_app.tsx | 6 +++++- src/store/animations.slice.ts | 10 +++++----- 8 files changed, 38 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 4c502d91..ece96fc7 100644 --- a/package.json +++ b/package.json @@ -26,12 +26,12 @@ "lint:ls": "npx @ls-lint/ls-lint", "lint:next": "next lint", "lint:sass": "stylelint \"./src/**/*.scss\"", + "autofix:store": "prettier src/store --write && eslint src/store --fix", "adviser:dev": "adviser --tags dev --verbose", "adviser:ci": "adviser --tags ci --verbose --quiet", "generate": "plop", "preinstall": "npm i -g husky@8.0.3", "prepare": "husky install && node scripts/prepare.js", - "autofix": "next lint --ignore-path .eslintignore --max-warnings=0 --fix", "tsc": "tsc" }, "engines": { diff --git a/plopfile.js b/plopfile.js index 17481b10..515b9a0c 100644 --- a/plopfile.js +++ b/plopfile.js @@ -124,7 +124,7 @@ module.exports = function ( } }, function customAction() { - execSync('npm run autofix', { stdio: 'inherit' }) + execSync('npm run autofix:store', { stdio: 'inherit' }) return '' } ] diff --git a/src/components/Layout/Layout.tsx b/src/components/Layout/Layout.tsx index 0b2e6ca7..e04c2f0b 100644 --- a/src/components/Layout/Layout.tsx +++ b/src/components/Layout/Layout.tsx @@ -3,7 +3,7 @@ import type { AppProps } from 'next/app' import type { NavHandle } from '@/components/Nav' import type { PageProps } from '@/data/types' -import { memo, useCallback, useEffect, useRef, useState } from 'react' +import { memo, useCallback, useEffect, useRef } from 'react' import dynamic from 'next/dynamic' import { useRouter } from 'next/router' import classNames from 'classnames' @@ -45,13 +45,6 @@ export const Layout: FC> = memo(({ Component, pageProps }) = const router = useRouter() - const [introComplete, setIntroComplete] = useState(false) - - const handleIntroComplete = useCallback(() => { - setIntroComplete(true) - storeState().animations.setAnimationsEnabled(true) - }, []) - const handlePageMounted = useCallback(() => { storeState().navigation.setPathname(refs.pathname.current || '/') // restore scroll @@ -78,10 +71,12 @@ export const Layout: FC> = memo(({ Component, pageProps }) = // Update pathname ref // useEffect(() => { - refs.pathname.current = router.asPath + const fixedPath = router.asPath .split('#')[0] .split('?')[0] .replace(/^\/..-..\/?/u, '') + if (!refs.pathname.current) storeState().navigation.setPathname(fixedPath) + refs.pathname.current = fixedPath }, [refs, router.asPath]) // @@ -91,8 +86,8 @@ export const Layout: FC> = memo(({ Component, pageProps }) = const navigateTo = (href: string) => { const to = href.split('/').filter(Boolean).join('/').replace(/\/$/u, '') const from = router.asPath.split('/').filter(Boolean).join('/').replace(/\/$/u, '') - if (to === from) router.replace(href, '', { scroll: false }).catch(console.log) - else router.push(href, '', { scroll: false }).catch(console.log) + if (to === from) router.replace(href, '', { scroll: false }) + else router.push(href, '', { scroll: false }) } const navigateBack = () => { if (storeState().navigation.hasNavigated) { @@ -149,7 +144,7 @@ export const Layout: FC> = memo(({ Component, pageProps }) =