@openelement/create 1.0.0-alpha.10 → 1.0.0-alpha.11

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.
Files changed (43) hide show
  1. package/README.md +49 -44
  2. package/package.json +1 -1
  3. package/src/cli.js +177 -45
  4. package/src/pm.js +30 -0
  5. package/src/template-builder.js +21 -71
  6. package/src/version.js +2 -12
  7. package/templates/README.tmpl +84 -48
  8. package/templates/app/components/badges.css +5 -0
  9. package/templates/app/components/page-404.css +7 -0
  10. package/templates/app/components/page-404.tsx.tmpl +32 -11
  11. package/templates/app/components/page-about.css +15 -0
  12. package/templates/app/components/page-about.tsx.tmpl +93 -0
  13. package/templates/app/components/page-home.css +23 -0
  14. package/templates/app/components/page-home.tsx.tmpl +113 -39
  15. package/templates/app/components/site-chrome.css +15 -0
  16. package/templates/app/head.tsx.tmpl +5 -15
  17. package/templates/app/islands/live-timer.css +6 -0
  18. package/templates/app/islands/live-timer.tsx.tmpl +54 -0
  19. package/templates/app/islands/my-counter.css +11 -0
  20. package/templates/app/islands/my-counter.tsx.tmpl +5 -21
  21. package/templates/app/routes/about.tsx.tmpl +10 -0
  22. package/templates/app/routes/api/ping.ts.tmpl +12 -0
  23. package/templates/app/routes/index.tsx.tmpl +2 -2
  24. package/templates/app/styles/recipes.css +43 -0
  25. package/templates/{tailwind → app/styles}/theme.css +74 -12
  26. package/templates/openelement.config.ts.tmpl +11 -3
  27. package/templates/package.json.tmpl +2 -0
  28. package/templates/tsconfig.json.tmpl +1 -0
  29. package/templates/vite.config.ts.tmpl +3 -3
  30. package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
  31. package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
  32. package/templates/app/components/page-contact.tsx.tmpl +0 -49
  33. package/templates/app/components/page-freshness.tsx.tmpl +0 -26
  34. package/templates/app/components/page-styles.ts.tmpl +0 -123
  35. package/templates/app/islands/app-shell.tsx.tmpl +0 -83
  36. package/templates/app/islands/only-ticker.tsx.tmpl +0 -51
  37. package/templates/app/routes/api/health.ts.tmpl +0 -7
  38. package/templates/app/routes/blog/index.tsx.tmpl +0 -10
  39. package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
  40. package/templates/app/routes/contact.tsx.tmpl +0 -36
  41. package/templates/app/routes/freshness.tsx.tmpl +0 -17
  42. package/templates/app/styles/tokens.css +0 -57
  43. package/templates/tailwind/vite.config.ts.tmpl +0 -38
@@ -1,31 +1,47 @@
1
- # My openElement App
1
+ # openElement Showcase
2
2
 
