@kadoui/react
Version:
Kadoui primitive components for React
12 lines (11 loc) • 667 B
JavaScript
"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { use } from "react";
import { AnimatePresence, motion } from "framer-motion";
import { Portal } from "../Portal/Portal";
import { SheetContext } from "./SheetContext";
import { ClientOnly } from "../ClientOnly/ClientOnly";
export function SheetPortal(p) {
const { isOpen, closeHandler: handleClose, scope } = use(SheetContext);
return (_jsx(ClientOnly, { children: _jsx(Portal, { children: _jsx(AnimatePresence, { children: isOpen ? (_jsx(motion.div, { ref: scope, onClick: handleClose, initial: { opacity: 0 }, animate: { opacity: 1 }, exit: { opacity: 0 }, ...p })) : null }) }) }));
}