-
Notifications
You must be signed in to change notification settings - Fork 86
Expand file tree
/
Copy pathModalExamples.js
More file actions
193 lines (183 loc) · 7.96 KB
/
ModalExamples.js
File metadata and controls
193 lines (183 loc) · 7.96 KB
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import React, { Component } from 'react';
import {
Modal,
Form,
Input,
DateInput,
Picklist,
PicklistItem,
FieldSet,
Button,
Lookup,
} from 'react-lightning-design-system';
const { Row } = FieldSet;
const { Header, Content, Footer } = Modal;
const LOOKUP_DATA = [
{ label: 'Account', value: '1', icon: 'standard:account' },
{ label: 'Contact', value: '2', icon: 'standard:contact' },
{ label: 'Opportunity', value: '3', icon: 'standard:opportunity' },
];
function onModalToastClose() {
alert('Close modal toast requested');
}
export default class ModalExamples extends Component {
constructor() {
super();
this.state = {
modal1: { opened: false },
modal2: { opened: false },
modal3: { opened: false },
modal4: { opened: false },
};
}
showModal(name) {
this.setState({
[name]: { ...this.state[name], opened: true },
});
}
hideModal(name) {
this.setState({
[name]: { ...this.state[name], opened: false },
});
}
render() {
/* eslint-disable max-len, react/jsx-first-prop-new-line */
const styles = { padding: '12px' };
const hideModal1 = this.hideModal.bind(this, 'modal1');
const hideModal2 = this.hideModal.bind(this, 'modal2');
const hideModal3 = this.hideModal.bind(this, 'modal3');
const hideModal4 = this.hideModal.bind(this, 'modal4');
const modalToastConfig = {
modalToastClose: onModalToastClose,
modalToastLevel: 'error',
modalToastIcon: 'warning',
modalToastAlt: 'Close',
modalToastText: 'This is error alert with icon and close button.',
};
return (
<div>
<h2 className='slds-m-vertical--medium'>Modal</h2>
<div style={ styles }>
<Button type='neutral' onClick={ this.showModal.bind(this, 'modal1') }>Show Modal #1</Button>
<Modal
opened={ this.state.modal1.opened }
onHide={ hideModal1 }
>
<Header title='Modal #1' closeButton />
<Content style={ { padding: '1em' } }>
<div>
<p>
Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.
</p>
<p>
Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.
</p>
</div>
</Content>
<Footer>
<Button type='neutral' label='Cancel' onClick={ hideModal1 } />
<Button type='brand' label='Done' onClick={ hideModal1 } />
</Footer>
</Modal>
</div>
<div style={ styles }>
<Button type='neutral' onClick={ this.showModal.bind(this, 'modal2') }>Show Modal #2</Button>
<Modal
opened={ this.state.modal2.opened }
size='large'
onHide={ hideModal2 }
>
<Header title='Modal #2' closeButton />
<Content style={ { padding: '1em' } }>
<div>
<p>
Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.
</p>
<p>
Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.
</p>
</div>
</Content>
<Footer directional>
<Button type='neutral' label='Cancel' onClick={ hideModal2 } />
<Button type='brand' label='Done' onClick={ hideModal2 } />
</Footer>
</Modal>
</div>
<div style={ styles }>
<Button type='neutral' onClick={ this.showModal.bind(this, 'modal3') }>Show Modal #3 (Form)</Button>
<Modal
opened={ this.state.modal3.opened }
onHide={ hideModal3 }
size='large'
>
<Header title='Modal #3' closeButton />
<Content style={ { padding: '1em' } }>
<Form type='compound'>
<FieldSet label='Name'>
<Row>
<Input label='First Name' placeholder='First Name' />
<Input label='Last Name' placeholder='Last Name' />
</Row>
</FieldSet>
<FieldSet label='Date Range'>
<Row>
<DateInput label='Start' />
<DateInput label='End' />
</Row>
</FieldSet>
<Row>
<DateInput label='Closing Date' />
</Row>
<Row>
<Picklist label='Picklist #1' menuSize='medium'>
{
new Array(10).join('_').split('')
.map((a, i) => (
<PicklistItem value={ i + 1 } label={ `Item #${(i + 1)}` } key={ i } />
))
}
</Picklist>
<Lookup label='Lookup' data={ LOOKUP_DATA } />
</Row>
</Form>
</Content>
<Footer directional>
<Button type='neutral' label='Cancel' onClick={ hideModal3 } />
<Button type='brand' label='Done' onClick={ hideModal3 } />
</Footer>
</Modal>
</div>
<div style={ styles }>
<Button type='neutral' onClick={ this.showModal.bind(this, 'modal4') }>Show Modal #4 (Modal toast)</Button>
<Modal
opened={ this.state.modal4.opened }
onHide={ hideModal4 }
>
<Header title='Modal' closeButton modalToast={ modalToastConfig } />
<Content style={ { padding: '1em' } }>
<div>
<p>
Sit nulla est ex deserunt exercitation anim occaecat. Nostrud ullamco deserunt aute id consequat veniam incididunt duis in sint irure nisi. Mollit officia cillum Lorem ullamco minim nostrud elit officia tempor esse quis. Cillum sunt ad dolore
quis aute consequat ipsum magna exercitation reprehenderit magna. Tempor cupidatat consequat elit dolor adipisicing.
</p>
<p>
Dolor eiusmod sunt ex incididunt cillum quis nostrud velit duis sit officia. Lorem aliqua enim laboris do dolor eiusmod officia. Mollit incididunt nisi consectetur esse laborum eiusmod pariatur proident. Eiusmod et adipisicing culpa deserunt
nostrud ad veniam nulla aute est. Labore esse esse cupidatat amet velit id elit consequat minim ullamco mollit enim excepteur ea.
</p>
</div>
</Content>
<Footer>
<Button type='neutral' label='Cancel' onClick={ hideModal4 } />
<Button type='brand' label='Done' onClick={ hideModal4 } />
</Footer>
</Modal>
</div>
</div>
);
}
}