Feature/cleanup files (#528)

* Move menu components into new dir

* Move chapter components into new dir

* Extract menu helper functions

* Move "SelectionFAB" to "collection" dir

* Move debounce hook to global utils dir

* Rename manga "hooks" to "useRefreshManga"
This commit is contained in:
schroda
2023-12-30 14:30:04 +01:00
committed by GitHub
parent ecea80f41e
commit edc2a62a76
20 changed files with 109 additions and 96 deletions

View File

@@ -0,0 +1,36 @@
/*
* 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 { MenuProps } from '@mui/material/Menu/Menu';
import { Menu as MuiMenu } from '@mui/material';
import { useState } from 'react';
export const Menu = ({
children,
onClose,
...props
}: Omit<MenuProps, 'children' | 'onClose'> &
Required<Pick<MenuProps, 'onClose'>> & {
children: (onClose: () => void, setHideMenu: (hide: boolean) => void) => JSX.Element;
}) => {
const [shouldHideMenu, setShouldHideMenu] = useState(false);
return (
<MuiMenu
{...props}
open={props.open}
onClose={onClose}
sx={{ visibility: !props.open || shouldHideMenu ? 'hidden' : 'visible' }}
>
{children(() => {
onClose({}, 'backdropClick');
setShouldHideMenu(false);
}, setShouldHideMenu)}
</MuiMenu>
);
};