React Close Dialog with Animation

Developer
Size
5,569 Kb
Views
16,192

How do I make an react close dialog with animation?

What is a react close dialog with animation? How do you make a react close dialog with animation? This script and codes were developed by Joost Jansen on 19 November 2022, Saturday.

React Close Dialog with Animation Previews

React Close Dialog with Animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>React Close Dialog with Animation</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css"> <link rel='stylesheet prefetch' href='https://fonts.googleapis.com/css?family=Paprika|Open+Sans'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div class="root"></div> <script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/react/15.4.2/react-dom.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

React Close Dialog with Animation - Script Codes CSS Codes

body { -webkit-font-smoothing: antialiased;
}
.App { height: 100vh; position: relative; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column nowrap; flex-flow: column nowrap; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; background-color: #C55;
}
.Content { display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column nowrap; flex-flow: column nowrap; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center;
}
.Content__Title { font-family: "Paprika", sans-serif; font-weight: 300;
}
.Content__Controls { width: 240px; margin-top: 25px; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: justify; -ms-flex-pack: justify; justify-content: space-between;
}
.Dialog { height: 400px; width: 500px; display: -webkit-box; display: -ms-flexbox; display: flex; -ms-flex-flow: column nowrap; flex-flow: column nowrap; -webkit-box-align: center; -ms-flex-align: center; align-items: center; -ms-flex-pack: distribute; justify-content: space-around; position: absolute; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); opacity: 0; background-color: rgba(0, 0, 0, 0.85); color: #fff; -webkit-animation-duration: 400ms; animation-duration: 400ms; -webkit-animation-fill-mode: both; animation-fill-mode: both;
}
.Dialog.hidden { -webkit-animation-name: fadeOut; animation-name: fadeOut;
}
.Dialog.show { -webkit-animation-name: fadeIn; animation-name: fadeIn;
}
.Dialog__Title { font-family: "Paprika", sans-serif;
}
.Button { outline: 0; border: 0; cursor: pointer; font-family: 'Open Sans', sans-serif; font-weight: 300; padding: 15px; background-color: #fff;
}
.Button--Default { -webkit-transition: background-color 150ms linear, -webkit-transform 150ms linear; transition: background-color 150ms linear, -webkit-transform 150ms linear; transition: transform 150ms linear, background-color 150ms linear; transition: transform 150ms linear, background-color 150ms linear, -webkit-transform 150ms linear;
}
.Button--Default:hover { -webkit-transform: translate(0, -3px); transform: translate(0, -3px); background-color: #ccc;
}
.Button--Modal { -webkit-transition: background-color 150ms linear; transition: background-color 150ms linear; background-color: #000; color: #fff;
}
.Button--Modal:hover { background-color: #333;
}
@-webkit-keyframes fadeIn { from { opacity: 0; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); } to { opacity: 1; -webkit-transform: translate(-50%, -50%) scale(1); transform: translate(-50%, -50%) scale(1); }
}
@keyframes fadeIn { from { opacity: 0; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); } to { opacity: 1; -webkit-transform: translate(-50%, -50%) scale(1); transform: translate(-50%, -50%) scale(1); }
}
@-webkit-keyframes fadeOut { from { opacity: 1; -webkit-transform: translate(-50%, -50%) scale(1); transform: translate(-50%, -50%) scale(1); } to { opacity: 0; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); }
}
@keyframes fadeOut { from { opacity: 1; -webkit-transform: translate(-50%, -50%) scale(1); transform: translate(-50%, -50%) scale(1); } to { opacity: 0; -webkit-transform: translate(-50%, -50%) scale(0); transform: translate(-50%, -50%) scale(0); }
}

React Close Dialog with Animation - Script Codes JS Codes

"use strict";
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
////////////////////// IMPORTS //////////////////////
var _React = React;
var Component = _React.Component;
var _ReactDOM = ReactDOM;
var render = _ReactDOM.render;
////////////////////// COMPONENTS //////////////////////
/* The App component keeps track of which dialog is opened * in its state (a.k.a. $scope). * Every component has its own props (configuration, like * directive attributes) and state (again, $scope at component * level). */
var App = function (_Component) { _inherits(App, _Component); function App(props) { _classCallCheck(this, App); var _this = _possibleConstructorReturn(this, _Component.call(this, props)); _this.state = { openedDialogName: null }; _this.openDialog = _this.openDialog.bind(_this); _this.closeDialog = _this.closeDialog.bind(_this); return _this; } App.prototype.openDialog = function openDialog(e, name) { e.preventDefault(); this.setState({ openedDialogName: name }); }; App.prototype.closeDialog = function closeDialog(e) { e.preventDefault(); this.setState({ openedDialogName: null }); }; App.prototype.render = function render() { return React.createElement( "div", { className: "App" }, React.createElement(Content, { open: this.openDialog }), React.createElement(Dialog, { name: "login", show: this.state.openedDialogName === "login", close: this.closeDialog }), React.createElement(Dialog, { name: "checkout", show: this.state.openedDialogName === "checkout", close: this.closeDialog }) ); }; return App;
}(Component);
var Content = function Content(_ref) { var open = _ref.open; return React.createElement( "div", { className: "Content" }, React.createElement( "h1", { className: "Content__Title" }, "Hi from the app container!" ), React.createElement( "div", { className: "Content__Controls" }, React.createElement( "button", { className: "Button Button--Default", onClick: function onClick(e) { return open(e, "login"); } }, "Login" ), React.createElement( "button", { className: "Button Button--Default", onClick: function onClick(e) { return open(e, "checkout"); } }, "Go to Checkout" ) ) );
};
/* * The Dialog component recieves some initial props, and * returns a view representation of the dialog. * It's only shown depending on the value of the * property called {show}. */
var Dialog = function Dialog(_ref2) { var name = _ref2.name; var show = _ref2.show; var close = _ref2.close; var classNames = "Dialog " + (show ? 'show' : 'hidden'); return React.createElement( "div", { className: classNames }, React.createElement( "h2", { className: "Dialog__Title" }, "Hi from the ", name, " dialog!" ), React.createElement( "button", { className: "Button Button--Modal", onClick: function onClick(e) { return close(e); } }, "Close" ) );
};
////////////////////// RENDERING //////////////////////
render(React.createElement(App, null), document.querySelector('.root'));
React Close Dialog with Animation - Script Codes
React Close Dialog with Animation - Script Codes
Home Page Home
Developer Joost Jansen
Username DevItWithDavid
Uploaded November 19, 2022
Rating 3
Size 5,569 Kb
Views 16,192
Do you need developer help for React Close Dialog with Animation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Joost Jansen (DevItWithDavid) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!