@instructure/ui-modal 11.0.1-snapshot-0 → 11.0.1-snapshot-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/package.json +17 -17
- package/src/Modal/README.md +443 -975
- package/tsconfig.build.tsbuildinfo +1 -1
package/src/Modal/README.md
CHANGED
|
@@ -8,154 +8,77 @@ overlays the application content and applies a mask to it.
|
|
|
8
8
|
The default `padding` of the Modal content is `medium` but can be overridden
|
|
9
9
|
by using the `padding` prop on the `<Modal.Body/>` if the use case requires it.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.state = {
|
|
19
|
-
open: false
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
handleButtonClick = () => {
|
|
24
|
-
this.setState(function (state) {
|
|
25
|
-
return { open: !state.open }
|
|
26
|
-
})
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
handleFormSubmit = (e) => {
|
|
30
|
-
e.preventDefault()
|
|
31
|
-
console.log('form submitted')
|
|
32
|
-
this.setState((state) => ({ open: false }))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
renderCloseButton() {
|
|
36
|
-
return (
|
|
37
|
-
<CloseButton
|
|
38
|
-
placement="end"
|
|
39
|
-
offset="small"
|
|
40
|
-
onClick={this.handleButtonClick}
|
|
41
|
-
screenReaderLabel="Close"
|
|
42
|
-
/>
|
|
43
|
-
)
|
|
44
|
-
}
|
|
11
|
+
```js
|
|
12
|
+
---
|
|
13
|
+
type: example
|
|
14
|
+
---
|
|
15
|
+
const fpo = lorem.paragraphs(5)
|
|
16
|
+
const Example = () => {
|
|
17
|
+
const [open, setOpen] = useState(false)
|
|
45
18
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
<div style={{ padding: '0 0 11rem 0', margin: '0 auto' }}>
|
|
49
|
-
<Button onClick={this.handleButtonClick}>
|
|
50
|
-
{this.state.open ? 'Close' : 'Open'} the Modal
|
|
51
|
-
</Button>
|
|
52
|
-
<Modal
|
|
53
|
-
as="form"
|
|
54
|
-
open={this.state.open}
|
|
55
|
-
onDismiss={() => {
|
|
56
|
-
this.setState({ open: false })
|
|
57
|
-
}}
|
|
58
|
-
onSubmit={this.handleFormSubmit}
|
|
59
|
-
size="auto"
|
|
60
|
-
label="Hello World"
|
|
61
|
-
shouldCloseOnDocumentClick
|
|
62
|
-
>
|
|
63
|
-
<Modal.Header>
|
|
64
|
-
{this.renderCloseButton()}
|
|
65
|
-
<Heading>Hello World</Heading>
|
|
66
|
-
</Modal.Header>
|
|
67
|
-
<Modal.Body>
|
|
68
|
-
<TextInput
|
|
69
|
-
renderLabel="Example"
|
|
70
|
-
placeholder="if you hit enter here, it should submit the form"
|
|
71
|
-
/>
|
|
72
|
-
<Text lineHeight="double">{fpo}</Text>
|
|
73
|
-
</Modal.Body>
|
|
74
|
-
<Modal.Footer>
|
|
75
|
-
<Button onClick={this.handleButtonClick} margin="0 x-small 0 0">
|
|
76
|
-
Close
|
|
77
|
-
</Button>
|
|
78
|
-
<Button color="primary" type="submit">
|
|
79
|
-
Submit
|
|
80
|
-
</Button>
|
|
81
|
-
</Modal.Footer>
|
|
82
|
-
</Modal>
|
|
83
|
-
</div>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
19
|
+
const handleButtonClick = () => {
|
|
20
|
+
setOpen((state) => !state)
|
|
86
21
|
}
|
|
87
22
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
const Example = () => {
|
|
94
|
-
const [open, setOpen] = useState(false)
|
|
95
|
-
|
|
96
|
-
const handleButtonClick = () => {
|
|
97
|
-
setOpen((state) => !state)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const handleFormSubmit = (e) => {
|
|
101
|
-
e.preventDefault()
|
|
102
|
-
console.log('form submitted')
|
|
103
|
-
setOpen(false)
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const renderCloseButton = () => {
|
|
107
|
-
return (
|
|
108
|
-
<CloseButton
|
|
109
|
-
placement="end"
|
|
110
|
-
offset="small"
|
|
111
|
-
onClick={handleButtonClick}
|
|
112
|
-
screenReaderLabel="Close"
|
|
113
|
-
/>
|
|
114
|
-
)
|
|
115
|
-
}
|
|
23
|
+
const handleFormSubmit = (e) => {
|
|
24
|
+
e.preventDefault()
|
|
25
|
+
console.log('form submitted')
|
|
26
|
+
setOpen(false)
|
|
27
|
+
}
|
|
116
28
|
|
|
29
|
+
const renderCloseButton = () => {
|
|
117
30
|
return (
|
|
118
|
-
<
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
open={open}
|
|
125
|
-
onDismiss={() => {
|
|
126
|
-
setOpen(false)
|
|
127
|
-
}}
|
|
128
|
-
onSubmit={handleFormSubmit}
|
|
129
|
-
size="auto"
|
|
130
|
-
label="Hello World"
|
|
131
|
-
shouldCloseOnDocumentClick
|
|
132
|
-
>
|
|
133
|
-
<Modal.Header>
|
|
134
|
-
{renderCloseButton()}
|
|
135
|
-
<Heading>Hello World</Heading>
|
|
136
|
-
</Modal.Header>
|
|
137
|
-
<Modal.Body>
|
|
138
|
-
<TextInput
|
|
139
|
-
renderLabel="Example"
|
|
140
|
-
placeholder="if you hit enter here, it should submit the form"
|
|
141
|
-
/>
|
|
142
|
-
<Text lineHeight="double">{fpo}</Text>
|
|
143
|
-
</Modal.Body>
|
|
144
|
-
<Modal.Footer>
|
|
145
|
-
<Button onClick={handleButtonClick} margin="0 x-small 0 0">
|
|
146
|
-
Close
|
|
147
|
-
</Button>
|
|
148
|
-
<Button color="primary" type="submit">
|
|
149
|
-
Submit
|
|
150
|
-
</Button>
|
|
151
|
-
</Modal.Footer>
|
|
152
|
-
</Modal>
|
|
153
|
-
</div>
|
|
31
|
+
<CloseButton
|
|
32
|
+
placement="end"
|
|
33
|
+
offset="small"
|
|
34
|
+
onClick={handleButtonClick}
|
|
35
|
+
screenReaderLabel="Close"
|
|
36
|
+
/>
|
|
154
37
|
)
|
|
155
38
|
}
|
|
156
39
|
|
|
157
|
-
|
|
158
|
-
|
|
40
|
+
return (
|
|
41
|
+
<div style={{ padding: '0 0 11rem 0', margin: '0 auto' }}>
|
|
42
|
+
<Button onClick={handleButtonClick}>
|
|
43
|
+
{open ? 'Close' : 'Open'} the Modal
|
|
44
|
+
</Button>
|
|
45
|
+
<Modal
|
|
46
|
+
as="form"
|
|
47
|
+
open={open}
|
|
48
|
+
onDismiss={() => {
|
|
49
|
+
setOpen(false)
|
|
50
|
+
}}
|
|
51
|
+
onSubmit={handleFormSubmit}
|
|
52
|
+
size="auto"
|
|
53
|
+
label="Hello World"
|
|
54
|
+
shouldCloseOnDocumentClick
|
|
55
|
+
>
|
|
56
|
+
<Modal.Header>
|
|
57
|
+
{renderCloseButton()}
|
|
58
|
+
<Heading>Hello World</Heading>
|
|
59
|
+
</Modal.Header>
|
|
60
|
+
<Modal.Body>
|
|
61
|
+
<TextInput
|
|
62
|
+
renderLabel="Example"
|
|
63
|
+
placeholder="if you hit enter here, it should submit the form"
|
|
64
|
+
/>
|
|
65
|
+
<Text lineHeight="double">{fpo}</Text>
|
|
66
|
+
</Modal.Body>
|
|
67
|
+
<Modal.Footer>
|
|
68
|
+
<Button onClick={handleButtonClick} margin="0 x-small 0 0">
|
|
69
|
+
Close
|
|
70
|
+
</Button>
|
|
71
|
+
<Button color="primary" type="submit">
|
|
72
|
+
Submit
|
|
73
|
+
</Button>
|
|
74
|
+
</Modal.Footer>
|
|
75
|
+
</Modal>
|
|
76
|
+
</div>
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
render(<Example />)
|
|
81
|
+
```
|
|
159
82
|
|
|
160
83
|
### Constraining Modal to a parent element
|
|
161
84
|
|
|
@@ -163,256 +86,124 @@ By default, Modals are positioned relative to the document body.
|
|
|
163
86
|
|
|
164
87
|
Setting the `constrain` property to `parent` will constrain the Modal within the element it is mounted from (specified via the `mountNode` property). Note: in these cases, the `mountNode` element should have an explicit `height` set: Because Modal is absolutely positioned, it has no height of its own.
|
|
165
88
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
size: 'auto'
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
handleButtonClick = () => {
|
|
179
|
-
this.setState(function (state) {
|
|
180
|
-
return { open: !state.open }
|
|
181
|
-
})
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
renderCloseButton() {
|
|
185
|
-
return (
|
|
186
|
-
<CloseButton
|
|
187
|
-
placement="end"
|
|
188
|
-
offset="small"
|
|
189
|
-
onClick={this.handleButtonClick}
|
|
190
|
-
screenReaderLabel="Close"
|
|
191
|
-
/>
|
|
192
|
-
)
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
render() {
|
|
196
|
-
return (
|
|
197
|
-
<div>
|
|
198
|
-
<Button onClick={this.handleButtonClick}>
|
|
199
|
-
{this.state.open ? 'Close' : 'Open'} the Modal
|
|
200
|
-
</Button>
|
|
201
|
-
<Modal
|
|
202
|
-
open={this.state.open}
|
|
203
|
-
onDismiss={() => {
|
|
204
|
-
this.setState({ open: false })
|
|
205
|
-
}}
|
|
206
|
-
size="fullscreen"
|
|
207
|
-
label="Hello World"
|
|
208
|
-
shouldCloseOnDocumentClick
|
|
209
|
-
mountNode={() => document.getElementById('constrainExample')}
|
|
210
|
-
constrain="parent"
|
|
211
|
-
>
|
|
212
|
-
<Modal.Header>
|
|
213
|
-
{this.renderCloseButton()}
|
|
214
|
-
<Heading>This Modal is constrained to a parent</Heading>
|
|
215
|
-
</Modal.Header>
|
|
216
|
-
<Modal.Body>
|
|
217
|
-
<View as="p" margin="none none small">
|
|
218
|
-
<Text>{fpo}</Text>
|
|
219
|
-
</View>
|
|
220
|
-
<ModalAutoCompleteExample renderLabel="Choose a state" />
|
|
221
|
-
</Modal.Body>
|
|
222
|
-
<Modal.Footer>
|
|
223
|
-
<Button onClick={this.handleButtonClick} margin="0 x-small 0 0">
|
|
224
|
-
Close
|
|
225
|
-
</Button>
|
|
226
|
-
<Button
|
|
227
|
-
onClick={this.handleButtonClick}
|
|
228
|
-
color="primary"
|
|
229
|
-
type="submit"
|
|
230
|
-
>
|
|
231
|
-
Submit
|
|
232
|
-
</Button>
|
|
233
|
-
</Modal.Footer>
|
|
234
|
-
</Modal>
|
|
235
|
-
<View
|
|
236
|
-
background="primary-inverse"
|
|
237
|
-
margin="medium auto none"
|
|
238
|
-
display="block"
|
|
239
|
-
width="25rem"
|
|
240
|
-
height="25rem"
|
|
241
|
-
borderWidth="large"
|
|
242
|
-
id="constrainExample"
|
|
243
|
-
></View>
|
|
244
|
-
</div>
|
|
245
|
-
)
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
class ModalAutoCompleteExample extends React.Component {
|
|
250
|
-
state = {
|
|
251
|
-
isShowingOptions: false
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
handleShowOptions = () => {
|
|
255
|
-
this.setState({ isShowingOptions: true })
|
|
256
|
-
}
|
|
257
|
-
handleHideOptions = () => {
|
|
258
|
-
this.setState({ isShowingOptions: false })
|
|
259
|
-
}
|
|
260
|
-
render() {
|
|
261
|
-
const options = [
|
|
262
|
-
'Alabama',
|
|
263
|
-
'Alaska',
|
|
264
|
-
'American Samoa',
|
|
265
|
-
'Arizona',
|
|
266
|
-
'Arkansas',
|
|
267
|
-
'California',
|
|
268
|
-
'Colorado',
|
|
269
|
-
'Connecticut',
|
|
270
|
-
'Delaware',
|
|
271
|
-
'District Of Columbia',
|
|
272
|
-
'Federated States Of Micronesia',
|
|
273
|
-
'Florida',
|
|
274
|
-
'Georgia',
|
|
275
|
-
'Guam',
|
|
276
|
-
'Hawaii',
|
|
277
|
-
'Idaho',
|
|
278
|
-
'Illinois'
|
|
279
|
-
]
|
|
89
|
+
```js
|
|
90
|
+
---
|
|
91
|
+
type: example
|
|
92
|
+
---
|
|
93
|
+
const fpo = lorem.paragraphs(1)
|
|
94
|
+
const Example = () => {
|
|
95
|
+
const [open, setOpen] = useState(false)
|
|
96
|
+
const [size, setSize] = useState('auto')
|
|
280
97
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
{...this.props}
|
|
284
|
-
isShowingOptions={this.state.isShowingOptions}
|
|
285
|
-
onRequestShowOptions={this.handleShowOptions}
|
|
286
|
-
onRequestHideOptions={this.handleHideOptions}
|
|
287
|
-
>
|
|
288
|
-
{options.map((label, index) => (
|
|
289
|
-
<Select.Option key={label} id={'' + index}>
|
|
290
|
-
{label}
|
|
291
|
-
</Select.Option>
|
|
292
|
-
))}
|
|
293
|
-
</Select>
|
|
294
|
-
)
|
|
295
|
-
}
|
|
98
|
+
const handleButtonClick = () => {
|
|
99
|
+
setOpen((state) => !state)
|
|
296
100
|
}
|
|
297
101
|
|
|
298
|
-
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
- ```js
|
|
302
|
-
const fpo = lorem.paragraphs(1)
|
|
303
|
-
const Example = () => {
|
|
304
|
-
const [open, setOpen] = useState(false)
|
|
305
|
-
const [size, setSize] = useState('auto')
|
|
306
|
-
|
|
307
|
-
const handleButtonClick = () => {
|
|
308
|
-
setOpen((state) => !state)
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
const renderCloseButton = () => {
|
|
312
|
-
return (
|
|
313
|
-
<CloseButton
|
|
314
|
-
placement="end"
|
|
315
|
-
offset="small"
|
|
316
|
-
onClick={handleButtonClick}
|
|
317
|
-
screenReaderLabel="Close"
|
|
318
|
-
/>
|
|
319
|
-
)
|
|
320
|
-
}
|
|
102
|
+
const renderCloseButton = () => {
|
|
321
103
|
return (
|
|
322
|
-
<
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
onDismiss={() => {
|
|
329
|
-
setOpen(false)
|
|
330
|
-
}}
|
|
331
|
-
size="fullscreen"
|
|
332
|
-
label="Hello World"
|
|
333
|
-
shouldCloseOnDocumentClick
|
|
334
|
-
mountNode={() => document.getElementById('constrainExample')}
|
|
335
|
-
constrain="parent"
|
|
336
|
-
>
|
|
337
|
-
<Modal.Header>
|
|
338
|
-
{renderCloseButton()}
|
|
339
|
-
<Heading>This Modal is constrained to a parent</Heading>
|
|
340
|
-
</Modal.Header>
|
|
341
|
-
<Modal.Body>
|
|
342
|
-
<View as="p" margin="none none small">
|
|
343
|
-
<Text>{fpo}</Text>
|
|
344
|
-
</View>
|
|
345
|
-
<ModalAutoCompleteExample renderLabel="Choose a state" />
|
|
346
|
-
</Modal.Body>
|
|
347
|
-
<Modal.Footer>
|
|
348
|
-
<Button onClick={handleButtonClick} margin="0 x-small 0 0">
|
|
349
|
-
Close
|
|
350
|
-
</Button>
|
|
351
|
-
<Button onClick={handleButtonClick} color="primary" type="submit">
|
|
352
|
-
Submit
|
|
353
|
-
</Button>
|
|
354
|
-
</Modal.Footer>
|
|
355
|
-
</Modal>
|
|
356
|
-
<View
|
|
357
|
-
background="primary-inverse"
|
|
358
|
-
margin="medium auto none"
|
|
359
|
-
display="block"
|
|
360
|
-
width="25rem"
|
|
361
|
-
height="25rem"
|
|
362
|
-
borderWidth="large"
|
|
363
|
-
id="constrainExample"
|
|
364
|
-
></View>
|
|
365
|
-
</div>
|
|
104
|
+
<CloseButton
|
|
105
|
+
placement="end"
|
|
106
|
+
offset="small"
|
|
107
|
+
onClick={handleButtonClick}
|
|
108
|
+
screenReaderLabel="Close"
|
|
109
|
+
/>
|
|
366
110
|
)
|
|
367
111
|
}
|
|
112
|
+
return (
|
|
113
|
+
<div>
|
|
114
|
+
<Button onClick={handleButtonClick}>
|
|
115
|
+
{open ? 'Close' : 'Open'} the Modal
|
|
116
|
+
</Button>
|
|
117
|
+
<Modal
|
|
118
|
+
open={open}
|
|
119
|
+
onDismiss={() => {
|
|
120
|
+
setOpen(false)
|
|
121
|
+
}}
|
|
122
|
+
size="fullscreen"
|
|
123
|
+
label="Hello World"
|
|
124
|
+
shouldCloseOnDocumentClick
|
|
125
|
+
mountNode={() => document.getElementById('constrainExample')}
|
|
126
|
+
constrain="parent"
|
|
127
|
+
>
|
|
128
|
+
<Modal.Header>
|
|
129
|
+
{renderCloseButton()}
|
|
130
|
+
<Heading>This Modal is constrained to a parent</Heading>
|
|
131
|
+
</Modal.Header>
|
|
132
|
+
<Modal.Body>
|
|
133
|
+
<View as="p" margin="none none small">
|
|
134
|
+
<Text>{fpo}</Text>
|
|
135
|
+
</View>
|
|
136
|
+
<ModalAutoCompleteExample renderLabel="Choose a state" />
|
|
137
|
+
</Modal.Body>
|
|
138
|
+
<Modal.Footer>
|
|
139
|
+
<Button onClick={handleButtonClick} margin="0 x-small 0 0">
|
|
140
|
+
Close
|
|
141
|
+
</Button>
|
|
142
|
+
<Button onClick={handleButtonClick} color="primary" type="submit">
|
|
143
|
+
Submit
|
|
144
|
+
</Button>
|
|
145
|
+
</Modal.Footer>
|
|
146
|
+
</Modal>
|
|
147
|
+
<View
|
|
148
|
+
background="primary-inverse"
|
|
149
|
+
margin="medium auto none"
|
|
150
|
+
display="block"
|
|
151
|
+
width="25rem"
|
|
152
|
+
height="25rem"
|
|
153
|
+
borderWidth="large"
|
|
154
|
+
id="constrainExample"
|
|
155
|
+
></View>
|
|
156
|
+
</div>
|
|
157
|
+
)
|
|
158
|
+
}
|
|
368
159
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
const handleShowOptions = () => {
|
|
373
|
-
setIsShowingOptions(true)
|
|
374
|
-
}
|
|
375
|
-
const handleHideOptions = () => {
|
|
376
|
-
setIsShowingOptions(false)
|
|
377
|
-
}
|
|
160
|
+
const ModalAutoCompleteExample = (props) => {
|
|
161
|
+
const [isShowingOptions, setIsShowingOptions] = useState(false)
|
|
378
162
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
'Arkansas',
|
|
385
|
-
'California',
|
|
386
|
-
'Colorado',
|
|
387
|
-
'Connecticut',
|
|
388
|
-
'Delaware',
|
|
389
|
-
'District Of Columbia',
|
|
390
|
-
'Federated States Of Micronesia',
|
|
391
|
-
'Florida',
|
|
392
|
-
'Georgia',
|
|
393
|
-
'Guam',
|
|
394
|
-
'Hawaii',
|
|
395
|
-
'Idaho',
|
|
396
|
-
'Illinois'
|
|
397
|
-
]
|
|
398
|
-
return (
|
|
399
|
-
<Select
|
|
400
|
-
{...props}
|
|
401
|
-
isShowingOptions={isShowingOptions}
|
|
402
|
-
onRequestShowOptions={handleShowOptions}
|
|
403
|
-
onRequestHideOptions={handleHideOptions}
|
|
404
|
-
>
|
|
405
|
-
{options.map((label, index) => (
|
|
406
|
-
<Select.Option key={label} id={'' + index}>
|
|
407
|
-
{label}
|
|
408
|
-
</Select.Option>
|
|
409
|
-
))}
|
|
410
|
-
</Select>
|
|
411
|
-
)
|
|
163
|
+
const handleShowOptions = () => {
|
|
164
|
+
setIsShowingOptions(true)
|
|
165
|
+
}
|
|
166
|
+
const handleHideOptions = () => {
|
|
167
|
+
setIsShowingOptions(false)
|
|
412
168
|
}
|
|
413
169
|
|
|
414
|
-
|
|
415
|
-
|
|
170
|
+
const options = [
|
|
171
|
+
'Alabama',
|
|
172
|
+
'Alaska',
|
|
173
|
+
'American Samoa',
|
|
174
|
+
'Arizona',
|
|
175
|
+
'Arkansas',
|
|
176
|
+
'California',
|
|
177
|
+
'Colorado',
|
|
178
|
+
'Connecticut',
|
|
179
|
+
'Delaware',
|
|
180
|
+
'District Of Columbia',
|
|
181
|
+
'Federated States Of Micronesia',
|
|
182
|
+
'Florida',
|
|
183
|
+
'Georgia',
|
|
184
|
+
'Guam',
|
|
185
|
+
'Hawaii',
|
|
186
|
+
'Idaho',
|
|
187
|
+
'Illinois'
|
|
188
|
+
]
|
|
189
|
+
return (
|
|
190
|
+
<Select
|
|
191
|
+
{...props}
|
|
192
|
+
isShowingOptions={isShowingOptions}
|
|
193
|
+
onRequestShowOptions={handleShowOptions}
|
|
194
|
+
onRequestHideOptions={handleHideOptions}
|
|
195
|
+
>
|
|
196
|
+
{options.map((label, index) => (
|
|
197
|
+
<Select.Option key={label} id={'' + index}>
|
|
198
|
+
{label}
|
|
199
|
+
</Select.Option>
|
|
200
|
+
))}
|
|
201
|
+
</Select>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
render(<Example />)
|
|
206
|
+
```
|
|
416
207
|
|
|
417
208
|
### Media (images, etc.) inside Modals
|
|
418
209
|
|
|
@@ -420,636 +211,313 @@ Setting the `constrain` property to `parent` will constrain the Modal within the
|
|
|
420
211
|
|
|
421
212
|
**If you are displaying small, relatively uniform images or videos inside Modal, the default settings should work well.** Modal.Body will expand to the height of the media you're displaying. If there is overflow, scrollbars will be available.
|
|
422
213
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
open: false
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
handleButtonClick = () => {
|
|
434
|
-
this.setState(function (state) {
|
|
435
|
-
return { open: !state.open }
|
|
436
|
-
})
|
|
437
|
-
}
|
|
214
|
+
```js
|
|
215
|
+
---
|
|
216
|
+
type: example
|
|
217
|
+
---
|
|
218
|
+
const Example = () => {
|
|
219
|
+
const [open, setOpen] = useState(false)
|
|
438
220
|
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
<div>
|
|
442
|
-
<Button onClick={this.handleButtonClick}>
|
|
443
|
-
{this.state.open ? 'Close' : 'Open'} the Modal
|
|
444
|
-
</Button>
|
|
445
|
-
<Modal
|
|
446
|
-
open={this.state.open}
|
|
447
|
-
onDismiss={() => {
|
|
448
|
-
this.setState({ open: false })
|
|
449
|
-
}}
|
|
450
|
-
size="auto"
|
|
451
|
-
label="Hello Media"
|
|
452
|
-
shouldCloseOnDocumentClick
|
|
453
|
-
variant="inverse"
|
|
454
|
-
>
|
|
455
|
-
<Modal.Header>
|
|
456
|
-
<Flex>
|
|
457
|
-
<Flex.Item shouldGrow shouldShrink>
|
|
458
|
-
<Heading level="h2">
|
|
459
|
-
<TruncateText>A small image</TruncateText>
|
|
460
|
-
</Heading>
|
|
461
|
-
</Flex.Item>
|
|
462
|
-
<Flex.Item>
|
|
463
|
-
<CloseButton
|
|
464
|
-
color="primary-inverse"
|
|
465
|
-
placement="end"
|
|
466
|
-
offset="small"
|
|
467
|
-
onClick={this.handleButtonClick}
|
|
468
|
-
screenReaderLabel="Close"
|
|
469
|
-
/>
|
|
470
|
-
</Flex.Item>
|
|
471
|
-
</Flex>
|
|
472
|
-
</Modal.Header>
|
|
473
|
-
<Modal.Body padding="none">
|
|
474
|
-
<Img
|
|
475
|
-
src={placeholderImage(500, 250)}
|
|
476
|
-
display="block"
|
|
477
|
-
margin="0 auto"
|
|
478
|
-
/>
|
|
479
|
-
</Modal.Body>
|
|
480
|
-
<Modal.Footer>
|
|
481
|
-
<Button
|
|
482
|
-
onClick={this.handleButtonClick}
|
|
483
|
-
withBackground={false}
|
|
484
|
-
color="primary-inverse"
|
|
485
|
-
type="submit"
|
|
486
|
-
>
|
|
487
|
-
Submit
|
|
488
|
-
</Button>
|
|
489
|
-
</Modal.Footer>
|
|
490
|
-
</Modal>
|
|
491
|
-
</div>
|
|
492
|
-
)
|
|
493
|
-
}
|
|
221
|
+
const handleButtonClick = () => {
|
|
222
|
+
setOpen((state) => !state)
|
|
494
223
|
}
|
|
495
224
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
withBackground={false}
|
|
551
|
-
color="primary-inverse"
|
|
552
|
-
type="submit"
|
|
553
|
-
>
|
|
554
|
-
Submit
|
|
555
|
-
</Button>
|
|
556
|
-
</Modal.Footer>
|
|
557
|
-
</Modal>
|
|
558
|
-
</div>
|
|
559
|
-
)
|
|
560
|
-
}
|
|
225
|
+
return (
|
|
226
|
+
<div>
|
|
227
|
+
<Button onClick={handleButtonClick}>
|
|
228
|
+
{open ? 'Close' : 'Open'} the Modal
|
|
229
|
+
</Button>
|
|
230
|
+
<Modal
|
|
231
|
+
open={open}
|
|
232
|
+
onDismiss={() => {
|
|
233
|
+
setOpen(false)
|
|
234
|
+
}}
|
|
235
|
+
size="auto"
|
|
236
|
+
label="Hello Media"
|
|
237
|
+
shouldCloseOnDocumentClick
|
|
238
|
+
variant="inverse"
|
|
239
|
+
>
|
|
240
|
+
<Modal.Header>
|
|
241
|
+
<Flex>
|
|
242
|
+
<Flex.Item shouldGrow shouldShrink>
|
|
243
|
+
<Heading level="h2">
|
|
244
|
+
<TruncateText>A small image</TruncateText>
|
|
245
|
+
</Heading>
|
|
246
|
+
</Flex.Item>
|
|
247
|
+
<Flex.Item>
|
|
248
|
+
<CloseButton
|
|
249
|
+
color="primary-inverse"
|
|
250
|
+
placement="end"
|
|
251
|
+
offset="small"
|
|
252
|
+
onClick={handleButtonClick}
|
|
253
|
+
screenReaderLabel="Close"
|
|
254
|
+
/>
|
|
255
|
+
</Flex.Item>
|
|
256
|
+
</Flex>
|
|
257
|
+
</Modal.Header>
|
|
258
|
+
<Modal.Body padding="none">
|
|
259
|
+
<Img
|
|
260
|
+
src={placeholderImage(500, 250)}
|
|
261
|
+
display="block"
|
|
262
|
+
margin="0 auto"
|
|
263
|
+
/>
|
|
264
|
+
</Modal.Body>
|
|
265
|
+
<Modal.Footer>
|
|
266
|
+
<Button
|
|
267
|
+
onClick={handleButtonClick}
|
|
268
|
+
withBackground={false}
|
|
269
|
+
color="primary-inverse"
|
|
270
|
+
type="submit"
|
|
271
|
+
>
|
|
272
|
+
Submit
|
|
273
|
+
</Button>
|
|
274
|
+
</Modal.Footer>
|
|
275
|
+
</Modal>
|
|
276
|
+
</div>
|
|
277
|
+
)
|
|
278
|
+
}
|
|
561
279
|
|
|
562
|
-
|
|
563
|
-
|
|
280
|
+
render(<Example />)
|
|
281
|
+
```
|
|
564
282
|
|
|
565
283
|
**When you have to display large media inside the Modal (or have no control over the size of the media)**, set `overflow` to `fit`. Doing so makes Modal.Body fill 100% of the available width and height, enabling you to
|
|
566
284
|
use the [Img](#Img) component's `constrain` property to fit the image inside Modal.Body.
|
|
567
285
|
|
|
568
286
|
> `<Img />` uses CSS's [`object-fit`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) for its constrain property. If you're not using `<Img />`, add an `object-fit` rule to your media, and it will work with `overflow="fit"`.
|
|
569
287
|
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
modalSize: 'fullscreen'
|
|
579
|
-
}
|
|
580
|
-
}
|
|
288
|
+
```js
|
|
289
|
+
---
|
|
290
|
+
type: example
|
|
291
|
+
---
|
|
292
|
+
const Example = () => {
|
|
293
|
+
const [open, setOpen] = useState(false)
|
|
294
|
+
const [imageFit, setImageFit] = useState('cover')
|
|
295
|
+
const [modalSize, setModalSize] = useState('fullscreen')
|
|
581
296
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
})
|
|
586
|
-
}
|
|
297
|
+
const handleButtonClick = () => {
|
|
298
|
+
setOpen((state) => !state)
|
|
299
|
+
}
|
|
587
300
|
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
301
|
+
const handleImageFitChange = (event, value) => {
|
|
302
|
+
setImageFit(value)
|
|
303
|
+
}
|
|
591
304
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
305
|
+
const handleModalSizeChange = (event, value) => {
|
|
306
|
+
setModalSize(value)
|
|
307
|
+
}
|
|
595
308
|
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
title="Icon Example"
|
|
654
|
-
/>
|
|
655
|
-
</Flex.Item>
|
|
656
|
-
<Flex.Item shouldGrow shouldShrink>
|
|
657
|
-
<Heading level="h2">
|
|
658
|
-
<TruncateText>This Modal Contains Media</TruncateText>
|
|
659
|
-
</Heading>
|
|
660
|
-
</Flex.Item>
|
|
661
|
-
</Flex>
|
|
662
|
-
</Flex.Item>
|
|
663
|
-
<Flex.Item>
|
|
664
|
-
<IconButton
|
|
665
|
-
color="primary-inverse"
|
|
666
|
-
withBackground={false}
|
|
667
|
-
withBorder={false}
|
|
668
|
-
renderIcon={IconPrinterSolid}
|
|
669
|
-
screenReaderLabel="Print This Image"
|
|
670
|
-
margin="0 x-small 0 0"
|
|
671
|
-
/>
|
|
672
|
-
<IconButton
|
|
673
|
-
color="primary-inverse"
|
|
674
|
-
withBackground={false}
|
|
675
|
-
withBorder={false}
|
|
676
|
-
renderIcon={IconDownloadSolid}
|
|
677
|
-
screenReaderLabel="Download This Image"
|
|
678
|
-
margin="0 x-small 0 0"
|
|
679
|
-
/>
|
|
680
|
-
<IconButton
|
|
681
|
-
color="primary-inverse"
|
|
682
|
-
withBackground={false}
|
|
683
|
-
withBorder={false}
|
|
684
|
-
renderIcon={IconXSolid}
|
|
685
|
-
screenReaderLabel="Close"
|
|
686
|
-
onClick={this.handleButtonClick}
|
|
309
|
+
return (
|
|
310
|
+
<div>
|
|
311
|
+
<FormFieldGroup
|
|
312
|
+
description={
|
|
313
|
+
<Heading level="h3" as="h3">
|
|
314
|
+
Media Modal
|
|
315
|
+
</Heading>
|
|
316
|
+
}
|
|
317
|
+
rowSpacing="medium"
|
|
318
|
+
>
|
|
319
|
+
<RadioInputGroup
|
|
320
|
+
onChange={handleImageFitChange}
|
|
321
|
+
name="imageFit"
|
|
322
|
+
defaultValue="cover"
|
|
323
|
+
description="Img component's `constrain` prop"
|
|
324
|
+
variant="toggle"
|
|
325
|
+
>
|
|
326
|
+
<RadioInput label="Cover" value="cover" />
|
|
327
|
+
<RadioInput label="Contain" value="contain" />
|
|
328
|
+
</RadioInputGroup>
|
|
329
|
+
<RadioInputGroup
|
|
330
|
+
onChange={handleModalSizeChange}
|
|
331
|
+
name="modalSize"
|
|
332
|
+
defaultValue="fullscreen"
|
|
333
|
+
description="Modal size"
|
|
334
|
+
variant="toggle"
|
|
335
|
+
>
|
|
336
|
+
<RadioInput label="fullscreen" value="fullscreen" />
|
|
337
|
+
<RadioInput label="small" value="small" />
|
|
338
|
+
<RadioInput label="medium" value="medium" />
|
|
339
|
+
<RadioInput label="large" value="large" />
|
|
340
|
+
<RadioInput label="auto" value="auto" />
|
|
341
|
+
</RadioInputGroup>
|
|
342
|
+
</FormFieldGroup>
|
|
343
|
+
<Button onClick={handleButtonClick} margin="medium 0 0">
|
|
344
|
+
{open ? 'Close' : 'Open'} the Modal
|
|
345
|
+
</Button>
|
|
346
|
+
<Modal
|
|
347
|
+
open={open}
|
|
348
|
+
onDismiss={() => {
|
|
349
|
+
setOpen(false)
|
|
350
|
+
}}
|
|
351
|
+
size={modalSize}
|
|
352
|
+
label="Hello Media"
|
|
353
|
+
shouldCloseOnDocumentClick
|
|
354
|
+
variant="inverse"
|
|
355
|
+
overflow="fit"
|
|
356
|
+
>
|
|
357
|
+
<Modal.Header>
|
|
358
|
+
<Flex>
|
|
359
|
+
<Flex.Item shouldGrow shouldShrink>
|
|
360
|
+
<Flex alignItems="center">
|
|
361
|
+
<Flex.Item margin="0 x-small 0 0">
|
|
362
|
+
<SVGIcon
|
|
363
|
+
src={iconExample}
|
|
364
|
+
size="small"
|
|
365
|
+
title="Icon Example"
|
|
687
366
|
/>
|
|
688
367
|
</Flex.Item>
|
|
368
|
+
<Flex.Item shouldGrow shouldShrink>
|
|
369
|
+
<Heading level="h2">
|
|
370
|
+
<TruncateText>This Modal Contains Media</TruncateText>
|
|
371
|
+
</Heading>
|
|
372
|
+
</Flex.Item>
|
|
689
373
|
</Flex>
|
|
690
|
-
</
|
|
691
|
-
<
|
|
692
|
-
<
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
374
|
+
</Flex.Item>
|
|
375
|
+
<Flex.Item>
|
|
376
|
+
<IconButton
|
|
377
|
+
color="primary-inverse"
|
|
378
|
+
withBackground={false}
|
|
379
|
+
withBorder={false}
|
|
380
|
+
renderIcon={IconPrinterSolid}
|
|
381
|
+
screenReaderLabel="Print This Image"
|
|
382
|
+
margin="0 x-small 0 0"
|
|
696
383
|
/>
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
<Button
|
|
700
|
-
onClick={this.handleButtonClick}
|
|
384
|
+
<IconButton
|
|
385
|
+
color="primary-inverse"
|
|
701
386
|
withBackground={false}
|
|
387
|
+
withBorder={false}
|
|
388
|
+
renderIcon={IconDownloadSolid}
|
|
389
|
+
screenReaderLabel="Download This Image"
|
|
390
|
+
margin="0 x-small 0 0"
|
|
391
|
+
/>
|
|
392
|
+
<IconButton
|
|
702
393
|
color="primary-inverse"
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const [modalSize, setModalSize] = useState('fullscreen')
|
|
722
|
-
|
|
723
|
-
const handleButtonClick = () => {
|
|
724
|
-
setOpen((state) => !state)
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
const handleImageFitChange = (event, value) => {
|
|
728
|
-
setImageFit(value)
|
|
729
|
-
}
|
|
730
|
-
|
|
731
|
-
const handleModalSizeChange = (event, value) => {
|
|
732
|
-
setModalSize(value)
|
|
733
|
-
}
|
|
734
|
-
|
|
735
|
-
return (
|
|
736
|
-
<div>
|
|
737
|
-
<FormFieldGroup
|
|
738
|
-
description={
|
|
739
|
-
<Heading level="h3" as="h3">
|
|
740
|
-
Media Modal
|
|
741
|
-
</Heading>
|
|
742
|
-
}
|
|
743
|
-
rowSpacing="medium"
|
|
744
|
-
>
|
|
745
|
-
<RadioInputGroup
|
|
746
|
-
onChange={handleImageFitChange}
|
|
747
|
-
name="imageFit"
|
|
748
|
-
defaultValue="cover"
|
|
749
|
-
description="Img component's `constrain` prop"
|
|
750
|
-
variant="toggle"
|
|
751
|
-
>
|
|
752
|
-
<RadioInput label="Cover" value="cover" />
|
|
753
|
-
<RadioInput label="Contain" value="contain" />
|
|
754
|
-
</RadioInputGroup>
|
|
755
|
-
<RadioInputGroup
|
|
756
|
-
onChange={handleModalSizeChange}
|
|
757
|
-
name="modalSize"
|
|
758
|
-
defaultValue="fullscreen"
|
|
759
|
-
description="Modal size"
|
|
760
|
-
variant="toggle"
|
|
394
|
+
withBackground={false}
|
|
395
|
+
withBorder={false}
|
|
396
|
+
renderIcon={IconXSolid}
|
|
397
|
+
screenReaderLabel="Close"
|
|
398
|
+
onClick={handleButtonClick}
|
|
399
|
+
/>
|
|
400
|
+
</Flex.Item>
|
|
401
|
+
</Flex>
|
|
402
|
+
</Modal.Header>
|
|
403
|
+
<Modal.Body padding="none">
|
|
404
|
+
<Img src={avatarSquare} constrain={imageFit} display="block" />
|
|
405
|
+
</Modal.Body>
|
|
406
|
+
<Modal.Footer>
|
|
407
|
+
<Button
|
|
408
|
+
onClick={handleButtonClick}
|
|
409
|
+
withBackground={false}
|
|
410
|
+
color="primary-inverse"
|
|
411
|
+
type="submit"
|
|
761
412
|
>
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
<Button onClick={handleButtonClick} margin="medium 0 0">
|
|
770
|
-
{open ? 'Close' : 'Open'} the Modal
|
|
771
|
-
</Button>
|
|
772
|
-
<Modal
|
|
773
|
-
open={open}
|
|
774
|
-
onDismiss={() => {
|
|
775
|
-
setOpen(false)
|
|
776
|
-
}}
|
|
777
|
-
size={modalSize}
|
|
778
|
-
label="Hello Media"
|
|
779
|
-
shouldCloseOnDocumentClick
|
|
780
|
-
variant="inverse"
|
|
781
|
-
overflow="fit"
|
|
782
|
-
>
|
|
783
|
-
<Modal.Header>
|
|
784
|
-
<Flex>
|
|
785
|
-
<Flex.Item shouldGrow shouldShrink>
|
|
786
|
-
<Flex alignItems="center">
|
|
787
|
-
<Flex.Item margin="0 x-small 0 0">
|
|
788
|
-
<SVGIcon
|
|
789
|
-
src={iconExample}
|
|
790
|
-
size="small"
|
|
791
|
-
title="Icon Example"
|
|
792
|
-
/>
|
|
793
|
-
</Flex.Item>
|
|
794
|
-
<Flex.Item shouldGrow shouldShrink>
|
|
795
|
-
<Heading level="h2">
|
|
796
|
-
<TruncateText>This Modal Contains Media</TruncateText>
|
|
797
|
-
</Heading>
|
|
798
|
-
</Flex.Item>
|
|
799
|
-
</Flex>
|
|
800
|
-
</Flex.Item>
|
|
801
|
-
<Flex.Item>
|
|
802
|
-
<IconButton
|
|
803
|
-
color="primary-inverse"
|
|
804
|
-
withBackground={false}
|
|
805
|
-
withBorder={false}
|
|
806
|
-
renderIcon={IconPrinterSolid}
|
|
807
|
-
screenReaderLabel="Print This Image"
|
|
808
|
-
margin="0 x-small 0 0"
|
|
809
|
-
/>
|
|
810
|
-
<IconButton
|
|
811
|
-
color="primary-inverse"
|
|
812
|
-
withBackground={false}
|
|
813
|
-
withBorder={false}
|
|
814
|
-
renderIcon={IconDownloadSolid}
|
|
815
|
-
screenReaderLabel="Download This Image"
|
|
816
|
-
margin="0 x-small 0 0"
|
|
817
|
-
/>
|
|
818
|
-
<IconButton
|
|
819
|
-
color="primary-inverse"
|
|
820
|
-
withBackground={false}
|
|
821
|
-
withBorder={false}
|
|
822
|
-
renderIcon={IconXSolid}
|
|
823
|
-
screenReaderLabel="Close"
|
|
824
|
-
onClick={handleButtonClick}
|
|
825
|
-
/>
|
|
826
|
-
</Flex.Item>
|
|
827
|
-
</Flex>
|
|
828
|
-
</Modal.Header>
|
|
829
|
-
<Modal.Body padding="none">
|
|
830
|
-
<Img src={avatarSquare} constrain={imageFit} display="block" />
|
|
831
|
-
</Modal.Body>
|
|
832
|
-
<Modal.Footer>
|
|
833
|
-
<Button
|
|
834
|
-
onClick={handleButtonClick}
|
|
835
|
-
withBackground={false}
|
|
836
|
-
color="primary-inverse"
|
|
837
|
-
type="submit"
|
|
838
|
-
>
|
|
839
|
-
Close
|
|
840
|
-
</Button>
|
|
841
|
-
</Modal.Footer>
|
|
842
|
-
</Modal>
|
|
843
|
-
</div>
|
|
844
|
-
)
|
|
845
|
-
}
|
|
413
|
+
Close
|
|
414
|
+
</Button>
|
|
415
|
+
</Modal.Footer>
|
|
416
|
+
</Modal>
|
|
417
|
+
</div>
|
|
418
|
+
)
|
|
419
|
+
}
|
|
846
420
|
|
|
847
|
-
|
|
848
|
-
|
|
421
|
+
render(<Example />)
|
|
422
|
+
```
|
|
849
423
|
|
|
850
424
|
### Small viewports
|
|
851
425
|
|
|
852
426
|
On smaller viewports (like mobile devices or scaled-up UI), we don't want to lose space because of padding and margins. In order to achieve that, use `size="fullscreen"` on the Modal and set the `spacing` property of Modal.Header to `compact`.
|
|
853
427
|
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
smallViewport: true
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
toggleOpen = () => {
|
|
867
|
-
this.setState(function (state) {
|
|
868
|
-
return { open: !state.open }
|
|
869
|
-
})
|
|
870
|
-
}
|
|
871
|
-
|
|
872
|
-
toggleViewport = async () => {
|
|
873
|
-
await this.setState(function (state) {
|
|
874
|
-
return { smallViewport: !state.smallViewport }
|
|
875
|
-
})
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
renderCloseButton() {
|
|
879
|
-
return (
|
|
880
|
-
<CloseButton
|
|
881
|
-
placement="end"
|
|
882
|
-
offset="small"
|
|
883
|
-
onClick={this.toggleOpen}
|
|
884
|
-
screenReaderLabel="Close"
|
|
885
|
-
/>
|
|
886
|
-
)
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
render() {
|
|
890
|
-
return (
|
|
891
|
-
<div>
|
|
892
|
-
<Button onClick={this.toggleOpen}>
|
|
893
|
-
{this.state.open ? 'Close' : 'Open'} the Modal
|
|
894
|
-
</Button>
|
|
895
|
-
<Button
|
|
896
|
-
onClick={this.toggleViewport}
|
|
897
|
-
margin="0 0 0 small"
|
|
898
|
-
id="toggleViewportButton"
|
|
899
|
-
>
|
|
900
|
-
Toggle viewport
|
|
901
|
-
</Button>
|
|
902
|
-
<Modal
|
|
903
|
-
open={this.state.open}
|
|
904
|
-
size={this.state.smallViewport ? 'fullscreen' : 'small'}
|
|
905
|
-
onDismiss={(event) => {
|
|
906
|
-
if (event.target.id !== 'toggleViewportButton') {
|
|
907
|
-
this.setState({ open: false })
|
|
908
|
-
}
|
|
909
|
-
}}
|
|
910
|
-
label="Hello World"
|
|
911
|
-
shouldCloseOnDocumentClick
|
|
912
|
-
mountNode={() => document.getElementById('viewportExample')}
|
|
913
|
-
constrain="parent"
|
|
914
|
-
>
|
|
915
|
-
<Modal.Header
|
|
916
|
-
spacing={this.state.smallViewport ? 'compact' : 'default'}
|
|
917
|
-
>
|
|
918
|
-
{this.renderCloseButton()}
|
|
919
|
-
{this.state.smallViewport ? (
|
|
920
|
-
<Heading
|
|
921
|
-
as="h2"
|
|
922
|
-
level="h3"
|
|
923
|
-
themeOverride={{ h3FontWeight: 400 }}
|
|
924
|
-
>
|
|
925
|
-
This Modal is optimized for small viewport
|
|
926
|
-
</Heading>
|
|
927
|
-
) : (
|
|
928
|
-
<Heading as="h2">This is a default size Modal</Heading>
|
|
929
|
-
)}
|
|
930
|
-
</Modal.Header>
|
|
931
|
-
<Modal.Body>
|
|
932
|
-
<View as="p" margin="none none small">
|
|
933
|
-
<Text>{fpo}</Text>
|
|
934
|
-
</View>
|
|
935
|
-
</Modal.Body>
|
|
936
|
-
<Modal.Footer>
|
|
937
|
-
<Button onClick={this.toggleOpen} margin="0 x-small 0 0">
|
|
938
|
-
Close
|
|
939
|
-
</Button>
|
|
940
|
-
<Button onClick={this.toggleOpen} color="primary" type="submit">
|
|
941
|
-
Submit
|
|
942
|
-
</Button>
|
|
943
|
-
</Modal.Footer>
|
|
944
|
-
</Modal>
|
|
428
|
+
```js
|
|
429
|
+
---
|
|
430
|
+
type: example
|
|
431
|
+
---
|
|
432
|
+
const fpo = lorem.paragraphs(1)
|
|
433
|
+
const Example = () => {
|
|
434
|
+
const [open, setOpen] = useState(false)
|
|
435
|
+
const [smallViewport, setSmallViewport] = useState(true)
|
|
945
436
|
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
margin="medium auto none"
|
|
949
|
-
display="block"
|
|
950
|
-
width={this.state.smallViewport ? '20rem' : '50rem'}
|
|
951
|
-
height="37.5rem"
|
|
952
|
-
borderWidth="large"
|
|
953
|
-
id="viewportExample"
|
|
954
|
-
></View>
|
|
955
|
-
</div>
|
|
956
|
-
)
|
|
957
|
-
}
|
|
437
|
+
const toggleOpen = () => {
|
|
438
|
+
setOpen((state) => !state)
|
|
958
439
|
}
|
|
959
440
|
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
- ```js
|
|
964
|
-
const fpo = lorem.paragraphs(1)
|
|
965
|
-
const Example = () => {
|
|
966
|
-
const [open, setOpen] = useState(false)
|
|
967
|
-
const [smallViewport, setSmallViewport] = useState(true)
|
|
968
|
-
|
|
969
|
-
const toggleOpen = () => {
|
|
970
|
-
setOpen((state) => !state)
|
|
971
|
-
}
|
|
972
|
-
|
|
973
|
-
const toggleViewport = () => {
|
|
974
|
-
setSmallViewport((state) => !state)
|
|
975
|
-
}
|
|
976
|
-
|
|
977
|
-
const renderCloseButton = () => {
|
|
978
|
-
return (
|
|
979
|
-
<CloseButton
|
|
980
|
-
placement="end"
|
|
981
|
-
offset="small"
|
|
982
|
-
onClick={toggleOpen}
|
|
983
|
-
screenReaderLabel="Close"
|
|
984
|
-
/>
|
|
985
|
-
)
|
|
986
|
-
}
|
|
441
|
+
const toggleViewport = () => {
|
|
442
|
+
setSmallViewport((state) => !state)
|
|
443
|
+
}
|
|
987
444
|
|
|
445
|
+
const renderCloseButton = () => {
|
|
988
446
|
return (
|
|
989
|
-
<
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
margin="0 0 0 small"
|
|
996
|
-
id="toggleViewportButton"
|
|
997
|
-
>
|
|
998
|
-
Toggle viewport
|
|
999
|
-
</Button>
|
|
1000
|
-
<Modal
|
|
1001
|
-
open={open}
|
|
1002
|
-
size={smallViewport ? 'fullscreen' : 'small'}
|
|
1003
|
-
onDismiss={(event) => {
|
|
1004
|
-
if (event.target.id !== 'toggleViewportButton') {
|
|
1005
|
-
setOpen(false)
|
|
1006
|
-
}
|
|
1007
|
-
}}
|
|
1008
|
-
label="Hello World"
|
|
1009
|
-
shouldCloseOnDocumentClick
|
|
1010
|
-
mountNode={() => document.getElementById('viewportExample')}
|
|
1011
|
-
constrain="parent"
|
|
1012
|
-
>
|
|
1013
|
-
<Modal.Header spacing={smallViewport ? 'compact' : 'default'}>
|
|
1014
|
-
{renderCloseButton()}
|
|
1015
|
-
{smallViewport ? (
|
|
1016
|
-
<Heading as="h2" level="h3" themeOverride={{ h3FontWeight: 400 }}>
|
|
1017
|
-
This Modal is optimized for small viewport
|
|
1018
|
-
</Heading>
|
|
1019
|
-
) : (
|
|
1020
|
-
<Heading as="h2">This is a default size Modal</Heading>
|
|
1021
|
-
)}
|
|
1022
|
-
</Modal.Header>
|
|
1023
|
-
<Modal.Body>
|
|
1024
|
-
<View as="p" margin="none none small">
|
|
1025
|
-
<Text>{fpo}</Text>
|
|
1026
|
-
</View>
|
|
1027
|
-
</Modal.Body>
|
|
1028
|
-
<Modal.Footer>
|
|
1029
|
-
<Button onClick={toggleOpen} margin="0 x-small 0 0">
|
|
1030
|
-
Close
|
|
1031
|
-
</Button>
|
|
1032
|
-
<Button onClick={toggleOpen} color="primary" type="submit">
|
|
1033
|
-
Submit
|
|
1034
|
-
</Button>
|
|
1035
|
-
</Modal.Footer>
|
|
1036
|
-
</Modal>
|
|
1037
|
-
|
|
1038
|
-
<View
|
|
1039
|
-
background="primary-inverse"
|
|
1040
|
-
margin="medium auto none"
|
|
1041
|
-
display="block"
|
|
1042
|
-
width={smallViewport ? '20rem' : '50rem'}
|
|
1043
|
-
height="37.5rem"
|
|
1044
|
-
borderWidth="large"
|
|
1045
|
-
id="viewportExample"
|
|
1046
|
-
></View>
|
|
1047
|
-
</div>
|
|
447
|
+
<CloseButton
|
|
448
|
+
placement="end"
|
|
449
|
+
offset="small"
|
|
450
|
+
onClick={toggleOpen}
|
|
451
|
+
screenReaderLabel="Close"
|
|
452
|
+
/>
|
|
1048
453
|
)
|
|
1049
454
|
}
|
|
1050
455
|
|
|
1051
|
-
|
|
1052
|
-
|
|
456
|
+
return (
|
|
457
|
+
<div>
|
|
458
|
+
<Button onClick={toggleOpen}>
|
|
459
|
+
{open ? 'Close' : 'Open'} the Modal
|
|
460
|
+
</Button>
|
|
461
|
+
<Button
|
|
462
|
+
onClick={toggleViewport}
|
|
463
|
+
margin="0 0 0 small"
|
|
464
|
+
id="toggleViewportButton"
|
|
465
|
+
>
|
|
466
|
+
Toggle viewport
|
|
467
|
+
</Button>
|
|
468
|
+
<Modal
|
|
469
|
+
open={open}
|
|
470
|
+
size={smallViewport ? 'fullscreen' : 'small'}
|
|
471
|
+
onDismiss={(event) => {
|
|
472
|
+
if (event.target.id !== 'toggleViewportButton') {
|
|
473
|
+
setOpen(false)
|
|
474
|
+
}
|
|
475
|
+
}}
|
|
476
|
+
label="Hello World"
|
|
477
|
+
shouldCloseOnDocumentClick
|
|
478
|
+
mountNode={() => document.getElementById('viewportExample')}
|
|
479
|
+
constrain="parent"
|
|
480
|
+
>
|
|
481
|
+
<Modal.Header spacing={smallViewport ? 'compact' : 'default'}>
|
|
482
|
+
{renderCloseButton()}
|
|
483
|
+
{smallViewport ? (
|
|
484
|
+
<Heading as="h2" level="h3" themeOverride={{ h3FontWeight: 400 }}>
|
|
485
|
+
This Modal is optimized for small viewport
|
|
486
|
+
</Heading>
|
|
487
|
+
) : (
|
|
488
|
+
<Heading as="h2">This is a default size Modal</Heading>
|
|
489
|
+
)}
|
|
490
|
+
</Modal.Header>
|
|
491
|
+
<Modal.Body>
|
|
492
|
+
<View as="p" margin="none none small">
|
|
493
|
+
<Text>{fpo}</Text>
|
|
494
|
+
</View>
|
|
495
|
+
</Modal.Body>
|
|
496
|
+
<Modal.Footer>
|
|
497
|
+
<Button onClick={toggleOpen} margin="0 x-small 0 0">
|
|
498
|
+
Close
|
|
499
|
+
</Button>
|
|
500
|
+
<Button onClick={toggleOpen} color="primary" type="submit">
|
|
501
|
+
Submit
|
|
502
|
+
</Button>
|
|
503
|
+
</Modal.Footer>
|
|
504
|
+
</Modal>
|
|
505
|
+
|
|
506
|
+
<View
|
|
507
|
+
background="primary-inverse"
|
|
508
|
+
margin="medium auto none"
|
|
509
|
+
display="block"
|
|
510
|
+
width={smallViewport ? '20rem' : '50rem'}
|
|
511
|
+
height="37.5rem"
|
|
512
|
+
borderWidth="large"
|
|
513
|
+
id="viewportExample"
|
|
514
|
+
></View>
|
|
515
|
+
</div>
|
|
516
|
+
)
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
render(<Example />)
|
|
520
|
+
```
|
|
1053
521
|
|
|
1054
522
|
### Using custom children
|
|
1055
523
|
|