import React from 'react'; import Examples from './utils/Examples.js'; import Button from '../../src/react/Button.js'; import Modal from '../../src/react/Modal.js'; import Input from '../../src/react/Input.js'; import HTMLStandardModal from '../../components/modal/standard-modal.html'; import HTMLAlertModal from '../../components/modal/alert-modal.html'; import HTMLErrorModal from '../../components/modal/error-modal.html'; import HTMLCustomModal from '../../components/modal/custom-modal.html'; class Example extends React.Component { constructor(props) { super(props); this.state = { show: false }; } render() { const { children } = this.props; const { show } = this.state; var childrenWithProps = React.Children.map(children, child => { let childChildrenWithProps = []; if (child.props.children) { let childChildren = child.props.children; childChildrenWithProps = React.Children.map(childChildren, child => React.cloneElement(child, { onClose: ()=>this.setState({show: !show}) })); } return React.cloneElement(child, { show: this.state.show, onClose: ()=>this.setState({show: !show}), children: childChildrenWithProps}); } ); return (
{childrenWithProps}
); } } const ModalBody = () => { return (
); }; const BODY_TEXT = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed risus nisl, egestas vitae erat non,' + 'pulvinar lacinia libero. Integer pulvinar pellentesque accumsan. Sed hendrerit lacus eu tempus pharetra'; const isShown = false; let examples = { Standard: { jsx: isShown()} size='small'> Standard Modal {BODY_TEXT} {}}/> , html: HTMLStandardModal, exclude: 'Example', renderFromJsx: true }, Alert: { jsx: isShown()} type='alert' size='small'> Title {BODY_TEXT} , html: HTMLAlertModal, exclude: 'Example', renderFromJsx: true }, Error: { jsx: isShown()} size='small' type='error'> isShown(false)} type='error'>Title {BODY_TEXT} isShown(false)} closeButtonText='Ok'/> , html: HTMLErrorModal, exclude: 'Example', renderFromJsx: true }, Custom: { jsx: isShown()} type='custom'> Title {}}/> , html: HTMLCustomModal, exclude: 'Example', renderFromJsx: true } }; const Modals = () => ( ); export default Modals;