Skip to content

Commit d1b7eea

Browse files
Modal PopUp
1 parent 82feb34 commit d1b7eea

File tree

2 files changed

+63
-3
lines changed

2 files changed

+63
-3
lines changed

examples/main.jsx

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ import DropZone from 'react-dropzone';
4242
import Toolbar from '@material-ui/core/Toolbar/Toolbar';
4343
import Typography from '@material-ui/core/Typography/Typography';
4444

45+
import { makeStyles } from '@material-ui/core/styles';
46+
import Modal from '@material-ui/core/Modal';
47+
48+
4549
const styles = {
4650
root: {
4751
padding: '3px',
@@ -94,6 +98,11 @@ const styles = {
9498
card: {
9599
margin: '10px 10px 5px 0'
96100
},
101+
modal: {
102+
top: '40%',
103+
left: '50%',
104+
transform: 'translate(50%, 50%)'
105+
}
97106
};
98107

99108
/**
@@ -156,7 +165,7 @@ class SketchFieldDemo extends React.Component {
156165
dataJson: dataJson,
157166
url: dataUrl,
158167
maxHeight: (window.innerHeight + 800),
159-
isCanvas: false
168+
isOpen: true
160169
};
161170
}
162171

@@ -412,7 +421,25 @@ class SketchFieldDemo extends React.Component {
412421

413422
};
414423

424+
_handleClose = () =>{
425+
this.setState({isOpen: false})
426+
}
427+
428+
_setInput1 = (event) =>{
429+
this.setState({newHeight: event.target.value})
430+
}
431+
_setInput2 = (event) =>{
432+
this.setState({newWidth: event.target.value})
433+
}
434+
435+
_saveClick = () =>{
415436

437+
if(this.state.newWidth && this.state.newHeight){
438+
this.setState({ height: parseInt(this.state.newHeight), width: parseInt(this.state.newWidth)})
439+
}
440+
this.setState({isOpen: false})
441+
console.log(this.state.height)
442+
}
416443

417444
render = () => {
418445
let { controlledValue } = this.state;
@@ -427,11 +454,11 @@ class SketchFieldDemo extends React.Component {
427454
});
428455

429456

430-
431457
return (
432458
<MuiThemeProvider theme={theme}>
433459
<div className="row">
434460
<div className="col-xs-12 col-sm-12 col-md-12 col-lg-12">
461+
435462
<AppBar position="static" style={styles.appBar}>
436463
<Toolbar>
437464
<Typography variant="h6" color="inherit" style={{ flexGrow: 1 }}>Sketch Tool</Typography>
@@ -492,8 +519,39 @@ class SketchFieldDemo extends React.Component {
492519
</AppBar>
493520
</div>
494521
</div>
522+
495523
<div className="row">
524+
<Modal
525+
open={this.state.isOpen}
526+
onClose={() => this._handleClose()}
527+
aria-labelledby="simple-modal-title"
528+
aria-describedby="simple-modal-description">
529+
<div className="row" style={{ background: '#fff', width: '30%', position: 'absolute', top: '25%', left: '25%', height: 300}}>
530+
<div className="text-center" style={{ textAlign: 'center', width: '100%', height: '0px'}}>
531+
<h2> Select Size</h2>
532+
</div>
533+
534+
<div className="col-md-4">
535+
<label> Height </label>
536+
<input type="text" value={this.state.height} onChange={this._setInput1} style={{ padding: 10, marginTop: 5}}/>
537+
</div>
538+
<div className="col-md-2"></div>
539+
540+
<div className="col-md-4">
541+
<label> Width </label>
542+
<input type="text" value={this.state.width} onChange={this._setInput2} style={{ padding: 10, marginTop: 5}}/>
543+
</div>
496544

545+
<div className="col-md-12" style={{ textAlign: 'center', marginTop: 0}}>
546+
<Button variant="contained" color="primary" onClick={this._saveClick}>
547+
Save
548+
</Button>
549+
</div>
550+
</div>
551+
</Modal>
552+
</div>
553+
554+
<div className="row">
497555
<div className="col-xs-7 col-sm-7 col-md-9 col-lg-9">
498556
<SketchField
499557
name="sketch"
@@ -525,7 +583,7 @@ class SketchFieldDemo extends React.Component {
525583
tool={this.state.tool}
526584
/>
527585
</div>
528-
586+
529587
<div className="col-xs-5 col-sm-5 col-md-3 col-lg-3">
530588
<Card style={styles.card}>
531589
<CardHeader

src/SketchField.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,8 @@ class SketchField extends PureComponent {
649649

650650
render = () => {
651651
let { className, style, width, height } = this.props;
652+
console.log(height);
653+
console.log(width);
652654

653655
let canvasDivStyle = Object.assign({}, style ? style : {},
654656
width ? { width: width } : {},

0 commit comments

Comments
 (0)