mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-09 15:05:35 +00:00
refactor: use tabs instead of spaces
This commit is contained in:
@@ -4,8 +4,8 @@ import { IoClose } from 'react-icons/io5';
|
||||
import ModalBody from '~/components/common/modal/_modal_body';
|
||||
import ModalContainer from '~/components/common/modal/_modal_container';
|
||||
import {
|
||||
ModalCloseBtn,
|
||||
ModalHeader,
|
||||
ModalCloseBtn,
|
||||
ModalHeader,
|
||||
} from '~/components/common/modal/_modal_header';
|
||||
import ModalWrapper from '~/components/common/modal/_modal_wrapper';
|
||||
import TextEllipsis from '~/components/common/text_ellipsis';
|
||||
@@ -14,54 +14,54 @@ import useGlobalHotkeys from '~/hooks/use_global_hotkeys';
|
||||
import useShortcut from '~/hooks/use_shortcut';
|
||||
|
||||
interface ModalProps {
|
||||
title?: string;
|
||||
children: ReactNode;
|
||||
opened: boolean;
|
||||
hideCloseBtn?: boolean;
|
||||
className?: string;
|
||||
title?: string;
|
||||
children: ReactNode;
|
||||
opened: boolean;
|
||||
hideCloseBtn?: boolean;
|
||||
className?: string;
|
||||
|
||||
close: () => void;
|
||||
close: () => void;
|
||||
}
|
||||
|
||||
export default function Modal({
|
||||
title,
|
||||
children,
|
||||
opened = true,
|
||||
hideCloseBtn = false,
|
||||
className,
|
||||
close,
|
||||
title,
|
||||
children,
|
||||
opened = true,
|
||||
hideCloseBtn = false,
|
||||
className,
|
||||
close,
|
||||
}: ModalProps) {
|
||||
const modalRef = useRef<HTMLDivElement>(null);
|
||||
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
|
||||
const modalRef = useRef<HTMLDivElement>(null);
|
||||
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
|
||||
|
||||
useClickOutside(modalRef, close);
|
||||
useShortcut('ESCAPE_KEY', close, { disableGlobalCheck: true });
|
||||
useClickOutside(modalRef, close);
|
||||
useShortcut('ESCAPE_KEY', close, { disableGlobalCheck: true });
|
||||
|
||||
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
|
||||
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
|
||||
|
||||
if (typeof window === 'undefined') {
|
||||
return <Fragment />;
|
||||
}
|
||||
if (typeof window === 'undefined') {
|
||||
return <Fragment />;
|
||||
}
|
||||
|
||||
return (
|
||||
opened &&
|
||||
createPortal(
|
||||
<ModalWrapper>
|
||||
<ModalContainer className={className} ref={modalRef}>
|
||||
{(!hideCloseBtn || title) && (
|
||||
<ModalHeader>
|
||||
{title && <TextEllipsis>{title}</TextEllipsis>}
|
||||
{!hideCloseBtn && (
|
||||
<ModalCloseBtn onClick={close}>
|
||||
<IoClose size={20} />
|
||||
</ModalCloseBtn>
|
||||
)}
|
||||
</ModalHeader>
|
||||
)}
|
||||
<ModalBody>{children}</ModalBody>
|
||||
</ModalContainer>
|
||||
</ModalWrapper>,
|
||||
document.body
|
||||
)
|
||||
);
|
||||
return (
|
||||
opened &&
|
||||
createPortal(
|
||||
<ModalWrapper>
|
||||
<ModalContainer className={className} ref={modalRef}>
|
||||
{(!hideCloseBtn || title) && (
|
||||
<ModalHeader>
|
||||
{title && <TextEllipsis>{title}</TextEllipsis>}
|
||||
{!hideCloseBtn && (
|
||||
<ModalCloseBtn onClick={close}>
|
||||
<IoClose size={20} />
|
||||
</ModalCloseBtn>
|
||||
)}
|
||||
</ModalHeader>
|
||||
)}
|
||||
<ModalBody>{children}</ModalBody>
|
||||
</ModalContainer>
|
||||
</ModalWrapper>,
|
||||
document.body
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user