| 2 | import {Modal} from './index.js'; |
| 3 | |
| 4 | export default class ModalDemo extends React.Component { |
| 5 | constructor(props){ |
| 6 | super(props); |
| 7 | } |
| 8 | |
| 9 | handleConfirm(){ |
| 10 | return confirm('close modal?'); |
| 11 | } |
| 12 | |
| 13 | handleCancel(){ |
| 14 | return true; |
| 15 | } |
| 16 | |
| 17 | handleConfirm1(){ |
| 18 | alert('confirmed'); |
| 19 | return true; |
| 20 | } |
| 21 | |
| 22 | openModal(ref){ |
| 23 | const node = this.refs[ref] |
| 24 | node.open() |
| 25 | } |
| 26 | |
| 27 | handleClose(){ |
| 28 | return confirm('close') |
| 29 | } |
| 30 | |
| 31 | render() { |
| 32 | const content = <div> |
| 33 | <h4>this is content</h4> |
| 34 | <p>This is a modal window. You can do the following things with it:</p> |
| 35 | <ul> |
| 36 | <li>Read: modal windows will probably tell you something important so don't forget to read what they say.</li> |
| 37 | <li>Look: a modal window enjoys a certain kind of attention; just look at it and appreciate its presence.</li> |
| 38 | <li>Close: click on the button to close the modal.</li> |
| 39 | <li> |
| 40 | <a href="http://braavos.me" target="_blank">blog</a> |
| 41 | </li> |
| 42 | </ul> |
| 43 | </div> |
| 44 | return ( |
| 45 | <div> |
| 46 | <h3>Modal</h3> |
| 47 | <pre> |
| 48 | <code>onConfirm, onCancel, onClose need a return value(Boolean) to decide whether to close modal</code> |
| 49 | </pre> |
| 50 | <ol> |
| 51 | <li> |
| 52 | <h4>Default modal</h4> |
| 53 | <button onClick={this.openModal.bind(this, 'modal0')}>click</button> |
| 54 | <Modal ref="modal0" title={<h4>Confirm deleted</h4>}> |
| 55 | {content} |
| 56 | </Modal> |
| 57 | <pre> |
| 58 | <code> |
| 59 | {` |
| 60 | <a href="#" onClick={this.refs.modal.open}>click</a> |
| 61 | <Modal title={<h4>Confirm deleted</h4>} ref="modal"> |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…