forked from motss/app-datepicker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
316 lines (267 loc) · 10.2 KB
/
index.html
File metadata and controls
316 lines (267 loc) · 10.2 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title><app-datepicker> demo</title>
<link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
<link rel="preconnect" href="https://unpkg.com" crossorigin>
<!-- <script src="https://cdn.jsdelivr.net/npm/@babel/polyfill@latest/dist/polyfill.min.js"></script> -->
<script src="https://unpkg.com/dimport@latest/dist/index.min.js"></script>
<script src="https://unpkg.com/@webcomponents/webcomponentsjs@latest/webcomponents-loader.js"></script>
<!-- <script src="/node_modules/@webcomponents/webcomponentsjs/webcomponents-loader.js"></script> -->
<script>
var hasWebAnimations = 'animate' in Element.prototype;
var hasIntl = 'Intl' in window;
var hasArrayFind = 'find' in Array.prototype;
if (!hasWebAnimations) {
const wa = document.createElement('script');
wa.src = 'https://unpkg.com/web-animations-js@latest/web-animations.min.js';
wa.onload = () => console.info('⚒ Web Animations Next lite loaded');
wa.onerror = console.error;
document.head.appendChild(wa);
}
if (!hasIntl) {
const wa = document.createElement('script');
/** FIXME: Pin package version due to https://github.com/andyearnshaw/Intl.js/issues/256 */
wa.src = 'https://unpkg.com/intl@1.2.4/dist/Intl.complete.js';
wa.onload = () => console.info('🌐 Intl polyfill loaded');
wa.onerror = console.error;
document.head.appendChild(wa);
}
if (!window.fetch) {
const wa = document.createElement('script');
wa.src = 'https://unpkg.com/whatwg-fetch@3.0.0/dist/fetch.umd.js';
wa.onload = () => console.info('🌐 Fetch polyfill loaded');
wa.onerror = console.error;
document.head.appendChild(wa);
}
if (!hasArrayFind) {
Object.defineProperty(Array.prototype, 'find', {
value: function arrayFind(cb) {
const filtered = this.filter(cb);
return !filtered.length ? void 0 : filtered[0];
}
});
}
</script>
<script type="module">
import '/node_modules/@reallyland/really-elements/dist/code-configurator/code-configurator.js';
import '/dist/app-datepicker.js';
import '/dist/app-datepicker-dialog.js';
import { properties, cssProperties, propertiesDialog, cssPropertiesDialog } from '/dist/demo/properties.config.js';
const $ = s => document.body.querySelector(s);
const darkThemeMq = matchMedia('(prefers-color-scheme: dark)');
const updateCssPropertiesWithTheme = (matches, props) => {
return matches ?
props.map((n) => {
if (n.name === '--app-datepicker-bg-color') return { name: n.name, value: '#000' };
if (n.name === '--app-datepicker-color') return { name: n.name, value: '#f5f5f5' };
if (n.name === '--app-datepicker-disabled-day-color') return { name: n.name, value: 'rgba(255, 255, 255, .35)' };
if (n.name === '--app-datepicker-focused-day-color') return { name: n.name, value: '#000' };
if (n.name === '--app-datepicker-selector-color') return { name: n.name, value: 'rgba(255, 255, 255, .55)' };
if (n.name === '--app-datepicker-separator-color') return { name: n.name, value: '#000' };
if (n.name === '--app-datepicker-weekday-color') return { name: n.name, value: 'rgba(255, 255, 255, .55)' };
return n;
}) :
props;
};
// const inputCheckboxPointerEvent = $('.input-checkbox__pointer-event');
const inputCheckboxArrayFind = $('.input-checkbox__array-find');
const inputCheckboxIntl = $('.input-checkbox__intl');
const inputCheckboxWebAnimations = $('.input-checkbox__web-animations');
const configuratorDatepickerEl = $('.configurator--datepicker');
const configuratorDatepickerDialogEl = $('.configurator--datepicker-dialog');
const openBtnEl = $('.open-btn');
const datepickerDialogEl = $('.datepicker-dialog');
// inputCheckboxPointerEvent.checked = 'PointerEvent' in self;
inputCheckboxArrayFind.checked = hasArrayFind;
inputCheckboxIntl.checked = hasIntl;
inputCheckboxWebAnimations.checked = hasWebAnimations;
// Element.prototype.animate.toString().indexOf('[native code]') >= 0;
configuratorDatepickerEl.properties = properties;
configuratorDatepickerDialogEl.properties = propertiesDialog;
configuratorDatepickerEl.cssProperties =
updateCssPropertiesWithTheme(darkThemeMq.matches, cssProperties);
configuratorDatepickerDialogEl.cssProperties =
updateCssPropertiesWithTheme(darkThemeMq.matches, cssPropertiesDialog);
darkThemeMq.addListener((ev) => {
const matches = ev.matches;
configuratorDatepickerEl.cssProperties =
updateCssPropertiesWithTheme(matches, cssProperties);
configuratorDatepickerDialogEl.cssProperties =
updateCssPropertiesWithTheme(matches, cssPropertiesDialog)
});
openBtnEl.addEventListener('click', () => {
datepickerDialogEl.open();
});
</script>
</head>
<body>
<style>
html,
body {
position: relative;
width: 100%;
min-height: 100vh;
margin: 0;
padding: 0;
background-color: #f1f1f1;
color: #000;
font-family: 'Google Sans', sans-serif;
font-size: 16px;
line-height: 1.5;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
* {
box-sizing: border-box;
}
h1,
h2 {
margin: 0;
padding: 0;
}
header {
display: flex;
flex-direction: column;
padding: 0 16px;
}
.toc {
margin: 16px 0 0;
}
section {
max-width: calc(100vw - 24px * 2);
width: 100%;
margin: 0 auto;
padding: 24px 16px;
background-color: #fff;
border-radius: 12px;
}
section + section {
margin: 16px auto 0;
}
section:first-of-type:not(:last-of-type) {
margin: 16px auto 0;
}
section:first-of-type:last-of-type {
margin: 0 auto 40px;
}
section:last-of-type:not(:first-of-type) {
margin: 16px auto 40px;
}
@media screen and (min-width: 1200px) {
section {
max-width: calc(1200px - 40px * 2);
}
}
.api-desc {
font-size: 14px;
}
input:checked + span + a {
display: none;
}
.calendar-render-time {
font-size: 14px;
}
.centered-section {
display: flex;
justify-content: center;
padding: 16px;
}
.datepicker {
box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14),
0 1px 5px 0 rgba(0, 0, 0, 0.12),
0 3px 1px -2px rgba(0, 0, 0, 0.2);
}
.open-btn {
--mdc-theme-primary: #1a73e8;
}
@media (prefers-color-scheme: dark) {
app-datepicker,
app-datepicker-dialog {
--app-datepicker-bg-color: #000;
--app-datepicker-color: #f5f5f5;
--app-datepicker-disabled-day-color: rgba(255, 255, 255, .35);
--app-datepicker-focused-day-color: #000;
--app-datepicker-selector-color: rgba(255, 255, 255, .55);
--app-datepicker-separator-color: #000;
--app-datepicker-weekday-color: rgba(255, 255, 255, .55);
}
}
</style>
<header>
<h1>Demo</h1>
<div class="toc">
<h2>Table of contents</h2>
<ul>
<li><a href="/#app-datepicker">app-datepicker</a></li>
<li><a href="/#app-datepicker-dialog">app-datepicker-dialog</a></li>
</ul>
</div>
</header>
<section>
<h2>Required web platform APIs:</h2>
<p class="api-desc"><i>* Checked if API is natively supported</i></p>
<!-- <div>
<label>
<input class="input-checkbox__pointer-event" type="checkbox" disabled>
<span>PointerEvent</span>
<a
href="https://unpkg.com/pepjs@latest/"
target="_blank"
rel="noopener">PointerEvent polyfill</a>
</label>
</div> -->
<div>
<label>
<input class="input-checkbox__array-find" type="checkbox" disabled>
<span>Array.prototype.find</span>
<a
href="https://bit.ly/2LHkXiN"
target="_blank"
rel="noopener">Array.prototype.find polyfill</a>
</label>
</div>
<div>
<label>
<input class="input-checkbox__intl" type="checkbox" disabled>
<span>Intl.DateTimeFormat</span>
<a
href="https://unpkg.com/intl@1.2.4/"
target="_blank"
rel="noopener">Intl polyfill</a>
</label>
</div>
<div>
<label>
<input class="input-checkbox__web-animations" type="checkbox" disabled>
<span>Web Animations</span>
<a
href="https://unpkg.com/web-animations-js@latest/"
target="_blank"
rel="noopener">Web Animations polyfill</a>
</label>
</div>
</section>
<section>
<h2><a id="app-datepicker" href="/#app-datepicker">app-datepicker</a></h2>
<i class="calendar-render-time"></i>
<really-code-configurator class="configurator--datepicker" customelement="app-datepicker">
<div class="centered-section">
<app-datepicker class="datepicker"></app-datepicker>
</div>
</really-code-configurator>
</section>
<section>
<h2><a id="app-datepicker-dialog" href="/#app-datepicker-dialog">app-datepicker-dialog</a></h2>
<really-code-configurator class="configurator--datepicker-dialog" customelement="app-datepicker-dialog">
<div class="centered-section">
<mwc-button class="open-btn">Open datepicker dialog</mwc-button>
<app-datepicker-dialog class="datepicker-dialog"></app-datepicker-dialog>
</div>
</really-code-configurator>
</section>
</body>
</html>