Files
suwayomi-material-you-webui/src/components/chapter/ChaptersToolbarMenu.tsx
T

45 lines
1.5 KiB
TypeScript
Raw Normal View History

2022-11-09 18:09:15 +01:00
/*
* 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/.
*/
2022-11-09 18:09:15 +01:00
import FilterList from '@mui/icons-material/FilterList';
2024-04-14 15:50:12 +02:00
import IconButton from '@mui/material/IconButton';
import Tooltip from '@mui/material/Tooltip';
2022-11-09 18:09:15 +01:00
import * as React from 'react';
2023-11-05 17:22:29 +01:00
import { useTranslation } from 'react-i18next';
2023-12-30 14:30:04 +01:00
import { ChapterListOptions, ChapterOptionsReducerAction } from '@/typings.ts';
import { ChapterOptions } from '@/components/chapter/ChapterOptions.tsx';
import { isFilterActive } from '@/components/chapter/util.tsx';
2022-11-09 18:09:15 +01:00
interface IProps {
2023-02-06 10:06:33 +01:00
options: ChapterListOptions;
optionsDispatch: React.Dispatch<ChapterOptionsReducerAction>;
2022-11-09 18:09:15 +01:00
}
2023-10-28 00:32:02 +02:00
export const ChaptersToolbarMenu = ({ options, optionsDispatch }: IProps) => {
2023-11-05 17:22:29 +01:00
const { t } = useTranslation();
2022-11-09 18:09:15 +01:00
const [open, setOpen] = React.useState(false);
const isFiltered = isFilterActive(options);
return (
<>
2023-11-05 17:22:29 +01:00
<Tooltip title={t('settings.title')}>
<IconButton onClick={() => setOpen(true)}>
<FilterList color={isFiltered ? 'warning' : undefined} />
</IconButton>
</Tooltip>
2022-11-09 18:09:15 +01:00
<ChapterOptions
open={open}
onClose={() => setOpen(false)}
options={options}
optionsDispatch={optionsDispatch}
/>
</>
);
};