UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing systems.

51 lines (38 loc) 903 B
import { Component } from '../../ui' /** Modal dialog component @class @component @prop {String} width 'small', 'medium', 'large' and 'full' @example ```js var form = $$(Modal, { width: 'medium', textAlign: 'center' }); ``` */ class Modal extends Component { render($$) { let el = $$('div').addClass('sc-modal') // TODO: don't think that this is good enough. Right the modal is closed by any unhandled click. // Need to be discussed. el.on('click', this._closeModal) if (this.props.width) { el.addClass('sm-width-'+this.props.width) } el.append( $$('div').addClass('se-body').append( this.props.children ) ) return el } _closeModal(e) { let closeSurfaceClick = e.target.classList.contains('sc-modal') if (closeSurfaceClick) { this.send('closeModal') } } } export default Modal