feat: add a search modal using the database (wip)

This commit is contained in:
Sonny
2024-05-25 03:40:08 +02:00
committed by Sonny
parent b28499a69a
commit 56c05f1bf6
21 changed files with 535 additions and 621 deletions

View File

@@ -17,6 +17,7 @@ interface ModalProps {
title?: string;
children: ReactNode;
opened: boolean;
hideCloseBtn?: boolean;
close: () => void;
}
@@ -25,13 +26,14 @@ export default function Modal({
title,
children,
opened = true,
hideCloseBtn = false,
close,
}: ModalProps) {
const modalRef = useRef<HTMLDivElement>(null);
const { setGlobalHotkeysEnabled } = useGlobalHotkeys();
useClickOutside(modalRef, close);
useShortcut('ESCAPE_KEY', close, { ignoreGlobalHotkeysStatus: true });
useShortcut('ESCAPE_KEY', close);
useEffect(() => setGlobalHotkeysEnabled(!opened), [opened]);
@@ -44,12 +46,17 @@ export default function Modal({
createPortal(
<ModalWrapper>
<ModalContainer ref={modalRef}>
<ModalHeader>
{title && <TextEllipsis>{title}</TextEllipsis>}
<ModalCloseBtn onClick={close}>
<IoClose size={20} />
</ModalCloseBtn>
</ModalHeader>
{!hideCloseBtn ||
(title && (
<ModalHeader>
{title && <TextEllipsis>{title}</TextEllipsis>}
{!hideCloseBtn && (
<ModalCloseBtn onClick={close}>
<IoClose size={20} />
</ModalCloseBtn>
)}
</ModalHeader>
))}
<ModalBody>{children}</ModalBody>
</ModalContainer>
</ModalWrapper>,