mirror of
https://github.com/Alamantus/Lexiconga.git
synced 2025-04-19 01:50:12 +02:00
Create Modal component
This commit is contained in:
parent
aaee2bcdb0
commit
eb91db4b4a
1 changed files with 75 additions and 0 deletions
75
src/components/structure/Modal.jsx
Normal file
75
src/components/structure/Modal.jsx
Normal file
|
@ -0,0 +1,75 @@
|
|||
import Inferno from 'inferno';
|
||||
import Component from 'inferno-component';
|
||||
|
||||
export class Modal extends Component {
|
||||
constructor (props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
isVisible: false,
|
||||
}
|
||||
}
|
||||
|
||||
show () {
|
||||
this.setState({
|
||||
isVisible: true,
|
||||
});
|
||||
}
|
||||
|
||||
hide () {
|
||||
this.setState({
|
||||
isVisible: false,
|
||||
});
|
||||
}
|
||||
|
||||
render () {
|
||||
const {
|
||||
buttonText,
|
||||
title,
|
||||
children,
|
||||
footerAlign = 'left',
|
||||
footerContent,
|
||||
} = this.props;
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div className='field'>
|
||||
<p className='control'>
|
||||
<a className='button'
|
||||
onClick={ this.show.bind(this) }>
|
||||
{ buttonText || 'Show' }
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div className={ `modal ${(this.state.isVisible) ? 'is-active' : ''}` }>
|
||||
|
||||
<div className='modal-background' onClick={ this.hide.bind(this) } />
|
||||
|
||||
<div className='modal-card'>
|
||||
<header className='modal-card-head'>
|
||||
<h3 className='modal-card-title'>
|
||||
{ title || 'Modal' }
|
||||
</h3>
|
||||
<button className='delete' aria-label='close'
|
||||
onClick={ this.hide.bind(this) }
|
||||
/>
|
||||
</header>
|
||||
|
||||
<section className='modal-card-body'>
|
||||
|
||||
{ children }
|
||||
|
||||
</section>
|
||||
|
||||
<footer className={ `modal-card-foot ${ (footerAlign === 'right') ? 'has-text-right is-pulled-right' : '' }` }>
|
||||
|
||||
{ footerContent }
|
||||
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue