-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelements.html
92 lines (84 loc) · 3.86 KB
/
elements.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Elements: Isomorphic Web Components with Declarative Shadow DOM</title>
<script type="importmap">
{
"env": [
"browser",
"development",
"module"
],
"imports": {
"@preact/signals": "https://cdn.jsdelivr.net/npm/@preact/[email protected]/dist/signals.module.js",
"preact": "https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.module.js",
"preact/jsx-runtime": "https://cdn.jsdelivr.net/npm/[email protected]/jsx-runtime/dist/jsxRuntime.module.js"
},
"scopes": {
"https://cdn.jsdelivr.net/": {
"@preact/signals-core": "https://cdn.jsdelivr.net/npm/@preact/[email protected]/dist/signals-core.module.js",
"preact/hooks": "https://cdn.jsdelivr.net/npm/[email protected]/hooks/dist/hooks.module.js"
}
}
}
</script>
<template shadowrootmode="open" id="template-counter" shadowrootserializable="true">
<link rel="stylesheet" href="/templates/counter.css" />
<div>
{count}
</div>
</template>
<template shadowrootmode="open" id="template-button" shadowrootserializable="true">
<link rel="stylesheet" href="/templates/button.css" />
<button type="button">
<slot></slot>
</button>
</template>
<script type="module">
import { Counter } from "/elements/counter.js";
import { Button } from "/elements/button.js";
function main() {
customElements.define("element-counter", Counter);
customElements.define("element-button", Button);
}
document.addEventListener("DOMContentLoaded", main)
</script>
</head>
<body>
<main>
<h1>Elements: Isomorphic Web Components with Declarative Shadow DOM</h1>
<div>
<h2>Button Component with Declarative Shadow DOM</h2>
<section>
<element-counter>count</element-counter>
<element-button>Count</element-button>
</section>
</div>
<footer>
<h2>References</h2>
<ul>
<li><a href="https://html.spec.whatwg.org/multipage/scripting.html#attr-template-shadowrootmode">Declarative
Shadow DOM Specs</a></li>
<li><a href="https://web.dev/articles/declarative-shadow-dom">Declarative Shadow DOM by Jason Miller and
Mason Freed</a></li>
<li><a href="https://jakelazaroff.com/words/isomorphic-web-components/">Isomorphic Web Components by
Jake Lazaroff</a></li>
<li><a href="https://github.com/mayank99/declarative-shadow-dom">Utility to get Declarative Shadow Dom
work in JSX</a></li>
<li><a href="https://www.konnorrogers.com/posts/2023/what-is-declarative-shadow-dom">What is DSD</a>
</li>
<li><a href="https://12daysofweb.dev/2024/declarative-shadow-dom/">DSD</a></li>
<li><a href="https://fullystacked.net/declarative-shadow-dom/">Declarative Shadow DOM and issue in
React</a></li>
<li><a href="https://blog.stackademic.com/server-rendering-web-components-in-react-869c248f1df7">Declarative
Shadow DOM and issue in SSR</a></li>
<li><a href="https://fullystacked.net/innerhtml-alternatives/">Some useful modern browser APIs for Web
components</a></li>
<li><a href="https://github.com/solidjs/solid/issues/1834">Solid JS DSD issue</a></li>
</ul>
</footer>
</main>
</body>
</html>