-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdemo.jsx
111 lines (107 loc) · 4.22 KB
/
demo.jsx
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React from 'react'
import Single from './single'
import Flow from './flow'
import Btn from './btn'
class StaticModal extends React.Component {
componentDidMount() {
this.props.setIsHighlighted(true)
this.props.setIsValid(true)
}
submit(cb) {
console.log('doing submit logic')
cb()
}
render() {
return <div style={{marginBottom: '4em'}}>
<h1>Modal</h1>
<p>This is the modal content</p>
</div>
}
}
class ModalForm extends React.Component {
constructor(props) {
super(props)
this.state = {
inputValue: ''
}
}
componentDidMount() {
this.props.setIsHighlighted(true)
this.validate()
}
validate() {
this.props.setIsValid(!!this.state.inputValue)
this.props.setHelpText(!this.state.inputValue ? 'Help Text: Type some text to make the form valid' : 'Help Text: You can now press Finish!')
}
submit(cb) {
console.log('doing submit logic')
cb()
}
render() {
const onInputChange = e => {
this.setState({ inputValue: e.target.value }, this.validate.bind(this))
}
return <div style={{marginBottom: '4em'}}>
<form>
<h1>Modal Form</h1>
<p><label>What is your name?<br/><input type="text" onChange={onInputChange} value={this.state.inputValue} /></label></p>
</form>
</div>
}
}
class StaticModal1 extends StaticModal {
render() {
return <div style={{marginBottom: '4em'}}>
<h1>Modal 1</h1>
<p>This is the first modal</p>
</div>
}
}
class StaticModal2 extends StaticModal {
render() {
return <div style={{marginBottom: '4em'}}>
<h1>Modal 2</h1>
<p>This is the second modal</p>
</div>
}
}
class StaticModal3 extends StaticModal {
render() {
return <div style={{marginBottom: '4em'}}>
<h1>Modal 3</h1>
<p>This is the third modal</p>
</div>
}
}
export default class ModalDemo extends React.Component {
render() {
const onClose = (err, res) => console.log('Closed', err, res)
return <div>
<h1>patchkit-modal</h1>
<section className="modal-btn-single-fullheight-static">
<header><Btn Form=StaticModal className="fullheight"> (static content)</header>
<div className="content"><Btn Form={StaticModal} className="fullheight" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
<section className="modal-btn-single-center-block-static">
<header><Btn Form=StaticModal className="center-block"> (static content)</header>
<div className="content"><Btn Form={StaticModal} className="center-block" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
<section className="modal-btn-single-fullheight-form">
<header><Btn Form=ModalForm className="fullheight"> (with form)</header>
<div className="content"><Btn Form={ModalForm} className="fullheight" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
<section className="modal-btn-single-center-block-form">
<header><Btn Form=ModalForm className="center-block"> (with form)</header>
<div className="content"><Btn Form={ModalForm} className="center-block" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
<section className="modal-btn-flow-fullheight-static">
<header><Btn Forms=[StaticModal1,StaticModal2,StaticModal3] labels=["First","Second","Third"] className="fullheight"> (static content)</header>
<div className="content"><Btn Forms={[StaticModal1,StaticModal2,StaticModal3]} labels={["First","Second","Third"]} className="fullheight" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
<section className="modal-btn-flow-center-block-static">
<header><Btn Forms=[StaticModal1,StaticModal2,StaticModal3] labels=["First","Second","Third"] className="center-block"> (static content)</header>
<div className="content"><Btn Forms={[StaticModal1,StaticModal2,StaticModal3]} labels={["First","Second","Third"]} className="center-block" onClose={onClose}><a className="btn highlighted">Click to open</a></Btn></div>
</section>
</div>
}
}