888f4afde9
* fix: paragraph mode * test: paragraph mode * test: remove paragraph mode * fix: paragraph utils * fix: paragraph hook * fix: paragraph overlay * fix: paragraph bar * fix: paragraph control * fix: paragraph shortcuts * test: paragraph utils * test: paragraph hook * test: paragraph overlay * test: paragraph shortcuts * fix: paragraph overlay * test: paragraph mode * test: shortcuts * test: remove overlay * test: remove hook * test: remove utils * fix: paragraph overlay * fix: paragraph overlay * feat: paragraph overlay * fix: vertical container sizing * test: paragraph container * fix: paragraph animation * fix: paragraph text animation * fix: remove container morph
60 lines
1.6 KiB
TypeScript
60 lines
1.6 KiB
TypeScript
'use client';
|
|
|
|
import React from 'react';
|
|
import { FoliateView } from '@/types/view';
|
|
import { Insets } from '@/types/misc';
|
|
import { useReaderStore } from '@/store/readerStore';
|
|
import { useParagraphMode } from '../../hooks/useParagraphMode';
|
|
import ParagraphBar from './ParagraphBar';
|
|
import ParagraphOverlay from './ParagraphOverlay';
|
|
|
|
const DIM_OPACITY = 0.3;
|
|
|
|
interface ParagraphControlProps {
|
|
bookKey: string;
|
|
viewRef: React.RefObject<FoliateView | null>;
|
|
gridInsets: Insets;
|
|
}
|
|
|
|
const ParagraphControl: React.FC<ParagraphControlProps> = ({ bookKey, viewRef, gridInsets }) => {
|
|
const { getViewSettings } = useReaderStore();
|
|
const viewSettings = getViewSettings(bookKey);
|
|
|
|
const {
|
|
paragraphState,
|
|
paragraphConfig,
|
|
toggleParagraphMode,
|
|
goToNextParagraph,
|
|
goToPrevParagraph,
|
|
} = useParagraphMode({ bookKey, viewRef });
|
|
|
|
if (!paragraphConfig?.enabled) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<>
|
|
<ParagraphOverlay
|
|
bookKey={bookKey}
|
|
dimOpacity={DIM_OPACITY}
|
|
viewSettings={viewSettings ?? undefined}
|
|
gridInsets={gridInsets}
|
|
onClose={toggleParagraphMode}
|
|
/>
|
|
<ParagraphBar
|
|
bookKey={bookKey}
|
|
currentIndex={paragraphState.currentIndex}
|
|
totalParagraphs={paragraphState.totalParagraphs}
|
|
isLoading={paragraphState.isLoading}
|
|
onPrev={goToPrevParagraph}
|
|
onNext={goToNextParagraph}
|
|
onClose={toggleParagraphMode}
|
|
viewSettings={viewSettings ?? undefined}
|
|
gridInsets={gridInsets}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default ParagraphControl;
|