@openelement/create 1.0.0-alpha.15 → 1.0.0-alpha.16
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 +23 -43
- package/package.json +1 -1
- package/src/template-builder.js +1 -7
- package/src/version.js +1 -1
- package/templates/AGENTS.md.tmpl +8 -6
- package/templates/README.tmpl +36 -186
- package/templates/app/islands/live-timer.tsx.tmpl +49 -53
- package/templates/app/islands/my-counter.tsx.tmpl +43 -43
- package/templates/app/layout.tsx.tmpl +64 -53
- package/templates/app/routes/404.tsx.tmpl +17 -2
- package/templates/app/routes/about.tsx.tmpl +34 -3
- package/templates/app/routes/index.tsx.tmpl +32 -3
- package/templates/app/styles/theme.css +19 -0
- package/templates/gitignore.tmpl +2 -0
- package/templates/package.json.tmpl +3 -3
- package/templates/tests/ping.test.ts.tmpl +15 -0
- package/templates/tsconfig.json.tmpl +1 -1
- package/templates/app/components/page-404.css +0 -5
- package/templates/app/components/page-404.tsx.tmpl +0 -27
- package/templates/app/components/page-about.css +0 -5
- package/templates/app/components/page-about.tsx.tmpl +0 -97
- package/templates/app/components/page-home.css +0 -5
- package/templates/app/components/page-home.tsx.tmpl +0 -155
- package/templates/app/components/site-chrome.css +0 -5
|
@@ -2,67 +2,78 @@
|
|
|
2
2
|
* app/layout.tsx — the auto-registered layout: header, main slot and footer
|
|
3
3
|
* exist here exactly once, so a page module carries only its own content.
|
|
4
4
|
*
|
|
5
|
-
* `root: 'shadow-open'` is what makes the projection work — the chrome renders
|
|
6
|
-
* in this element's shadow tree while the slotted page content stays in the
|
|
7
|
-
* page's light DOM. The markup below is styled with Tailwind utilities; the
|
|
8
|
-
* sheet in `static styles` holds only the host box, which has no markup to
|
|
9
|
-
* carry it.
|
|
10
|
-
*
|
|
11
5
|
* A convention, not a requirement: delete the file and pages render their own
|
|
12
6
|
* chrome again, or opt out with `layout: false` in openelement.config.ts.
|
|
13
7
|
*/
|
|
14
|
-
import {
|
|
15
|
-
import siteChromeStyles from "./components/site-chrome.css";
|
|
8
|
+
import { defineIslandConfig } from "@openelement/router";
|
|
16
9
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
/**
|
|
11
|
+
* The convention layout on the generated-element lane (2026-11-20).
|
|
12
|
+
*
|
|
13
|
+
* The class this template used to declare is a function component plus the
|
|
14
|
+
* sidecar below. The tag is the router's convention constant, and the entry
|
|
15
|
+
* registers the host through the generated host PAIR channel, so the layout
|
|
16
|
+
* renders as a generated element instead of a class.
|
|
17
|
+
*
|
|
18
|
+
* LIGHT root on purpose. The chrome is styled with Tailwind utilities, and a
|
|
19
|
+
* LIGHT root's CSS is a DOCUMENT resource: the utilities ride the compiled
|
|
20
|
+
* document sheet, and the host's box rule lives in `app/styles/theme.css`
|
|
21
|
+
* (`app-layout { display: block }`). Page content still projects through the
|
|
22
|
+
* `<slot>` — the generated light-root producer substitutes it at the slot.
|
|
23
|
+
* A shadow root would need the utilities inside its shadow tree, which requires
|
|
24
|
+
* a component-sheet link channel the generated lane has no app-local
|
|
25
|
+
* declaration for (package components declare it in their manifest; an app's
|
|
26
|
+
* own layout does not).
|
|
27
|
+
*/
|
|
28
|
+
export const openElement = defineIslandConfig({
|
|
29
|
+
tag: "app-layout",
|
|
30
|
+
});
|
|
20
31
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
32
|
+
function Layout() {
|
|
33
|
+
return (
|
|
34
|
+
<div>
|
|
35
|
+
<header class="site-head border-b border-line bg-paper">
|
|
36
|
+
<div class="mx-auto flex max-w-(--content-width) items-baseline justify-between gap-4 px-5 py-4">
|
|
37
|
+
<a
|
|
38
|
+
class="text-[1.1rem] font-bold tracking-[-0.01em] text-ink no-underline hover:text-brand"
|
|
39
|
+
href="/"
|
|
40
|
+
>
|
|
41
|
+
openElement
|
|
42
|
+
</a>
|
|
43
|
+
<nav class="flex gap-5">
|
|
26
44
|
<a
|
|
27
|
-
class="text-[
|
|
45
|
+
class="text-[0.95rem] font-medium text-ink-soft no-underline hover:text-brand"
|
|
28
46
|
href="/"
|
|
29
47
|
>
|
|
30
|
-
|
|
48
|
+
Home
|
|
31
49
|
</a>
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
Home
|
|
38
|
-
</a>
|
|
39
|
-
<a
|
|
40
|
-
class="text-[0.95rem] font-medium text-ink-soft no-underline hover:text-brand"
|
|
41
|
-
href="/about"
|
|
42
|
-
>
|
|
43
|
-
About
|
|
44
|
-
</a>
|
|
45
|
-
<a
|
|
46
|
-
class="text-[0.95rem] font-medium text-ink-soft no-underline hover:text-brand"
|
|
47
|
-
href="/api/ping"
|
|
48
|
-
>
|
|
49
|
-
API
|
|
50
|
-
</a>
|
|
51
|
-
</nav>
|
|
52
|
-
</div>
|
|
53
|
-
</header>
|
|
54
|
-
<main class="mx-auto max-w-(--content-width) px-5 pt-12 pb-16">
|
|
55
|
-
<slot></slot>
|
|
56
|
-
</main>
|
|
57
|
-
<footer class="site-foot border-t border-line text-[0.85rem] text-ink-soft">
|
|
58
|
-
<div class="mx-auto flex max-w-(--content-width) flex-wrap justify-between gap-4 p-5">
|
|
59
|
-
<span>Generated by @openelement/create.</span>
|
|
60
|
-
<a class="text-ink-soft no-underline hover:text-brand" href="https://openelement.org">
|
|
61
|
-
openelement.org
|
|
50
|
+
<a
|
|
51
|
+
class="text-[0.95rem] font-medium text-ink-soft no-underline hover:text-brand"
|
|
52
|
+
href="/about"
|
|
53
|
+
>
|
|
54
|
+
About
|
|
62
55
|
</a>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
<a
|
|
57
|
+
class="text-[0.95rem] font-medium text-ink-soft no-underline hover:text-brand"
|
|
58
|
+
href="/api/ping"
|
|
59
|
+
>
|
|
60
|
+
API
|
|
61
|
+
</a>
|
|
62
|
+
</nav>
|
|
63
|
+
</div>
|
|
64
|
+
</header>
|
|
65
|
+
<main class="mx-auto max-w-(--content-width) px-5 pt-12 pb-16">
|
|
66
|
+
<slot></slot>
|
|
67
|
+
</main>
|
|
68
|
+
<footer class="site-foot border-t border-line text-[0.85rem] text-ink-soft">
|
|
69
|
+
<div class="mx-auto flex max-w-(--content-width) flex-wrap justify-between gap-4 p-5">
|
|
70
|
+
<a class="text-ink-soft no-underline hover:text-brand" href="https://openelement.org">
|
|
71
|
+
openelement.org
|
|
72
|
+
</a>
|
|
73
|
+
</div>
|
|
74
|
+
</footer>
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
68
77
|
}
|
|
78
|
+
|
|
79
|
+
export default Layout;
|
|
@@ -2,9 +2,24 @@
|
|
|
2
2
|
* Styled 404: `renderIntent: { mode: 'dynamic' }` keeps this route on the
|
|
3
3
|
* request-time path — the reason this starter's build emits `dist/server/`.
|
|
4
4
|
* Drop the line and the route prerenders to dist/404.html instead.
|
|
5
|
-
|
|
5
|
+
*
|
|
6
|
+
* Server function component declared in its own route module; the root box rule
|
|
7
|
+
* lives in the document token sheet. */
|
|
6
8
|
import { definePage } from "@openelement/router";
|
|
7
|
-
|
|
9
|
+
|
|
10
|
+
export function NotFoundPage() {
|
|
11
|
+
return (
|
|
12
|
+
<div class="page-content">
|
|
13
|
+
<h1 class="mt-3 mb-2 text-[2.4rem] font-bold tracking-[-0.02em]">404</h1>
|
|
14
|
+
<p class="leading-[1.6] text-ink-soft">The page you are looking for does not exist.</p>
|
|
15
|
+
<p class="leading-[1.6] text-ink-soft">
|
|
16
|
+
<a class="font-semibold text-brand no-underline hover:underline" href="/">
|
|
17
|
+
Back to the homepage
|
|
18
|
+
</a>
|
|
19
|
+
</p>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
8
23
|
|
|
9
24
|
export default definePage(NotFoundPage, {
|
|
10
25
|
renderIntent: { mode: "dynamic" },
|
|
@@ -1,10 +1,41 @@
|
|
|
1
|
-
/** Static About page (default renderIntent mode 'static') — prerendered at build time. */
|
|
2
1
|
import { definePage } from "@openelement/router";
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export function AboutPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div class="page-content">
|
|
6
|
+
<h1 class="mt-0 mb-4 text-[clamp(1.9rem,5vw,2.6rem)] leading-[1.15] font-bold tracking-[-0.02em]">
|
|
7
|
+
Static first, interactive where it counts
|
|
8
|
+
</h1>
|
|
9
|
+
<p class="max-w-[58ch] text-[1.08rem] text-ink-soft">
|
|
10
|
+
This route is built as HTML and CSS and has no islands of its own. The{" "}
|
|
11
|
+
<a class="text-brand hover:underline" href="/">
|
|
12
|
+
home page
|
|
13
|
+
</a>{" "}
|
|
14
|
+
adds a counter and a timer.
|
|
15
|
+
</p>
|
|
16
|
+
<h2 class="mt-9 text-[1.25rem]">Make a change</h2>
|
|
17
|
+
<ul class="space-y-2 pl-5 text-ink-soft">
|
|
18
|
+
<li>
|
|
19
|
+
Add a page under <code class="font-mono text-brand">app/routes/</code>.
|
|
20
|
+
</li>
|
|
21
|
+
<li>
|
|
22
|
+
Edit the counter or timer under <code class="font-mono text-brand">app/islands/</code>.
|
|
23
|
+
</li>
|
|
24
|
+
<li>
|
|
25
|
+
Try{" "}
|
|
26
|
+
<a class="text-brand hover:underline" href="/api/ping">
|
|
27
|
+
/api/ping
|
|
28
|
+
</a>{" "}
|
|
29
|
+
for a request-time JSON response.
|
|
30
|
+
</li>
|
|
31
|
+
</ul>
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
4
35
|
|
|
5
36
|
export default definePage(AboutPage, {
|
|
6
37
|
head: {
|
|
7
38
|
title: "About",
|
|
8
|
-
description: "
|
|
39
|
+
description: "A prerendered route with no client islands of its own.",
|
|
9
40
|
},
|
|
10
41
|
});
|
|
@@ -1,10 +1,39 @@
|
|
|
1
|
-
/** Static home page (default renderIntent mode 'static') — prerendered at build time. */
|
|
2
1
|
import { definePage } from "@openelement/router";
|
|
3
|
-
|
|
2
|
+
|
|
3
|
+
export function HomePage() {
|
|
4
|
+
return (
|
|
5
|
+
<div class="page-content">
|
|
6
|
+
<h1 class="mt-0 mb-4 max-w-[22ch] text-[clamp(2.2rem,6vw,3.2rem)] leading-[1.1] font-bold tracking-[-0.02em]">
|
|
7
|
+
Rendered before JavaScript arrives
|
|
8
|
+
</h1>
|
|
9
|
+
<p class="max-w-[56ch] text-[1.12rem] leading-[1.75] text-ink-soft">
|
|
10
|
+
Edit <code class="font-mono text-brand">app/routes/index.tsx</code> and save to see your
|
|
11
|
+
first change in the dev server.
|
|
12
|
+
</p>
|
|
13
|
+
<div class="mt-10 grid grid-cols-[repeat(auto-fit,minmax(min(100%,18rem),1fr))] gap-4">
|
|
14
|
+
<section class="rounded-(--radius-l) border border-line bg-paper px-7 py-6">
|
|
15
|
+
<h2 class="m-0 text-[1.3rem]">Interactive island</h2>
|
|
16
|
+
<p class="mt-2 mb-5 text-ink-soft">
|
|
17
|
+
The server renders the counter. Its button starts responding when the browser hydrates
|
|
18
|
+
the island during idle time.
|
|
19
|
+
</p>
|
|
20
|
+
<my-counter></my-counter>
|
|
21
|
+
</section>
|
|
22
|
+
<section class="rounded-(--radius-l) border border-line bg-paper px-7 py-6">
|
|
23
|
+
<h2 class="m-0 text-[1.3rem]">Client-only timer</h2>
|
|
24
|
+
<p class="mt-2 mb-5 text-ink-soft">
|
|
25
|
+
The browser mounts the timer and measures elapsed time locally.
|
|
26
|
+
</p>
|
|
27
|
+
<live-timer></live-timer>
|
|
28
|
+
</section>
|
|
29
|
+
</div>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
4
33
|
|
|
5
34
|
export default definePage(HomePage, {
|
|
6
35
|
head: {
|
|
7
36
|
title: "Rendered before JavaScript arrives",
|
|
8
|
-
description: "
|
|
37
|
+
description: "A prerendered page with an interactive counter and a client-only timer.",
|
|
9
38
|
},
|
|
10
39
|
});
|
|
@@ -162,3 +162,22 @@ body {
|
|
|
162
162
|
--color-ok: var(--color-zinc-100);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
+
|
|
166
|
+
/* ── LIGHT-root host boxes ────────────────────────────────────────────────
|
|
167
|
+
A custom element is inline by default and the host tag is not authored
|
|
168
|
+
markup, so no utility can carry its own box. The layout and the page
|
|
169
|
+
components are function components on the generated-element lane and render
|
|
170
|
+
LIGHT roots, whose CSS is a DOCUMENT resource — this token sheet is its
|
|
171
|
+
single owner. These selectors are the exact replacements for the retired
|
|
172
|
+
per-component `:host { display: block }` sheets.
|
|
173
|
+
|
|
174
|
+
The layout is a LIGHT root on purpose: its chrome is styled with Tailwind
|
|
175
|
+
utilities, and a shadow root's utilities would need a component-sheet link
|
|
176
|
+
channel the generated lane has no app-local declaration for. Slotted page
|
|
177
|
+
content still projects through its `<slot>`. */
|
|
178
|
+
app-layout,
|
|
179
|
+
index-page,
|
|
180
|
+
about-page,
|
|
181
|
+
el-404 {
|
|
182
|
+
display: block;
|
|
183
|
+
}
|
package/templates/gitignore.tmpl
CHANGED
|
@@ -21,11 +21,11 @@
|
|
|
21
21
|
"@tailwindcss/vite": "4.3.3",
|
|
22
22
|
"@types/node": "26.5.0",
|
|
23
23
|
"hono": "^4.12",
|
|
24
|
-
"oxfmt": "0.
|
|
25
|
-
"oxlint": "1.
|
|
24
|
+
"oxfmt": "0.74.0",
|
|
25
|
+
"oxlint": "1.89.0",
|
|
26
26
|
"tailwindcss": "4.3.3",
|
|
27
27
|
"typescript": "6.0.3",
|
|
28
|
-
"vite": "8.
|
|
28
|
+
"vite": "8.1.6"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
31
|
"node": ">=24.2"
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { test } from "node:test";
|
|
3
|
+
import ping from "../app/routes/api/ping.ts";
|
|
4
|
+
|
|
5
|
+
test("GET /api/ping returns the JSON health response", async () => {
|
|
6
|
+
const response = ping();
|
|
7
|
+
|
|
8
|
+
assert.equal(response.status, 200);
|
|
9
|
+
assert.match(response.headers.get("content-type") ?? "", /^application\/json(?:;|$)/i);
|
|
10
|
+
assert.deepEqual(await response.json(), {
|
|
11
|
+
pong: true,
|
|
12
|
+
framework: "openElement",
|
|
13
|
+
route: "/api/ping",
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styled 404 page element (path-derived tag 'el-404'): the request-time server
|
|
3
|
-
* renders it with a 404 status for unmatched paths. Presentation is
|
|
4
|
-
* utility-first in the markup; the one rule in `static styles` is the root's
|
|
5
|
-
* own box.
|
|
6
|
-
*/
|
|
7
|
-
import { element, OpenElement } from "@openelement/element";
|
|
8
|
-
import notFoundPageStyles from "./page-404.css";
|
|
9
|
-
|
|
10
|
-
@element("el-404", { root: "light" })
|
|
11
|
-
export default class NotFoundPage extends OpenElement {
|
|
12
|
-
static override styles = [notFoundPageStyles];
|
|
13
|
-
|
|
14
|
-
render() {
|
|
15
|
-
return (
|
|
16
|
-
<div class="page-content">
|
|
17
|
-
<h1 class="mt-3 mb-2 text-[2.4rem] font-bold tracking-[-0.02em]">404</h1>
|
|
18
|
-
<p class="leading-[1.6] text-ink-soft">The page you are looking for does not exist.</p>
|
|
19
|
-
<p class="leading-[1.6] text-ink-soft">
|
|
20
|
-
<a class="font-semibold text-brand no-underline hover:underline" href="/">
|
|
21
|
-
Back to the homepage
|
|
22
|
-
</a>
|
|
23
|
-
</p>
|
|
24
|
-
</div>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* About page element — the fully static showcase page: no islands, so nothing
|
|
3
|
-
* here ships JavaScript. The default static renderIntent prerenders it to HTML
|
|
4
|
-
* at build time; the layout owns the chrome; the one rule in `static styles`
|
|
5
|
-
* is the root's own box.
|
|
6
|
-
*/
|
|
7
|
-
import { element, OpenElement } from "@openelement/element";
|
|
8
|
-
import aboutPageStyles from "./page-about.css";
|
|
9
|
-
|
|
10
|
-
@element("about-page", { root: "light" })
|
|
11
|
-
export default class AboutPage extends OpenElement {
|
|
12
|
-
static override styles = [aboutPageStyles];
|
|
13
|
-
|
|
14
|
-
render() {
|
|
15
|
-
return (
|
|
16
|
-
<div class="page-content">
|
|
17
|
-
<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">
|
|
18
|
-
static · no islands on this page
|
|
19
|
-
</span>
|
|
20
|
-
<p class="m-0 text-[0.78rem] font-semibold tracking-[0.14em] text-brand uppercase">About</p>
|
|
21
|
-
<h1 class="mt-3 mb-4 text-[clamp(1.9rem,5vw,2.6rem)] leading-[1.15] font-bold tracking-[-0.02em]">
|
|
22
|
-
Static first, interactive where it counts
|
|
23
|
-
</h1>
|
|
24
|
-
<p class="mb-8 max-w-[58ch] text-[1.08rem] text-ink-soft">
|
|
25
|
-
openElement prerenders pages to plain HTML and CSS at build time and hydrates compiled
|
|
26
|
-
islands only where a page needs interactivity. This page is the first half of that story:
|
|
27
|
-
it ships no islands at all.
|
|
28
|
-
</p>
|
|
29
|
-
<h2 class="mt-9 mb-[0.6rem] text-[1.25rem] tracking-[-0.01em]">
|
|
30
|
-
What happened when you opened this page
|
|
31
|
-
</h2>
|
|
32
|
-
<p class="my-[0.6rem] max-w-[62ch]">
|
|
33
|
-
The server sent HTML — prerendered at build time by SSG — plus the stylesheet the page's
|
|
34
|
-
utility classes compile into. No framework runtime executed to produce what you are
|
|
35
|
-
reading; the markup is the artifact.
|
|
36
|
-
</p>
|
|
37
|
-
<h2 class="mt-9 mb-[0.6rem] text-[1.25rem] tracking-[-0.01em]">Where things live</h2>
|
|
38
|
-
<ul class="mt-4 list-none border-t border-line p-0">
|
|
39
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
40
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/routes/</code>
|
|
41
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
42
|
-
page routes — one file per URL, prerendered by default
|
|
43
|
-
</span>
|
|
44
|
-
</li>
|
|
45
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
46
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/routes/api/</code>
|
|
47
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
48
|
-
request-time server routes — plain Request → Response handlers
|
|
49
|
-
</span>
|
|
50
|
-
</li>
|
|
51
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
52
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/components/</code>
|
|
53
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
54
|
-
compiled page elements and the shared style sheets they array
|
|
55
|
-
</span>
|
|
56
|
-
</li>
|
|
57
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
58
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/islands/</code>
|
|
59
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
60
|
-
client islands — the only code that ships JavaScript
|
|
61
|
-
</span>
|
|
62
|
-
</li>
|
|
63
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
64
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/layout.tsx</code>
|
|
65
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
66
|
-
the shared site chrome wrapped around every page
|
|
67
|
-
</span>
|
|
68
|
-
</li>
|
|
69
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
70
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">
|
|
71
|
-
app/styles/theme.css
|
|
72
|
-
</code>
|
|
73
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
74
|
-
design tokens — the @theme role sheet every utility reads
|
|
75
|
-
</span>
|
|
76
|
-
</li>
|
|
77
|
-
<li class="flex flex-wrap gap-4 border-b border-line py-[0.7rem]">
|
|
78
|
-
<code class="min-w-[15rem] font-mono text-[0.85rem] text-brand">app/head.tsx</code>
|
|
79
|
-
<span class="text-[0.92rem] text-ink-soft">
|
|
80
|
-
structural document-head content (meta tags, preloads)
|
|
81
|
-
</span>
|
|
82
|
-
</li>
|
|
83
|
-
</ul>
|
|
84
|
-
<h2 class="mt-9 mb-[0.6rem] text-[1.25rem] tracking-[-0.01em]">See it working</h2>
|
|
85
|
-
<p class="my-[0.6rem] max-w-[62ch]">
|
|
86
|
-
The{" "}
|
|
87
|
-
<a class="text-brand no-underline hover:underline" href="/">
|
|
88
|
-
home page
|
|
89
|
-
</a>{" "}
|
|
90
|
-
carries the interactive half: a counter island that hydrates on idle and a client-only
|
|
91
|
-
live timer. Open the browser DevTools on both pages and compare the network panels — the
|
|
92
|
-
badge on each section names what it costs.
|
|
93
|
-
</p>
|
|
94
|
-
</div>
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Home page element — the showcase landing page (static prerendered, the
|
|
3
|
-
* default renderIntent mode).
|
|
4
|
-
*
|
|
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.
|
|
13
|
-
*/
|
|
14
|
-
import { element, OpenElement } from "@openelement/element";
|
|
15
|
-
import homePageStyles from "./page-home.css";
|
|
16
|
-
|
|
17
|
-
@element("index-page", { root: "light" })
|
|
18
|
-
export default class HomePage extends OpenElement {
|
|
19
|
-
static override styles = [homePageStyles];
|
|
20
|
-
|
|
21
|
-
render() {
|
|
22
|
-
// Single root element: the compiled grammar lowers one root per render.
|
|
23
|
-
return (
|
|
24
|
-
<div class="page-content">
|
|
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">
|
|
36
|
-
Every page here is prerendered HTML. JavaScript loads only where a section is
|
|
37
|
-
interactive — the badges below name the cost of each block. Edit{" "}
|
|
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.
|
|
42
|
-
</p>
|
|
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
|
-
>
|
|
48
|
-
How it works
|
|
49
|
-
</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
|
-
>
|
|
54
|
-
Read the docs
|
|
55
|
-
</a>
|
|
56
|
-
</div>
|
|
57
|
-
</section>
|
|
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>
|
|
64
|
-
</div>
|
|
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>
|
|
70
|
-
): the server renders its markup, the browser hydrates it when idle.
|
|
71
|
-
</p>
|
|
72
|
-
<my-counter></my-counter>
|
|
73
|
-
</section>
|
|
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>
|
|
80
|
-
</div>
|
|
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
|
-
.
|
|
92
|
-
</p>
|
|
93
|
-
<live-timer></live-timer>
|
|
94
|
-
</section>
|
|
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>
|
|
101
|
-
</div>
|
|
102
|
-
<p class="mt-[0.35rem] mb-5 max-w-[60ch] text-ink-soft">
|
|
103
|
-
This section — like the hero above — is plain prerendered HTML and CSS. No framework
|
|
104
|
-
script runs it.
|
|
105
|
-
</p>
|
|
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.
|
|
118
|
-
</p>
|
|
119
|
-
</li>
|
|
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.
|
|
131
|
-
</p>
|
|
132
|
-
</li>
|
|
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.
|
|
148
|
-
</p>
|
|
149
|
-
</li>
|
|
150
|
-
</ul>
|
|
151
|
-
</section>
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
}
|