@openelement/create 1.0.0-alpha.14 → 1.0.0-alpha.15
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 +49 -19
- package/package.json +1 -1
- package/src/cli.js +159 -76
- package/src/node-version.js +102 -0
- package/src/pm.js +143 -9
- package/src/template-builder.js +58 -7
- package/src/version.js +2 -10
- package/templates/.node-version +1 -0
- package/templates/AGENTS.md.tmpl +44 -0
- package/templates/README.tmpl +137 -96
- package/templates/app/components/page-404.css +2 -18
- package/templates/app/components/page-404.tsx.tmpl +10 -11
- package/templates/app/components/page-about.css +2 -69
- package/templates/app/components/page-about.tsx.tmpl +68 -48
- package/templates/app/components/page-home.css +2 -132
- package/templates/app/components/page-home.tsx.tmpl +106 -67
- package/templates/app/components/site-chrome.css +2 -65
- package/templates/app/head.tsx.tmpl +11 -26
- package/templates/app/islands/live-timer.css +2 -20
- package/templates/app/islands/live-timer.tsx.tmpl +25 -15
- package/templates/app/islands/my-counter.css +2 -29
- package/templates/app/islands/my-counter.tsx.tmpl +17 -8
- package/templates/app/layout.tsx.tmpl +68 -0
- package/templates/app/routes/404.tsx.tmpl +3 -6
- package/templates/app/routes/api/ping.ts.tmpl +2 -3
- package/templates/app/styles/theme.css +62 -77
- package/templates/openelement.config.ts.tmpl +16 -28
- package/templates/package.json.tmpl +8 -6
- package/templates/tsconfig.json.tmpl +1 -1
- package/templates/vite.config.ts.tmpl +7 -14
- package/templates/app/components/badges.css +0 -24
- package/templates/app/islands/app-shell.tsx.tmpl +0 -54
- package/templates/app/styles/recipes.css +0 -43
- package/templates/pnpm-workspace.yaml.tmpl +0 -29
|
@@ -1,135 +1,5 @@
|
|
|
1
|
+
/* The page-home light root's box: a custom element is inline by default and
|
|
2
|
+
the host tag is not authored markup, so no utility can carry it. */
|
|
1
3
|
:host {
|
|
2
4
|
display: block;
|
|
3
5
|
}
|
|
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
|
-
}
|
|
@@ -2,110 +2,149 @@
|
|
|
2
2
|
* Home page element — the showcase landing page (static prerendered, the
|
|
3
3
|
* default renderIntent mode).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
-
*
|
|
19
|
-
* The badge spans name each section's client cost: static sections ship
|
|
20
|
-
* markup only; island sections hydrate a compiled island (see the island
|
|
21
|
-
* modules under app/islands/).
|
|
5
|
+
* The compiled grammar lowers one root per render, so the page returns a
|
|
6
|
+
* single content wrapper; the header/footer chrome lives in the
|
|
7
|
+
* auto-registered layout (app/layout.tsx), which projects this render into its
|
|
8
|
+
* default slot. Presentation is authored as Tailwind utilities in the markup
|
|
9
|
+
* (the badge spans name each section's client cost); the one rule in
|
|
10
|
+
* `static styles` is the root's own box, which has no markup to carry it. The
|
|
11
|
+
* two island hosts (<my-counter>, <live-timer>) are expanded by the generated
|
|
12
|
+
* server entry through the islands' own compiled classes.
|
|
22
13
|
*/
|
|
23
14
|
import { element, OpenElement } from "@openelement/element";
|
|
24
15
|
import homePageStyles from "./page-home.css";
|
|
25
|
-
import badgeStyles from "./badges.css";
|
|
26
16
|
|
|
27
17
|
@element("index-page", { root: "light" })
|
|
28
18
|
export default class HomePage extends OpenElement {
|
|
29
|
-
static override styles = [homePageStyles
|
|
19
|
+
static override styles = [homePageStyles];
|
|
30
20
|
|
|
31
21
|
render() {
|
|
32
22
|
// Single root element: the compiled grammar lowers one root per render.
|
|
33
23
|
return (
|
|
34
24
|
<div class="page-content">
|
|
35
|
-
<section class="
|
|
36
|
-
<span class="
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
<p class="
|
|
25
|
+
<section class="pt-10 pb-4">
|
|
26
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-ok/35 bg-ok/8 px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-ok uppercase">
|
|
27
|
+
static · 0 KB JS
|
|
28
|
+
</span>
|
|
29
|
+
<p class="m-0 text-[0.78rem] font-semibold tracking-[0.14em] text-brand uppercase">
|
|
30
|
+
openElement starter
|
|
31
|
+
</p>
|
|
32
|
+
<h1 class="mt-3 mb-4 max-w-[22ch] text-[clamp(2.2rem,6vw,3.2rem)] leading-[1.1] font-bold tracking-[-0.02em]">
|
|
33
|
+
Rendered before JavaScript arrives
|
|
34
|
+
</h1>
|
|
35
|
+
<p class="m-0 max-w-[56ch] text-[1.12rem] leading-[1.75] text-ink-soft">
|
|
40
36
|
Every page here is prerendered HTML. JavaScript loads only where a section is
|
|
41
37
|
interactive — the badges below name the cost of each block. Edit{" "}
|
|
42
|
-
<code
|
|
38
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
39
|
+
app/components/page-home.tsx
|
|
40
|
+
</code>{" "}
|
|
41
|
+
to make it yours.
|
|
43
42
|
</p>
|
|
44
|
-
<div class="
|
|
45
|
-
<a
|
|
43
|
+
<div class="mt-7 flex flex-wrap items-center gap-3">
|
|
44
|
+
<a
|
|
45
|
+
class="inline-block rounded-(--radius-m) border border-brand bg-brand px-[1.15rem] py-[0.6rem] font-semibold text-brand-ink no-underline transition-opacity duration-150 ease-out hover:opacity-[0.88] hover:no-underline"
|
|
46
|
+
href="/about"
|
|
47
|
+
>
|
|
46
48
|
How it works
|
|
47
49
|
</a>
|
|
48
|
-
<a
|
|
50
|
+
<a
|
|
51
|
+
class="inline-block rounded-(--radius-m) border border-line bg-paper px-[1.15rem] py-[0.6rem] font-semibold text-ink no-underline transition-[border-color,color] duration-150 ease-out hover:border-brand hover:text-brand hover:no-underline"
|
|
52
|
+
href="https://openelement.org"
|
|
53
|
+
>
|
|
49
54
|
Read the docs
|
|
50
55
|
</a>
|
|
51
56
|
</div>
|
|
52
57
|
</section>
|
|
53
|
-
<section class="
|
|
54
|
-
<div class="
|
|
55
|
-
<h2>Interactive island</h2>
|
|
56
|
-
<span class="
|
|
58
|
+
<section class="mt-10 rounded-(--radius-l) border border-line bg-paper px-7 py-6 shadow-(--shadow-1)">
|
|
59
|
+
<div class="mb-2 flex flex-wrap items-baseline justify-between gap-4">
|
|
60
|
+
<h2 class="m-0 text-[1.3rem] tracking-[-0.01em]">Interactive island</h2>
|
|
61
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-brand/40 bg-brand-soft px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-brand uppercase">
|
|
62
|
+
island · hydrates on idle
|
|
63
|
+
</span>
|
|
57
64
|
</div>
|
|
58
|
-
<p>
|
|
59
|
-
The counter is a compiled island (
|
|
65
|
+
<p class="mt-[0.35rem] mb-5 max-w-[60ch] text-ink-soft">
|
|
66
|
+
The counter is a compiled island (
|
|
67
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
68
|
+
app/islands/my-counter.tsx
|
|
69
|
+
</code>
|
|
60
70
|
): the server renders its markup, the browser hydrates it when idle.
|
|
61
71
|
</p>
|
|
62
72
|
<my-counter></my-counter>
|
|
63
73
|
</section>
|
|
64
|
-
<section class="
|
|
65
|
-
<div class="
|
|
66
|
-
<h2>Live stats</h2>
|
|
67
|
-
<span class="
|
|
74
|
+
<section class="mt-10 rounded-(--radius-l) border border-line bg-paper px-7 py-6 shadow-(--shadow-1)">
|
|
75
|
+
<div class="mb-2 flex flex-wrap items-baseline justify-between gap-4">
|
|
76
|
+
<h2 class="m-0 text-[1.3rem] tracking-[-0.01em]">Live stats</h2>
|
|
77
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-brand/40 bg-brand-soft px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-brand uppercase">
|
|
78
|
+
island · client-only
|
|
79
|
+
</span>
|
|
68
80
|
</div>
|
|
69
|
-
<p>
|
|
70
|
-
Elapsed time on this page (
|
|
71
|
-
|
|
72
|
-
|
|
81
|
+
<p class="mt-[0.35rem] mb-5 max-w-[60ch] text-ink-soft">
|
|
82
|
+
Elapsed time on this page (
|
|
83
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
84
|
+
app/islands/live-timer.tsx
|
|
85
|
+
</code>
|
|
86
|
+
) renders only in the browser — a live clock has nothing meaningful to prerender, so the
|
|
87
|
+
island ships{" "}
|
|
88
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
89
|
+
ssr: false
|
|
90
|
+
</code>
|
|
91
|
+
.
|
|
73
92
|
</p>
|
|
74
93
|
<live-timer></live-timer>
|
|
75
94
|
</section>
|
|
76
|
-
<section class="
|
|
77
|
-
<div class="
|
|
78
|
-
<h2>The architecture</h2>
|
|
79
|
-
<span class="
|
|
95
|
+
<section class="mt-10 rounded-(--radius-l) border border-line bg-paper px-7 py-6 shadow-(--shadow-1)">
|
|
96
|
+
<div class="mb-2 flex flex-wrap items-baseline justify-between gap-4">
|
|
97
|
+
<h2 class="m-0 text-[1.3rem] tracking-[-0.01em]">The architecture</h2>
|
|
98
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-ok/35 bg-ok/8 px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-ok uppercase">
|
|
99
|
+
static · 0 KB JS
|
|
100
|
+
</span>
|
|
80
101
|
</div>
|
|
81
|
-
<p>
|
|
102
|
+
<p class="mt-[0.35rem] mb-5 max-w-[60ch] text-ink-soft">
|
|
82
103
|
This section — like the hero above — is plain prerendered HTML and CSS. No framework
|
|
83
104
|
script runs it.
|
|
84
105
|
</p>
|
|
85
|
-
<ul class="
|
|
86
|
-
<li class="
|
|
87
|
-
<span class="
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
106
|
+
<ul class="m-0 grid list-none grid-cols-[repeat(auto-fit,minmax(15rem,1fr))] gap-4 p-0">
|
|
107
|
+
<li class="rounded-(--radius-m) border border-line bg-surface px-[1.15rem] py-4">
|
|
108
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-ok/35 bg-ok/8 px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-ok uppercase">
|
|
109
|
+
static
|
|
110
|
+
</span>
|
|
111
|
+
<h3 class="mt-[0.6rem] mb-[0.35rem] text-[1rem]">Prerendered pages</h3>
|
|
112
|
+
<p class="m-0 text-[0.9rem] leading-[1.6] text-ink-soft">
|
|
113
|
+
Routes under{" "}
|
|
114
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
115
|
+
app/routes/
|
|
116
|
+
</code>{" "}
|
|
117
|
+
compile to static HTML at build time (SSG) and keep their HTTP cache semantics.
|
|
92
118
|
</p>
|
|
93
119
|
</li>
|
|
94
|
-
<li class="
|
|
95
|
-
<span class="
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
120
|
+
<li class="rounded-(--radius-m) border border-line bg-surface px-[1.15rem] py-4">
|
|
121
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-brand/40 bg-brand-soft px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-brand uppercase">
|
|
122
|
+
island
|
|
123
|
+
</span>
|
|
124
|
+
<h3 class="mt-[0.6rem] mb-[0.35rem] text-[1rem]">Islands where needed</h3>
|
|
125
|
+
<p class="m-0 text-[0.9rem] leading-[1.6] text-ink-soft">
|
|
126
|
+
Interactive pieces live in{" "}
|
|
127
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
128
|
+
app/islands/
|
|
129
|
+
</code>{" "}
|
|
130
|
+
and hydrate on the strategy each one declares — idle, load, visible, or client-only.
|
|
100
131
|
</p>
|
|
101
132
|
</li>
|
|
102
|
-
<li class="
|
|
103
|
-
<span class="
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
<li class="rounded-(--radius-m) border border-line bg-surface px-[1.15rem] py-4">
|
|
134
|
+
<span class="inline-flex items-center gap-[0.4em] rounded-full border border-ok/35 bg-ok/8 px-[0.65rem] py-[0.2rem] text-[0.72rem] font-semibold tracking-[0.04em] text-ok uppercase">
|
|
135
|
+
static
|
|
136
|
+
</span>
|
|
137
|
+
<h3 class="mt-[0.6rem] mb-[0.35rem] text-[1rem]">Platform APIs</h3>
|
|
138
|
+
<p class="m-0 text-[0.9rem] leading-[1.6] text-ink-soft">
|
|
139
|
+
Server routes (
|
|
140
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
141
|
+
app/routes/api/
|
|
142
|
+
</code>
|
|
143
|
+
) are plain{" "}
|
|
144
|
+
<code class="rounded-[5px] border border-line bg-surface px-[0.35em] py-[0.08em] font-mono text-[0.85em]">
|
|
145
|
+
Request → Response
|
|
146
|
+
</code>{" "}
|
|
147
|
+
handlers — WinterCG-shaped, no framework runtime attached.
|
|
109
148
|
</p>
|
|
110
149
|
</li>
|
|
111
150
|
</ul>
|
|
@@ -1,68 +1,5 @@
|
|
|
1
|
+
/* The chrome shadow host's box; the bars, brand and nav links are authored
|
|
2
|
+
as Tailwind utilities in layout.tsx. */
|
|
1
3
|
:host {
|
|
2
4
|
display: block;
|
|
3
5
|
}
|
|
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
|
-
}
|
|
@@ -1,32 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* app/head.tsx —
|
|
2
|
+
* app/head.tsx — structural document-head content: the entries a URL list
|
|
3
|
+
* cannot express (here, the color-scheme declaration).
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* a
|
|
5
|
+
* Entries are DATA and are emitted in the order written: `{ meta: {...} }` is
|
|
6
|
+
* one meta tag, `{ link: { rel, href } }` one link tag, `{ style: 'css' }` one
|
|
7
|
+
* inline style block. The build compiles this module, so it can import CSS by
|
|
8
|
+
* URL and pull local constants — but it must not use host APIs: its output is
|
|
9
|
+
* a build artifact.
|
|
9
10
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* The module is compiled by the build, so it can import CSS by URL
|
|
16
|
-
* (`import css from './site.css?raw'`) and pull constants from local modules.
|
|
17
|
-
* It must not use host APIs (no Deno, no Node): its output is a build artifact,
|
|
18
|
-
* so a runtime read would make the document depend on the build machine.
|
|
19
|
-
*
|
|
20
|
-
* `head` in openelement.config.ts already covers the title, description,
|
|
21
|
-
* favicon and the og:/twitter: pairs; `head.scripts` / `head.stylesheets`
|
|
22
|
-
* cover external scripts and stylesheets. This file is for what neither can
|
|
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.
|
|
11
|
+
* Title, description, favicon and the og:/twitter: pairs come from `head` in
|
|
12
|
+
* openelement.config.ts. A route's own `head.meta` overrides a site default
|
|
13
|
+
* with the same property; `name=` entries never suppress one. Delete this file
|
|
14
|
+
* and the starter still builds — it is a convention, not a requirement.
|
|
30
15
|
*/
|
|
31
16
|
export default [
|
|
32
17
|
// Declaring the color scheme the starter supports lets the browser pick the
|
|
@@ -1,23 +1,5 @@
|
|
|
1
|
+
/* The island shadow host's box; the row and clock are authored as Tailwind
|
|
2
|
+
utilities in live-timer.tsx. */
|
|
1
3
|
:host {
|
|
2
4
|
display: inline-block;
|
|
3
5
|
}
|
|
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
|
|
10
|
-
`.value` selector matched nothing, so the clock lost its brand color
|
|
11
|
-
and tabular figures. */
|
|
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
|
-
}
|
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
* live-timer — client-only live stats island (compiled).
|
|
3
3
|
*
|
|
4
4
|
* hydrate: 'only' with ssr: false renders nothing on the server; the client
|
|
5
|
-
* entry
|
|
6
|
-
*
|
|
7
|
-
* time origin (performance.now()), so the number is honest page time, and
|
|
5
|
+
* entry builds the DOM from the compiled Part Program and starts the clock in
|
|
6
|
+
* connectedCallback, measured from the document's time origin.
|
|
8
7
|
* disconnectedCallback stops the interval when the host leaves the tree.
|
|
9
8
|
*/
|
|
10
9
|
import { defineIslandConfig } from "@openelement/router";
|
|
@@ -13,41 +12,52 @@ import timerStyles from "./live-timer.css";
|
|
|
13
12
|
|
|
14
13
|
export const openElement = defineIslandConfig({ hydrate: "only", ssr: false, dsd: false });
|
|
15
14
|
|
|
16
|
-
// The interval handle rides
|
|
17
|
-
//
|
|
18
|
-
// runtime statements are outside the compiled grammar (OEC9008). In the
|
|
19
|
-
// browser setInterval returns a number, so the handle is a plain number here.
|
|
15
|
+
// The interval handle rides compiled per-instance property state (module-level
|
|
16
|
+
// runtime statements are outside the compiled grammar, OEC9008).
|
|
20
17
|
@element("live-timer", { root: "shadow-open" })
|
|
21
18
|
export default class LiveTimer extends OpenElement {
|
|
22
19
|
static override styles = [timerStyles];
|
|
23
20
|
|
|
24
|
-
/** Elapsed seconds
|
|
25
|
-
*
|
|
21
|
+
/** Elapsed seconds, preformatted: a compiled text Part binds a plain
|
|
22
|
+
* property, never a method call (OEC9013). */
|
|
26
23
|
@property({ reflect: false, attribute: false })
|
|
27
24
|
elapsed = "0.0";
|
|
28
25
|
|
|
29
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The ticking interval's handle; 0 when the host is not connected.
|
|
28
|
+
*
|
|
29
|
+
* `window.setInterval`, not the bare global: the generated tsconfig loads
|
|
30
|
+
* both DOM and node types (@types/node), so the bare `setInterval` name
|
|
31
|
+
* resolves to Node's overload and the handle becomes a `NodeJS.Timeout`
|
|
32
|
+
* (TS2322 on the assignment). The browser entry runs in the DOM, where the
|
|
33
|
+
* call returns a `number` — the honest type for this field.
|
|
34
|
+
*/
|
|
30
35
|
@property({ reflect: false, attribute: false })
|
|
31
36
|
interval = 0;
|
|
32
37
|
|
|
33
38
|
override connectedCallback(): void {
|
|
34
39
|
super.connectedCallback();
|
|
35
|
-
this.interval = setInterval(() => {
|
|
40
|
+
this.interval = window.setInterval(() => {
|
|
36
41
|
this.elapsed = (Math.round(performance.now()) / 1000).toFixed(1);
|
|
37
42
|
}, 100);
|
|
38
43
|
}
|
|
39
44
|
|
|
40
45
|
override disconnectedCallback(): void {
|
|
41
|
-
clearInterval(this.interval);
|
|
46
|
+
window.clearInterval(this.interval);
|
|
42
47
|
this.interval = 0;
|
|
43
48
|
super.disconnectedCallback();
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
render() {
|
|
47
52
|
return (
|
|
48
|
-
<div class="
|
|
49
|
-
<span
|
|
50
|
-
|
|
53
|
+
<div class="inline-flex items-baseline gap-[0.6rem]">
|
|
54
|
+
<span
|
|
55
|
+
id="elapsed"
|
|
56
|
+
class="min-w-[6ch] text-right text-[1.4rem] font-semibold text-brand tabular-nums"
|
|
57
|
+
>
|
|
58
|
+
{this.elapsed}
|
|
59
|
+
</span>
|
|
60
|
+
<span class="text-[0.85rem] text-ink-soft">seconds on this page</span>
|
|
51
61
|
</div>
|
|
52
62
|
);
|
|
53
63
|
}
|
|
@@ -1,32 +1,5 @@
|
|
|
1
|
+
/* The island shadow host's box; the row, buttons and count are authored as
|
|
2
|
+
Tailwind utilities in my-counter.tsx. */
|
|
1
3
|
:host {
|
|
2
4
|
display: inline-block;
|
|
3
5
|
}
|
|
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
|
-
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* my-counter — the interactive counter island (compiled).
|
|
3
3
|
*
|
|
4
|
-
* Hydrates on idle; the buttons
|
|
5
|
-
*
|
|
6
|
-
* shadow root keeps the island a DSD citizen.
|
|
7
|
-
* app/styles/theme.css inherit through the shadow boundary.
|
|
4
|
+
* Hydrates on idle; the buttons drive compiled event Parts and the count
|
|
5
|
+
* renders through a compiled text Part. Presentation is utility-first below,
|
|
6
|
+
* and the shadow root keeps the island a DSD citizen.
|
|
8
7
|
*/
|
|
9
8
|
import { defineIslandConfig } from "@openelement/router";
|
|
10
9
|
import { element, OpenElement, property } from "@openelement/element";
|
|
@@ -29,12 +28,22 @@ export default class MyCounter extends OpenElement {
|
|
|
29
28
|
|
|
30
29
|
render() {
|
|
31
30
|
return (
|
|
32
|
-
<div class="
|
|
33
|
-
<button
|
|
31
|
+
<div class="inline-flex items-center gap-3">
|
|
32
|
+
<button
|
|
33
|
+
class="size-8 cursor-pointer rounded-(--radius-s) border border-line bg-paper text-[1rem] leading-none text-ink transition-[border-color,color] duration-150 ease-out hover:border-brand hover:text-brand"
|
|
34
|
+
type="button"
|
|
35
|
+
onClick={this.decrement}
|
|
36
|
+
>
|
|
34
37
|
-
|
|
35
38
|
</button>
|
|
36
|
-
<span id="count">
|
|
37
|
-
|
|
39
|
+
<span id="count" class="min-w-[2ch] text-center font-semibold tabular-nums">
|
|
40
|
+
{this.count}
|
|
41
|
+
</span>
|
|
42
|
+
<button
|
|
43
|
+
class="size-8 cursor-pointer rounded-(--radius-s) border border-line bg-paper text-[1rem] leading-none text-ink transition-[border-color,color] duration-150 ease-out hover:border-brand hover:text-brand"
|
|
44
|
+
type="button"
|
|
45
|
+
onClick={this.increment}
|
|
46
|
+
>
|
|
38
47
|
+
|
|
39
48
|
</button>
|
|
40
49
|
</div>
|