@openelement/create 1.0.0-alpha.14 → 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 +61 -51
- 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 +59 -14
- package/src/version.js +2 -10
- package/templates/.node-version +1 -0
- package/templates/AGENTS.md.tmpl +46 -0
- package/templates/README.tmpl +36 -145
- 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 +49 -43
- package/templates/app/islands/my-counter.css +2 -29
- package/templates/app/islands/my-counter.tsx.tmpl +43 -34
- package/templates/app/layout.tsx.tmpl +79 -0
- package/templates/app/routes/404.tsx.tmpl +20 -8
- package/templates/app/routes/about.tsx.tmpl +34 -3
- package/templates/app/routes/api/ping.ts.tmpl +2 -3
- package/templates/app/routes/index.tsx.tmpl +32 -3
- package/templates/app/styles/theme.css +81 -77
- package/templates/gitignore.tmpl +2 -0
- package/templates/openelement.config.ts.tmpl +16 -28
- package/templates/package.json.tmpl +8 -6
- package/templates/tests/ping.test.ts.tmpl +15 -0
- package/templates/tsconfig.json.tmpl +2 -2
- package/templates/vite.config.ts.tmpl +7 -14
- package/templates/app/components/badges.css +0 -24
- package/templates/app/components/page-404.css +0 -21
- package/templates/app/components/page-404.tsx.tmpl +0 -28
- package/templates/app/components/page-about.css +0 -72
- package/templates/app/components/page-about.tsx.tmpl +0 -77
- package/templates/app/components/page-home.css +0 -135
- package/templates/app/components/page-home.tsx.tmpl +0 -116
- package/templates/app/components/site-chrome.css +0 -68
- 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,39 +1,27 @@
|
|
|
1
1
|
// openelement.config.ts — framework options have exactly one home: this file.
|
|
2
2
|
//
|
|
3
|
-
// Every
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// preloads, icons, inline CSS — the entries a URL list
|
|
12
|
-
// cannot express; `head` below covers the rest)
|
|
13
|
-
// - site title: the "name" field of package.json
|
|
3
|
+
// Every key is OPTIONAL; what it omits comes from a file convention:
|
|
4
|
+
// tokens app/styles/theme.css (the @theme role sheet, compiled through
|
|
5
|
+
// the `tailwind` key below)
|
|
6
|
+
// layout app/layout.tsx (auto-registered; delete it and pages still
|
|
7
|
+
// render their own chrome)
|
|
8
|
+
// head app/head.tsx (structural head entries; `head` below covers the
|
|
9
|
+
// title/description/favicon/og pairs)
|
|
10
|
+
// site name the "name" field of package.json
|
|
14
11
|
//
|
|
15
|
-
// The conventions follow `dirs`: give the
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// Passing framework options inline to openElement() while this file carries
|
|
21
|
-
// options is a hard error: framework options cannot have two homes. Unknown
|
|
22
|
-
// keys are rejected with the accepted-key list.
|
|
12
|
+
// The conventions follow `dirs`: give the app roots a shared leading directory
|
|
13
|
+
// and the conventions resolve under it too. Passing options inline to
|
|
14
|
+
// openElement() while this file carries options is a hard error — one home —
|
|
15
|
+
// and unknown keys are rejected with the accepted-key list.
|
|
23
16
|
import { defineConfig } from "@openelement/router";
|
|
24
17
|
|
|
25
18
|
export default defineConfig({
|
|
26
|
-
// The Tailwind
|
|
27
|
-
//
|
|
28
|
-
// serves the compile from /.openElement/tailwind-preset/entry.css and links
|
|
29
|
-
// it in the document head, the build emits the same compile as the
|
|
30
|
-
// layer-ordered /assets/open-tailwind.css after the SSG render. The path is
|
|
31
|
-
// app-relative (resolved against the app root); package CSS specifiers such
|
|
32
|
-
// as '@openelement/ui/theme.css' also work here.
|
|
19
|
+
// The Tailwind entry: the path is app-relative, and package CSS specifiers
|
|
20
|
+
// such as '@openelement/ui/theme.css' work here too.
|
|
33
21
|
tailwind: { theme: ["app/styles/theme.css"] },
|
|
34
22
|
head: {
|
|
35
|
-
//
|
|
36
|
-
//
|
|
23
|
+
// Overrides the package.json-name title fallback; page routes keep their
|
|
24
|
+
// own `head: { title }`.
|
|
37
25
|
title: "openElement Showcase",
|
|
38
26
|
description: "A static-first openElement showcase — rendered before JavaScript arrives.",
|
|
39
27
|
favicon: "/openelement-mark.svg",
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"dev": "
|
|
7
|
+
"dev": "oe dev",
|
|
8
8
|
"build": "oe build",
|
|
9
9
|
"start": "oe start",
|
|
10
10
|
"test": "node --test",
|
|
11
|
-
"fmt": "
|
|
12
|
-
"lint": "
|
|
11
|
+
"fmt": "oxfmt",
|
|
12
|
+
"lint": "oxlint",
|
|
13
13
|
"typecheck": "tsc --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
@@ -19,13 +19,15 @@
|
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@hono/vite-dev-server": "^0.25.3",
|
|
21
21
|
"@tailwindcss/vite": "4.3.3",
|
|
22
|
+
"@types/node": "26.5.0",
|
|
22
23
|
"hono": "^4.12",
|
|
24
|
+
"oxfmt": "0.74.0",
|
|
25
|
+
"oxlint": "1.89.0",
|
|
23
26
|
"tailwindcss": "4.3.3",
|
|
24
27
|
"typescript": "6.0.3",
|
|
25
|
-
"vite
|
|
28
|
+
"vite": "8.1.6"
|
|
26
29
|
},
|
|
27
30
|
"engines": {
|
|
28
31
|
"node": ">=24.2"
|
|
29
|
-
}
|
|
30
|
-
"packageManager": "pnpm@12.8.1"
|
|
32
|
+
}
|
|
31
33
|
}
|
|
@@ -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
|
+
});
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
7
|
"jsx": "react-jsx",
|
|
8
8
|
"jsxImportSource": "@openelement/element",
|
|
9
|
-
"types": ["@openelement/element/css-modules"],
|
|
9
|
+
"types": ["@openelement/element/css-modules", "node"],
|
|
10
10
|
"strict": true,
|
|
11
11
|
"skipLibCheck": true,
|
|
12
12
|
"noEmit": true,
|
|
13
13
|
"allowImportingTsExtensions": true
|
|
14
14
|
},
|
|
15
|
-
"include": ["app", "vite.config.ts", "openelement.config.ts"]
|
|
15
|
+
"include": ["app", "tests", "vite.config.ts", "openelement.config.ts"]
|
|
16
16
|
}
|
|
@@ -1,20 +1,13 @@
|
|
|
1
1
|
import { openElement } from "@openelement/router/vite";
|
|
2
|
-
import { defineConfig } from "vite
|
|
2
|
+
import { defineConfig } from "vite";
|
|
3
3
|
|
|
4
|
-
// Vite configuration only
|
|
5
|
-
// the plugin reads
|
|
6
|
-
// transform is owned by the plugin's compiler pass
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
// tool blocks: `fmt` is what `vp fmt` reads. Its ignore list stays empty —
|
|
11
|
-
// the formatter's defaults already skip markdown, JSON, YAML, and CSS, so
|
|
12
|
-
// the authored sources ship in formatted form and `pnpm fmt --check`
|
|
13
|
-
// (`vp fmt --check`) passes out of the box.
|
|
4
|
+
// Vite configuration only: framework options live in openelement.config.ts,
|
|
5
|
+
// which the plugin reads itself, so the plugin call stays bare, and the JSX
|
|
6
|
+
// transform is owned by the plugin's compiler pass. `vite` is a direct
|
|
7
|
+
// devDependency pinned to the exact version @openelement/router resolves, so
|
|
8
|
+
// the tree carries one Vite copy; `oxfmt` / `oxlint` back the `fmt` / `lint`
|
|
9
|
+
// scripts and run with their defaults (markdown, JSON, YAML and CSS skipped).
|
|
14
10
|
export default defineConfig({
|
|
15
|
-
fmt: {
|
|
16
|
-
ignorePatterns: [],
|
|
17
|
-
},
|
|
18
11
|
base: "/",
|
|
19
12
|
plugins: [...openElement()],
|
|
20
13
|
});
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
.badge {
|
|
2
|
-
display: inline-flex;
|
|
3
|
-
align-items: center;
|
|
4
|
-
gap: 0.4em;
|
|
5
|
-
padding: 0.2rem 0.65rem;
|
|
6
|
-
border-radius: 999px;
|
|
7
|
-
font-size: 0.72rem;
|
|
8
|
-
font-weight: 600;
|
|
9
|
-
letter-spacing: 0.04em;
|
|
10
|
-
text-transform: uppercase;
|
|
11
|
-
border: 1px solid var(--line);
|
|
12
|
-
color: var(--ink-soft);
|
|
13
|
-
background: var(--surface);
|
|
14
|
-
}
|
|
15
|
-
.badge-static {
|
|
16
|
-
border-color: color-mix(in srgb, var(--ok) 35%, transparent);
|
|
17
|
-
color: var(--ok);
|
|
18
|
-
background: color-mix(in srgb, var(--ok) 8%, transparent);
|
|
19
|
-
}
|
|
20
|
-
.badge-island {
|
|
21
|
-
border-color: color-mix(in srgb, var(--brand) 40%, transparent);
|
|
22
|
-
color: var(--brand);
|
|
23
|
-
background: var(--brand-soft);
|
|
24
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: block;
|
|
3
|
-
}
|
|
4
|
-
h1 {
|
|
5
|
-
font-size: 2.4rem;
|
|
6
|
-
letter-spacing: -0.02em;
|
|
7
|
-
margin: 0.75rem 0 0.5rem;
|
|
8
|
-
font-weight: 700;
|
|
9
|
-
}
|
|
10
|
-
p {
|
|
11
|
-
color: var(--ink-soft);
|
|
12
|
-
line-height: 1.6;
|
|
13
|
-
}
|
|
14
|
-
a {
|
|
15
|
-
color: var(--brand);
|
|
16
|
-
font-weight: 600;
|
|
17
|
-
text-decoration: none;
|
|
18
|
-
}
|
|
19
|
-
a:hover {
|
|
20
|
-
text-decoration: underline;
|
|
21
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Styled 404 page element (#923): the request-time server renders this page
|
|
3
|
-
* with a 404 status for unmatched paths; a build with no request-time route
|
|
4
|
-
* prerenders the route (see ./../routes/404.tsx) to dist/404.html instead.
|
|
5
|
-
* The path-derived tag is 'el-404'. Light root: the page owns its rules via
|
|
6
|
-
* `static styles` (the imported .css sheets), inlined into SSR as
|
|
7
|
-
* @scope(el-404). Like every page it renders inside the app shell
|
|
8
|
-
* (app/islands/app-shell.tsx), which owns the header and footer.
|
|
9
|
-
*/
|
|
10
|
-
import { element, OpenElement } from "@openelement/element";
|
|
11
|
-
import notFoundPageStyles from "./page-404.css";
|
|
12
|
-
|
|
13
|
-
@element("el-404", { root: "light" })
|
|
14
|
-
export default class NotFoundPage extends OpenElement {
|
|
15
|
-
static override styles = [notFoundPageStyles];
|
|
16
|
-
|
|
17
|
-
render() {
|
|
18
|
-
return (
|
|
19
|
-
<div class="page-content">
|
|
20
|
-
<h1>404</h1>
|
|
21
|
-
<p>The page you are looking for does not exist.</p>
|
|
22
|
-
<p>
|
|
23
|
-
<a href="/">Back to the homepage</a>
|
|
24
|
-
</p>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
:host {
|
|
2
|
-
display: block;
|
|
3
|
-
}
|
|
4
|
-
.eyebrow {
|
|
5
|
-
color: var(--brand);
|
|
6
|
-
font-weight: 600;
|
|
7
|
-
font-size: 0.78rem;
|
|
8
|
-
letter-spacing: 0.14em;
|
|
9
|
-
text-transform: uppercase;
|
|
10
|
-
margin: 0;
|
|
11
|
-
}
|
|
12
|
-
h1 {
|
|
13
|
-
font-size: clamp(1.9rem, 5vw, 2.6rem);
|
|
14
|
-
line-height: 1.15;
|
|
15
|
-
letter-spacing: -0.02em;
|
|
16
|
-
margin: 0.75rem 0 1rem;
|
|
17
|
-
font-weight: 700;
|
|
18
|
-
}
|
|
19
|
-
.lede {
|
|
20
|
-
font-size: 1.08rem;
|
|
21
|
-
color: var(--ink-soft);
|
|
22
|
-
max-width: 58ch;
|
|
23
|
-
margin: 0 0 2rem;
|
|
24
|
-
}
|
|
25
|
-
h2 {
|
|
26
|
-
font-size: 1.25rem;
|
|
27
|
-
letter-spacing: -0.01em;
|
|
28
|
-
margin: 2.25rem 0 0.6rem;
|
|
29
|
-
}
|
|
30
|
-
p {
|
|
31
|
-
margin: 0.6rem 0;
|
|
32
|
-
max-width: 62ch;
|
|
33
|
-
}
|
|
34
|
-
p code,
|
|
35
|
-
li code {
|
|
36
|
-
font-family: var(--font-mono);
|
|
37
|
-
font-size: 0.85em;
|
|
38
|
-
background: var(--surface);
|
|
39
|
-
border: 1px solid var(--line);
|
|
40
|
-
border-radius: 5px;
|
|
41
|
-
padding: 0.08em 0.35em;
|
|
42
|
-
}
|
|
43
|
-
.conventions {
|
|
44
|
-
list-style: none;
|
|
45
|
-
margin: 1rem 0 0;
|
|
46
|
-
padding: 0;
|
|
47
|
-
border-top: 1px solid var(--line);
|
|
48
|
-
}
|
|
49
|
-
.conventions li {
|
|
50
|
-
display: flex;
|
|
51
|
-
gap: 1rem;
|
|
52
|
-
padding: 0.7rem 0;
|
|
53
|
-
border-bottom: 1px solid var(--line);
|
|
54
|
-
flex-wrap: wrap;
|
|
55
|
-
}
|
|
56
|
-
.conventions code {
|
|
57
|
-
font-family: var(--font-mono);
|
|
58
|
-
font-size: 0.85rem;
|
|
59
|
-
color: var(--brand);
|
|
60
|
-
min-width: 15rem;
|
|
61
|
-
}
|
|
62
|
-
.conventions span {
|
|
63
|
-
color: var(--ink-soft);
|
|
64
|
-
font-size: 0.92rem;
|
|
65
|
-
}
|
|
66
|
-
a {
|
|
67
|
-
color: var(--brand);
|
|
68
|
-
text-decoration: none;
|
|
69
|
-
}
|
|
70
|
-
a:hover {
|
|
71
|
-
text-decoration: underline;
|
|
72
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* About page element — the fully static showcase page.
|
|
3
|
-
*
|
|
4
|
-
* Compiled page with the default static renderIntent: prerendered to HTML at
|
|
5
|
-
* build time (SSG). There are NO islands on this page — everything below is
|
|
6
|
-
* prerendered markup and CSS. The page renders inside the auto-registered
|
|
7
|
-
* app shell (app/islands/app-shell.tsx), which owns the header, main region
|
|
8
|
-
* and footer; the badges come from ./badges.css (light root, inlined into
|
|
9
|
-
* SSR as @scope(about-page)). The compiled grammar lowers one root per
|
|
10
|
-
* render, so the page returns a single content wrapper.
|
|
11
|
-
*/
|
|
12
|
-
import { element, OpenElement } from "@openelement/element";
|
|
13
|
-
import aboutPageStyles from "./page-about.css";
|
|
14
|
-
import badgeStyles from "./badges.css";
|
|
15
|
-
|
|
16
|
-
@element("about-page", { root: "light" })
|
|
17
|
-
export default class AboutPage extends OpenElement {
|
|
18
|
-
static override styles = [aboutPageStyles, badgeStyles];
|
|
19
|
-
|
|
20
|
-
render() {
|
|
21
|
-
return (
|
|
22
|
-
<div class="page-content">
|
|
23
|
-
<span class="badge badge-static">static · no islands on this page</span>
|
|
24
|
-
<p class="eyebrow">About</p>
|
|
25
|
-
<h1>Static first, interactive where it counts</h1>
|
|
26
|
-
<p class="lede">
|
|
27
|
-
openElement prerenders pages to plain HTML and CSS at build time and hydrates compiled
|
|
28
|
-
islands only where a page needs interactivity. This page is the first half of that story:
|
|
29
|
-
it ships no islands at all.
|
|
30
|
-
</p>
|
|
31
|
-
<h2>What happened when you opened this page</h2>
|
|
32
|
-
<p>
|
|
33
|
-
The server sent HTML — prerendered at build time by SSG — plus one inlined stylesheet per
|
|
34
|
-
page scope. No framework runtime executed to produce what you are reading; the markup is
|
|
35
|
-
the artifact.
|
|
36
|
-
</p>
|
|
37
|
-
<h2>Where things live</h2>
|
|
38
|
-
<ul class="conventions">
|
|
39
|
-
<li>
|
|
40
|
-
<code>app/routes/</code>
|
|
41
|
-
<span>page routes — one file per URL, prerendered by default</span>
|
|
42
|
-
</li>
|
|
43
|
-
<li>
|
|
44
|
-
<code>app/routes/api/</code>
|
|
45
|
-
<span>request-time server routes — plain Request → Response handlers</span>
|
|
46
|
-
</li>
|
|
47
|
-
<li>
|
|
48
|
-
<code>app/components/</code>
|
|
49
|
-
<span>compiled page elements and shared style sheets</span>
|
|
50
|
-
</li>
|
|
51
|
-
<li>
|
|
52
|
-
<code>app/islands/</code>
|
|
53
|
-
<span>client islands — the only code that ships JavaScript</span>
|
|
54
|
-
</li>
|
|
55
|
-
<li>
|
|
56
|
-
<code>app/islands/app-shell.tsx</code>
|
|
57
|
-
<span>the shared site chrome wrapped around every page</span>
|
|
58
|
-
</li>
|
|
59
|
-
<li>
|
|
60
|
-
<code>app/styles/theme.css</code>
|
|
61
|
-
<span>design tokens, inlined into every document head</span>
|
|
62
|
-
</li>
|
|
63
|
-
<li>
|
|
64
|
-
<code>app/head.tsx</code>
|
|
65
|
-
<span>structural document-head content (meta tags, preloads)</span>
|
|
66
|
-
</li>
|
|
67
|
-
</ul>
|
|
68
|
-
<h2>See it working</h2>
|
|
69
|
-
<p>
|
|
70
|
-
The <a href="/">home page</a> carries the interactive half: a counter island that hydrates
|
|
71
|
-
on idle and a client-only live timer. Open the browser DevTools on both pages and compare
|
|
72
|
-
the network panels — the badge on each section names what it costs.
|
|
73
|
-
</p>
|
|
74
|
-
</div>
|
|
75
|
-
);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
@@ -1,135 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Home page element — the showcase landing page (static prerendered, the
|
|
3
|
-
* default renderIntent mode).
|
|
4
|
-
*
|
|
5
|
-
* Compiled page: the render() below is lowered to a Part Program
|
|
6
|
-
* at build time. The page uses a light root and owns its rules via
|
|
7
|
-
* `static styles` (the imported .css sheets): the server inlines them into the SSR
|
|
8
|
-
* output as a @scope(index-page) <style data-oe-static-styles> block, so the
|
|
9
|
-
* page is styled with zero client JS. The two island hosts (<my-counter>,
|
|
10
|
-
* <live-timer>) are static custom-element hosts that the generated server
|
|
11
|
-
* entry expands through the islands' own compiled classes.
|
|
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/).
|
|
22
|
-
*/
|
|
23
|
-
import { element, OpenElement } from "@openelement/element";
|
|
24
|
-
import homePageStyles from "./page-home.css";
|
|
25
|
-
import badgeStyles from "./badges.css";
|
|
26
|
-
|
|
27
|
-
@element("index-page", { root: "light" })
|
|
28
|
-
export default class HomePage extends OpenElement {
|
|
29
|
-
static override styles = [homePageStyles, badgeStyles];
|
|
30
|
-
|
|
31
|
-
render() {
|
|
32
|
-
// Single root element: the compiled grammar lowers one root per render.
|
|
33
|
-
return (
|
|
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
|
|
50
|
-
</a>
|
|
51
|
-
</div>
|
|
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>
|
|
80
|
-
</div>
|
|
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>
|
|
113
|
-
</div>
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
}
|