diff --git a/src/components/library/LibraryOptions.tsx b/src/components/library/LibraryOptions.tsx index 332f02f2..bca0fcce 100644 --- a/src/components/library/LibraryOptions.tsx +++ b/src/components/library/LibraryOptions.tsx @@ -8,7 +8,6 @@ import React, { useState } from 'react'; import FilterListIcon from '@mui/icons-material/FilterList'; -import SortIcon from '@mui/icons-material/Sort'; import { Drawer, FormControlLabel, @@ -30,86 +29,39 @@ import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; import TabPanel from 'components/util/TabPanel'; import { useLibraryOptionsContext } from 'components/context/LibraryOptionsContext'; -function Options() { +function filtersTab(currentTab: number) { const { downloaded, setDownloaded, unread, setUnread, } = useLibraryOptions(); - const [currentTab, setCurrentTab] = useState(0); - const { options, setOptions } = useLibraryOptionsContext(); - - function setContextOptions( - e: React.ChangeEvent, - checked: boolean, - ) { - setOptions((prev) => ({ ...prev, [e.target.name]: checked })); - } - return ( - - setCurrentTab(newTab)} - indicatorColor="primary" - textColor="primary" - > - - - - - - - )} - label="Unread" - /> - - )} - label="Downloaded" - /> - - - - - - )} - /> - - )} - /> - - - + + + + )} + label="Unread" + /> + + )} + label="Downloaded" + /> + + ); } -function SortOptions() { +function sortsTab(currentTab: number) { const { sorts, setSorts, sortDesc, setSortDesc, } = useLibraryOptions(); @@ -124,31 +76,95 @@ function SortOptions() { return ( <> - { - ['sortToRead', 'sortAlph', 'sortID'].map((e) => { - let icon; - if (sorts === e) { - icon = !sortDesc ? () - : (); + + + { + ['sortToRead', 'sortAlph', 'sortID'].map((e) => { + let icon; + if (sorts === e) { + icon = !sortDesc ? () + : (); + } + icon = icon === undefined && sortDesc === undefined && e === 'sortID' ? () : icon; + return ( + + handleChange(event, e)}> + {icon} + + + + ); + }) } - icon = icon === undefined && sortDesc === undefined && e === 'sortID' ? () : icon; - return ( - - handleChange(event, e)}> - {icon} - - - - ); - }) - } + + ); } +function dispalyTab(currentTab: number) { + const { options, setOptions } = useLibraryOptionsContext(); + + function setContextOptions( + e: React.ChangeEvent, + checked: boolean, + ) { + setOptions((prev) => ({ ...prev, [e.target.name]: checked })); + } + return ( + + + + )} + /> + + )} + /> + + + ); +} + +function Options() { + const [currentTab, setCurrentTab] = useState(0); + + return ( + + setCurrentTab(newTab)} + indicatorColor="primary" + textColor="primary" + > + + + + + {filtersTab(currentTab)} + {sortsTab(currentTab)} + {dispalyTab(currentTab)} + + ); +} + export default function LibraryOptions() { const [filtersOpen, setFiltersOpen] = React.useState(false); - const [sortsOpen, setSortsOpen] = React.useState(false); const { active } = useLibraryOptions(); return ( <> @@ -171,27 +187,6 @@ export default function LibraryOptions() { > - - setSortsOpen(!filtersOpen)} - color={active ? 'warning' : 'default'} - > - - - - setSortsOpen(false)} - PaperProps={{ - style: { - maxWidth: 600, padding: '1em', marginLeft: 'auto', marginRight: 'auto', - }, - }} - > - - - ); }