Files
suwayomi-material-you-webui/src/features/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';
2024-09-17 03:40:55 +02:00
import { ComponentProps, useState } from 'react';
import { useLingui } from '@lingui/react/macro';
import { CustomTooltip } from '@/base/components/CustomTooltip.tsx';
2025-08-15 22:02:58 +02:00
import { LibraryOptionsPanel } from '@/features/library/components/LibraryOptionsPanel.tsx';
import { getCategoryMetadata } from '@/features/category/services/CategoryMetadata.ts';
2024-09-17 03:40:55 +02:00
export const LibraryToolbarMenu = ({
category,
}: {
category: ComponentProps<typeof LibraryOptionsPanel>['category'];
}) => {
const { t } = useLingui();
2023-11-05 17:22:29 +01:00
const [open, setOpen] = useState(false);
const options = getCategoryMetadata(category);
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 (
<>
<CustomTooltip title={t`Settings`}>
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>
</CustomTooltip>
2024-09-17 03:40:55 +02:00
<LibraryOptionsPanel category={category} open={open} onClose={() => setOpen(false)} />
</>
);
};