@openelement/create 1.0.0-alpha.13 → 1.0.0-alpha.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/src/template-builder.js +3 -1
- package/src/version.js +1 -1
- package/templates/README.tmpl +64 -39
- package/templates/app/components/badges.css +24 -5
- package/templates/app/components/page-404.css +21 -7
- package/templates/app/components/page-404.tsx.tmpl +14 -34
- package/templates/app/components/page-about.css +72 -15
- package/templates/app/components/page-about.tsx.tmpl +62 -78
- package/templates/app/components/page-home.css +135 -23
- package/templates/app/components/page-home.tsx.tmpl +87 -103
- package/templates/app/components/site-chrome.css +68 -15
- package/templates/app/head.tsx.tmpl +8 -4
- package/templates/app/islands/app-shell.tsx.tmpl +54 -0
- package/templates/app/islands/live-timer.css +21 -7
- package/templates/app/islands/live-timer.tsx.tmpl +9 -9
- package/templates/app/islands/my-counter.css +32 -11
- package/templates/app/islands/my-counter.tsx.tmpl +13 -9
- package/templates/app/routes/404.tsx.tmpl +4 -4
- package/templates/app/routes/about.tsx.tmpl +4 -4
- package/templates/app/routes/api/ping.ts.tmpl +2 -2
- package/templates/app/routes/index.tsx.tmpl +4 -4
- package/templates/app/styles/theme.css +2 -2
- package/templates/openelement.config.ts.tmpl +5 -5
- package/templates/package.json.tmpl +13 -11
- package/templates/pnpm-workspace.yaml.tmpl +29 -0
- package/templates/vite.config.ts.tmpl +12 -3
|
@@ -1,23 +1,135 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
.hero {
|
|
5
|
+
padding: 2.5rem 0 1rem;
|
|
6
|
+
}
|
|
7
|
+
.eyebrow {
|
|
8
|
+
color: var(--brand);
|
|
9
|
+
font-weight: 600;
|
|
10
|
+
font-size: 0.78rem;
|
|
11
|
+
letter-spacing: 0.14em;
|
|
12
|
+
text-transform: uppercase;
|
|
13
|
+
margin: 0;
|
|
14
|
+
}
|
|
15
|
+
h1 {
|
|
16
|
+
font-size: clamp(2.2rem, 6vw, 3.2rem);
|
|
17
|
+
line-height: 1.1;
|
|
18
|
+
letter-spacing: -0.02em;
|
|
19
|
+
margin: 0.75rem 0 1rem;
|
|
20
|
+
font-weight: 700;
|
|
21
|
+
max-width: 22ch;
|
|
22
|
+
}
|
|
23
|
+
.lede {
|
|
24
|
+
font-size: 1.12rem;
|
|
25
|
+
line-height: 1.75;
|
|
26
|
+
color: var(--ink-soft);
|
|
27
|
+
max-width: 56ch;
|
|
28
|
+
margin: 0;
|
|
29
|
+
}
|
|
30
|
+
.lede code,
|
|
31
|
+
.panel p code {
|
|
32
|
+
font-family: var(--font-mono);
|
|
33
|
+
font-size: 0.85em;
|
|
34
|
+
background: var(--surface);
|
|
35
|
+
border: 1px solid var(--line);
|
|
36
|
+
border-radius: 5px;
|
|
37
|
+
padding: 0.08em 0.35em;
|
|
38
|
+
}
|
|
39
|
+
.cta {
|
|
40
|
+
display: flex;
|
|
41
|
+
gap: 0.75rem;
|
|
42
|
+
flex-wrap: wrap;
|
|
43
|
+
align-items: center;
|
|
44
|
+
margin-top: 1.75rem;
|
|
45
|
+
}
|
|
46
|
+
.button {
|
|
47
|
+
display: inline-block;
|
|
48
|
+
padding: 0.6rem 1.15rem;
|
|
49
|
+
border-radius: var(--radius-m);
|
|
50
|
+
background: var(--brand);
|
|
51
|
+
border: 1px solid var(--brand);
|
|
52
|
+
color: var(--brand-ink);
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
text-decoration: none;
|
|
55
|
+
transition: opacity 0.15s ease;
|
|
56
|
+
}
|
|
57
|
+
.button:hover {
|
|
58
|
+
opacity: 0.88;
|
|
59
|
+
text-decoration: none;
|
|
60
|
+
}
|
|
61
|
+
.button-ghost {
|
|
62
|
+
display: inline-block;
|
|
63
|
+
padding: 0.6rem 1.15rem;
|
|
64
|
+
border-radius: var(--radius-m);
|
|
65
|
+
border: 1px solid var(--line);
|
|
66
|
+
color: var(--ink);
|
|
67
|
+
font-weight: 600;
|
|
68
|
+
text-decoration: none;
|
|
69
|
+
background: var(--paper);
|
|
70
|
+
transition:
|
|
71
|
+
border-color 0.15s ease,
|
|
72
|
+
color 0.15s ease;
|
|
73
|
+
}
|
|
74
|
+
.button-ghost:hover {
|
|
75
|
+
border-color: var(--brand);
|
|
76
|
+
color: var(--brand);
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
}
|
|
79
|
+
.panel {
|
|
80
|
+
margin-top: 2.5rem;
|
|
81
|
+
border: 1px solid var(--line);
|
|
82
|
+
border-radius: var(--radius-l);
|
|
83
|
+
padding: 1.5rem 1.75rem;
|
|
84
|
+
background: var(--paper);
|
|
85
|
+
box-shadow: var(--shadow-1);
|
|
86
|
+
}
|
|
87
|
+
.panel-head {
|
|
88
|
+
display: flex;
|
|
89
|
+
justify-content: space-between;
|
|
90
|
+
align-items: baseline;
|
|
91
|
+
gap: 1rem;
|
|
92
|
+
flex-wrap: wrap;
|
|
93
|
+
margin-bottom: 0.5rem;
|
|
94
|
+
}
|
|
95
|
+
.panel-head h2 {
|
|
96
|
+
margin: 0;
|
|
97
|
+
font-size: 1.3rem;
|
|
98
|
+
letter-spacing: -0.01em;
|
|
99
|
+
}
|
|
100
|
+
.panel > p {
|
|
101
|
+
color: var(--ink-soft);
|
|
102
|
+
margin: 0.35rem 0 1.25rem;
|
|
103
|
+
max-width: 60ch;
|
|
104
|
+
}
|
|
105
|
+
.cards {
|
|
106
|
+
list-style: none;
|
|
107
|
+
margin: 0;
|
|
108
|
+
padding: 0;
|
|
109
|
+
display: grid;
|
|
110
|
+
gap: 1rem;
|
|
111
|
+
grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
|
|
112
|
+
}
|
|
113
|
+
.card {
|
|
114
|
+
border: 1px solid var(--line);
|
|
115
|
+
border-radius: var(--radius-m);
|
|
116
|
+
padding: 1rem 1.15rem;
|
|
117
|
+
background: var(--surface);
|
|
118
|
+
}
|
|
119
|
+
.card h3 {
|
|
120
|
+
margin: 0.6rem 0 0.35rem;
|
|
121
|
+
font-size: 1rem;
|
|
122
|
+
}
|
|
123
|
+
.card p {
|
|
124
|
+
margin: 0;
|
|
125
|
+
color: var(--ink-soft);
|
|
126
|
+
font-size: 0.9rem;
|
|
127
|
+
line-height: 1.6;
|
|
128
|
+
}
|
|
129
|
+
a {
|
|
130
|
+
color: var(--brand);
|
|
131
|
+
text-decoration: none;
|
|
132
|
+
}
|
|
133
|
+
a:hover {
|
|
134
|
+
text-decoration: underline;
|
|
135
|
+
}
|
|
@@ -10,122 +10,106 @@
|
|
|
10
10
|
* <live-timer>) are static custom-element hosts that the generated server
|
|
11
11
|
* entry expands through the islands' own compiled classes.
|
|
12
12
|
*
|
|
13
|
+
* The site chrome (header, main region, footer) is NOT here: every page
|
|
14
|
+
* renders inside the auto-registered app shell
|
|
15
|
+
* (app/islands/app-shell.tsx), which owns that markup exactly once. The
|
|
16
|
+
* compiled grammar lowers one root per render, so the page returns a single
|
|
17
|
+
* content wrapper and the shell's <slot> carries it.
|
|
18
|
+
*
|
|
13
19
|
* The badge spans name each section's client cost: static sections ship
|
|
14
20
|
* markup only; island sections hydrate a compiled island (see the island
|
|
15
21
|
* modules under app/islands/).
|
|
16
22
|
*/
|
|
17
|
-
import { element, OpenElement } from
|
|
18
|
-
import homePageStyles from
|
|
19
|
-
import badgeStyles from
|
|
20
|
-
import siteChromeStyles from './site-chrome.css';
|
|
23
|
+
import { element, OpenElement } from "@openelement/element";
|
|
24
|
+
import homePageStyles from "./page-home.css";
|
|
25
|
+
import badgeStyles from "./badges.css";
|
|
21
26
|
|
|
22
|
-
@element(
|
|
27
|
+
@element("index-page", { root: "light" })
|
|
23
28
|
export default class HomePage extends OpenElement {
|
|
24
|
-
static override styles = [homePageStyles, badgeStyles
|
|
29
|
+
static override styles = [homePageStyles, badgeStyles];
|
|
25
30
|
|
|
26
31
|
render() {
|
|
27
32
|
// Single root element: the compiled grammar lowers one root per render.
|
|
28
33
|
return (
|
|
29
|
-
<div class=
|
|
30
|
-
<
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
<div class="page-content">
|
|
35
|
+
<section class="hero">
|
|
36
|
+
<span class="badge badge-static">static · 0 KB JS</span>
|
|
37
|
+
<p class="eyebrow">openElement starter</p>
|
|
38
|
+
<h1>Rendered before JavaScript arrives</h1>
|
|
39
|
+
<p class="lede">
|
|
40
|
+
Every page here is prerendered HTML. JavaScript loads only where a section is
|
|
41
|
+
interactive — the badges below name the cost of each block. Edit{" "}
|
|
42
|
+
<code>app/routes/index.tsx</code> to make it yours.
|
|
43
|
+
</p>
|
|
44
|
+
<div class="cta">
|
|
45
|
+
<a class="button" href="/about">
|
|
46
|
+
How it works
|
|
47
|
+
</a>
|
|
48
|
+
<a class="button-ghost" href="https://openelement.org">
|
|
49
|
+
Read the docs
|
|
34
50
|
</a>
|
|
35
|
-
<nav>
|
|
36
|
-
<a href='/'>Home</a>
|
|
37
|
-
<a href='/about'>About</a>
|
|
38
|
-
<a href='/api/ping'>API</a>
|
|
39
|
-
</nav>
|
|
40
51
|
</div>
|
|
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
|
-
</p>
|
|
70
|
-
<my-counter></my-counter>
|
|
71
|
-
</section>
|
|
72
|
-
<section class='panel'>
|
|
73
|
-
<div class='panel-head'>
|
|
74
|
-
<h2>Live stats</h2>
|
|
75
|
-
<span class='badge badge-island'>island · client-only</span>
|
|
76
|
-
</div>
|
|
77
|
-
<p>
|
|
78
|
-
Elapsed time on this page (<code>app/islands/live-timer.tsx</code>) renders
|
|
79
|
-
only in the browser — a live clock has nothing meaningful to
|
|
80
|
-
prerender, so the island ships <code>ssr: false</code>.
|
|
81
|
-
</p>
|
|
82
|
-
<live-timer></live-timer>
|
|
83
|
-
</section>
|
|
84
|
-
<section class='panel'>
|
|
85
|
-
<div class='panel-head'>
|
|
86
|
-
<h2>The architecture</h2>
|
|
87
|
-
<span class='badge badge-static'>static · 0 KB JS</span>
|
|
88
|
-
</div>
|
|
89
|
-
<p>
|
|
90
|
-
This section — like the hero and this page's header — is plain
|
|
91
|
-
prerendered HTML and CSS. No framework script runs it.
|
|
92
|
-
</p>
|
|
93
|
-
<ul class='cards'>
|
|
94
|
-
<li class='card'>
|
|
95
|
-
<span class='badge badge-static'>static</span>
|
|
96
|
-
<h3>Prerendered pages</h3>
|
|
97
|
-
<p>
|
|
98
|
-
Routes under <code>app/routes/</code> compile to static HTML at
|
|
99
|
-
build time (SSG) and keep their HTTP cache semantics.
|
|
100
|
-
</p>
|
|
101
|
-
</li>
|
|
102
|
-
<li class='card'>
|
|
103
|
-
<span class='badge badge-island'>island</span>
|
|
104
|
-
<h3>Islands where needed</h3>
|
|
105
|
-
<p>
|
|
106
|
-
Interactive pieces live in <code>app/islands/</code> and hydrate
|
|
107
|
-
on the strategy each one declares — idle, load, visible, or
|
|
108
|
-
client-only.
|
|
109
|
-
</p>
|
|
110
|
-
</li>
|
|
111
|
-
<li class='card'>
|
|
112
|
-
<span class='badge badge-static'>static</span>
|
|
113
|
-
<h3>Platform APIs</h3>
|
|
114
|
-
<p>
|
|
115
|
-
Server routes (<code>app/routes/api/</code>) are plain{' '}
|
|
116
|
-
<code>Request → Response</code> handlers — WinterCG-shaped, no
|
|
117
|
-
framework runtime attached.
|
|
118
|
-
</p>
|
|
119
|
-
</li>
|
|
120
|
-
</ul>
|
|
121
|
-
</section>
|
|
122
|
-
</main>
|
|
123
|
-
<footer class='site-foot'>
|
|
124
|
-
<div class='bar'>
|
|
125
|
-
<span>Generated by @openelement/create.</span>
|
|
126
|
-
<a href='https://openelement.org'>openelement.org</a>
|
|
52
|
+
</section>
|
|
53
|
+
<section class="panel">
|
|
54
|
+
<div class="panel-head">
|
|
55
|
+
<h2>Interactive island</h2>
|
|
56
|
+
<span class="badge badge-island">island · hydrates on idle</span>
|
|
57
|
+
</div>
|
|
58
|
+
<p>
|
|
59
|
+
The counter is a compiled island (<code>app/islands/my-counter.tsx</code>
|
|
60
|
+
): the server renders its markup, the browser hydrates it when idle.
|
|
61
|
+
</p>
|
|
62
|
+
<my-counter></my-counter>
|
|
63
|
+
</section>
|
|
64
|
+
<section class="panel">
|
|
65
|
+
<div class="panel-head">
|
|
66
|
+
<h2>Live stats</h2>
|
|
67
|
+
<span class="badge badge-island">island · client-only</span>
|
|
68
|
+
</div>
|
|
69
|
+
<p>
|
|
70
|
+
Elapsed time on this page (<code>app/islands/live-timer.tsx</code>) renders only in the
|
|
71
|
+
browser — a live clock has nothing meaningful to prerender, so the island ships{" "}
|
|
72
|
+
<code>ssr: false</code>.
|
|
73
|
+
</p>
|
|
74
|
+
<live-timer></live-timer>
|
|
75
|
+
</section>
|
|
76
|
+
<section class="panel">
|
|
77
|
+
<div class="panel-head">
|
|
78
|
+
<h2>The architecture</h2>
|
|
79
|
+
<span class="badge badge-static">static · 0 KB JS</span>
|
|
127
80
|
</div>
|
|
128
|
-
|
|
81
|
+
<p>
|
|
82
|
+
This section — like the hero above — is plain prerendered HTML and CSS. No framework
|
|
83
|
+
script runs it.
|
|
84
|
+
</p>
|
|
85
|
+
<ul class="cards">
|
|
86
|
+
<li class="card">
|
|
87
|
+
<span class="badge badge-static">static</span>
|
|
88
|
+
<h3>Prerendered pages</h3>
|
|
89
|
+
<p>
|
|
90
|
+
Routes under <code>app/routes/</code> compile to static HTML at build time (SSG) and
|
|
91
|
+
keep their HTTP cache semantics.
|
|
92
|
+
</p>
|
|
93
|
+
</li>
|
|
94
|
+
<li class="card">
|
|
95
|
+
<span class="badge badge-island">island</span>
|
|
96
|
+
<h3>Islands where needed</h3>
|
|
97
|
+
<p>
|
|
98
|
+
Interactive pieces live in <code>app/islands/</code> and hydrate on the strategy
|
|
99
|
+
each one declares — idle, load, visible, or client-only.
|
|
100
|
+
</p>
|
|
101
|
+
</li>
|
|
102
|
+
<li class="card">
|
|
103
|
+
<span class="badge badge-static">static</span>
|
|
104
|
+
<h3>Platform APIs</h3>
|
|
105
|
+
<p>
|
|
106
|
+
Server routes (<code>app/routes/api/</code>) are plain{" "}
|
|
107
|
+
<code>Request → Response</code> handlers — WinterCG-shaped, no framework runtime
|
|
108
|
+
attached.
|
|
109
|
+
</p>
|
|
110
|
+
</li>
|
|
111
|
+
</ul>
|
|
112
|
+
</section>
|
|
129
113
|
</div>
|
|
130
114
|
);
|
|
131
115
|
}
|
|
@@ -1,15 +1,68 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
.site-head {
|
|
5
|
+
border-bottom: 1px solid var(--line);
|
|
6
|
+
background: var(--paper);
|
|
7
|
+
}
|
|
8
|
+
.site-head .bar {
|
|
9
|
+
max-width: var(--content-width);
|
|
10
|
+
margin: 0 auto;
|
|
11
|
+
padding: 1rem 1.25rem;
|
|
12
|
+
display: flex;
|
|
13
|
+
justify-content: space-between;
|
|
14
|
+
align-items: baseline;
|
|
15
|
+
gap: 1rem;
|
|
16
|
+
}
|
|
17
|
+
.site-brand {
|
|
18
|
+
font-weight: 700;
|
|
19
|
+
font-size: 1.1rem;
|
|
20
|
+
letter-spacing: -0.01em;
|
|
21
|
+
color: var(--ink);
|
|
22
|
+
text-decoration: none;
|
|
23
|
+
}
|
|
24
|
+
.site-brand:hover {
|
|
25
|
+
color: var(--brand);
|
|
26
|
+
text-decoration: none;
|
|
27
|
+
}
|
|
28
|
+
.site-head nav {
|
|
29
|
+
display: flex;
|
|
30
|
+
gap: 1.25rem;
|
|
31
|
+
}
|
|
32
|
+
.site-head nav a {
|
|
33
|
+
color: var(--ink-soft);
|
|
34
|
+
font-size: 0.95rem;
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
text-decoration: none;
|
|
37
|
+
}
|
|
38
|
+
.site-head nav a:hover {
|
|
39
|
+
color: var(--brand);
|
|
40
|
+
text-decoration: none;
|
|
41
|
+
}
|
|
42
|
+
main {
|
|
43
|
+
max-width: var(--content-width);
|
|
44
|
+
margin: 0 auto;
|
|
45
|
+
padding: 3rem 1.25rem 4rem;
|
|
46
|
+
}
|
|
47
|
+
.site-foot {
|
|
48
|
+
border-top: 1px solid var(--line);
|
|
49
|
+
color: var(--ink-soft);
|
|
50
|
+
font-size: 0.85rem;
|
|
51
|
+
}
|
|
52
|
+
.site-foot .bar {
|
|
53
|
+
max-width: var(--content-width);
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
padding: 1.25rem;
|
|
56
|
+
display: flex;
|
|
57
|
+
justify-content: space-between;
|
|
58
|
+
gap: 1rem;
|
|
59
|
+
flex-wrap: wrap;
|
|
60
|
+
}
|
|
61
|
+
.site-foot a {
|
|
62
|
+
color: var(--ink-soft);
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
}
|
|
65
|
+
.site-foot a:hover {
|
|
66
|
+
color: var(--brand);
|
|
67
|
+
text-decoration: none;
|
|
68
|
+
}
|
|
@@ -20,13 +20,17 @@
|
|
|
20
20
|
* `head` in openelement.config.ts already covers the title, description,
|
|
21
21
|
* favicon and the og:/twitter: pairs; `head.scripts` / `head.stylesheets`
|
|
22
22
|
* cover external scripts and stylesheets. This file is for what neither can
|
|
23
|
-
* express — here, the color-scheme declaration.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* express — here, the color-scheme declaration. A route module's `head`
|
|
24
|
+
* resolves at render time: its title and description update only <title> and
|
|
25
|
+
* the meta description. The og:* tags keep the site-wide defaults except
|
|
26
|
+
* where the route's `head.meta` declares the same `property="og:…"` — that
|
|
27
|
+
* property's site default is then not emitted (the route's own tag is the
|
|
28
|
+
* only one, in prerendered and request-rendered HTML alike). `name=` meta
|
|
29
|
+
* entries (e.g. twitter:card) never suppress a site default.
|
|
26
30
|
*/
|
|
27
31
|
export default [
|
|
28
32
|
// Declaring the color scheme the starter supports lets the browser pick the
|
|
29
33
|
// right native form/scrollbar palette before any CSS is parsed. The dark
|
|
30
34
|
// palette itself is theme.css's dark pair block — no runtime.
|
|
31
|
-
{ meta: { name:
|
|
35
|
+
{ meta: { name: "color-scheme", content: "dark light" } },
|
|
32
36
|
];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* app/islands/app-shell.tsx — the auto-registered application shell.
|
|
3
|
+
*
|
|
4
|
+
* The convention path is enough: the build finds this module, registers its
|
|
5
|
+
* compiled class under the `app-shell` tag, and renders EVERY page inside
|
|
6
|
+
* it, projecting the page's own render into the default <slot>. The header
|
|
7
|
+
* and footer markup that used to be copied onto every page lives here
|
|
8
|
+
* exactly once — a page module now carries only its own content.
|
|
9
|
+
*
|
|
10
|
+
* The shadow root (root: 'shadow-open') is what makes the projection work:
|
|
11
|
+
* the chrome below renders in this element's shadow tree (styled by the
|
|
12
|
+
* site-chrome sheet in `static styles`), while the slotted page content
|
|
13
|
+
* stays in the page element's own light DOM with its own @scope styles.
|
|
14
|
+
* Layout tokens from app/styles/theme.css inherit through the boundary.
|
|
15
|
+
*
|
|
16
|
+
* The shell is a convention, not a requirement: delete this file and every
|
|
17
|
+
* page still renders (back to carrying its own chrome), or opt out
|
|
18
|
+
* explicitly with `appShell: false` in openelement.config.ts.
|
|
19
|
+
*/
|
|
20
|
+
import { element, OpenElement } from "@openelement/element";
|
|
21
|
+
import siteChromeStyles from "../components/site-chrome.css";
|
|
22
|
+
|
|
23
|
+
@element("app-shell", { root: "shadow-open" })
|
|
24
|
+
export default class AppShell extends OpenElement {
|
|
25
|
+
static override styles = [siteChromeStyles];
|
|
26
|
+
|
|
27
|
+
render() {
|
|
28
|
+
return (
|
|
29
|
+
<div class="page-body">
|
|
30
|
+
<header class="site-head">
|
|
31
|
+
<div class="bar">
|
|
32
|
+
<a class="site-brand" href="/">
|
|
33
|
+
openElement
|
|
34
|
+
</a>
|
|
35
|
+
<nav>
|
|
36
|
+
<a href="/">Home</a>
|
|
37
|
+
<a href="/about">About</a>
|
|
38
|
+
<a href="/api/ping">API</a>
|
|
39
|
+
</nav>
|
|
40
|
+
</div>
|
|
41
|
+
</header>
|
|
42
|
+
<main>
|
|
43
|
+
<slot></slot>
|
|
44
|
+
</main>
|
|
45
|
+
<footer class="site-foot">
|
|
46
|
+
<div class="bar">
|
|
47
|
+
<span>Generated by @openelement/create.</span>
|
|
48
|
+
<a href="https://openelement.org">openelement.org</a>
|
|
49
|
+
</div>
|
|
50
|
+
</footer>
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
.timer-row {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
gap: 0.6rem;
|
|
7
|
+
align-items: baseline;
|
|
8
|
+
}
|
|
9
|
+
/* #1582: the selector names the id the class renders (#elapsed) — a
|
|
5
10
|
`.value` selector matched nothing, so the clock lost its brand color
|
|
6
11
|
and tabular figures. */
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
#elapsed {
|
|
13
|
+
min-width: 6ch;
|
|
14
|
+
text-align: right;
|
|
15
|
+
font-variant-numeric: tabular-nums;
|
|
16
|
+
font-weight: 600;
|
|
17
|
+
font-size: 1.4rem;
|
|
18
|
+
color: var(--brand);
|
|
19
|
+
}
|
|
20
|
+
.unit {
|
|
21
|
+
color: var(--ink-soft);
|
|
22
|
+
font-size: 0.85rem;
|
|
23
|
+
}
|
|
@@ -7,24 +7,24 @@
|
|
|
7
7
|
* time origin (performance.now()), so the number is honest page time, and
|
|
8
8
|
* disconnectedCallback stops the interval when the host leaves the tree.
|
|
9
9
|
*/
|
|
10
|
-
import { defineIslandConfig } from
|
|
11
|
-
import { element, OpenElement, property } from
|
|
12
|
-
import timerStyles from
|
|
10
|
+
import { defineIslandConfig } from "@openelement/router";
|
|
11
|
+
import { element, OpenElement, property } from "@openelement/element";
|
|
12
|
+
import timerStyles from "./live-timer.css";
|
|
13
13
|
|
|
14
|
-
export const openElement = defineIslandConfig({ hydrate:
|
|
14
|
+
export const openElement = defineIslandConfig({ hydrate: "only", ssr: false, dsd: false });
|
|
15
15
|
|
|
16
16
|
// The interval handle rides the compiled per-instance property state: island
|
|
17
17
|
// classes carry compiled @property fields and methods, and module-level
|
|
18
18
|
// runtime statements are outside the compiled grammar (OEC9008). In the
|
|
19
19
|
// browser setInterval returns a number, so the handle is a plain number here.
|
|
20
|
-
@element(
|
|
20
|
+
@element("live-timer", { root: "shadow-open" })
|
|
21
21
|
export default class LiveTimer extends OpenElement {
|
|
22
22
|
static override styles = [timerStyles];
|
|
23
23
|
|
|
24
24
|
/** Elapsed seconds as preformatted text (compiled text Parts bind plain
|
|
25
25
|
* properties — no method calls in a text region, OEC9013). */
|
|
26
26
|
@property({ reflect: false, attribute: false })
|
|
27
|
-
elapsed =
|
|
27
|
+
elapsed = "0.0";
|
|
28
28
|
|
|
29
29
|
/** The ticking interval's handle; 0 when the host is not connected. */
|
|
30
30
|
@property({ reflect: false, attribute: false })
|
|
@@ -45,9 +45,9 @@ export default class LiveTimer extends OpenElement {
|
|
|
45
45
|
|
|
46
46
|
render() {
|
|
47
47
|
return (
|
|
48
|
-
<div class=
|
|
49
|
-
<span id=
|
|
50
|
-
<span class=
|
|
48
|
+
<div class="timer-row">
|
|
49
|
+
<span id="elapsed">{this.elapsed}</span>
|
|
50
|
+
<span class="unit">seconds on this page</span>
|
|
51
51
|
</div>
|
|
52
52
|
);
|
|
53
53
|
}
|
|
@@ -1,11 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
}
|
|
4
|
+
.counter-row {
|
|
5
|
+
display: inline-flex;
|
|
6
|
+
gap: 0.75rem;
|
|
7
|
+
align-items: center;
|
|
8
|
+
}
|
|
9
|
+
button {
|
|
10
|
+
width: 2rem;
|
|
11
|
+
height: 2rem;
|
|
12
|
+
border: 1px solid var(--line);
|
|
13
|
+
border-radius: var(--radius-s);
|
|
14
|
+
background: var(--paper);
|
|
15
|
+
color: var(--ink);
|
|
16
|
+
font-size: 1rem;
|
|
17
|
+
line-height: 1;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
transition:
|
|
20
|
+
border-color 0.15s ease,
|
|
21
|
+
color 0.15s ease;
|
|
22
|
+
}
|
|
23
|
+
button:hover {
|
|
24
|
+
border-color: var(--brand);
|
|
25
|
+
color: var(--brand);
|
|
26
|
+
}
|
|
27
|
+
span {
|
|
28
|
+
min-width: 2ch;
|
|
29
|
+
text-align: center;
|
|
30
|
+
font-variant-numeric: tabular-nums;
|
|
31
|
+
font-weight: 600;
|
|
32
|
+
}
|