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

11 #59

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

11 #59

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
16 changes: 15 additions & 1 deletion src/Components/Main/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +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 {

Expand Down Expand Up @@ -79,6 +80,8 @@ 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 +152,18 @@ 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 +396,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
34 changes: 34 additions & 0 deletions src/Components/Modal/Modal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import './modal.css';
import WarningRoundedIcon from '@mui/icons-material/WarningRounded';
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">
<div className='warning-container'>
<WarningRoundedIcon className='war-icon'></WarningRoundedIcon>
<h1 className='heading-popup'>Are you sure?</h1>
</div>
<p className='subheading-popup'>this action cannot be undo</p>

</div>
<div className="btn-container">
<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
122 changes: 122 additions & 0 deletions src/Components/Modal/modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
.modal {
position: fixed;
top: 0;
left: 0;
width:100%;
height: 100%;
background: rgba(0, 0, 0, 0.6);
}

.modal-main {
position:fixed;
background: white;
height: 200px;
width: 500px;
top:50%;
left:50%;
transform: translate(-50%,-50%);
border-radius: 0.31rem;

}
.warning-container{
display: flex;
align-items: center;
justify-content: center;
padding-right: 10px;
}

.war-icon{
color: rgb(230, 57, 57);
}
.display-block {
display: block;
}

.display-none {
display: none;
}

/* button {

} */

.btn-container{
display: flex;
align-items: center;
justify-content: center;
}

.btn-1:hover {
background-color: #044ab3;
}

.btn-2:hover {
background-color: #37393c;
}


.heading-popup{
text-align: center;
margin-left: 10px;
}

.subheading-popup{
text-align: center;
font-size: large;
font-weight: 200;
}

.btn-2{
color: #fff;
background-color: #5c636a;
border-color: #565e64;
}

.btn-1{
color: #fff;
background-color: #0b5ed7;
border-color: #0a58ca;
}

button{
margin: .25rem;
display: inline-block;
font-weight: 400;
line-height: 1.5;
text-align: center;
text-decoration: none;
border: 1px solid transparent;
padding: .375rem .75rem;
font-size: 1rem;
border-radius: .25rem;
transition: color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out;
user-select: none;
-webkit-appearance: button;
text-transform: none;
margin: 20px 50px 10px 50px;
width: 70px;
cursor: pointer;
}


@media (max-width:414px){
.modal-main {
padding: 8px;
height: 140px;
width: 200px;
top: 40%;
}
.btn-container{
height: 35px;
}
button{
line-height: 1;
margin: 3px;
}
.warning-container{
height: 39px;
}
.subheading-popup{
font-weight:lighter;
}
}