This file contains hidden or 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
| import React from "react"; | |
| import { animated } from "react-spring"; | |
| import "./modal.css"; | |
| const Modal = ({ style, closeModal }) => ( | |
| <div className="modal"> | |
| <h3 className="modal-title">Modal title</h3> | |
| <p className="modal-content">Here is some random text.</p> | |
| <button className="modal-close-button" onClick={closeModal}> | |
| Close |
This file contains hidden or 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
| import React from "react"; | |
| import { animated } from "react-spring"; | |
| import "./modal.css"; | |
| const Modal = ({ style, closeModal }) => ( | |
| <div className="modal"> | |
| <h3 className="modal-title">Modal title</h3> | |
| <p className="modal-content">Here is some random text.</p> | |
| <button className="modal-close-button"> Close </button> | |
| </div> |
This file contains hidden or 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
| import React from "react"; | |
| import { animated } from "react-spring"; | |
| import "./modal.css"; | |
| const Modal = ({ style, closeModal }) => ( <div>Modal</div> ); | |
| export default Modal; |
This file contains hidden or 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
| import React, { useState } from "react"; | |
| import { useTransition } from "react-spring"; | |
| import ReactDOM from "react-dom"; | |
| import Modal from "./Modal"; | |
| import "./styles.css"; | |
| function App() { | |
| const [modalVisible, setModalVisible] = useState(false); | |
| const fadingAnimation = useTransition(modalVisible, null, { | |
| from: { opacity: 0, transform: "translateY(-40px)" }, |
This file contains hidden or 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
| <button className="show-modal-button" onClick={() => setModalVisible(true)}>Show modal</button> |
This file contains hidden or 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
| {fadingAnimation.map( ({ item, key, props: style }) => | |
| item && ( <Modal style={style} closeModal={() => setModalVisible(false)} key={key} /> ) | |
| )} |
This file contains hidden or 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
| const fadingAnimation = useTransition(modalVisible, null, { | |
| from: { opacity: 0, transform: "translateY(-40px)" }, | |
| enter: { opacity: 1, transform: "translateY(0px)" }, | |
| leave: { opacity: 0, transform: "translateY(-40px)" } | |
| }); |
This file contains hidden or 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
| const fadingAnimation = useTransition(); |
This file contains hidden or 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
| const [modalVisible, setModalVisible] = useState(false); |
This file contains hidden or 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
| import React, { useState } from "react" | |
| import { useTransition } from "react-spring" | |
| import Modal from "./Modal"; | |
| function App() { | |
| return ( | |
| <div className="App"> | |
| <Modal /> | |
| </div> | |
| ); |