Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the warning modal for clearboard #36

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions src/App.js

This file was deleted.

22 changes: 20 additions & 2 deletions src/Components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -54,6 +54,7 @@ class Main extends React.Component {
iAmReciever : false,
receiverConnected: false,
joinError: '',
show: false,
}

this.setColor = this.setColor.bind(this);
Expand All @@ -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() {
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -384,7 +400,9 @@ class Main extends React.Component {
<PaletteIcon onClick={this.toggleColorPicker} className = 'header--item'/>
{ this.state.showColorPicker && <HexColorPicker className='color__palette' color={this.state.color} onChange={this.setColor} />}
</span>
<ClearIcon className = 'header--item' onClick = {this.clearBoard}/>
<Modal show={this.state.show} handleClose={this.hideModal} handleConfirm={this.clearBoard}>
</Modal>
<ClearIcon className = 'header--item' onClick = {this.showModal}/>
<UndoIcon onClick = {this.undoStep} className='undo header--item' />
<RedoIcon onClick = {this.redoStep} className='redo header--item'/></>}
<ZoomInIcon className = {`header--item`} onClick = {this.zoomIn} />
Expand Down
31 changes: 31 additions & 0 deletions src/Components/Modal/Modal.js
Original file line number Diff line number Diff line change
@@ -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 (
<><div className={showHideClassName}>
<section className="modal-main">
{children}
<div className="titleCloseBtn">
<h1 className='heading-popup'>Are you sure?</h1>
<p className='subheading-popup'>this action cannot be undo</p>
<button className='btn btn-1' type='button'
onClick={handleConfirm}>
Yes
</button>
<button className='btn btn-2' type='button'
onClick={handleClose}>
No
</button>
</div>
</section>
</div></>



);
}

export default Modal
66 changes: 66 additions & 0 deletions src/Components/Modal/modal.css
Original file line number Diff line number Diff line change
@@ -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;
}