3
- Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create).
4
- A file-based openElement app: page routes live in `app/routes/`, compiled page
5
- elements and shared style sheets in `app/components/`, and client islands
6
- (including the `app-shell` layout island) in `app/islands/`.
3
+ Generated by [`@openelement/create`](https://www.npmjs.com/package/@openelement/create) —
4
+ scaffold it elsewhere with `npm create @openelement@1.0.0-alpha.10 <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. The router compiles the `app/head.tsx`
10
- head convention there (build-plan bookkeeping and Tailwind preset staging land
11
- alongside); `pnpm dev` and `pnpm build` write it as needed. The starter's
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 (`${v.element}`) in `package.json`; update both
17
- there when moving to a new release.
18
-
19
- Styling ownership is split three ways. Global design tokens and the document
20
- baseline (`body`, `::selection`) live in `app/styles/tokens.css` — the file
21
- convention the build inlines into every document `<head>`. Pages use light
22
- roots and own their rules in `static styles`
23
- (`app/components/page-styles.ts`): the server inlines each page's sheets into
24
- the SSR output as a `@scope(<page-tag>)` style block, so pages are fully styled
25
- with zero client JavaScript. The shell and the islands hydrate in the browser
26
- and carry their own `static styles`.
27
- ${tailwind.section}
28
- ## Where options live
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/tokens.css` |
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
- The conventions follow the `dirs` block, so moving the three roots under
45
- `src/` moves the token, shell and head files with them.
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. Use this for production
56
- preview: the starter ships a request-time route (`/contact`), so
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
- ## Blog
90
+ ## Styling ownership
62
91
 
63
- Blog posts are compiled page routes: `app/routes/blog/welcome.tsx` renders at
64
- `/blog/welcome`, prerendered at build time. Add a post by creating a page
65
- element under `app/components/` and a route module under `app/routes/blog/`,
66
- then link it from `app/routes/blog/index.tsx` (the index list is static
67
- authoring). Interactive content belongs in a compiled island composed from
68
- the page.
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 — use it for a favicon or page header, or delete it if unused.
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` (./page-styles.ts), inlined into SSR as
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 { notFoundPageStyles } from './page-styles.ts';
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
- <main>
18
- <h1>404</h1>
19
- <p>The page you are looking for does not exist.</p>
20
- <p>
21
- <a href='/'>Back to the homepage</a>
22
- </p>
23
- </main>
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
+
@@ -1,58 +1,132 @@
1
1
  /**
2
- * Home page element — static prerendered (default renderIntent mode).
2
+ * Home page element — the showcase landing page (static prerendered, the
3
+ * default renderIntent mode).
3
4
  *
4
5
  * Compiled page: the render() below is lowered to a Part Program
5
6
  * at build time. The page uses a light root and owns its rules via
6
- * `static styles` (./page-styles.ts): the server inlines them into the SSR
7
+ * `static styles` (the imported .css sheets): the server inlines them into the SSR
7
8
  * output as a @scope(index-page) <style data-oe-static-styles> block, so the
8
9
  * page is styled with zero client JS. The two island hosts (<my-counter>,
9
- * <only-ticker>) are static custom-element hosts that the generated server
10
+ * <live-timer>) are static custom-element hosts that the generated server
10
11
  * entry expands through the islands' own compiled classes.
12
+ *
13
+ * The badge spans name each section's client cost: static sections ship
14
+ * markup only; island sections hydrate a compiled island (see the island
15
+ * modules under app/islands/).
11
16
  */
12
17
  import { element, OpenElement } from '@openelement/element';
13
- import { homePageStyles } from './page-styles.ts';
18
+ import homePageStyles from './page-home.css';
19
+ import badgeStyles from './badges.css';
20
+ import siteChromeStyles from './site-chrome.css';
14
21
 
15
22
  @element('index-page', { root: 'light' })
16
23
  export default class HomePage extends OpenElement {
17
- static override styles = homePageStyles;
24
+ static override styles = [homePageStyles, badgeStyles, siteChromeStyles];
18
25
 
19
26
  render() {
27
+ // Single root element: the compiled grammar lowers one root per render.
20
28
  return (
21
- <main>
22
- <section class='hero'>
23
- <span class='eyebrow'>openElement starter</span>
24
- <h1>Static pages, alive where it counts</h1>
25
- <p class='lede'>
26
- Your app is running. Edit <code>app/routes/index.tsx</code>{' '}
27
- to make it yours — add posts under <code>app/routes/blog/</code>, add pages under{' '}
28
- <code>app/routes/</code>, and hydrate only the components that need it.
29
- </p>
30
- <a class='more' href='/blog'>Read the blog →</a>
31
- </section>
32
- <section class='demo'>
33
- <p class='label'>Live island — hydrates on idle</p>
34
- <my-counter></my-counter>
35
- </section>
36
- <section class='demo'>
37
- <p class='label'>Client-only island — renders without SSR</p>
38
- <only-ticker></only-ticker>
39
- </section>
40
- <section class='recent'>
41
- <h2>From the blog</h2>
42
- <p class='sub'>
43
- Posts are compiled page routes under{' '}
44
- <code>app/routes/blog/</code>, prerendered at build time.
45
- </p>
46
- <ul class='posts'>
47
- <li>
48
- <a class='post' href='/blog/welcome'>
49
- <span class='title'>Welcome</span>
50
- <span class='meta'>Your first post — edit app/routes/blog/welcome.tsx</span>
29
+ <div class='page-body'>
30
+ <header class='site-head'>
31
+ <div class='bar'>
32
+ <a class='site-brand' href='/'>
33
+ openElement
34
+ </a>
35
+ <nav>
36
+ <a href='/'>Home</a>
37
+ <a href='/about'>About</a>
38
+ <a href='/api/ping'>API</a>
39
+ </nav>
40
+ </div>
41
+ </header>
42
+ <main>
43
+ <section class='hero'>
44
+ <span class='badge badge-static'>static · 0 KB JS</span>
45
+ <p class='eyebrow'>openElement starter</p>
46
+ <h1>Rendered before JavaScript arrives</h1>
47
+ <p class='lede'>
48
+ Every page here is prerendered HTML. JavaScript loads only where a
49
+ section is interactive — the badges below name the cost of each
50
+ block. Edit <code>app/routes/index.tsx</code> to make it yours.
51
+ </p>
52
+ <div class='cta'>
53
+ <a class='button' href='/about'>
54
+ How it works
55
+ </a>
56
+ <a class='button-ghost' href='https://openelement.org'>
57
+ Read the docs
51
58
  </a>
52
- </li>
53
- </ul>
54
- </section>
55
- </main>
59
+ </div>
60
+ </section>
61
+ <section class='panel'>
62
+ <div class='panel-head'>
63
+ <h2>Interactive island</h2>
64
+ <span class='badge badge-island'>island · hydrates on idle</span>
65
+ </div>
66
+ <p>
67
+ The counter is a compiled island (<code>app/islands/my-counter.tsx</code>
68
+ ): the server renders its markup, the browser hydrates it when idle.
69
+ </p>
70
+ <my-counter></my-counter>
71
+ </section>
72
+ <section class='panel'>
73
+ <div class='panel-head'>
74
+ <h2>Live stats</h2>
75
+ <span class='badge badge-island'>island · client-only</span>
76
+ </div>
77
+ <p>
78
+ Elapsed time on this page (<code>app/islands/live-timer.tsx</code>) renders
79
+ only in the browser — a live clock has nothing meaningful to
80
+ prerender, so the island ships <code>ssr: false</code>.
81
+ </p>
82
+ <live-timer></live-timer>
83
+ </section>
84
+ <section class='panel'>
85
+ <div class='panel-head'>
86
+ <h2>The architecture</h2>
87
+ <span class='badge badge-static'>static · 0 KB JS</span>
88
+ </div>
89
+ <p>
90
+ This section — like the hero and this page's header — is plain
91
+ prerendered HTML and CSS. No framework script runs it.
92
+ </p>
93
+ <ul class='cards'>
94
+ <li class='card'>
95
+ <span class='badge badge-static'>static</span>
96
+ <h3>Prerendered pages</h3>
97
+ <p>
98
+ Routes under <code>app/routes/</code> compile to static HTML at
99
+ build time (SSG) and keep their HTTP cache semantics.
100
+ </p>
101
+ </li>
102
+ <li class='card'>
103
+ <span class='badge badge-island'>island</span>
104
+ <h3>Islands where needed</h3>
105
+ <p>
106
+ Interactive pieces live in <code>app/islands/</code> and hydrate
107
+ on the strategy each one declares — idle, load, visible, or
108
+ client-only.
109
+ </p>
110
+ </li>
111
+ <li class='card'>
112
+ <span class='badge badge-static'>static</span>
113
+ <h3>Platform APIs</h3>
114
+ <p>
115
+ Server routes (<code>app/routes/api/</code>) are plain{' '}
116
+ <code>Request → Response</code> handlers — WinterCG-shaped, no
117
+ framework runtime attached.
118
+ </p>
119
+ </li>
120
+ </ul>
121
+ </section>
122
+ </main>
123
+ <footer class='site-foot'>
124
+ <div class='bar'>
125
+ <span>Generated by @openelement/create.</span>
126
+ <a href='https://openelement.org'>openelement.org</a>
127
+ </div>
128
+ </footer>
129
+ </div>
56
130
  );
57
131
  }
58
132
  }
@@ -0,0 +1,15 @@
1
+
2
+ :host { display: block; }
3
+ .site-head { border-bottom: 1px solid var(--line); background: var(--paper); }
4
+ .site-head .bar { max-width: var(--content-width); margin: 0 auto; padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; }
5
+ .site-brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
6
+ .site-brand:hover { color: var(--brand); text-decoration: none; }
7
+ .site-head nav { display: flex; gap: 1.25rem; }
8
+ .site-head nav a { color: var(--ink-soft); font-size: 0.95rem; font-weight: 500; text-decoration: none; }
9
+ .site-head nav a:hover { color: var(--brand); text-decoration: none; }
10
+ main { max-width: var(--content-width); margin: 0 auto; padding: 3rem 1.25rem 4rem; }
11
+ .site-foot { border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 0.85rem; }
12
+ .site-foot .bar { max-width: var(--content-width); margin: 0 auto; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
13
+ .site-foot a { color: var(--ink-soft); text-decoration: none; }
14
+ .site-foot a:hover { color: var(--brand); text-decoration: none; }
15
+
@@ -20,23 +20,13 @@
20
20
  * `head` in openelement.config.ts already covers the title, description,
21
21
  * favicon and the og:/twitter: pairs; `head.scripts` / `head.stylesheets`
22
22
  * cover external scripts and stylesheets. This file is for what neither can
23
- * express — here, a resource preload. Per-page meaning (title, description,
24
- * og:title, canonical) is declared by each route module's `head`, which
25
- * resolves at render time and wins for crawlers.
23
+ * express — here, the color-scheme declaration. Per-page meaning (title,
24
+ * description, og:title, canonical) is declared by each route module's `head`,
25
+ * which resolves at render time and wins for crawlers.
26
26
  */
27
27
  export default [
28
- // The brand mark is used above the fold on the starter home page, so it is
29
- // preloaded. `crossorigin` needs an explicit value when the resource is
30
- // fetched with CORS; an image preload without it is same-origin as authored.
31
- {
32
- link: {
33
- rel: 'preload',
34
- href: '/openelement-mark.svg',
35
- as: 'image',
36
- type: 'image/svg+xml',
37
- },
38
- },
39
28
  // Declaring the color scheme the starter supports lets the browser pick the
40
- // right native form/scrollbar palette before any CSS is parsed.
29
+ // right native form/scrollbar palette before any CSS is parsed. The dark
30
+ // palette itself is theme.css's dark pair block — no runtime.
41
31
  { meta: { name: 'color-scheme', content: 'dark light' } },
42
32
  ];
@@ -0,0 +1,6 @@
1
+
2
+ :host { display: inline-block; }
3
+ .timer-row { display: inline-flex; gap: 0.6rem; align-items: baseline; }
4
+ .value { min-width: 6ch; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 1.4rem; color: var(--brand); }
5
+ .unit { color: var(--ink-soft); font-size: 0.85rem; }
6
+