File size: 1,591 Bytes
4e1096a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | import React from 'react';
import { Insets } from '@/types/misc';
import { TOCItem } from '@/libs/document';
import { useTranslation } from '@/hooks/useTranslation';
import { useBooknotesNav } from '../../hooks/useBooknotesNav';
import ContentNavBar from './ContentNavBar';
interface BooknotesNavProps {
bookKey: string;
gridInsets: Insets;
toc: TOCItem[];
}
const BooknotesNav: React.FC<BooknotesNavProps> = ({ bookKey, gridInsets, toc }) => {
const {
activeBooknoteType,
currentSection,
showBooknotesNav,
hasPreviousPage,
hasNextPage,
handleShowResults,
handleClose,
handlePrevious,
handleNext,
} = useBooknotesNav(bookKey, toc);
const _ = useTranslation();
if (!showBooknotesNav) {
return null;
}
const getShowResultsTitle = () => {
switch (activeBooknoteType) {
case 'bookmark':
return _('Bookmarks');
case 'annotation':
return _('Annotations');
case 'excerpt':
return _('Excerpts');
default:
return '';
}
};
return (
<ContentNavBar
bookKey={bookKey}
gridInsets={gridInsets}
title={getShowResultsTitle()}
section={currentSection}
hasPrevious={hasPreviousPage}
hasNext={hasNextPage}
progress={1}
previousTitle={_('Previous')}
nextTitle={_('Next')}
showResultsTitle={getShowResultsTitle()}
closeTitle={_('Close')}
onShowResults={handleShowResults}
onClose={handleClose}
onPrevious={handlePrevious}
onNext={handleNext}
/>
);
};
export default BooknotesNav;
|