mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-27 13:53:09 +00:00
add image selector field type, modal component, and new snippet widgets
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
require('./modal.less');
|
||||
const React = require('react');
|
||||
const createClass = require('create-react-class');
|
||||
|
||||
const Modal = createClass({
|
||||
getDefaultProps : function () {
|
||||
return {
|
||||
header : '',
|
||||
save : ()=>{},
|
||||
};
|
||||
},
|
||||
|
||||
getInitialState : function() {
|
||||
return {
|
||||
visible : false,
|
||||
};
|
||||
},
|
||||
|
||||
setVisible : function(visible) {
|
||||
this.setState({
|
||||
visible
|
||||
});
|
||||
},
|
||||
|
||||
save : function() {
|
||||
this.props.save();
|
||||
this.setVisible(false);
|
||||
},
|
||||
|
||||
render : function () {
|
||||
const { children, header } = this.props;
|
||||
const { visible } = this.state;
|
||||
return <React.Fragment>
|
||||
{visible ? <div className={'bg-cover'}>
|
||||
<div className={'modal'}>
|
||||
<h1>{header}</h1>
|
||||
<hr/>
|
||||
{children}
|
||||
<div className={'action-row'}>
|
||||
<button id={'save'} onClick={()=>this.save()}>Save</button>
|
||||
<button id={'cancel'} onClick={()=>this.setVisible(false)}>Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> : null}
|
||||
</React.Fragment>;
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = Modal;
|
||||
Reference in New Issue
Block a user