@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
@@ -0,0 +1,54 @@
1
+ /**
2
+ * live-timer — client-only live stats island (compiled).
3
+ *
4
+ * hydrate: 'only' with ssr: false renders nothing on the server; the client
5
+ * entry creates the DOM fresh from the compiled Part Program and starts the
6
+ * clock in connectedCallback. Elapsed time is measured from the document's
7
+ * time origin (performance.now()), so the number is honest page time, and
8
+ * disconnectedCallback stops the interval when the host leaves the tree.
9
+ */
10
+ import { defineIslandConfig } from '@openelement/router';
11
+ import { element, OpenElement, property } from '@openelement/element';
12
+ import timerStyles from './live-timer.css';
13
+
14
+ export const openElement = defineIslandConfig({ hydrate: 'only', ssr: false, dsd: false });
15
+
16
+ // The interval handle rides the compiled per-instance property state: island
17
+ // classes carry compiled @property fields and methods, and module-level
18
+ // runtime statements are outside the compiled grammar (OEC9008). In the
19
+ // browser setInterval returns a number, so the handle is a plain number here.
20
+ @element('live-timer', { root: 'shadow-open' })
21
+ export default class LiveTimer extends OpenElement {
22
+ static override styles = [timerStyles];
23
+
24
+ /** Elapsed seconds as preformatted text (compiled text Parts bind plain
25
+ * properties — no method calls in a text region, OEC9013). */
26
+ @property({ reflect: false, attribute: false })
27
+ elapsed = '0.0';
28
+
29
+ /** The ticking interval's handle; 0 when the host is not connected. */
30
+ @property({ reflect: false, attribute: false })
31
+ interval = 0;
32
+
33
+ override connectedCallback(): void {
34
+ super.connectedCallback();
35
+ this.interval = setInterval(() => {
36
+ this.elapsed = (Math.round(performance.now()) / 1000).toFixed(1);
37
+ }, 100);
38
+ }
39
+
40
+ override disconnectedCallback(): void {
41
+ clearInterval(this.interval);
42
+ this.interval = 0;
43
+ super.disconnectedCallback();
44
+ }
45
+
46
+ render() {
47
+ return (
48
+ <div class='timer-row'>
49
+ <span id='elapsed'>{this.elapsed}</span>
50
+ <span class='unit'>seconds on this page</span>
51
+ </div>
52
+ );
53
+ }
54
+ }
@@ -0,0 +1,11 @@
1
+
2
+ :host { display: inline-block; }
3
+ .counter-row { display: inline-flex; gap: 0.75rem; align-items: center; }
4
+ button {
5
+ width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: var(--radius-s);
6
+ background: var(--paper); color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer;
7
+ transition: border-color 0.15s ease, color 0.15s ease;
8
+ }
9
+ button:hover { border-color: var(--brand); color: var(--brand); }
10
+ span { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
11
+
@@ -1,36 +1,20 @@
1
1
  /**
2
- * my-counter — minimal counter island (compiled).
2
+ * my-counter — the interactive counter island (compiled).
3
3
  *
4
4
  * Hydrates on idle; the buttons increment/decrement through the compiled
5
5
  * event Parts and the count renders through the compiled text Part. The
6
- * shadow root keeps the island a DSD citizen.
6
+ * shadow root keeps the island a DSD citizen. Design tokens from
7
+ * app/styles/theme.css inherit through the shadow boundary.
7
8
  */
8
9
  import { defineIslandConfig } from '@openelement/router';
9
10
  import { element, OpenElement, property } from '@openelement/element';
10
- import { compiledStyle } from '../components/page-styles.ts';
11
+ import counterStyles from './my-counter.css';
11
12
 
12
13
  export const openElement = defineIslandConfig({ hydrate: 'idle', ssr: true, dsd: true });
13
14
 
14
- // Same-module style sheet: the compiler erases this const from
15
- // the island module and emits its bytes as the component's `.oe-style.css`
16
- // asset. Cross-module sheet imports fail closed (OEC9028).
17
- const counterStyles = [
18
- compiledStyle(`
19
- :host { display: inline-block; }
20
- .counter-row { display: inline-flex; gap: 0.75rem; align-items: center; }
21
- button {
22
- width: 2rem; height: 2rem; border: 1px solid var(--line); border-radius: 6px;
23
- background: #fff; color: var(--ink); font-size: 1rem; line-height: 1; cursor: pointer;
24
- transition: border-color 0.15s ease, color 0.15s ease;
25
- }
26
- button:hover { border-color: var(--brand); color: var(--brand); }
27
- span { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
28
- `),
29
- ];
30
-
31
15
  @element('my-counter', { root: 'shadow-open' })
32
16
  export default class MyCounter extends OpenElement {
33
- static override styles = counterStyles;
17
+ static override styles = [counterStyles];
34
18
 
35
19
  @property({ reflect: false, attribute: false })
36
20
  count = 0;
@@ -0,0 +1,10 @@
1
+ /** Static About page (default renderIntent mode 'static') — prerendered at build time. */
2
+ import { definePage } from '@openelement/router';
3
+ import AboutPage from '../components/page-about.tsx';
4
+
5
+ export default definePage(AboutPage, {
6
+ head: {
7
+ title: 'About',
8
+ description: 'Static-first openElement showcase — this page ships no islands',
9
+ },
10
+ });
@@ -0,0 +1,12 @@
1
+ /**
2
+ * /api/ping — a request-time server route: a plain WinterCG-shaped handler
3
+ * (Request → Response). No framework runtime attaches to it; any Response
4
+ * works, and Response.json is the common shape.
5
+ */
6
+ export default function ping() {
7
+ return Response.json({
8
+ pong: true,
9
+ framework: 'openElement',
10
+ route: '/api/ping',
11
+ });
12
+ }
@@ -4,7 +4,7 @@ import HomePage from '../components/page-home.tsx';
4
4
 
5
5
  export default definePage(HomePage, {
6
6
  head: {
7
- title: 'My openElement App',
8
- description: 'Generated openElement starter app',
7
+ title: 'Rendered before JavaScript arrives',
8
+ description: 'openElement showcase — static pages, alive where it counts',
9
9
  },
10
10
  });
@@ -0,0 +1,43 @@
1
+ /* authored from HEAD extraction — replace with design pass */
2
+ /* Plain HTML+CSS recipes for the four retired zero-interaction ui shapes
3
+ * (open-badge, open-callout, open-card, open-tabs #1557): the class
4
+ * structures their HEAD markup rendered, as copyable rules. Consumers delete
5
+ * what they do not use. Structure only — replace with the design pass. */
6
+
7
+ /* open-badge */
8
+ .badge {
9
+ display: inline-flex;
10
+ align-items: center;
11
+ }
12
+
13
+ /* open-callout */
14
+ .callout {
15
+ display: block;
16
+ }
17
+
18
+ .callout-header {
19
+ display: flex;
20
+ align-items: center;
21
+ }
22
+
23
+ .callout-icon {
24
+ display: inline-flex;
25
+ }
26
+
27
+ .callout-title {
28
+ margin: 0;
29
+ }
30
+
31
+ /* open-card */
32
+ .surface {
33
+ display: block;
34
+ }
35
+
36
+ .card-body {
37
+ display: block;
38
+ }
39
+
40
+ /* open-tabs */
41
+ .tabs {
42
+ display: flex;
43
+ }
@@ -1,16 +1,18 @@
1
1
  /* ═══════════════════════════════════════════════════════════════════════
2
- The starter's @theme role sheet (scaffolded with Tailwind enabled).
3
-
4
- Same contract as @openelement/ui's theme.css (the reference table): every
5
- role is a shadcn-style semantic name expressed with Tailwind default theme
6
- variables (var(--color-<ramp>-<step>)) — no role carries a handwritten
7
- scale value. The installed tailwindcss build provides the scale variables
8
- through the preset's compile (the router's Tailwind preset), the compiled
9
- bundle links into every rendered page, and the custom properties inherit
10
- into every shadow root, so compiled elements and islands read the roles
11
- directly. Extend this table with new roles the same way — name on the
12
- left, an existing Tailwind variable on the right — or override a role per
13
- theme with the dark pairs below.
2
+ The starter's @theme role sheet — the ONE styling source (Tailwind-ON is
3
+ the single scaffold default; there is no variant pair and no flag).
4
+
5
+ Two layers share this file:
6
+ 1. @theme roles — shadcn-style semantic names over Tailwind default scale
7
+ variables (var(--color-<ramp>-<step>)). Extend by naming a role on the
8
+ left and an existing Tailwind variable on the right.
9
+ 2. The starter palette aliases — the --paper/--ink/--brand names the
10
+ component sheets use, each seated on a role so the dark and
11
+ forced-colors pairs below apply everywhere.
12
+
13
+ `pnpm dev` serves this file directly (the #1558 authored-sheet path); the
14
+ build compiles it through the router's Tailwind preset into the linked,
15
+ layer-ordered bundle.
14
16
  ═══════════════════════════════════════════════════════════════════════ */
15
17
 
16
18
  @theme {
@@ -106,3 +108,63 @@
106
108
  --color-ring: Highlight;
107
109
  }
108
110
  }
111
+
112
+ /* ── Starter palette aliases (component sheet names → roles) ── */
113
+ :root {
114
+ --paper: var(--color-background);
115
+ --surface: var(--color-card);
116
+ --ink: var(--color-foreground);
117
+ --ink-soft: var(--color-muted-foreground);
118
+ --line: var(--color-border);
119
+ --brand: var(--color-primary);
120
+ --brand-ink: var(--color-primary-foreground);
121
+ --brand-soft: var(--color-secondary);
122
+ --ok: var(--color-secondary);
123
+ --warn: var(--color-accent);
124
+ }
125
+
126
+ /* ── Static (non-role) design tokens the component sheets read ── */
127
+ :root {
128
+ --gray-0: var(--color-muted);
129
+ --size-1: 4px;
130
+ --size-2: 8px;
131
+ --size-3: 12px;
132
+ --size-4: 16px;
133
+ --size-6: 24px;
134
+ --size-8: 32px;
135
+ --border-size-1: 1px;
136
+ --radius-s: 6px;
137
+ --radius-m: 10px;
138
+ --radius-l: 16px;
139
+ --font-sans: system-ui, -apple-system, sans-serif;
140
+ --font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
141
+ --content-width: 46rem;
142
+ --shadow-1: 0 1px 3px 0 rgb(20 18 33 / 0.07);
143
+ --shadow-2: 0 10px 28px rgb(60 50 120 / 0.1);
144
+ }
145
+
146
+ /* ── Document base (rides the same sheet; no separate tokens convention) ── */
147
+ body {
148
+ margin: 0;
149
+ background: var(--paper);
150
+ color: var(--ink);
151
+ font-family: var(--font-sans);
152
+ line-height: 1.6;
153
+ }
154
+
155
+ ::selection {
156
+ background: var(--brand);
157
+ color: var(--brand-ink);
158
+ }
159
+
160
+ /* Automatic dark for the starter palette (no runtime): the role sheet's
161
+ data-theme pairs above cover runtime-toggled themes. */
162
+ @media (prefers-color-scheme: dark) {
163
+ :root {
164
+ --paper: var(--color-zinc-950);
165
+ --surface: var(--color-zinc-900);
166
+ --ink: var(--color-zinc-50);
167
+ --ink-soft: var(--color-zinc-400);
168
+ --line: var(--color-zinc-800);
169
+ }
170
+ }
@@ -2,7 +2,8 @@
2
2
  //
3
3
  // Every option below is OPTIONAL. With an empty object, options come from the
4
4
  // file conventions:
5
- // - design tokens: app/styles/tokens.css (inlined into every document <head>)
5
+ // - design tokens: app/styles/theme.css (the @theme role sheet; dev serves
6
+ // it directly, the build compiles it through the `tailwind` key below)
6
7
  // - app shell: app/islands/app-shell.tsx (auto-registered; the file is
7
8
  // deletable and pages still render)
8
9
  // - document head: app/head.tsx (structural head content: meta tags, font
@@ -21,11 +22,18 @@
21
22
  import { defineConfig } from '@openelement/router';
22
23
 
23
24
  export default defineConfig({
25
+ // The Tailwind preset — the single-default scaffold form. The roles in
26
+ // app/styles/theme.css compile into the preset's linked, layer-ordered
27
+ // bundle (/assets/open-tailwind.css) after the SSG render; the path climbs
28
+ // out of the preset's build-time staging entry (.openElement/
29
+ // tailwind-preset/), the file the @import resolves from. `pnpm dev` serves
30
+ // the authored sheet directly.
31
+ tailwind: { theme: ['../../app/styles/theme.css'] },
24
32
  head: {
25
33
  // Titles default to the package.json "name"; this overrides the document
26
34
  // title fallback while page routes keep their own `head: { title }`.
27
- title: 'My openElement App',
28
- description: 'An openElement starter application.',
35
+ title: 'openElement Showcase',
36
+ description: 'A static-first openElement showcase — rendered before JavaScript arrives.',
29
37
  favicon: '/openelement-mark.svg',
30
38
  },
31
39
  });
@@ -23,6 +23,8 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@playwright/test": "1.59.1",
26
+ "@tailwindcss/vite": "4.3.3",
27
+ "tailwindcss": "4.3.3",
26
28
  "typescript": "6.0.3",
27
29
  "vite": "${v.vite}"
28
30
  }
