Skip to content

Commit

Permalink
feat:(modal): Added "slideInTop" and "slideInLeft" motion preset (cha…
Browse files Browse the repository at this point in the history
  • Loading branch information
backy22 authored Aug 30, 2023
1 parent 7d348da commit eb477b6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/nervous-moles-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@chakra-ui/modal": patch
---

Added "slideInTop" and "slideInLeft" options in motionPreset prop in modal
component
16 changes: 15 additions & 1 deletion packages/components/modal/src/modal-transition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,13 @@ import { forwardRef } from "react"
export interface ModalTransitionProps
extends Omit<HTMLMotionProps<"section">, "color" | "transition">,
ChakraProps {
preset?: "slideInBottom" | "slideInRight" | "scale" | "none"
preset?:
| "slideInBottom"
| "slideInRight"
| "slideInTop"
| "slideInLeft"
| "scale"
| "none"
motionProps?: HTMLMotionProps<"section">
}

Expand All @@ -19,6 +25,14 @@ const transitions = {
...slideFadeConfig,
custom: { offsetX: 16, reverse: true },
},
slideInTop: {
...slideFadeConfig,
custom: { offsetY: -16, reverse: true },
},
slideInLeft: {
...slideFadeConfig,
custom: { offsetX: -16, reverse: true },
},
scale: {
...scaleFadeConfig,
custom: { initialScale: 0.95, reverse: true },
Expand Down
8 changes: 7 additions & 1 deletion packages/components/modal/src/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ interface ModalOptions extends Pick<FocusLockProps, "lockFocusAcrossFrames"> {

type ScrollBehavior = "inside" | "outside"

type MotionPreset = "slideInBottom" | "slideInRight" | "scale" | "none"
type MotionPreset =
| "slideInBottom"
| "slideInRight"
| "slideInTop"
| "slideInLeft"
| "scale"
| "none"

export interface ModalProps
extends UseModalProps,
Expand Down

0 comments on commit eb477b6

Please sign in to comment.