-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmodal.html
315 lines (273 loc) · 15.2 KB
/
modal.html
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>modal</title>
<script type="module" src="https://js.arcgis.com/calcite-components/1.0.0-beta.91/calcite.esm.js"></script>
<link rel="stylesheet" type="text/css" href="https://js.arcgis.com/calcite-components/1.0.0-beta.91/calcite.css" />
<style>
h1 {
margin-bottom: 5rem;
}
h2,
.button-space {
margin-bottom: 3rem;
}
body {
font-family: var(--calcite-sans-family);
font-size: var(--calcite-font-size-0);
color: var(--calcite-ui-text-1);
max-width: 1024px;
min-width: 280px;
width: 70vw;
padding: 0 var(--calcite-spacing-double);
margin: 0 auto;
background-color: var(--calcite-ui-background);
}
/* Theme Switcher */
#theme-label {
position: fixed;
top: 20px;
right: 20px;
z-index: 2;
background-color: var(--calcite-ui-background);
border: 1px solid;
border-color: var(--calcite-ui-border-1);
border-radius: var(--calcite-border-radius);
margin: 0;
padding: 10px;
}
#theme-label label {
margin: 0;
}
</style>
</head>
<body>
<main>
<!-- calcite-switch -->
<div id="theme-label">
<calcite-label layout="inline">
Toggle theme
<calcite-switch id="theme-switch"></calcite-switch>
</calcite-label>
</div>
<h1><code>modal</code></h1>
<ul>
<li>To view each modal test, a button is located after each h2 heading that needs to be activated to display it.</li>
<li>Test 4 is intended for mouse users, but can be conducted by someone who doesn't use a mouse.</li>
<li>If possible, run through each test with each theme by toggling the theme switch.</li>
</ul>
<h2>Test 1. Modal scale</h2>
<!-- Small scale -->
<calcite-modal class="js-modal-s-s" width="s" scale="s" aria-labelledby="modal-title">
<div slot="header" id="modal-title">Small scale modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.js-modal-s-s')" onClick="openModal(event, '.js-modal-s-s')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.js-modal-s-s')" onClick="openModal(event, '.js-modal-s-s')" appearance="outline">Small scale modal</calcite-button>
<br>
<!-- Medium scale -->
<calcite-modal class="js-modal-s-m" width="s" scale="m" aria-labelledby="modal-title-2">
<div slot="header" id="modal-title-2">Medium scale modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.js-modal-s-m')" onClick="openModal(event, '.js-modal-s-m')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.js-modal-s-m')" onClick="openModal(event, '.js-modal-s-m')" appearance="outline">Medium scale modal</calcite-button>
<br>
<!-- Large scale -->
<calcite-modal class="js-modal-s-l" width="s" scale="l" aria-labelledby="modal-title-3">
<div slot="header" id="modal-title-3">Large scale modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.js-modal-s-l')" onClick="openModal(event, '.js-modal-s-l')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.js-modal-s-l')" onClick="openModal(event, '.js-modal-s-l')" appearance="outline">Large scale modal</calcite-button>
<h2>Test 2. Modal type</h2>
<!-- Destructive modal -->
<calcite-modal class="destructive" color="red" aria-labelledby="modal-title-4">
<div slot="header" id="modal-title-4">Destructive action modal</div>
<div slot="content">
<p>The "Delete" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button color="red" onkeypress="openModal(event, '.destructive')" onClick="openModal(event, '.destructive')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button color="red" disabled slot="primary" width="full">Delete</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.destructive')" onClick="openModal(event, '.destructive')" appearance="outline">Destructive modal</calcite-button>
<br>
<!-- Info modal -->
<calcite-modal class="info" color="blue" aria-labelledby="modal-title-5">
<div slot="header" id="modal-title-5">Info action modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.info')" onClick="openModal(event, '.info')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.info')" onClick="openModal(event, '.info')" appearance="outline">Info modal</calcite-button>
<h2>Test 3. Modal cannot close with escape key</h2>
<calcite-modal disable-escape class="no-esc" aria-labelledby="modal-title-6">
<div slot="header" id="modal-title-6">Modal cannot close with escape key</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.no-esc')" onClick="openModal(event, '.no-esc')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.no-esc')" onClick="openModal(event, '.no-esc')" appearance="outline">Modal cannot close with escape key</calcite-button>
<h2>Test 4. [Intended for Mouse users] Modal cannot close when clicked outside of the modal dialog</h2>
<calcite-modal disable-outside-close class="no-out-close" aria-labelledby="modal-title-7">
<div slot="header" id="modal-title-7">Modal cannot close when clicked outside of modal dialog</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.no-out-close')" onClick="openModal(event, '.no-out-close')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.no-out-close')" onClick="openModal(event, '.no-out-close')" appearance="outline">Modal cannot close when clicked outside of modal dialog</calcite-button>
<h2>Test 5. Modal window size and features</h2>
<!-- Full screen -->
<calcite-modal fullscreen class="full-screen" aria-labelledby="modal-title-8">
<div slot="header" id="modal-title-8">Full screen modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.full-screen')" onClick="openModal(event, '.full-screen')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.full-screen')" onClick="openModal(event, '.full-screen')" appearance="outline">Full screen modal</calcite-button>
<br>
<!-- Docked -->
<calcite-modal docked class="docked" aria-labelledby="modal-title-9">
<div slot="header" id="modal-title-9">Docked modal</div>
<div slot="content">
<p>For devices smaller than a tablet, this modal with "dock" to the bottom.</p>
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.docked')" onClick="openModal(event, '.docked')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.docked')" onClick="openModal(event, '.docked')" appearance="outline">Docked modal</calcite-button>
<br>
<!-- Custom width -->
<calcite-modal class="width" width="500" aria-labelledby="modal-title-10">
<div slot="header" id="modal-title-10">Custom width modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.width')" onClick="openModal(event, '.width')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.width')" onClick="openModal(event, '.width')" appearance="outline">Custom width modal</calcite-button>
<br>
<!-- Gray background -->
<calcite-modal class="gray" background-color="grey" aria-labelledby="modal-title-11">
<div slot="header" id="modal-title-11">Grey background modal</div>
<div slot="content">
<p>The "Save" button is for visual purposes only, and is disabled.</p>
<p>To close the modal either:</p>
<ul>
<li>Select the "Cancel" button via keyboard or mouse,</li>
<li>Use the "esc" key,</li>
<li>Select the close button via keyboard or mouse, or</li>
<li>Click outside the modal dialog window.</li>
</ul>
</div>
<calcite-button onkeypress="openModal(event, '.gray')" onClick="openModal(event, '.gray')" slot="secondary" width="full" appearance="outline">Cancel</calcite-button>
<calcite-button disabled slot="primary" width="full">Save</calcite-button>
</calcite-modal>
<calcite-button class="button-space" onkeypress="openModal(event, '.gray')" onClick="openModal(event, '.gray')" appearance="outline">Grey background modal</calcite-button>
</main>
</body>
<script>
window.onload = () => {
// Theme Switcher
const themeSwitch = document.getElementById("theme-switch");
themeSwitch.addEventListener("calciteSwitchChange", () => {
document.body.classList.toggle("calcite-theme-dark");
});
};
// Open the selected modal dialog
function openModal(event, selector) {
if (event.type === 'click' || event.type === 'keypress' && event.keyCode === '13' || event.type === 'keypress' && event.keyCode === '32') {
document.querySelector(selector).active = !document.querySelector(selector).active;
}
}
</script>
</html>