@@ -6,6 +6,7 @@
6
6
  "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
7
  "jsx": "react-jsx",
8
8
  "jsxImportSource": "@openelement/element",
9
+ "types": ["@openelement/element/css-modules"],
9
10
  "strict": true,
10
11
  "skipLibCheck": true,
11
12
  "noEmit": true,
@@ -2,9 +2,9 @@ import { openElement } from '@openelement/router/vite';
2
2
  import { defineConfig } from 'vite';
3
3
 
4
4
  // Vite configuration only. Framework options live in openelement.config.ts —
5
- // the plugin reads that file itself, so this stays `plugins: [openElement()]`.
6
- // The JSX transform is owned by the plugin's compiler pass (TSX → Part
7
- // Program); nothing JSX-related needs configuring here.
5
+ // the plugin reads that file itself, so the plugin call stays bare. The JSX
6
+ // transform is owned by the plugin's compiler pass (TSX → Part Program);
7
+ // nothing JSX-related needs configuring here.
8
8
  export default defineConfig({
9
9
  base: '/',
10
10
  plugins: [...openElement()],
@@ -1,39 +0,0 @@
1
- /**
2
- * /blog index page element — static prerendered. Posts are markdown routes
3
- * under app/routes/blog/ (compiled to static pages at build time); the list
4
- * below is authored statically — add a link per post. (Compiler grammar v1
5
- * list Regions carry one value slot per item and no per-item attributes, so
6
- * a data-driven link list is a known v1 boundary.) Light root: the page owns
7
- * its rules via `static styles` (./page-styles.ts), inlined into SSR as
8
- * @scope(blog-index).
9
- */
10
- import { element, OpenElement } from '@openelement/element';
11
- import { blogIndexStyles } from './page-styles.ts';
12
-
13
- @element('blog-index', { root: 'light' })
14
- export default class BlogIndexPage extends OpenElement {
15
- static override styles = blogIndexStyles;
16
-
17
- render() {
18
- return (
19
- <main>
20
- <span class='eyebrow'>Index</span>
21
- <h1>Blog</h1>
22
- <p class='sub'>
23
- Every post is a compiled page route in{' '}
24
- <code>app/routes/blog/</code>, pre-rendered at build time.
25
- </p>
26
- <ul class='posts'>
27
- <li>
28
- <a class='post' href='/blog/welcome'>
29
- <span class='title'>Welcome</span>
30
- <span class='meta'>
31
- The starter blog is wired up — replace it with your first post.
32
- </span>
33
- </a>
34
- </li>
35
- </ul>
36
- </main>
37
- );
38
- }
39
- }
@@ -1,57 +0,0 @@
1
- /**
2
- * /blog/welcome post page element — static prerendered. A post is a compiled
3
- * page route in the 1.0 Alpha baseline: static markup in the render() below,
4
- * page rules in `static styles` (./page-styles.ts, inlined into SSR as
5
- * @scope(blog-welcome)). The path derives the tag ('blog-welcome'); there is
6
- * no dynamic [slug] route in grammar v1 (with no raw-HTML sink), so unknown
7
- * slugs fall through to the styled 404 (#922).
8
- */
9
- import { element, OpenElement } from '@openelement/element';
10
- import { blogWelcomeStyles } from './page-styles.ts';
11
-
12
- @element('blog-welcome', { root: 'light' })
13
- export default class BlogWelcomePage extends OpenElement {
14
- static override styles = blogWelcomeStyles;
15
-
16
- render() {
17
- return (
18
- <main>
19
- <p>
20
- <a href='/blog'>← Back to the blog</a>
21
- </p>
22
- <h1>Welcome</h1>
23
- <p class='meta'>
24
- <time>2026-01-01</time>
25
- </p>
26
- <article class='post-body'>
27
- <p>
28
- This starter keeps one post route present so the blog is wired up from the first build.
29
- In the 1.0 Alpha baseline a post is a compiled page: edit{' '}
30
- <code>app/components/page-blog-welcome.tsx</code> and the route module{' '}
31
- <code>app/routes/blog/welcome.tsx</code> next to it.
32
- </p>
33
- <h2>What ships in the box</h2>
34
- <p>The starter demonstrates the pieces a content site needs:</p>
35
- <ul>
36
- <li>
37
- static routes prerendered at build time (the home page, the blog index, this post)
38
- </li>
39
- <li>a request-time route with a plain HTML form loop (/contact)</li>
40
- <li>client islands hydrated on demand (the counter on the home page)</li>
41
- <li>an app shell composed around every page by the app-shell convention</li>
42
- </ul>
43
- <h2>Write your own posts</h2>
44
- <p>
45
- Add a page element under <code>app/components/</code> and a route module under{' '}
46
- <code>app/routes/blog/</code>, then link the post from the blog index. Interactive
47
- content belongs in a compiled island composed from the page.
48
- </p>
49
- <p>
50
- When you are ready, replace this page with your first real post and update the links on
51
- the blog index and home pages.
52
- </p>
53
- </article>
54
- </main>
55
- );
56
- }
57
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * /contact page element — request-time rendered (renderIntent mode
3
- * 'dynamic'). The plain form works without JavaScript (422 echo / 303 PRG)
4
- * and morphs in place with it (data-open-enhance). The route module's props
5
- * projector maps request/action state onto the compiled properties below;
6
- * the feedback paragraphs render empty (zero-height, invisible) until the
7
- * action supplies text. Light root: the page owns its rules via
8
- * `static styles` (./page-styles.ts), inlined into SSR as @scope(contact-page).
9
- */
10
- import { element, OpenElement, property } from '@openelement/element';
11
- import { contactPageStyles } from './page-styles.ts';
12
-
13
- @element('contact-page', { root: 'light' })
14
- export default class ContactPage extends OpenElement {
15
- static override styles = contactPageStyles;
16
-
17
- @property({ reflect: false, attribute: false })
18
- email = '';
19
-
20
- @property({ reflect: false, attribute: false })
21
- errorText = '';
22
-
23
- @property({ reflect: false, attribute: false })
24
- subscribedText = '';
25
-
26
- render() {
27
- return (
28
- <main>
29
- <h1>Stay in the loop</h1>
30
- <p class='sub'>
31
- A request-time route: the plain form works without JavaScript, and morphs in place with
32
- it.
33
- </p>
34
- <form method='post' data-open-enhance>
35
- <input
36
- id='email'
37
- name='email'
38
- type='text'
39
- value={this.email}
40
- placeholder='you@example.com'
41
- />
42
- <button type='submit'>Subscribe</button>
43
- </form>
44
- <p id='error'>{this.errorText}</p>
45
- <p id='thanks'>{this.subscribedText}</p>
46
- </main>
47
- );
48
- }
49
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * /freshness page element — prerendered statically at build time like any
3
- * other static route. v0.44 ships no route-level cache revalidation
4
- * semantics (ISR was removed, see issue #1217). Light root: the page owns its
5
- * rules via `static styles` (./page-styles.ts), inlined into SSR as
6
- * @scope(freshness-page).
7
- */
8
- import { element, OpenElement } from '@openelement/element';
9
- import { freshnessPageStyles } from './page-styles.ts';
10
-
11
- @element('freshness-page', { root: 'light' })
12
- export default class FreshnessPage extends OpenElement {
13
- static override styles = freshnessPageStyles;
14
-
15
- render() {
16
- return (
17
- <main>
18
- <h1>Freshness proof</h1>
19
- <p>
20
- This page is prerendered statically at build time like any other static route. The
21
- framework ships no route-level cache revalidation in v0.44.
22
- </p>
23
- </main>
24
- );
25
- }
26
- }
@@ -1,123 +0,0 @@
1
- /**
2
- * Style sheets for the starter's compiled elements (v0.44).
3
- *
4
- * Page sheets live in this plain module (compiled modules may not carry
5
- * runtime top-level statements, and page components are not islands). Page
6
- * elements use light roots: the server inlines their sheets into the SSR
7
- * output as a @scope(<page-tag>) block (<style data-oe-static-styles>), so
8
- * pages are styled with zero client JS. Under @scope the host tag prefixes
9
- * of a document stylesheet are dropped: the page element itself is `:host`
10
- * and descendant selectors go unprefixed.
11
- *
12
- * ISLAND sheets are same-module `compiledStyle()` consts in the island
13
- * modules under the island style asset protocol — cross-module
14
- * sheet imports fail closed (OEC9028). This module ships the factory helper
15
- * the islands spell.
16
- */
17
- import { StyleSheet, type StyleSheetLike } from '@openelement/element';
18
-
19
- export function compiledStyle(css: string): StyleSheetLike {
20
- const instance: StyleSheetLike = new StyleSheet();
21
- instance.replaceSync(css);
22
- return instance;
23
- }
24
-
25
- // ─── Page sheets (light roots → inlined as @scope(<page-tag>) in SSR) ───
26
-
27
- // Shared post-list rules (home teaser + blog index) — one source, both pages
28
- // include this sheet in their `static styles` arrays.
29
- export const postListStyles = [
30
- compiledStyle(`
31
- .posts { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
32
- .post { display: block; padding: 1.15rem 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
33
- a.post:hover .title { color: var(--brand); }
34
- .post .title { display: block; font-family: var(--font-serif); font-size: 1.3rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); transition: color 0.15s ease; }
35
- .post .meta { display: block; margin-top: 0.3rem; font-size: 0.85rem; color: var(--ink-2); }
36
- .post .excerpt { display: block; margin-top: 0.45rem; color: var(--ink-2); line-height: 1.6; }
37
- `),
38
- ];
39
-
40
- // Home page (index-page)
41
- export const homePageStyles = [
42
- compiledStyle(`
43
- :host { display: block; }
44
- .hero { padding: 2.5rem 0 1rem; }
45
- .eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
46
- h1 { font-family: var(--font-serif); font-size: 3rem; line-height: 1.12; letter-spacing: -0.015em; margin: 0.75rem 0 1.25rem; font-weight: 700; }
47
- .lede { font-size: 1.15rem; line-height: 1.75; color: var(--ink-2); max-width: 58ch; margin: 0; }
48
- .lede code { font-size: 0.85em; }
49
- .more { display: inline-block; margin-top: 1.5rem; font-weight: 600; }
50
- .demo { margin-top: 2.75rem; border: 1px solid var(--line); border-radius: 8px; padding: 1.25rem 1.5rem; }
51
- .demo .label { color: var(--ink-2); font-size: 0.8rem; letter-spacing: 0.1em; text-transform: uppercase; margin: 0 0 0.9rem; }
52
- .recent { margin-top: 3rem; }
53
- .recent h2 { font-family: var(--font-serif); letter-spacing: -0.01em; margin: 0 0 0.25rem; }
54
- .recent .sub { color: var(--ink-2); font-size: 0.925rem; margin: 0 0 1.5rem; }
55
- .recent .sub code { font-size: 0.85em; }
56
- a { color: var(--brand); text-decoration: none; }
57
- a:hover { text-decoration: underline; }
58
- `),
59
- ...postListStyles,
60
- ];
61
-
62
- // Blog index (blog-index)
63
- export const blogIndexStyles = [
64
- compiledStyle(`
65
- :host { display: block; }
66
- .eyebrow { color: var(--brand); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; }
67
- h1 { font-family: var(--font-serif); letter-spacing: -0.015em; margin: 0.5rem 0; }
68
- .sub { color: var(--ink-2); font-size: 0.925rem; margin: 0 0 1.5rem; }
69
- .sub code { font-size: 0.85em; }
70
- a { color: var(--brand); text-decoration: none; }
71
- `),
72
- ...postListStyles,
73
- ];
74
-
75
- // Blog post page (blog-welcome)
76
- export const blogWelcomeStyles = [
77
- compiledStyle(`
78
- :host { display: block; }
79
- h1 { font-family: var(--font-serif); font-size: 2.4rem; line-height: 1.15; letter-spacing: -0.015em; margin: 0.5rem 0; }
80
- .meta { color: var(--ink-2); font-size: 0.9rem; margin-top: 0; padding-bottom: 1.5rem; border-bottom: 1px solid var(--line); }
81
- a { color: var(--brand); text-decoration: none; }
82
- .post-body { line-height: 1.8; font-size: 1.05rem; }
83
- .post-body h2 { font-family: var(--font-serif); margin: 2.5rem 0 0.75rem; letter-spacing: -0.01em; }
84
- .post-body p { margin: 1rem 0; }
85
- .post-body code { font-family: var(--font-mono, ui-monospace, Menlo, monospace); font-size: 0.85em; background: #f1efe8; border: 1px solid var(--line); padding: 0.1em 0.4em; border-radius: 5px; }
86
- `),
87
- ];
88
-
89
- // Freshness proof (freshness-page)
90
- export const freshnessPageStyles = [
91
- compiledStyle(`
92
- :host { display: block; max-width: 800px; margin: 2rem auto; padding: 0 1rem; }
93
- p { color: var(--ink-2); }
94
- `),
95
- ];
96
-
97
- // Styled 404 (el-404)
98
- export const notFoundPageStyles = [
99
- compiledStyle(`
100
- :host { display: block; }
101
- h1 { font-family: var(--font-serif); font-size: 2.4rem; letter-spacing: -0.015em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
102
- p { color: var(--ink-2); line-height: 1.6; }
103
- a { color: var(--brand); font-weight: 600; text-decoration: none; }
104
- a:hover { text-decoration: underline; }
105
- `),
106
- ];
107
-
108
- // Contact form (contact-page)
109
- export const contactPageStyles = [
110
- compiledStyle(`
111
- :host { display: block; }
112
- h1 { font-family: var(--font-serif); font-size: 2.4rem; letter-spacing: -0.015em; margin: 0.75rem 0 0.5rem; font-weight: 700; }
113
- .sub { color: var(--ink-2); line-height: 1.6; max-width: 52ch; margin: 0 0 1.75rem; }
114
- form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
115
- input { font: inherit; min-width: 16rem; padding: 0.55rem 0.8rem; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; background: #fff; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
116
- input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #8262db2e; }
117
- button { font: inherit; font-weight: 600; padding: 0.55rem 1.1rem; cursor: pointer; border: 1px solid var(--brand); border-radius: 6px; background: var(--brand); color: #fff; transition: opacity 0.15s ease; }
118
- button:hover { opacity: 0.88; }
119
- #error { color: #c92a2a; margin: 1rem 0 0; }
120
- #error:empty, #thanks:empty { display: none; }
121
- #thanks { color: var(--brand); font-weight: 600; margin: 1rem 0 0; }
122
- `),
123
- ];