From 59451ddc42e48016c230aa9612304ded1afbc633 Mon Sep 17 00:00:00 2001 From: Daniel Filat Date: Tue, 2 Jan 2024 08:33:12 +0200 Subject: [PATCH] prevents reader controls rerendering when chapter changes --- .../{[bookCode]/[chapter] => }/_components/Footer.tsx | 0 .../{[bookCode]/[chapter] => }/_components/Header.tsx | 0 .../_components/ReaderControls/ChapterPicker/BookList.tsx | 0 .../ReaderControls/ChapterPicker/BookListSectionHeader.tsx | 3 +-- .../ReaderControls/ChapterPicker/ChapterListHeader.tsx | 3 +-- .../ReaderControls/ChapterPicker/ChapterPicker.styles.tsx | 0 .../ReaderControls/ChapterPicker/ChapterPicker.tsx | 0 .../_components/ReaderControls/ChapterPicker/Header.tsx | 2 +- .../ReaderControls/ChapterPicker/SafeAreaBottom.tsx | 0 .../_components/ReaderControls/ChapterPicker/index.ts | 0 .../ChapterPicker/useCloseChapterPickerOnParamChange.ts | 0 .../_components/ReaderControls/ReaderControls.tsx | 0 .../_components/ReaderControls/ReaderNavButton.tsx | 0 .../[chapter] => }/_components/ReaderControls/index.ts | 0 .../_components/ReaderControls/useOnReaderParamChange.tsx | 0 .../ReaderControls/useResetReaderScrollOnParamChange.tsx | 5 +++-- .../[chapter] => }/_components/ReaderPageContainer.tsx | 0 .../{[bookCode]/[chapter] => }/_readerPage.state.ts | 0 src/app/[readerMode]/{[bookCode]/[chapter] => }/layout.tsx | 0 19 files changed, 6 insertions(+), 7 deletions(-) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/Footer.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/Header.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/BookList.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx (90%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx (91%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/ChapterPicker.styles.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/ChapterPicker.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/Header.tsx (95%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/SafeAreaBottom.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/index.ts (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ChapterPicker/useCloseChapterPickerOnParamChange.ts (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ReaderControls.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/ReaderNavButton.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/index.ts (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/useOnReaderParamChange.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx (77%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_components/ReaderPageContainer.tsx (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/_readerPage.state.ts (100%) rename src/app/[readerMode]/{[bookCode]/[chapter] => }/layout.tsx (100%) diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/Footer.tsx b/src/app/[readerMode]/_components/Footer.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/Footer.tsx rename to src/app/[readerMode]/_components/Footer.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/Header.tsx b/src/app/[readerMode]/_components/Header.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/Header.tsx rename to src/app/[readerMode]/_components/Header.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/BookList.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/BookList.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/BookList.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/BookList.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx similarity index 90% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx index 41f40195..0dc32bc6 100644 --- a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx +++ b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/BookListSectionHeader.tsx @@ -2,10 +2,9 @@ import { type ReactNode } from 'react' import { css, cx } from 'styled-system/css' import { subgrid } from 'styled-system/patterns' +import { Separator } from '~/components' import { labelCss } from '~/styles/label.css' -import { Separator } from '../../../../../../../components' - export const BookListSectionHeader = ({ children, }: { diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx similarity index 91% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx index 5e96d039..f0899383 100644 --- a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx +++ b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterListHeader.tsx @@ -1,10 +1,9 @@ import { type ReactNode } from 'react' import { css, cx } from 'styled-system/css' +import { Separator } from '~/components' import { labelCss } from '~/styles/label.css' -import { Separator } from '../../../../../../../components' - export const ChapterListHeader = ({ children, chapterListItemHeight, diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterPicker.styles.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterPicker.styles.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterPicker.styles.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterPicker.styles.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterPicker.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterPicker.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/ChapterPicker.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/ChapterPicker.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/Header.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/Header.tsx similarity index 95% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/Header.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/Header.tsx index ec65b12b..dfe74646 100644 --- a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/Header.tsx +++ b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/Header.tsx @@ -3,7 +3,7 @@ import { css } from 'styled-system/css' import { styled } from 'styled-system/jsx' import { center, hstack, macrogrid } from 'styled-system/patterns' -import { Icon, Separator } from '../../../../../../../components' +import { Icon, Separator } from '~/components' const ButtonClose = styled('button', { base: center.raw({ diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/SafeAreaBottom.tsx b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/SafeAreaBottom.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/SafeAreaBottom.tsx rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/SafeAreaBottom.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/index.ts b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/index.ts similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/index.ts rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/index.ts diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/useCloseChapterPickerOnParamChange.ts b/src/app/[readerMode]/_components/ReaderControls/ChapterPicker/useCloseChapterPickerOnParamChange.ts similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ChapterPicker/useCloseChapterPickerOnParamChange.ts rename to src/app/[readerMode]/_components/ReaderControls/ChapterPicker/useCloseChapterPickerOnParamChange.ts diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ReaderControls.tsx b/src/app/[readerMode]/_components/ReaderControls/ReaderControls.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ReaderControls.tsx rename to src/app/[readerMode]/_components/ReaderControls/ReaderControls.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ReaderNavButton.tsx b/src/app/[readerMode]/_components/ReaderControls/ReaderNavButton.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/ReaderNavButton.tsx rename to src/app/[readerMode]/_components/ReaderControls/ReaderNavButton.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/index.ts b/src/app/[readerMode]/_components/ReaderControls/index.ts similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/index.ts rename to src/app/[readerMode]/_components/ReaderControls/index.ts diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/useOnReaderParamChange.tsx b/src/app/[readerMode]/_components/ReaderControls/useOnReaderParamChange.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/useOnReaderParamChange.tsx rename to src/app/[readerMode]/_components/ReaderControls/useOnReaderParamChange.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx b/src/app/[readerMode]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx similarity index 77% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx rename to src/app/[readerMode]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx index 825b4656..234d580c 100644 --- a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx +++ b/src/app/[readerMode]/_components/ReaderControls/useResetReaderScrollOnParamChange.tsx @@ -1,7 +1,8 @@ import { useAtomValue } from 'jotai' import { useCallback } from 'react' -import { readerPageContainerElAtom } from '../../_readerPage.state' +import { readerPageContainerElAtom } from '~/app/[readerMode]/_readerPage.state' + import { useOnReaderParamChange } from './useOnReaderParamChange' export const useResetReaderScrollOnParamChange = ( @@ -11,7 +12,7 @@ export const useResetReaderScrollOnParamChange = ( const readerPageContentEl = useAtomValue(readerPageContainerElAtom) const handler = useCallback(() => { - readerPageContentEl && readerPageContentEl.scrollTo(0, 0) + readerPageContentEl?.scrollTo(0, 0) }, [readerPageContentEl]) useOnReaderParamChange(handler, currBookCode, currChapter) diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderPageContainer.tsx b/src/app/[readerMode]/_components/ReaderPageContainer.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_components/ReaderPageContainer.tsx rename to src/app/[readerMode]/_components/ReaderPageContainer.tsx diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/_readerPage.state.ts b/src/app/[readerMode]/_readerPage.state.ts similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/_readerPage.state.ts rename to src/app/[readerMode]/_readerPage.state.ts diff --git a/src/app/[readerMode]/[bookCode]/[chapter]/layout.tsx b/src/app/[readerMode]/layout.tsx similarity index 100% rename from src/app/[readerMode]/[bookCode]/[chapter]/layout.tsx rename to src/app/[readerMode]/layout.tsx