Files
suwayomi-material-you-webui/src/modules/library/components/LibraryToolbarMenu.tsx

46 lines
1.8 KiB
TypeScript
Raw Normal View History

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import FilterList from '@mui/icons-material/FilterList';
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';
2024-09-17 03:40:55 +02:00
import { ComponentProps, useState } from 'react';
2023-11-05 17:22:29 +01:00
import { useTranslation } from 'react-i18next';
2024-10-05 19:33:09 +02:00
import { LibraryOptionsPanel } from '@/modules/library/components/LibraryOptionsPanel.tsx';
import { useLibraryOptionsContext } from '@/modules/library/contexts/LibraryOptionsContext.tsx';
2024-09-17 03:40:55 +02:00
export const LibraryToolbarMenu = ({
category,
}: {
category: ComponentProps<typeof LibraryOptionsPanel>['category'];
}) => {
2023-11-05 17:22:29 +01:00
const { t } = useTranslation();
const [open, setOpen] = useState(false);
const { options } = useLibraryOptionsContext();
const active =
2024-09-16 11:35:55 +02:00
options.hasDownloadedChapters != null ||
options.hasUnreadChapters != null ||
2024-12-27 03:32:30 +01:00
options.hasReadChapters != null ||
2024-09-21 21:38:20 +02:00
options.hasBookmarkedChapters != null ||
options.hasDuplicateChapters != null ||
Object.values(options.hasStatus).some((hasStatus) => hasStatus != null) ||
2024-09-16 11:35:55 +02:00
Object.values(options.hasTrackerBinding).some((trackerFilterStatus) => trackerFilterStatus != null);
return (
<>
2023-11-05 17:22:29 +01:00
<Tooltip title={t('settings.title')}>
2024-09-06 16:59:27 +02:00
<IconButton onClick={() => setOpen(!open)} color={active ? 'warning' : 'inherit'}>
2023-11-05 17:22:29 +01:00
<FilterList />
</IconButton>
</Tooltip>
2024-09-17 03:40:55 +02:00
<LibraryOptionsPanel category={category} open={open} onClose={() => setOpen(false)} />
</>
);
};