From 8998d4c53c2797574b026c052d4b20f07fcfc9fb Mon Sep 17 00:00:00 2001 From: KamalSinghKhanna Date: Tue, 8 Mar 2022 21:44:52 +0530 Subject: [PATCH 1/2] added the warning modal for clearboard --- src/App.js | 1 + src/Components/Main/Main.js | 22 ++++++++++-- src/Components/Modal/Modal.js | 31 ++++++++++++++++ src/Components/Modal/modal.css | 66 ++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 src/Components/Modal/Modal.js create mode 100644 src/Components/Modal/modal.css diff --git a/src/App.js b/src/App.js index 090cee3..fc3eb0d 100644 --- a/src/App.js +++ b/src/App.js @@ -7,6 +7,7 @@ function App() {
+
); } diff --git a/src/Components/Main/Main.js b/src/Components/Main/Main.js index 89cd0ca..a510686 100644 --- a/src/Components/Main/Main.js +++ b/src/Components/Main/Main.js @@ -26,7 +26,7 @@ import CancelPresentationIcon from '@mui/icons-material/CancelPresentation'; import io from 'socket.io-client'; import Notification from '../Notification/Notification'; - +import Modal from '../Modal/Modal'; class Main extends React.Component { constructor(props) { @@ -54,6 +54,7 @@ class Main extends React.Component { iAmReciever : false, receiverConnected: false, joinError: '', + show: false, } this.setColor = this.setColor.bind(this); @@ -79,6 +80,9 @@ class Main extends React.Component { this.checkForSocketWatcher = this.checkForSocketWatcher.bind(this); this.socket = null; + + this.showModal = this.showModal.bind(this); + this.hideModal = this.hideModal.bind(this); } getLocalStorageData() { @@ -149,9 +153,21 @@ class Main extends React.Component { })) } + showModal() { + this.setState({ show: true }); + }; + + hideModal() { + this.setState({show:false}); + }; + clearBoard() { // this.sketchField.current.zoom(Number.MAX_SAFE_INTEGER) + this.sketchField.current.clear(); + this.setState({show:false}); + + // const canvas = this.sketchField.current._canvas // const ctx = canvas.getContext('2d'); // const currColor = this.props.theme === 'light' ? '#fff' : '#000'; @@ -384,7 +400,9 @@ class Main extends React.Component { { this.state.showColorPicker && } - + + + } diff --git a/src/Components/Modal/Modal.js b/src/Components/Modal/Modal.js new file mode 100644 index 0000000..f2b7862 --- /dev/null +++ b/src/Components/Modal/Modal.js @@ -0,0 +1,31 @@ +import React from 'react'; +import './modal.css'; + +function Modal({ handleClose, handleConfirm , show, children }) { + const showHideClassName = show ? "modal display-block" : "modal display-none"; + + return ( + <>
+
+ {children} +
+

Are you sure?

+

this action cannot be undo

+ + +
+
+
+ + + + ); +} + +export default Modal \ No newline at end of file diff --git a/src/Components/Modal/modal.css b/src/Components/Modal/modal.css new file mode 100644 index 0000000..ed7f557 --- /dev/null +++ b/src/Components/Modal/modal.css @@ -0,0 +1,66 @@ +.modal { + position: fixed; + top: 0; + left: 0; + width:100%; + height: 100%; + background: rgba(0, 0, 0, 0.6); + } + + .modal-main { + position:fixed; + background: white; + width: 40%; + height: auto; + top:50%; + left:50%; + transform: translate(-50%,-50%); + border-radius: 1.5%; + } + + .display-block { + display: block; + } + + .display-none { + display: none; + } + + button { + margin: 20px 100px 10px 100px; + width: 70px; + } + + + .btn-1:hover { + cursor: pointer; + box-shadow: 0.4rem 0.4rem 0 rgb(15, 133, 0); + transform: translate(-0.4rem, -0.4rem); + } + +.btn-2:hover { + cursor: pointer; + box-shadow: 0.4rem 0.4rem 0 rgb(223, 43, 43); + transform: translate(-0.4rem, -0.4rem); +} + +.btn:active { + box-shadow: 0 0 0 rgb(0, 0, 0); + transform: translate(0, 0); +} + + .heading-popup{ + text-align: center; + } + + .subheading-popup{ + text-align: center; + } + + .btn-2{ + color: red; + } + + .btn-1{ + color: green; + } \ No newline at end of file From cf627a062447f47316c7ec31c8f060c16dfdde7b Mon Sep 17 00:00:00 2001 From: Kamal Singh Khanna <78915058+KamalSinghKhanna@users.noreply.github.com> Date: Tue, 8 Mar 2022 21:59:06 +0530 Subject: [PATCH 2/2] Delete App.js --- src/App.js | 32 -------------------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/App.js diff --git a/src/App.js b/src/App.js deleted file mode 100644 index 81ac6a8..0000000 --- a/src/App.js +++ /dev/null @@ -1,32 +0,0 @@ -import "./App.scss"; -import React, { Suspense, lazy } from "react"; -import Preloader from "./Components/Preloader/Preloader"; - -const Header = lazy(() => { - return Promise.all([ - import("./Components/Header/Header"), - new Promise((resolve) => setTimeout(resolve, 3000)), - ]).then(([moduleExports]) => moduleExports); -}); -const Main = lazy(() => { - return Promise.all([ - import("./Components/Main/Main"), - new Promise((resolve) => setTimeout(resolve, 3000)), - ]).then(([moduleExports]) => moduleExports); -}); - -function App() { - return ( -
- }> - <> -
-
- - -
- ); - -} - -export default App;