-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add modal manager, animations, state management and hooks
- Loading branch information
1 parent
a5d2fba
commit 9625c8a
Showing
5 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
common/components/modal/animations/ModalManagar.animations.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { DEFAULT_EASE } from "@/common/constants/easings"; | ||
|
||
const transition= {ease: DEFAULT_EASE}; | ||
|
||
export const bgAnimation = { | ||
closed: {opacity: 0, transition}, | ||
opened: {opacity: 1, transition}, | ||
}; | ||
|
||
export const modalAnimation = { | ||
closed: {y:-100, transition}, | ||
opened: {y:0, transition}, | ||
exited: {y:100, transition}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DEFAULT_EASE= [0.6, 0.01, -0.05, 0.9]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { modalAtom } from "./modal.atom"; | ||
import useModal from "./modal.hooks"; | ||
|
||
export default modalAtom; | ||
export {useModal}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { atom } from "recoil"; | ||
|
||
export const modalAtom = atom <{ | ||
modal: JSX.Element | JSX.Element[]; | ||
opened: boolean; | ||
}>({ | ||
key: "modal", | ||
default: { | ||
modal:<></>, | ||
opened: false, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useSetRecoilState } from "recoil"; | ||
import { modalAtom } from "./modal.atom"; | ||
|
||
const useModal = () => { | ||
const setModal= useSetRecoilState(modalAtom); | ||
const openModal = (modal: JSX.Element | JSX.Element[]) => { | ||
setModal({ | ||
modal, | ||
opened: true, | ||
}); | ||
}; | ||
|
||
const closeModal = () => | ||
setModal({ | ||
modal: <></>, | ||
opened: false, | ||
}); | ||
|
||
return {openModal, closeModal}; | ||
|
||
}; | ||
|
||
export default useModal; |