@openelement/create 1.0.0-alpha.10 → 1.0.0-alpha.12
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 +67 -60
- package/package.json +1 -1
- package/src/cli.js +177 -45
- package/src/install-command.d.ts +18 -10
- package/src/install-command.js +19 -12
- package/src/pm.js +30 -0
- package/src/template-builder.js +21 -71
- package/src/version.js +2 -12
- package/templates/README.tmpl +84 -48
- package/templates/app/components/badges.css +5 -0
- package/templates/app/components/page-404.css +7 -0
- package/templates/app/components/page-404.tsx.tmpl +32 -11
- package/templates/app/components/page-about.css +15 -0
- package/templates/app/components/page-about.tsx.tmpl +93 -0
- package/templates/app/components/page-home.css +23 -0
- package/templates/app/components/page-home.tsx.tmpl +113 -39
- package/templates/app/components/site-chrome.css +15 -0
- package/templates/app/head.tsx.tmpl +5 -15
- package/templates/app/islands/live-timer.css +9 -0
- package/templates/app/islands/live-timer.tsx.tmpl +54 -0
- package/templates/app/islands/my-counter.css +11 -0
- package/templates/app/islands/my-counter.tsx.tmpl +5 -21
- package/templates/app/routes/about.tsx.tmpl +10 -0
- package/templates/app/routes/api/ping.ts.tmpl +12 -0
- package/templates/app/routes/index.tsx.tmpl +2 -2
- package/templates/app/styles/recipes.css +43 -0
- package/templates/{tailwind → app/styles}/theme.css +83 -12
- package/templates/openelement.config.ts.tmpl +13 -3
- package/templates/package.json.tmpl +2 -0
- package/templates/tsconfig.json.tmpl +1 -0
- package/templates/vite.config.ts.tmpl +3 -3
- package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
- package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
- package/templates/app/components/page-contact.tsx.tmpl +0 -49
- package/templates/app/components/page-freshness.tsx.tmpl +0 -26
- package/templates/app/components/page-styles.ts.tmpl +0 -123
- package/templates/app/islands/app-shell.tsx.tmpl +0 -83
- package/templates/app/islands/only-ticker.tsx.tmpl +0 -51
- package/templates/app/routes/api/health.ts.tmpl +0 -7
- package/templates/app/routes/blog/index.tsx.tmpl +0 -10
- package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
- package/templates/app/routes/contact.tsx.tmpl +0 -36
- package/templates/app/routes/freshness.tsx.tmpl +0 -17
- package/templates/app/styles/tokens.css +0 -57
- package/templates/tailwind/vite.config.ts.tmpl +0 -38
package/src/template-builder.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CREATE_VERSION,
|
|
1
|
+
import { CREATE_VERSION, VITE_STARTER_PIN } from "./version.js";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
//#region src/template-builder.ts
|
|
4
4
|
const MAX_PROJECT_NAME_LENGTH = 214;
|
|
@@ -41,100 +41,50 @@ const TEMPLATE_FILES = [
|
|
|
41
41
|
["tsconfig.json.tmpl", "tsconfig.json"],
|
|
42
42
|
["vite.config.ts.tmpl", "vite.config.ts"],
|
|
43
43
|
["openelement.config.ts.tmpl", "openelement.config.ts"],
|
|
44
|
-
["app/styles/
|
|
44
|
+
["app/styles/theme.css", "app/styles/theme.css"],
|
|
45
|
+
["app/styles/recipes.css", "app/styles/recipes.css"],
|
|
45
46
|
["app/head.tsx.tmpl", "app/head.tsx"],
|
|
46
|
-
["app/
|
|
47
|
-
["app/components/page-
|
|
47
|
+
["app/components/page-home.css", "app/components/page-home.css"],
|
|
48
|
+
["app/components/page-about.css", "app/components/page-about.css"],
|
|
49
|
+
["app/components/page-404.css", "app/components/page-404.css"],
|
|
50
|
+
["app/components/badges.css", "app/components/badges.css"],
|
|
51
|
+
["app/components/site-chrome.css", "app/components/site-chrome.css"],
|
|
48
52
|
["app/components/page-home.tsx.tmpl", "app/components/page-home.tsx"],
|
|
49
|
-
["app/components/page-
|
|
53
|
+
["app/components/page-about.tsx.tmpl", "app/components/page-about.tsx"],
|
|
50
54
|
["app/components/page-404.tsx.tmpl", "app/components/page-404.tsx"],
|
|
51
|
-
["app/components/page-contact.tsx.tmpl", "app/components/page-contact.tsx"],
|
|
52
|
-
["app/components/page-blog-index.tsx.tmpl", "app/components/page-blog-index.tsx"],
|
|
53
|
-
["app/components/page-blog-welcome.tsx.tmpl", "app/components/page-blog-welcome.tsx"],
|
|
54
|
-
["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
|
|
55
55
|
["app/routes/index.tsx.tmpl", "app/routes/index.tsx"],
|
|
56
|
-
["app/routes/
|
|
57
|
-
["app/routes/
|
|
58
|
-
["app/routes/
|
|
59
|
-
["app/routes/blog/welcome.tsx.tmpl", "app/routes/blog/welcome.tsx"],
|
|
60
|
-
["app/routes/api/health.ts.tmpl", "app/routes/api/health.ts"],
|
|
56
|
+
["app/routes/about.tsx.tmpl", "app/routes/about.tsx"],
|
|
57
|
+
["app/routes/404.tsx.tmpl", "app/routes/404.tsx"],
|
|
58
|
+
["app/routes/api/ping.ts.tmpl", "app/routes/api/ping.ts"],
|
|
61
59
|
["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
|
|
62
|
-
["app/islands/
|
|
60
|
+
["app/islands/my-counter.css", "app/islands/my-counter.css"],
|
|
61
|
+
["app/islands/live-timer.tsx.tmpl", "app/islands/live-timer.tsx"],
|
|
62
|
+
["app/islands/live-timer.css", "app/islands/live-timer.css"]
|
|
63
63
|
];
|
|
64
|
-
/**
|
|
65
|
-
* The Tailwind-ON overlay (#1524): the default scaffold replaces the plain
|
|
66
|
-
* vite config with the preset-wired one and adds the @theme role sheet. The
|
|
67
|
-
* overlay lives in templates/tailwind/ so the OFF form stays exactly the
|
|
68
|
-
* pre-#1524 minimal starter. theme.css carries no scaffold tokens (like
|
|
69
|
-
* tokens.css), so it ships as a plain payload file.
|
|
70
|
-
*/
|
|
71
|
-
const TAILWIND_TEMPLATE_FILES = [["tailwind/vite.config.ts.tmpl", "vite.config.ts"], ["tailwind/theme.css", "app/styles/theme.css"]];
|
|
72
|
-
/** The README section token the Tailwind-ON prose replaces (OFF removes it). */
|
|
73
|
-
const TAILWIND_README_TOKEN = "${tailwind.section}";
|
|
74
|
-
/** The devDependencies the Tailwind-ON scaffold adds (exact pins, no ranges). */
|
|
75
|
-
const TAILWIND_DEV_DEPENDENCIES = {
|
|
76
|
-
"@tailwindcss/vite": TAILWIND_STARTER_PIN,
|
|
77
|
-
tailwindcss: TAILWIND_STARTER_PIN
|
|
78
|
-
};
|
|
79
64
|
function versionTokens(v) {
|
|
80
65
|
return {
|
|
81
66
|
["${v.router}"]: v.router,
|
|
82
67
|
["${v.element}"]: v.element
|
|
83
68
|
};
|
|
84
69
|
}
|
|
85
|
-
async function buildTemplates(v, projectName
|
|
70
|
+
async function buildTemplates(v, projectName) {
|
|
86
71
|
assertUnifiedProductVersions(v);
|
|
87
72
|
const invalid = validateProjectName(projectName);
|
|
88
73
|
if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
|
|
89
|
-
const tailwind = options.tailwind ?? true;
|
|
90
74
|
const templatesBase = new URL("../templates/", import.meta.url);
|
|
91
75
|
const tokens = {
|
|
92
76
|
...versionTokens(v),
|
|
93
77
|
["${v.vite}"]: VITE_STARTER_PIN,
|
|
94
|
-
["${name}"]: projectName
|
|
95
|
-
[TAILWIND_README_TOKEN]: tailwind ? tailwindReadmeSection() : ""
|
|
78
|
+
["${name}"]: projectName
|
|
96
79
|
};
|
|
97
|
-
const
|
|
98
|
-
const entries = await Promise.all(files.map(async ([source, target]) => {
|
|
80
|
+
const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target]) => {
|
|
99
81
|
let content = await readFile(new URL(source, templatesBase), "utf8");
|
|
100
82
|
for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
|
|
101
|
-
if (content.includes("${v.") || content.includes("${name}")
|
|
83
|
+
if (content.includes("${v.") || content.includes("${name}")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
|
|
102
84
|
return [target, content];
|
|
103
85
|
}));
|
|
104
|
-
const
|
|
105
|
-
if (tailwind) {
|
|
106
|
-
const manifestPath = "package.json";
|
|
107
|
-
const manifest = JSON.parse(byTarget.get(manifestPath));
|
|
108
|
-
manifest.devDependencies = Object.fromEntries(Object.entries({
|
|
109
|
-
...manifest.devDependencies,
|
|
110
|
-
...TAILWIND_DEV_DEPENDENCIES
|
|
111
|
-
}).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
112
|
-
byTarget.set(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
|
|
113
|
-
}
|
|
114
|
-
const out = Object.fromEntries(byTarget);
|
|
86
|
+
const out = Object.fromEntries(entries);
|
|
115
87
|
return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
|
|
116
88
|
}
|
|
117
|
-
/**
|
|
118
|
-
* The README prose the Tailwind-ON scaffold injects (the OFF form removes the
|
|
119
|
-
* token line). One source here, so the generated README and the tests cannot
|
|
120
|
-
* drift apart. The leading/trailing newline keeps the injected heading
|
|
121
|
-
* blank-line separated in both replacements.
|
|
122
|
-
*/
|
|
123
|
-
function tailwindReadmeSection() {
|
|
124
|
-
return `
|
|
125
|
-
## Tailwind and the @theme role sheet
|
|
126
|
-
|
|
127
|
-
This project was scaffolded with Tailwind enabled (pass \`--no-tailwind\` to
|
|
128
|
-
\`@openelement/create\` for a starter without it). \`app/styles/theme.css\` is
|
|
129
|
-
the @theme role sheet: semantic roles (background, primary, muted, ...) over
|
|
130
|
-
the Tailwind default scale, with dark pairs and a forced-colors layer. The
|
|
131
|
-
router's Tailwind preset compiles the sheet into one linked bundle during
|
|
132
|
-
\`pnpm build\` and references it from every rendered page; the custom
|
|
133
|
-
properties inherit into every shadow root, so pages and islands can consume
|
|
134
|
-
the roles directly. \`pnpm dev\` serves the tokens convention instead — the
|
|
135
|
-
compiled bundle exists in the build output. Extend the sheet by adding role
|
|
136
|
-
lines; \`@openelement/ui\`'s theme.css documents the same contract.
|
|
137
|
-
`;
|
|
138
|
-
}
|
|
139
89
|
//#endregion
|
|
140
|
-
export {
|
|
90
|
+
export { assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
|
package/src/version.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/version.ts
|
|
2
2
|
/** The published CLI version, embedded so packed npm installs are self-contained. */
|
|
3
|
-
const CREATE_VERSION = "1.0.0-alpha.
|
|
3
|
+
const CREATE_VERSION = "1.0.0-alpha.12";
|
|
4
4
|
/**
|
|
5
5
|
* The Vite release pinned into the generated starter's package.json (the
|
|
6
6
|
* `${v.vite}` scaffold token in the npm/pnpm starter). Embedded for the same
|
|
@@ -9,15 +9,5 @@ const CREATE_VERSION = "1.0.0-alpha.10";
|
|
|
9
9
|
* to the canonical dev pin.
|
|
10
10
|
*/
|
|
11
11
|
const VITE_STARTER_PIN = "8.0.16";
|
|
12
|
-
/**
|
|
13
|
-
* The Tailwind line pinned into the generated starter's devDependencies (the
|
|
14
|
-
* Tailwind-ON scaffold, #1524): both `tailwindcss` and `@tailwindcss/vite`,
|
|
15
|
-
* exactly, aligned with the router's own dev pins. The 4.3.x line is the
|
|
16
|
-
* preset's supported line (the v3-lts line is forbidden — see the router's
|
|
17
|
-
* preset-tailwind module). Embedded like the other pins so packed npm
|
|
18
|
-
* installs stay self-contained; the create tests anchor this copy to the
|
|
19
|
-
* router manifest the way deps:vite-check anchors VITE_STARTER_PIN.
|
|
20
|
-
*/
|
|
21
|
-
const TAILWIND_STARTER_PIN = "4.3.3";
|
|
22
12
|
//#endregion
|
|
23
|
-
export { CREATE_VERSION,
|
|
13
|
+
export { CREATE_VERSION, VITE_STARTER_PIN };
|
package/templates/README.tmpl
CHANGED
|
@@ -1,31 +1,47 @@
|
|
|
1
|
-
#
|
|
1
|
+
# openElement Showcase
|
|
2
2
|
|
|
3
|
-
Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create)
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create) —
|
|
4
|
+
scaffold it elsewhere with `npm create @openelement <project-name>` —
|
|
5
|
+
a static-first openElement app that shows its own costs. The landing page
|
|
6
|
+
carries two islands (`my-counter`, an interactive counter, and `live-timer`,
|
|
7
|
+
a client-only elapsed-time readout); every other page, including `/about`,
|
|
8
|
+
is prerendered HTML and CSS with no islands at all. The badge on each
|
|
9
|
+
section names what it costs the client.
|
|
10
|
+
|
|
11
|
+
Docs and guides: https://openelement.org
|
|
7
12
|
|
|
8
13
|
One directory is generated rather than source: `.openElement/` at the project
|
|
9
|
-
root holds the build's internal state
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
`.gitignore` excludes it, and deleting it is safe — the next dev run or build
|
|
13
|
-
recreates it.
|
|
14
|
+
root holds the build's internal state (head-convention bookkeeping and build
|
|
15
|
+
plans). `pnpm dev` and `pnpm build` write it as needed; the `.gitignore`
|
|
16
|
+
excludes it and deleting it is safe — the next run recreates it.
|
|
14
17
|
|
|
15
18
|
This starter pins the exact `@openelement/element` and `@openelement/router`
|
|
16
|
-
versions it was generated from
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
19
|
+
versions it was generated from in `package.json`; update both there when
|
|
20
|
+
moving to a new release.
|
|
21
|
+
|
|
22
|
+
## The JS cost map
|
|
23
|
+
|
|
24
|
+
| Surface | Ships JavaScript? | Why |
|
|
25
|
+
| --- | --- | --- |
|
|
26
|
+
| `/` hero + architecture sections | no | prerendered markup, styled with CSS |
|
|
27
|
+
| `/` counter island (`my-counter`) | yes, hydrates on idle | the one interactive piece |
|
|
28
|
+
| `/` live timer island (`live-timer`) | yes, client-only | a live clock has nothing to prerender |
|
|
29
|
+
| `/about` | no islands at all | fully static SSG output |
|
|
30
|
+
| `/api/ping` | no (server) | a plain `Request → Response` handler |
|
|
31
|
+
|
|
32
|
+
The badge classes (`badge-static`, `badge-island`) live in
|
|
33
|
+
`app/components/badges.css` — copy them onto new sections and keep the
|
|
34
|
+
map honest.
|
|
35
|
+
|
|
36
|
+
> Cost honesty: the island client is emitted app-wide today. A page without
|
|
37
|
+
> islands (like `/about`) carries no island hosts and renders nothing
|
|
38
|
+
> interactive, but the shared loader — and with the current app-wide
|
|
39
|
+
> hydration manifest, the island chunks themselves — still ride along in its
|
|
40
|
+
> network panel. Per-page pruning is framework work, not something a template
|
|
41
|
+
> can opt into; the page is authored so it becomes fully silent the moment
|
|
42
|
+
> the framework ships it.
|
|
43
|
+
|
|
44
|
+
## Where things live
|
|
29
45
|
|
|
30
46
|
Framework options have exactly one home: `openelement.config.ts`. It is
|
|
31
47
|
optional and nearly empty — every option it omits comes from a file
|
|
@@ -33,16 +49,32 @@ convention:
|
|
|
33
49
|
|
|
34
50
|
| Option | Convention |
|
|
35
51
|
| --- | --- |
|
|
36
|
-
| design tokens | `app/styles/
|
|
37
|
-
| app shell | `app/islands/app-shell.tsx` (deletable) |
|
|
52
|
+
| design tokens | `app/styles/theme.css` (the @theme role sheet) |
|
|
38
53
|
| document head content | `app/head.tsx` (meta tags, preloads, inline CSS) |
|
|
39
54
|
| site title | the `name` field of `package.json` |
|
|
55
|
+
| static-shape recipes | `app/styles/recipes.css` (zero-interaction badge/callout/card/tabs shapes as plain HTML+CSS — the @openelement/ui components retired to these recipes in #1557) |
|
|
40
56
|
|
|
41
57
|
Passing framework options inline to `openElement()` while the config file
|
|
42
58
|
carries options is a hard error, and an unknown key fails the build with the
|
|
43
59
|
accepted-key list. `vite.config.ts` stays Vite-only: `plugins: [...openElement()]`.
|
|
44
|
-
|
|
45
|
-
`
|
|
60
|
+
|
|
61
|
+
- `app/routes/` — page routes, one file per URL. The default renderIntent is
|
|
62
|
+
`static`: prerendered at build time (SSG). `/about` and `/` are static.
|
|
63
|
+
- `app/routes/api/` — request-time server routes. `/api/ping` is a plain
|
|
64
|
+
WinterCG-shaped handler returning `Response.json`.
|
|
65
|
+
- `app/components/` — compiled page elements and their style sheets
|
|
66
|
+
(page CSS lives in `.css` files next to each element; pages import and
|
|
67
|
+
array them in `static styles`, sharing `site-chrome.css`/`badges.css`).
|
|
68
|
+
- `app/islands/` — client islands, the only code that ships JavaScript. Each
|
|
69
|
+
island declares its hydration strategy (`idle`, `load`, `visible`,
|
|
70
|
+
client-only) through `defineIslandConfig`.
|
|
71
|
+
- `app/styles/theme.css` — the @theme role sheet: Tailwind-ON roles, the starter palette aliases, dark and forced-colors pairs. Dev serves it directly; the build compiles it through the router's Tailwind preset.
|
|
72
|
+
Dark values ride `prefers-color-scheme`; no theme runtime.
|
|
73
|
+
- `app/styles/recipes.css` — documented plain HTML+CSS recipes for the
|
|
74
|
+
zero-interaction shapes (badge, callout, card, CSS-only tabs) that retired
|
|
75
|
+
from `@openelement/ui` (#1557). Delete the blocks you do not use: static
|
|
76
|
+
content never justifies a custom element.
|
|
77
|
+
- `app/head.tsx` — structural head content the URL list cannot express.
|
|
46
78
|
|
|
47
79
|
## Scripts
|
|
48
80
|
|
|
@@ -52,30 +84,34 @@ The conventions follow the `dirs` block, so moving the three roots under
|
|
|
52
84
|
automatically.
|
|
53
85
|
- `pnpm test` — run Node's built-in test runner (the starter ships none).
|
|
54
86
|
- `pnpm build` — production build (SSG + Nitro server) into `dist/`.
|
|
55
|
-
- `pnpm start` — serve the production build.
|
|
56
|
-
|
|
57
|
-
`pnpm preview` (static-only preview, #601) is refused by design.
|
|
58
|
-
- `pnpm preview` — static-only preview; refused for this starter (see
|
|
59
|
-
above).
|
|
87
|
+
- `pnpm start` — serve the production build.
|
|
88
|
+
- `pnpm preview` — static-only preview of the SSG output.
|
|
60
89
|
|
|
61
|
-
##
|
|
90
|
+
## Styling ownership
|
|
62
91
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
the
|
|
69
|
-
|
|
70
|
-
## Dependency notes
|
|
71
|
-
|
|
72
|
-
`hono` and `@hono/vite-dev-server` are installed even though no source file
|
|
73
|
-
imports them: the dev server resolves `hono` when loading the generated
|
|
74
|
-
server entry (the bundled `dist/` output inlines it). For Nitro deployments,
|
|
75
|
-
the built handler bridges through the `@openelement/router/nitro-mount`
|
|
76
|
-
subpath of the one `@openelement/router` dependency. Do not remove them.
|
|
92
|
+
Global design tokens and the document baseline (`body`, `::selection`) live
|
|
93
|
+
in `app/styles/theme.css`. Pages use light roots and own their rules in
|
|
94
|
+
`static styles`, arrayed from imported `.css` files (#1558 — the one style
|
|
95
|
+
authoring form): the server inlines each page's sheets into the SSR output as
|
|
96
|
+
a `@scope(<page-tag>)` style block, so pages are fully styled with zero
|
|
97
|
+
client JavaScript. Islands carry their own `.css` sheets the same way; in
|
|
98
|
+
island chunks those ride the style-asset protocol as real `.css` assets.
|
|
77
99
|
|
|
78
100
|
## Brand assets
|
|
79
101
|
|
|
80
102
|
`public/openelement-mark.svg` is the openElement brand mark shipped with the
|
|
81
|
-
starter —
|
|
103
|
+
starter — the config file references it as the favicon, or delete it if
|
|
104
|
+
unused.
|
|
105
|
+
|
|
106
|
+
## Dependency notes
|
|
107
|
+
|
|
108
|
+
`@hono/vite-dev-server` is installed even though no source file imports it:
|
|
109
|
+
the Vite dev server needs it, and it is loaded lazily, so `build`/`start`
|
|
110
|
+
never resolve it. `hono` rides along because the dev server's own node
|
|
111
|
+
adapter declares it a peer. The generated server entry itself imports no
|
|
112
|
+
HTTP framework — it composes on the internal WinterCG layer (#1560); `hono`
|
|
113
|
+
is an optional peer of `@openelement/router`, and `@openelement/router/hono`
|
|
114
|
+
(`createHonoAdapter`) is the one opt-in if you ever want to mount the built
|
|
115
|
+
handler inside your own Hono app. For Nitro deployments, the built handler
|
|
116
|
+
bridges through the `@openelement/router/nitro-mount` subpath of the one
|
|
117
|
+
`@openelement/router` dependency. Do not remove them.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
|
|
2
|
+
.badge { display: inline-flex; align-items: center; gap: 0.4em; padding: 0.2rem 0.65rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; border: 1px solid var(--line); color: var(--ink-soft); background: var(--surface); }
|
|
3
|
+
.badge-static { border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, transparent); }
|
|
4
|
+
.badge-island { border-color: color-mix(in srgb, var(--brand) 40%, transparent); color: var(--brand); background: var(--brand-soft); }
|
|
5
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
|
|
2
|
+
:host { display: block; }
|
|
3
|
+
h1 { font-size: 2.4rem; letter-spacing: -0.02em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
|
|
4
|
+
p { color: var(--ink-soft); line-height: 1.6; }
|
|
5
|
+
a { color: var(--brand); font-weight: 600; text-decoration: none; }
|
|
6
|
+
a:hover { text-decoration: underline; }
|
|
7
|
+
|
|
@@ -2,25 +2,46 @@
|
|
|
2
2
|
* Styled 404 page element (#923): the request-time server renders this page
|
|
3
3
|
* with a 404 status for unmatched paths; SSG builds also emit it as static
|
|
4
4
|
* 404.html. The path-derived tag is 'el-404'. Light root: the page owns its
|
|
5
|
-
* rules via `static styles` (
|
|
6
|
-
* @scope(el-404).
|
|
5
|
+
* rules via `static styles` (the imported .css sheets), inlined into SSR as
|
|
6
|
+
* @scope(el-404). The site chrome sheet (./site-chrome.css) is shared
|
|
7
7
|
*/
|
|
8
8
|
import { element, OpenElement } from '@openelement/element';
|
|
9
|
-
import
|
|
9
|
+
import notFoundPageStyles from './page-404.css';
|
|
10
|
+
import siteChromeStyles from './site-chrome.css';
|
|
10
11
|
|
|
11
12
|
@element('el-404', { root: 'light' })
|
|
12
13
|
export default class NotFoundPage extends OpenElement {
|
|
13
|
-
static override styles = notFoundPageStyles;
|
|
14
|
+
static override styles = [notFoundPageStyles, siteChromeStyles];
|
|
14
15
|
|
|
15
16
|
render() {
|
|
16
17
|
return (
|
|
17
|
-
<
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
18
|
+
<div class='page-body'>
|
|
19
|
+
<header class='site-head'>
|
|
20
|
+
<div class='bar'>
|
|
21
|
+
<a class='site-brand' href='/'>
|
|
22
|
+
openElement
|
|
23
|
+
</a>
|
|
24
|
+
<nav>
|
|
25
|
+
<a href='/'>Home</a>
|
|
26
|
+
<a href='/about'>About</a>
|
|
27
|
+
<a href='/api/ping'>API</a>
|
|
28
|
+
</nav>
|
|
29
|
+
</div>
|
|
30
|
+
</header>
|
|
31
|
+
<main>
|
|
32
|
+
<h1>404</h1>
|
|
33
|
+
<p>The page you are looking for does not exist.</p>
|
|
34
|
+
<p>
|
|
35
|
+
<a href='/'>Back to the homepage</a>
|
|
36
|
+
</p>
|
|
37
|
+
</main>
|
|
38
|
+
<footer class='site-foot'>
|
|
39
|
+
<div class='bar'>
|
|
40
|
+
<span>Generated by @openelement/create.</span>
|
|
41
|
+
<a href='https://openelement.org'>openelement.org</a>
|
|
42
|
+
</div>
|
|
43
|
+
</footer>
|
|
44
|
+
</div>
|
|
24
45
|
);
|
|
25
46
|
}
|
|
26
47
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
|
|
2
|
+
:host { display: block; }
|
|
3
|
+
.eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 0; }
|
|
4
|
+
h1 { font-size: clamp(1.9rem, 5vw, 2.6rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0.75rem 0 1rem; font-weight: 700; }
|
|
5
|
+
.lede { font-size: 1.08rem; color: var(--ink-soft); max-width: 58ch; margin: 0 0 2rem; }
|
|
6
|
+
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 2.25rem 0 0.6rem; }
|
|
7
|
+
p { margin: 0.6rem 0; max-width: 62ch; }
|
|
8
|
+
p code, li code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0.08em 0.35em; }
|
|
9
|
+
.conventions { list-style: none; margin: 1rem 0 0; padding: 0; border-top: 1px solid var(--line); }
|
|
10
|
+
.conventions li { display: flex; gap: 1rem; padding: 0.7rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
|
|
11
|
+
.conventions code { font-family: var(--font-mono); font-size: 0.85rem; color: var(--brand); min-width: 15rem; }
|
|
12
|
+
.conventions span { color: var(--ink-soft); font-size: 0.92rem; }
|
|
13
|
+
a { color: var(--brand); text-decoration: none; }
|
|
14
|
+
a:hover { text-decoration: underline; }
|
|
15
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
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 header, footer and badges come from the
|
|
7
|
+
* shared sheets in ./site-chrome.css and ./badges.css (light root, inlined
|
|
8
|
+
* into SSR as @scope(about-page)).
|
|
9
|
+
*/
|
|
10
|
+
import { element, OpenElement } from '@openelement/element';
|
|
11
|
+
import aboutPageStyles from './page-about.css';
|
|
12
|
+
import badgeStyles from './badges.css';
|
|
13
|
+
import siteChromeStyles from './site-chrome.css';
|
|
14
|
+
|
|
15
|
+
@element('about-page', { root: 'light' })
|
|
16
|
+
export default class AboutPage extends OpenElement {
|
|
17
|
+
static override styles = [aboutPageStyles, badgeStyles, siteChromeStyles];
|
|
18
|
+
|
|
19
|
+
render() {
|
|
20
|
+
return (
|
|
21
|
+
<div class='page-body'>
|
|
22
|
+
<header class='site-head'>
|
|
23
|
+
<div class='bar'>
|
|
24
|
+
<a class='site-brand' href='/'>
|
|
25
|
+
openElement
|
|
26
|
+
</a>
|
|
27
|
+
<nav>
|
|
28
|
+
<a href='/'>Home</a>
|
|
29
|
+
<a href='/about'>About</a>
|
|
30
|
+
<a href='/api/ping'>API</a>
|
|
31
|
+
</nav>
|
|
32
|
+
</div>
|
|
33
|
+
</header>
|
|
34
|
+
<main>
|
|
35
|
+
<span class='badge badge-static'>static · no islands on this page</span>
|
|
36
|
+
<p class='eyebrow'>About</p>
|
|
37
|
+
<h1>Static first, interactive where it counts</h1>
|
|
38
|
+
<p class='lede'>
|
|
39
|
+
openElement prerenders pages to plain HTML and CSS at build time and
|
|
40
|
+
hydrates compiled islands only where a page needs interactivity. This
|
|
41
|
+
page is the first half of that story: it ships no islands at all.
|
|
42
|
+
</p>
|
|
43
|
+
<h2>What happened when you opened this page</h2>
|
|
44
|
+
<p>
|
|
45
|
+
The server sent HTML — prerendered at build time by SSG — plus one
|
|
46
|
+
inlined stylesheet per page scope. No framework runtime executed to
|
|
47
|
+
produce what you are reading; the markup is the artifact.
|
|
48
|
+
</p>
|
|
49
|
+
<h2>Where things live</h2>
|
|
50
|
+
<ul class='conventions'>
|
|
51
|
+
<li>
|
|
52
|
+
<code>app/routes/</code>
|
|
53
|
+
<span>page routes — one file per URL, prerendered by default</span>
|
|
54
|
+
</li>
|
|
55
|
+
<li>
|
|
56
|
+
<code>app/routes/api/</code>
|
|
57
|
+
<span>request-time server routes — plain Request → Response handlers</span>
|
|
58
|
+
</li>
|
|
59
|
+
<li>
|
|
60
|
+
<code>app/components/</code>
|
|
61
|
+
<span>compiled page elements and shared style sheets</span>
|
|
62
|
+
</li>
|
|
63
|
+
<li>
|
|
64
|
+
<code>app/islands/</code>
|
|
65
|
+
<span>client islands — the only code that ships JavaScript</span>
|
|
66
|
+
</li>
|
|
67
|
+
<li>
|
|
68
|
+
<code>app/styles/theme.css</code>
|
|
69
|
+
<span>design tokens, inlined into every document head</span>
|
|
70
|
+
</li>
|
|
71
|
+
<li>
|
|
72
|
+
<code>app/head.tsx</code>
|
|
73
|
+
<span>structural document-head content (meta tags, preloads)</span>
|
|
74
|
+
</li>
|
|
75
|
+
</ul>
|
|
76
|
+
<h2>See it working</h2>
|
|
77
|
+
<p>
|
|
78
|
+
The <a href='/'>home page</a> carries the interactive half: a counter
|
|
79
|
+
island that hydrates on idle and a client-only live timer. Open your
|
|
80
|
+
browser's DevTools on both pages and compare the network panels — the
|
|
81
|
+
badge on each section names what it costs.
|
|
82
|
+
</p>
|
|
83
|
+
</main>
|
|
84
|
+
<footer class='site-foot'>
|
|
85
|
+
<div class='bar'>
|
|
86
|
+
<span>Generated by @openelement/create.</span>
|
|
87
|
+
<a href='https://openelement.org'>openelement.org</a>
|
|
88
|
+
</div>
|
|
89
|
+
</footer>
|
|
90
|
+
</div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
|
|
2
|
+
:host { display: block; }
|
|
3
|
+
.hero { padding: 2.5rem 0 1rem; }
|
|
4
|
+
.eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; margin: 0; }
|
|
5
|
+
h1 { font-size: clamp(2.2rem, 6vw, 3.2rem); line-height: 1.1; letter-spacing: -0.02em; margin: 0.75rem 0 1rem; font-weight: 700; max-width: 22ch; }
|
|
6
|
+
.lede { font-size: 1.12rem; line-height: 1.75; color: var(--ink-soft); max-width: 56ch; margin: 0; }
|
|
7
|
+
.lede code, .panel p code { font-family: var(--font-mono); font-size: 0.85em; background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0.08em 0.35em; }
|
|
8
|
+
.cta { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; margin-top: 1.75rem; }
|
|
9
|
+
.button { display: inline-block; padding: 0.6rem 1.15rem; border-radius: var(--radius-m); background: var(--brand); border: 1px solid var(--brand); color: var(--brand-ink); font-weight: 600; text-decoration: none; transition: opacity 0.15s ease; }
|
|
10
|
+
.button:hover { opacity: 0.88; text-decoration: none; }
|
|
11
|
+
.button-ghost { display: inline-block; padding: 0.6rem 1.15rem; border-radius: var(--radius-m); border: 1px solid var(--line); color: var(--ink); font-weight: 600; text-decoration: none; background: var(--paper); transition: border-color 0.15s ease, color 0.15s ease; }
|
|
12
|
+
.button-ghost:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
|
|
13
|
+
.panel { margin-top: 2.5rem; border: 1px solid var(--line); border-radius: var(--radius-l); padding: 1.5rem 1.75rem; background: var(--paper); box-shadow: var(--shadow-1); }
|
|
14
|
+
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
|
|
15
|
+
.panel-head h2 { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
|
|
16
|
+
.panel > p { color: var(--ink-soft); margin: 0.35rem 0 1.25rem; max-width: 60ch; }
|
|
17
|
+
.cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); }
|
|
18
|
+
.card { border: 1px solid var(--line); border-radius: var(--radius-m); padding: 1rem 1.15rem; background: var(--surface); }
|
|
19
|
+
.card h3 { margin: 0.6rem 0 0.35rem; font-size: 1rem; }
|
|
20
|
+
.card p { margin: 0; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.6; }
|
|
21
|
+
a { color: var(--brand); text-decoration: none; }
|
|
22
|
+
a:hover { text-decoration: underline; }
|
|
23
|
+
|