-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·389 lines (334 loc) · 12.8 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
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
<!doctype html>
<html lang="">
<head>
<meta charset="utf-8">
<title>Tag</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
@font-face {
font-family: 'Fira Code';
src: url('assets/FiraCode-VF.ttf') format("truetype-variations");
font-weight: 1 999;
}
@font-face {
font-family: 'STIXTwoText';
src: url('assets/STIXTwoText[wght].ttf') format("truetype-variations");
font-weight: 400 700;
}
@font-face {
font-family: 'STIXTwoText';
src: url('assets/STIXTwoText-Italic[wght].ttf') format("truetype-variations");
font-style: italic;
}
html {
background: oldlace;
font-size: 1.1em;
font-family: 'STIXTwoText';
}
body {
line-height: 1.5;
max-width: 45rem;
margin: 0 auto;
padding: 2rem 1rem;
overflow-x: hidden;
}
*:focus {
border-radius: none;
outline: 2px dashed orange;
outline-offset: .5rem;
}
h2 {
margin-top: 5rem;
}
h3 {
margin-top: 3rem;
}
hr {
border: none;
border-top: 1px dashed orange;
margin-top: 3rem;
}
nav {
border-top: 1px dashed orange;
border-bottom: 1px dashed orange;
padding: 1rem;
margin: 3rem 0;
font-style: italic;
}
pre,
code {
background: papayawhip;
border: 1px dashed orange;
font-family: 'Fira Code';
font-size: 1.1em;
}
xmp {
font-family: 'Fira Code';
}
pre {
padding: 1rem 2rem;
margin-bottom: 2rem;
overflow-x: auto;
}
code {
display: inline-block;
padding: 2px .5rem;
}
dt {
margin-bottom: .5rem;
}
dd {
margin-bottom: 2rem;
}
</style>
</head>
<body>
<center>
<h1><code><tag></code></h1>
<p>
The portable port-able part of the web for the whole wide world
</p>
<rainbow-button>
<a href="https://deno.land/x/tag" class="rainbow-button">
View Source
</a>
</rainbow-button>
<nav>
View <a href="#documentation" id="details-link">Documentation</a>
and <a href="#examples">Examples</a>.
Or learn <a href="#author">about the author</a>.
</nav>
</center>
<p style="font-size: 1.5em">
<strong>Tag provides a unified approach for</strong>
<highlighter color="orange">rendering</highlighter>,
<highlighter color="rebeccapurple">scoped styles</highlighter>,
<highlighter color="lime">event delegation</highlighter>,
<highlighter color="dodgerblue">state management</highlighter>,
and <strong>only those four things</strong>.
Plainly, Tag is a <a href="https://developer.mozilla.org/en-US/docs/Web/javascript">trifecta</a> of
<a href="https://developer.mozilla.org/en-US/docs/Web/HTML">fundamental</a>
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS">techonolgies</a>
designed to build expressive web applications.
</p>
<hr />
<h2>Quick Start <a href="./hello/hello-world.html">View Example</a></h2>
<p>
Hello World is a common program to write when first learning something new. The code below imports <code>tag.js</code>, creates a custom tag, and sets the content to 'Hello World!'
</p>
<pre><xmp>import tag from 'https://deno.land/x/tag'
tag('hello-world').draw(() => 'Hello World!')</xmp></pre>
<p><em>
<strong>Tip!</strong> View the source of the example page to see <hello-world> in action!
</em></p>
<a name="documentation"></a>
<h2>Documentation</h2>
<p>
<code>
<strong>const $ = tag(selector: string [, state: object]) : object</strong>
</code>
<p>
Creates an custom, scoped HTML tag. Requires a selector: a CSS selector. An optional second argument may be passed for seeding the initial state.
</p>
<p>
It will return an object with the selector as an attribute and the following namespaced functions.
</p>
<dl>
<dt><code>$.draw(function(target: EventTarget))</code></dt>
<dd>
Expects a function that returns HTML as a string to be rendered into the provided target. A falsey return will leave the target node untouched. This function will be invoked whenever state changes.
</dd>
<dt><code>$.flair(stylesheet: string)</code></dt>
<dd>
Expects a CSS stylesheet as a string. The ampersand (&) symbol may be used to scope rulesets.
</dd>
<dt><code>$.when(eventType: string, selector: string, function(event)) : function</code></dt>
<dd>
An event delegator that expects three arguments. A css selector, and a handler. No selector will listen on the tag's root. Returns a function to remove the listener when invoked.
</dd>
<dt><code>$.learn() : object</code></dt>
<dd>
Returns the current state.
</dd>
<dt><code>$.teach(payload [, function(state, payload)])</code></dt>
<dd>
Merges the payload into the current state. An optional second argument for managing the state update may be provided. That function will be called with the current state and the payload. It expects the reconciled, complete state to be returned
</dd>
</dl>
<p>
<strong>Browser Support:</strong> The tail feature set for this application is ES Modules, which is supported by all modern browsers. For an entertaining summary, please refer to <a href="https://www.youtube.com/watch?v=dAIckpwW9ds">Making Future Interfaces: ES Modules</a>.
</p>
<hr />
<a name="examples"></a>
<h2>Examples</h2>
<h3><code><hello-name></code> <a href="./hello/hello-name.html">View Example</a></h3>
<p>
The Hello Name example shows the fundamentals of incorporating variables into the tag's state.
</p>
<pre><xmp><!-- hello-name.html -->
<hello-name></hello-name>
<script type="module">
import tag from 'https://deno.land/x/tag'
const $ = tag('hello-name', {
'name': 'Earth'
})
$.draw(() => {
const { name } = learn()
return `Hello ${name}`
})
</script></xmp></pre>
<dl>
<!-- hello-nickname -->
<dt><code><hello-nickname></code> <a href="./hello/hello-nickname.html">View Example</a></dt>
<dd>
Demonstrates local two-way data binding and persisting updates across page reloads.
</dd>
<!-- hello-universe -->
<dt><code><hello-universe></code> <a href="./hello/hello-universe.html">View Example</a></dt>
<dd>
An application for managing planet information and viewing a sequential representation of our solar system.
</dd>
<!-- hello-gallery -->
<dt><code><hello-gallery></code> <a href="./hello/hello-gallery.html">View Example</a></dt>
<dd>
A static photo gallery that upgrades to a carousel with progressive enhancement.
</dd>
<!-- hello-editor -->
<dt><code><hello-editor></code> <a href="./hello/hello-editor.html">View Example</a></dt>
<dd>
What-You-See-Is-What-You-Get style content editing with <a href="https://quilljs.com/">QuillJS</a>.
</dd>
<!-- hello-map -->
<dt><code><hello-map></code> <a href="./hello/hello-map.html">View Example</a></dt>
<dd>
A <a href="https://maplibre.org">maplibre.org</a> integration that incorporates live realtime data. A direct port of <a href="https://maplibre.org/maplibre-gl-js-docs/example/live-geojson/">this example from their official docs</a>.
</dd>
<!-- hello-reddit -->
<dt><code><hello-reddit></code> <a href="./hello/hello-reddit.html">View Example</a></dt>
<dd>
A <a href="https://old.reddit.com">reddit</a> integration that exposes their API over HTML. Control which subreddits are queried and how they are sorted with attributes.
</dd>
<!-- hello-launcher -->
<dt><code><hello-launcher></code> <a href="./hello/hello-launcher.html">View Example</a></dt>
<dd>
An application that opens and manages other applications. Inspired by and a prototype for <a href="https://forum.solidproject.org/t/idea-launcher-app/3468">this forum post</a>.
</dd>
<!-- window-pane -->
<dt><code><window-pane></code> <a href="./fun/window-pane.html">View Example</a></dt>
<dd>
The foundation for a minimal window manager using a CSS stylesheet that replicates <a href="https://khang-nd.github.io/7.css/">Windows 7</a>.
</dd>
<!-- solid-user
<dt><code><solid-user></code> <a href="./solid/solid-user.html">View Example</a></dt>
<dd>
A <a href="https://solidproject.org">Solid POD</a> authenticator. This allows people to connect to their preferred identity provider.
</dd>
-->
<!-- todo-list
<dt><code><todo-list></code> <a href="./todo-list/index.html">View Example</a></dt>
<dd>
A <a href="https://todomvc.com/">TodoMVC</a> application that utilizes <a href="https://solidproject.org">Solid</a> as a backend.
</dd>
-->
<!-- braid-chat
<dt><code><braid-chat></code> <a href="./braid/braid-chat.html">View Example</a></dt>
<dd>
A <a href="https://braid.org/">Braid.org</a> application that syncs with a <a href="http://invisible.college:3007/messages">/messages backend</a>.
</dd>
-->
</dl>
<hr />
<a name="author"></a>
<div style="float: right; max-width: 240px; border: 2px orange dashed; padding: 1rem; margin: 4rem 0 1rem 1rem;">
<h3 style="margin-top: 0;">Inspirations</h3>
<p>
Inspiring people building interesting projects are everywhere. These links helped shape Tag's development by just being cool things on the internet.
</p>
<ul>
<li>
<a href="https://braid.org/">Braid</a>
</li>
<li>
<a href="https://small-tech.org">Small Technology Foundation</a>
</li>
<li>
<a href="https://solidproject.org/">Solid Project</a>
</li>
<li>
<a href="https://spritelyproject.org/">Spritely Project</a>
</li>
<li>
<a href="https://100r.co">Hundredrabbits</a>
</li>
<li>
<a href="https://safenetwork.tech/">Safe Network</a>
</li>
<li>
<a href="https://owncast.online/">Owncast</a>
</li>
</ul>
</div>
<h2>About the Author</h2>
<p>
<a href="https://tylerchilds.com">Tyler Childs</a> is a netizen with a deep passion for the open web and radical transparency. He believes everyone can go further together and sharing knowledge is critical to group success.
</p>
<p>
You can reach him via email at <a href="mailto:yooo@tychi.me">yooo@tychi.me</a> for any reason at any time. Response times may vary.
</p>
<p><strong>Fun fact!</strong> <a href="https://thelanding.page/tag">Tag</a> is the final part in a now-complete solo trilogy. <a href="https://www.tylerchilds.com/projects/vanilla-html/">Vanilla HTML</a> was a flop in 2013 and <a href="https://www.cutestrap.com/">Cutestrap</a> was a cult-hit in 2016!
<h2>Source Code</h2>
<p>
Available on
<a href="https://github.com/tylerchilds/tag">GitHub</a> under the
<a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode">CC BY-SA 4.0</a>
</p>
<footer>
<center style="font-style: italic; color: grey;">
Established: 2021. Last updated: 2022/06/13 (YYYY/MM/DD)
</center>
</footer>
<script type="module">
import tag from '../mod.js'
tag('#details-link').when('click', '', openAccordion)
const accordion = tag('details')
accordion.when('click', 'summary', function toggle() {
const { open } = accordion.learn()
accordion.teach({ open: ! open })
})
function openAccordion () {
accordion.teach({ open: true })
document.querySelector(accordion.selector)
.setAttribute('open', 'true')
}
</script>
<script src="../src/tags/highlighter.js" type="module"></script>
<script src="../src/tags/rainbow-button.js" type="module"></script>
<script type="module">
import handleKonami from '../src/tags/konami-kid.js'
handleKonami(async () => {
document.body.innerHTML = `
<guitar-hero></guitar-hero>
`
const {
default: guitarHero
} = await import('../src/games/guitar-hero.js')
guitarHero.flair(`
* {
box-sizing: border-box;
padding: 0;
margin: 0;
}
body {
all: unset;
}
& {
display: grid;
height: 100vh;
width: 100vw;
}
`)
})
</script>
</body>
</html>