From ed4c34f9094758c169d2bbe3fa4b204f67d5e8c7 Mon Sep 17 00:00:00 2001 From: Allan Oliveira Date: Sun, 5 Mar 2023 11:59:56 -0300 Subject: [PATCH] feat: add Dynamic Modal Animation Settings --- package.json | 2 +- src/components/molecules/Modal/Modal.tsx | 26 +++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 10cb34b..57ca61c 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "react", "typescript" ], - "version": "2.1.19", + "version": "2.1.20", "main": "./dist/index.cjs.js", "module": "./dist/index.esm.js", "types": "./dist/index.d.ts", diff --git a/src/components/molecules/Modal/Modal.tsx b/src/components/molecules/Modal/Modal.tsx index c008dbb..140e14f 100644 --- a/src/components/molecules/Modal/Modal.tsx +++ b/src/components/molecules/Modal/Modal.tsx @@ -15,7 +15,7 @@ import { ModalPortalDedupleContext, ModalPortalDedupleProvider, } from 'contexts/ModalPortalDedupleContext' -import { motion, AnimatePresence } from 'framer-motion' +import { motion, AnimatePresence, AnimationProps } from 'framer-motion' import { FlexProps } from 'components/atoms' import { Portal } from 'components/hocs/Portal' @@ -32,6 +32,12 @@ type ModalFunctionNotation = { } export type ModalProps = { + animation?: { + initial?: AnimationProps['initial'] + transition?: AnimationProps['transition'] + in?: AnimationProps['animate'] + out?: AnimationProps['exit'] + } render: (params: ModalFunctionNotation) => ReactNode onClickOutside?: () => void children?: (params: ModalFunctionNotation) => ReactNode @@ -42,6 +48,7 @@ export type ModalProps = { } & Omit const ModalBase = ({ + animation, render, onClickOutside, externalIsOpen, @@ -86,13 +93,17 @@ const ModalBase = ({ {modalIsOpen ? ( @@ -110,6 +121,7 @@ const ModalBase = ({ ModalBase.defaultProps = { children: undefined, + animation: undefined, onClickOutside: undefined, externalIsOpen: undefined, backgroundProps: undefined,