meshtastic/src/components/Modal.tsx

50 lines
1.6 KiB
TypeScript
Raw Normal View History

2023-01-19 04:41:44 -08:00
import React from "react";
2022-04-02 06:17:50 -07:00
2023-01-19 04:41:44 -08:00
import { AnimatePresence, motion } from "framer-motion";
2022-04-09 01:54:54 -07:00
2023-01-19 04:41:44 -08:00
import { Dialog } from "@headlessui/react";
2022-04-02 06:17:50 -07:00
export interface ModalProps {
open: boolean;
onClose: () => void;
children: React.ReactNode;
}
export const Modal = ({ open, onClose, children }: ModalProps): JSX.Element => {
return (
2022-04-09 01:54:54 -07:00
<AnimatePresence initial={false} exitBeforeEnter={true}>
2022-04-02 06:17:50 -07:00
<Dialog
as="div"
className="fixed inset-0 z-10 overflow-y-auto"
2022-04-09 01:54:54 -07:00
open={open}
2022-04-02 06:17:50 -07:00
onClose={onClose}
>
<div className="min-h-screen px-0.5 text-center md:px-4">
2022-04-09 01:54:54 -07:00
<motion.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
2022-04-02 06:17:50 -07:00
>
<Dialog.Overlay className="fixed inset-0 backdrop-blur-md" />
2022-04-09 01:54:54 -07:00
</motion.div>
2022-04-02 06:17:50 -07:00
<span
className="inline-block h-screen align-middle"
aria-hidden="true"
>
&#8203;
</span>
2022-04-09 01:54:54 -07:00
<div className="inline-block w-full transform text-left align-middle transition-all 2xl:max-w-7xl">
<div className="group relative">
<div className="animate-tilt absolute -inset-0.5 rotate-2 rounded-lg bg-accent shadow-md transition duration-1000 group-hover:opacity-100 group-hover:duration-200"></div>
<div className="relative flex flex-col overflow-hidden rounded-2xl bg-base shadow-md md:aspect-[2/1] md:flex-row md:bg-primary">
2022-04-09 01:54:54 -07:00
{children}
</div>
</div>
</div>
2022-04-02 06:17:50 -07:00
</div>
</Dialog>
2022-04-09 01:54:54 -07:00
</AnimatePresence>
2022-04-02 06:17:50 -07:00
);
};