import { chakra, HTMLChakraProps } from "@hakuna-matata-ui/system" import { HTMLMotionProps, motion, Variant } from "framer-motion" import { mergeWith } from "@hakuna-matata-ui/utils" import React from "react" import { usePopoverContext } from "./popover-context" // TODO: consider moving this to some util type HTMLMotionChakraProps = Omit< HTMLChakraProps, keyof HTMLMotionProps > & Omit< HTMLMotionProps, | "style" | "onDrag" | "onDragEnd" | "onDragStart" | "onAnimationStart" | "variants" > & { variants?: MotionVariants } type MotionVariants = Partial> const mergeVariants = (variants?: MotionVariants) => { if (!variants) return return mergeWith(variants, { enter: { visibility: "visible", }, exit: { transitionEnd: { visibility: "hidden", }, }, }) } const scaleFade: MotionVariants = { exit: { opacity: 0, scale: 0.95, transition: { duration: 0.1, ease: [0.4, 0, 1, 1], }, }, enter: { scale: 1, opacity: 1, transition: { duration: 0.15, ease: [0, 0, 0.2, 1], }, }, } const Section = motion(chakra.section) export interface PopoverTransitionProps extends HTMLMotionChakraProps<"section"> {} export const PopoverTransition = React.forwardRef( (props: HTMLMotionChakraProps<"section">, ref: React.Ref) => { const { isOpen } = usePopoverContext() return (
) }, ) PopoverTransition.defaultProps = { variants: scaleFade, }