-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbtn.jsx
More file actions
28 lines (27 loc) · 736 Bytes
/
btn.jsx
File metadata and controls
28 lines (27 loc) · 736 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React from 'react'
import ModalSingle from './single'
import ModalFlow from './flow'
export default class ModalBtn extends React.Component {
constructor(props) {
super(props)
this.state = { isOpen: false }
this.on = {
open: () => { this.setState({ isOpen: true }) },
close: (err, value) => {
this.setState({ isOpen: false })
this.props.onClose && this.props.onClose(err, value)
}
}
}
render() {
var Modal = ModalSingle
if (this.props.Forms)
Modal = ModalFlow
return <span>
<span onClick={this.on.open}>
{this.props.children}
</span>
<Modal {...this.props} isOpen={this.state.isOpen} onClose={this.on.close} />
</span>
}
}