-
Notifications
You must be signed in to change notification settings - Fork 1
/
0-form.html
329 lines (304 loc) · 9.25 KB
/
0-form.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html lang="en">
<head>
<title>Calcite Form</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>
html,
body {
margin: 0;
padding: 0;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0,0,0,0);
border: 0;
}
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;
}
/* Progress bar */
#progress {
position: fixed;
top: 0;
left: 0;
z-index: 999;
}
/* Form */
ol {
margin: 0.5em 0;
padding: 0 1.5rem;
}
ol li {
padding: 0 0 1em 0;
}
fieldset {
margin: 2.5rem 0;
padding: 1rem;
border-collapse: collapse;
border: 1px solid;
border-color: var(--calcite-ui-border-1);
border-radius: var(--calcite-border-radius);
}
</style>
</head>
<!-- Components included:
* calcite-label
* calcite-switch
* calcite-notice
* calcite-link
* calcite-tooltip-manager
* calcite-tooltip
* calcite-icon
* calcite-input
* calcite-select
* calcite-option
* calcite-radio-button-group
* calcite-radio-button
* calcite-slider
* calcite-combobox
* calcite-combobox-item
* calcite-radio-group
* calcite-radio-group-item
* calcite-checkbox
* calcite-input-date-picker
* calcite-rating
* calcite-button
* calcite-alert
* calcite-progress
-->
<body>
<main>
<h1>Calcite Form</h1>
<div id="theme-label">
<calcite-label layout="inline">
Toggle theme
<calcite-switch id="theme-switch"></calcite-switch>
</calcite-label>
</div>
<!-- calcite-notice -->
<!-- calcite-link -->
<calcite-notice icon="information" active dismissible>
<div slot="title">Accessibility audit on the Calcite components.</div>
<div slot="message"><ul>
<li>To verify each component, fill out the form in its entirety, and submit the form by selecting the "Submit" button.</li>
<li>The form can be cleared by selecting the "Reset form" button.</li>
</ul>
</div>
<div slot="link"><p>Link 1 test: <calcite-link href="https://codepen.io/jcfranco/pen/vYmoKYq" target="_blank">Survey Form Demo</p>
<p>Link 2 test: <calcite-link href="https://codepen.io/jcfranco/pen/vYmoKYq" target="_blank">Survey Form Demo<span class="sr-only">, opens in a new browser window</span></calcite-link></p></div>
</calcite-notice>
<!-- Form -->
<form id="form">
<fieldset>
<legend>Questionnaire</legend>
<ol>
<li>
<calcite-tooltip-manager>
<!-- calcite-tooltip -->
<!-- calcite-icon -->
<calcite-tooltip reference-element="theme-help">It's a pleasure to meet you! Let us know your name incase we have any further questions.</calcite-tooltip>
<!-- calcite-input -->
<calcite-label>
<span>Your name
<calcite-icon tabindex="0" id="theme-help" icon="question" scale="s"></calcite-icon>
</span>
<calcite-input type="text" placeholder="John Doe">
</calcite-input>
</calcite-label>
</calcite-tooltip-manager>
</li>
<li>
<!-- calcite-select -->
<!-- calcite-option -->
<calcite-label>Where did you hear about Calcite components?
<calcite-select>
<calcite-option label="Please select…"></calcite-option>
<calcite-option label="Esri DevSummit"></calcite-option>
<calcite-option label="Search engine"></calcite-option>
<calcite-option label="Social media"></calcite-option>
<calcite-option label="A little bird told me"></calcite-option>
</calcite-select>
</calcite-label>
</li>
<li>
<!-- calcite-radio-button-group -->
<!-- calcite-radio-button -->
<calcite-label>Will you be using Calcite components in an upcoming project?
<calcite-radio-button-group>
<calcite-label layout=inline>Yes
<calcite-radio-button value="yes"></calcite-radio-button>
</calcite-label>
<calcite-label layout=inline>No
<calcite-radio-button value="no"></calcite-radio-button>
</calcite-label>
<calcite-label layout=inline>Maybe
<calcite-radio-button value="maybe"></calcite-radio-button>
</calcite-label>
</calcite-radio-button-group>
</calcite-label>
</li>
<li>
<!-- calcite-slider -->
<calcite-label>How many components will you be using?
<calcite-slider snap label-handles label-ticks ticks="2" label="Number of components" value="0" min="0" max="10" step="1"></calcite-slider>
</calcite-label>
</li>
<li>
<!-- calcite-combobox -->
<!-- calcite-combobox-item -->
<calcite-label>What is your favorite component(s)?
<calcite-combobox id="combobox" placeholder="Select favorites…" max-items="6"></calcite-combobox>
</calcite-label>
</li>
<li>
<!-- calcite-radio-group -->
<!-- calcite-radio-group-item -->
<calcite-label for="radioGroup">How useful is the Calcite design system?
<calcite-radio-group id="radioGroup" layout="horizontal">
<calcite-radio-group-item value="0">😴 Very useless
</calcite-radio-group-item>
<calcite-radio-group-item value="1">🥱 Somewhat useless
</calcite-radio-group-item>
<calcite-radio-group-item value="2" checked>🤔 Undecided
</calcite-radio-group-item>
<calcite-radio-group-item value="3">😀 Somewhat useful
</calcite-radio-group-item>
<calcite-radio-group-item value="5">🥳 Very useful
</calcite-radio-group-item>
</calcite-radio-group>
</calcite-label>
</li>
<li>
<!-- calcite-checkbox -->
<fieldset>
<legend>
What is the most important aspect(s) of a component?
</legend>
<calcite-label layout=inline>
<calcite-checkbox></calcite-checkbox>Configuration
</calcite-label>
<calcite-label layout=inline>
<calcite-checkbox></calcite-checkbox>Accessibility
</calcite-label>
<calcite-label layout=inline>
<calcite-checkbox></calcite-checkbox>Ease of use
</calcite-label>
</fieldset>
</li>
<li>
<!-- calcite-input-date-picker -->
<calcite-label>When did you hear about Calcite components?
<calcite-input-date-picker id="date-picker"></calcite-input-date-picker>
</calcite-label>
</li>
<li>
<!-- calcite-rating -->
<calcite-label>How many stars would you give Calcite components?
<calcite-rating value="1"></calcite-rating>
</calcite-label>
</li>
</ol>
<!-- Submit form button -->
<calcite-button label="Submit the form" id="submit" type="submit">Submit</calcite-button>
<!-- Reset form button -->
<calcite-button label="Reset the form" appearance="clear" id="reset" type="reset">Reset form</calcite-button>
</fieldset>
</form>
<!-- calcite-alert -->
<calcite-alert id="alert" icon auto-dismiss auto-dismiss-duration="medium" color="green">
<div slot="message">
<strong>Success!</strong>
Thank you for your feedback.
</div>
</calcite-alert>
<!-- calcite-progress -->
<calcite-progress id="progress" type="indeterminate" hidden></calcite-progress>
</main>
</body>
<script>
window.onload = () => {
// Theme Switcher
const themeSwitch = document.getElementById("theme-switch");
themeSwitch.addEventListener("calciteSwitchChange", () => {
document.body.classList.toggle("calcite-theme-dark");
});
// Combobox
const comboboxItems = [
"Accordion",
"Alert",
"Button",
"Dropdown",
"Card",
"Combobox",
"Icon",
"Label",
"Loader",
"Modal",
"Notice",
"Pagination",
"Popover",
"Slider",
"Switch",
"Tabs",
"Tooltip",
"Tree"
];
const combobox = document.getElementById("combobox");
comboboxItems.forEach((item, index) => {
const comboboxItem = document.createElement("calcite-combobox-item");
comboboxItem.textLabel = item;
comboboxItem.value = index;
combobox.appendChild(comboboxItem);
});
// Datepicker
const datePicker = document.getElementById("date-picker");
datePicker.maxAsDate = new Date();
datePicker.min = "2021-01-01";
// Form submission
const form = document.getElementById("form");
const submit = document.getElementById("submit");
const progress = document.getElementById("progress");
const alert = document.getElementById("alert");
form.onsubmit = () => {
submit.loading = true;
progress.removeAttribute("hidden");
setTimeout(() => {
submit.loading = false;
progress.setAttribute("hidden", "");
alert.active = true;
}, 2500);
};
};
</script>
</html>