-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
280 lines (251 loc) · 10.7 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Count down to a future event date">
<meta name="author" content="event-Counter">
<meta name="keywords" content="date, counter, countdown, count down, count, down, future, event, web component">
<meta name="theme-color" content="#000000">
<script src="https://flagmeister.github.io/elements.flagmeister.min.js"></script>
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 160'>
<path d='M55 5a5 5 90 015-5h40a5 5 90 010 10h-10v11a70 70 90 0135 123l8 8a5 5 90 01-7 7l-9-9
a70 70 90 01-37 11a70 70 90 01-37-11l-9 9a5 5 90 01-7-7l8-8a70 70 90 0135-123v-11h-10
a5 5 90 01-5-5z
m-46 49a25 25 90 1135-35a80 80 90 00-35 35z
m126-44c-8 0-14 3-19 9a80 80 90 0135 35a25 25 90 00-16-44z
m-50 40a5 5 90 00-10 0v39l-15 29a5 5 90 109 5l15-30a5 5 90 001-2v-40z'/>
</svg>" />
<title>event-count</title>
<style>
body {
--event-count-font: 2.4rem;
}
event-count-html {
display: block;
font-size: 1.7em;
margin-bottom: 1em;
}
</style>
<style>
body {
font: 16px arial;
background: beige;
max-width: 1100px;
margin: 0 auto;
}
main section {
padding-left: 2em;
}
section+section {
margin-top: 5em;
}
h2 {
padding-left: .2em;
background: goldenrod;
}
article {
margin-left: 1em;
}
event-count-example+event-count-example {
display: inline-block;
margin-top: 2em;
}
code:not(.title) {
font-family: 'Courier New', Courier, monospace;
font-weight: bold;
display: inline-block;
background: lightgray;
padding: .5em .5em;
font-size: 90%;
}
svg {
display: inline-block;
width: 1.5em
}
#loadcomponent {
font-size: 140%;
}
</style>
<!-- <event-count> Web Component -->
<script src="./element.js"></script>
<!-- <file-size> Web Component - display GZIP size and GZIP analysis -->
<script src="https://file-size.github.io/element.js"></script>
<script>
customElements.define("header-and-footer", class extends HTMLElement {
connectedCallback() {
this.append(document.querySelector("#HEADER-AND-FOOTER").content.cloneNode(true));
}
})
customElements.define("event-count-example", class extends HTMLElement {
connectedCallback() {
setTimeout(() => {
this.innerHTML = `<section id="${this.getAttribute("id")}">` +
`<h2>${this.getAttribute("title")}</h2>` +
`<article>` +
`<event-count-html></event-count-html>` +
this.outerHTML.replaceAll("event-count-example", "event-count") +
`</article>` +
`</section>`;
this.querySelector("event-count").removeAttribute("id");
this.querySelector("event-count").removeAttribute("title");
});
}
})
customElements.define("event-count-html", class extends HTMLElement {
connectedCallback() {
setTimeout(() => {
this.innerHTML = ("<code>" +
this.closest("section")
.querySelector("event-count")
.outerHTML
.replaceAll("<", "<")
.replaceAll(`" `, '"<br>' + " ".repeat(this.getAttribute("spaces") || 13)) +
"</code>")
.replaceAll("=''", "");
});
}
});
</script>
<template id="HEADER-AND-FOOTER">
<h1><event-count> Web Component
<a href="https://github.com/event-count/event-count.github.io">
<svg viewBox="0 0 720 720">
<!-- Github Icon -->
<path fill="darkred"
d="M290 616v-78c0-26 9-43 19-52-63-7-128-32-128-140a110 110 90 0129-77c-3-7-13-36 3-75 0 0 23-7 77 30a264 264 90 01140 0c54-37 77-30 77-30 16 40 6 68 3 75a110 110 90 0129 77c0 109-66 133-128 140 10 8 19 26 19 52v78c0 8 5 17 19 14A284 284 90 00640 360 282 282 90 00360 77 284 284 90 00271 630c14 2 20-6 20-14z" />
<g fill="none" stroke="#000">
<path
d="M290 616v-78c0-26 9-43 19-52-63-7-128-32-128-140a110 110 90 0129-77c-3-7-13-36 3-75 0 0 23-7 77 30a264 264 90 01140 0c54-37 77-30 77-30 16 40 6 68 3 75a110 110 90 0129 77c0 109-66 133-128 140 10 8 19 26 19 52v78c0 8 5 17 19 14A284 284 90 00640 360 282 282 90 00360 77 284 284 90 00271 630c14 2 20-6 20-14zM163 480c26 9 36 17 48 38 12 20 26 42 80 30" />
</g>
</svg>
GitHub</a>
</h1>
<!-- <p>
<a href="https://masteringionic.com/blog/creating-a-event-count-with-stencil-web-components">inspiration
(with
less functionality and more code)</a>
</p> -->
<p>
I promote writing you own Web Components using native technology. <a
href="https://github.com/event-count/event-count.github.io/blob/main/element.js">The single file
sourcecode of this <event-count> Web Component</a> has the UNlicensed license; meaning you can copy
and re-use whatever you want from it, without giving any attribution.</a>
</p>
<h1>Load the <event-count> Web Component:</h1>
<code
id="loadcomponent"><script src="https://event-count.github.io/element.min.js"></script></code>
<br>
<br>
</template>
</head>
<body>
<!-- <a href="." style="position:fixed;bottom:10px;right:10px;font:21px arial;zoom:1">documentation</a> -->
<div style="text-align: center;zoom:2.1;--flagmeisterletterheight: 18vh">
<event-count event="48"></event-count>
</div>
<article id="documentation">
<header>
<header-and-footer></header-and-footer>
</header>
<main>
<h1>Use the <event-count> Web Component in HTML code:</h1>
<h2>event attribute Date notation: event="YYYY-MM-DD"</h2>
<event-count-example id="default"
title="Count down to the default future event date: january 19th 2038 "></event-count-example>
<event-count-example id="newyear" title="set custom date and hide years and seconds counter"
count="day,hour,minute" event="newyear">🎆 New
Year! 🍾</event-count-example>
<event-count-example calcnewyear id="newyeardays"
title="set custom event date, only display days counter and format font" count="day" event="newyear"
count-font="4rem Verdana">🎆 New Year!
🍾</event-count-example>
<event-count-example id="since" title="Count up from a past event date" event="1969-1-21" count="year,day">Danny's age
</event-count-example>
<event-count-example id="languageES" title="Set the labels to any language" format="es">Y2K38 in
Spanish
</event-count-example>
<event-count-example id="languageNL" count="year,day" title="Set the labels to any language" format="nl">Y2K38
in Dutch
</event-count-example>
<section id="CSS">
<h2>Set styles with CSS properties</h2>
<style>
#CSS {
--event-count-event-background: red;
--event-count-event-color: white;
--event-count-count-background: teal;
--event-count-count-font: 2.5rem Arial;
--event-count-count-color: gold;
--event-count-text-font: .7rem Arial;
}
</style>
<pre>
<style>
--event-count-event-background: red;
--event-count-event-color: white;
--event-count-count-background: teal;
--event-count-count-font: 2.5rem Arial;
--event-count-count-color: gold;
--event-count-text-font: .7rem Arial;
</style>
</pre>
<event-count></event-count>
</section>
<event-count-example id="CSS2" title="Set styles with CSS properties" count="year,day"
format="nl"></event-count-example>
<event-count-example id="attributes" title="Set styles with attributes (overrule global CSS properties)"
count-background="blue" count-color="gold"></event-count-example>
<section id="parts">
<h2>Style shadowDOM with <code>::part(...)</code></h2>
<event-count-html></event-count-html>
::part(X) can only style Nodes with attribute part=X inside shadowDOM
<br>
<img src="html_code.png" />
<style>
#parts event-count::part(event) {
background: gold;
color: blue;
}
#parts event-count::part(count) {
text-shadow: 2px 2px 2px black;
}
#parts event-count::part(year) {
color: beige;
}
</style>
<pre>
<style>
event-count::part(event) {
background: gold;
color: blue;
}
event-count::part(count) {
text-shadow: 2px 2px 2px black;
}
event-count::part(year) {
color: beige;
}
</style>
</pre>
<event-count>styled with ::part</event-count>
</section>
<event-count-example id="countdown" title="Countdown Timer HH:MM:SS" hms="11:11:11">
</event-count-example>
</main>
<br>
<br>
<br>
<br>
<section id="filesize">
<h1><code class="title"><event-count></code> minified GZIP Filesize is <i>small</i></h1>
<article>
<file-size gz src="https://event-count.github.io/element.min.js"></file-size>
</article>
</section>
<footer>
<header-and-footer></header-and-footer>
</footer>
</article>
</body>
</html>