@openelement/create 0.44.0-beta.2.2 → 1.0.0-alpha.10
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 +105 -24
- package/package.json +16 -4
- package/src/cli.d.ts +1 -1
- package/src/cli.js +126 -66
- package/src/install-command.d.ts +50 -0
- package/src/install-command.js +52 -0
- package/src/template-builder.js +128 -166
- package/src/version.js +23 -2
- package/templates/README.tmpl +56 -23
- package/templates/app/components/{page-404.tsx → page-404.tsx.tmpl} +6 -2
- package/templates/app/components/{page-blog-index.tsx → page-blog-index.tsx.tmpl} +6 -2
- package/templates/app/components/{page-blog-welcome.tsx → page-blog-welcome.tsx.tmpl} +9 -6
- package/templates/app/components/{page-contact.tsx → page-contact.tsx.tmpl} +5 -2
- package/templates/app/components/{page-freshness.tsx → page-freshness.tsx.tmpl} +6 -2
- package/templates/app/components/{page-home.tsx → page-home.tsx.tmpl} +10 -7
- package/templates/app/components/page-styles.ts.tmpl +123 -0
- package/templates/app/head.tsx.tmpl +42 -0
- package/templates/app/islands/app-shell.tsx.tmpl +83 -0
- package/templates/app/islands/my-counter.tsx.tmpl +55 -0
- package/templates/app/islands/only-ticker.tsx.tmpl +51 -0
- package/templates/app/routes/{404.tsx → 404.tsx.tmpl} +1 -1
- package/templates/app/routes/blog/{index.tsx → index.tsx.tmpl} +1 -1
- package/templates/app/routes/blog/{welcome.tsx → welcome.tsx.tmpl} +1 -1
- package/templates/app/routes/{contact.tsx → contact.tsx.tmpl} +1 -1
- package/templates/app/routes/{freshness.tsx → freshness.tsx.tmpl} +1 -1
- package/templates/app/routes/{index.tsx → index.tsx.tmpl} +1 -1
- package/templates/app/styles/tokens.css +57 -0
- package/templates/gitignore.tmpl +1 -0
- package/templates/openelement.config.ts.tmpl +31 -0
- package/templates/package.json.tmpl +29 -0
- package/templates/tailwind/theme.css +108 -0
- package/templates/tailwind/vite.config.ts.tmpl +38 -0
- package/templates/tsconfig.json.tmpl +15 -0
- package/templates/vite.config.ts.tmpl +11 -0
- package/templates/app/components/page-styles.ts +0 -64
- package/templates/app/data/_generated-blog-data.d.ts +0 -21
- package/templates/app/islands/app-shell.tsx +0 -58
- package/templates/app/islands/my-counter.tsx +0 -38
- package/templates/app/islands/only-ticker.tsx +0 -34
- package/templates/deno.json.tmpl +0 -26
- package/templates/vite.config.ts +0 -100
- /package/templates/app/routes/api/{health.ts → health.ts.tmpl} +0 -0
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* app/head.tsx — the starter's structural document-head content.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is DATA: the framework validates attribute names and URL
|
|
5
|
+
* values, escapes every attribute, and serializes the tags into the document
|
|
6
|
+
* <head>. The array is emitted in the order written, so this file is the head
|
|
7
|
+
* order. Delete the file and the starter still builds — it is a convention, not
|
|
8
|
+
* a requirement.
|
|
9
|
+
*
|
|
10
|
+
* Entries take one of three shapes:
|
|
11
|
+
* { meta: { name, content } } one <meta> tag
|
|
12
|
+
* { link: { rel, href, ... } } one <link> tag (rel and href are required)
|
|
13
|
+
* { style: 'css text' } one inline <style> block
|
|
14
|
+
*
|
|
15
|
+
* The module is compiled by the build, so it can import CSS by URL
|
|
16
|
+
* (`import css from './site.css?raw'`) and pull constants from local modules.
|
|
17
|
+
* It must not use host APIs (no Deno, no Node): its output is a build artifact,
|
|
18
|
+
* so a runtime read would make the document depend on the build machine.
|
|
19
|
+
*
|
|
20
|
+
* `head` in openelement.config.ts already covers the title, description,
|
|
21
|
+
* favicon and the og:/twitter: pairs; `head.scripts` / `head.stylesheets`
|
|
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.
|
|
26
|
+
*/
|
|
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
|
+
// Declaring the color scheme the starter supports lets the browser pick the
|
|
40
|
+
// right native form/scrollbar palette before any CSS is parsed.
|
|
41
|
+
{ meta: { name: 'color-scheme', content: 'dark light' } },
|
|
42
|
+
];
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* app-shell — compiled layout island.
|
|
3
|
+
*
|
|
4
|
+
* The server entry renders this class around every page, registered by the
|
|
5
|
+
* `app/islands/app-shell.tsx` file convention; `openelement.config.ts`
|
|
6
|
+
* overrides it with `appShell: { import, props }`. The entry injects the page
|
|
7
|
+
* host before the closing tag and the static <slot> projects it. Deleting
|
|
8
|
+
* this file is supported: pages still render, just without the shell chrome.
|
|
9
|
+
* The shell is also a 'load' island: the compiled style scope applies
|
|
10
|
+
* `static styles` when the element activates client-side (the serializer
|
|
11
|
+
* never inlines styles into DSD), so the shell chrome is styled as soon as
|
|
12
|
+
* it hydrates.
|
|
13
|
+
*
|
|
14
|
+
* The compiler grammar v1 has no data-driven per-item attribute slots, so the
|
|
15
|
+
* header nav is static authoring here — edit the links below directly.
|
|
16
|
+
*/
|
|
17
|
+
import { defineIslandConfig } from '@openelement/router';
|
|
18
|
+
import { element, OpenElement, property } from '@openelement/element';
|
|
19
|
+
import { compiledStyle } from '../components/page-styles.ts';
|
|
20
|
+
|
|
21
|
+
export const openElement = defineIslandConfig({ hydrate: 'load', ssr: true, dsd: true });
|
|
22
|
+
|
|
23
|
+
// Same-module style sheet: the compiler erases this const from
|
|
24
|
+
// the island module and emits its bytes as the component's `.oe-style.css`
|
|
25
|
+
// asset. Cross-module sheet imports fail closed (OEC9028).
|
|
26
|
+
const shellStyles = [
|
|
27
|
+
compiledStyle(`
|
|
28
|
+
:host { display: block; min-height: 100vh; }
|
|
29
|
+
header { border-bottom: 1px solid var(--line); }
|
|
30
|
+
.bar { max-width: 740px; margin: 0 auto; padding: 1.15rem 1.25rem; display: flex; justify-content: space-between; align-items: baseline; }
|
|
31
|
+
.brand { font-family: var(--font-serif); font-weight: 700; font-size: 1.2rem; letter-spacing: -0.01em; color: var(--ink); }
|
|
32
|
+
.brand:hover { text-decoration: none; color: var(--brand); }
|
|
33
|
+
nav { display: flex; gap: 1.5rem; }
|
|
34
|
+
nav a { color: var(--ink-2); font-size: 0.95rem; font-weight: 500; }
|
|
35
|
+
nav a:hover { color: var(--brand); text-decoration: none; }
|
|
36
|
+
main { max-width: 740px; margin: 0 auto; padding: 3rem 1.25rem 4rem; }
|
|
37
|
+
footer { border-top: 1px solid var(--line); color: var(--ink-2); font-size: 0.85rem; }
|
|
38
|
+
.foot { max-width: 740px; margin: 0 auto; padding: 1.25rem; display: flex; justify-content: space-between; gap: 1rem; }
|
|
39
|
+
a { color: var(--brand); text-decoration: none; }
|
|
40
|
+
a:hover { text-decoration: underline; }
|
|
41
|
+
`),
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
@element('app-shell', { root: 'shadow-open' })
|
|
45
|
+
export default class AppShell extends OpenElement {
|
|
46
|
+
static override styles = shellStyles;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Filled from `appShell.props` at render time; a convention app-shell
|
|
50
|
+
* carries no props, so set them in openelement.config.ts to change this
|
|
51
|
+
* (appShell: { import: './app/islands/app-shell.tsx', props: { siteName } }).
|
|
52
|
+
* Attribute-backed (site-name) so the SSR'd value survives the client claim:
|
|
53
|
+
* attribute: false properties reset to their compiled default on claim and
|
|
54
|
+
* the drift check would fail closed.
|
|
55
|
+
*/
|
|
56
|
+
@property({ reflect: false })
|
|
57
|
+
siteName = 'openElement';
|
|
58
|
+
|
|
59
|
+
render() {
|
|
60
|
+
return (
|
|
61
|
+
<div class='shell-body'>
|
|
62
|
+
<header data-open-layout='app-shell'>
|
|
63
|
+
<div class='bar'>
|
|
64
|
+
<a class='brand' href='/'>{this.siteName}</a>
|
|
65
|
+
<nav>
|
|
66
|
+
<a href='/'>Home</a>
|
|
67
|
+
<a href='/blog'>Blog</a>
|
|
68
|
+
</nav>
|
|
69
|
+
</div>
|
|
70
|
+
</header>
|
|
71
|
+
<main>
|
|
72
|
+
<slot></slot>
|
|
73
|
+
</main>
|
|
74
|
+
<footer>
|
|
75
|
+
<div class='foot'>
|
|
76
|
+
<span>Generated by @openelement/create.</span>
|
|
77
|
+
<a href='https://github.com/open-element/openelement'>GitHub</a>
|
|
78
|
+
</div>
|
|
79
|
+
</footer>
|
|
80
|
+
</div>
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* my-counter — minimal counter island (compiled).
|
|
3
|
+
*
|
|
4
|
+
* Hydrates on idle; the buttons increment/decrement through the compiled
|
|
5
|
+
* event Parts and the count renders through the compiled text Part. The
|
|
6
|
+
* shadow root keeps the island a DSD citizen.
|
|
7
|
+
*/
|
|
8
|
+
import { defineIslandConfig } from '@openelement/router';
|
|
9
|
+
import { element, OpenElement, property } from '@openelement/element';
|
|
10
|
+
import { compiledStyle } from '../components/page-styles.ts';
|
|
11
|
+
|
|
12
|
+
export const openElement = defineIslandConfig({ hydrate: 'idle', ssr: true, dsd: true });
|
|
13
|
+
|
|
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
|
+
@element('my-counter', { root: 'shadow-open' })
|
|
32
|
+
export default class MyCounter extends OpenElement {
|
|
33
|
+
static override styles = counterStyles;
|
|
34
|
+
|
|
35
|
+
@property({ reflect: false, attribute: false })
|
|
36
|
+
count = 0;
|
|
37
|
+
|
|
38
|
+
decrement(): void {
|
|
39
|
+
this.count--;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
increment(): void {
|
|
43
|
+
this.count++;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
render() {
|
|
47
|
+
return (
|
|
48
|
+
<div class='counter-row'>
|
|
49
|
+
<button type='button' onClick={this.decrement}>-</button>
|
|
50
|
+
<span id='count'>{this.count}</span>
|
|
51
|
+
<button type='button' onClick={this.increment}>+</button>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* only-ticker — client-only 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 binds the
|
|
6
|
+
* tick event Part. Each hydrated island gets its own compiled property state,
|
|
7
|
+
* so multiple tickers on one page never share state.
|
|
8
|
+
*/
|
|
9
|
+
import { defineIslandConfig } from '@openelement/router';
|
|
10
|
+
import { element, OpenElement, property } from '@openelement/element';
|
|
11
|
+
import { compiledStyle } from '../components/page-styles.ts';
|
|
12
|
+
|
|
13
|
+
export const openElement = defineIslandConfig({ hydrate: 'only', ssr: false, dsd: false });
|
|
14
|
+
|
|
15
|
+
// Same-module style sheet: the compiler erases this const from
|
|
16
|
+
// the island module and emits its bytes as the component's `.oe-style.css`
|
|
17
|
+
// asset. Cross-module sheet imports fail closed (OEC9028).
|
|
18
|
+
const tickerStyles = [
|
|
19
|
+
compiledStyle(`
|
|
20
|
+
:host { display: inline-block; }
|
|
21
|
+
.ticker-row { display: inline-flex; gap: 0.75rem; align-items: center; }
|
|
22
|
+
button {
|
|
23
|
+
height: 2rem; padding: 0 0.9rem; border: 1px solid var(--line); border-radius: 6px;
|
|
24
|
+
background: #fff; color: var(--ink); font-size: 0.9rem; cursor: pointer;
|
|
25
|
+
transition: border-color 0.15s ease, color 0.15s ease;
|
|
26
|
+
}
|
|
27
|
+
button:hover { border-color: var(--brand); color: var(--brand); }
|
|
28
|
+
span { min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
|
|
29
|
+
`),
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
@element('only-ticker', { root: 'shadow-open' })
|
|
33
|
+
export default class OnlyTicker extends OpenElement {
|
|
34
|
+
static override styles = tickerStyles;
|
|
35
|
+
|
|
36
|
+
@property({ reflect: false, attribute: false })
|
|
37
|
+
tick = 0;
|
|
38
|
+
|
|
39
|
+
bump(): void {
|
|
40
|
+
this.tick++;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
render() {
|
|
44
|
+
return (
|
|
45
|
+
<div class='ticker-row'>
|
|
46
|
+
<span id='tick'>{this.tick}</span>
|
|
47
|
+
<button type='button' onClick={this.bump}>tick</button>
|
|
48
|
+
</div>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Styled 404 (#923): the request-time server renders this page with a 404
|
|
3
3
|
* status for unmatched paths; SSG builds also emit it as static 404.html.
|
|
4
4
|
*/
|
|
5
|
-
import { definePage } from '@openelement/
|
|
5
|
+
import { definePage } from '@openelement/router';
|
|
6
6
|
import NotFoundPage from '../components/page-404.tsx';
|
|
7
7
|
|
|
8
8
|
export default definePage(NotFoundPage, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Static blog index (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/
|
|
2
|
+
import { definePage } from '@openelement/router';
|
|
3
3
|
import BlogIndexPage from '../../components/page-blog-index.tsx';
|
|
4
4
|
|
|
5
5
|
export default definePage(BlogIndexPage, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Static blog post page (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/
|
|
2
|
+
import { definePage } from '@openelement/router';
|
|
3
3
|
import BlogWelcomePage from '../../components/page-blog-welcome.tsx';
|
|
4
4
|
|
|
5
5
|
export default definePage(BlogWelcomePage, {
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* is the single deterministic seam mapping request scope onto the compiled
|
|
6
6
|
* page properties.
|
|
7
7
|
*/
|
|
8
|
-
import { definePage, fail, type OpenElementActionFailure, redirect } from '@openelement/
|
|
8
|
+
import { definePage, fail, type OpenElementActionFailure, redirect } from '@openelement/router';
|
|
9
9
|
import ContactPage from '../components/page-contact.tsx';
|
|
10
10
|
|
|
11
11
|
interface ContactActionData {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* build time like any other static route; v0.44 ships no route-level cache
|
|
4
4
|
* revalidation semantics (ISR was removed, see issue #1217).
|
|
5
5
|
*/
|
|
6
|
-
import { definePage } from '@openelement/
|
|
6
|
+
import { definePage } from '@openelement/router';
|
|
7
7
|
import FreshnessPage from '../components/page-freshness.tsx';
|
|
8
8
|
|
|
9
9
|
export default definePage(FreshnessPage, {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** Static home page (default renderIntent mode 'static') — prerendered at build time. */
|
|
2
|
-
import { definePage } from '@openelement/
|
|
2
|
+
import { definePage } from '@openelement/router';
|
|
3
3
|
import HomePage from '../components/page-home.tsx';
|
|
4
4
|
|
|
5
5
|
export default definePage(HomePage, {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/* Design tokens + the document baseline (openElement starter).
|
|
2
|
+
*
|
|
3
|
+
* Convention, not configuration: `openelement.config.ts` inlines this file
|
|
4
|
+
* into every rendered document's <head> as <style data-oe-tokens>. Override
|
|
5
|
+
* the path with `styles: { tokens: '...' }` there; delete the file and the
|
|
6
|
+
* pages render unstyled but functional.
|
|
7
|
+
*
|
|
8
|
+
* Styling ownership: only true globals (design tokens, body baseline) live
|
|
9
|
+
* here. Each page element carries its own rules in `static styles`
|
|
10
|
+
* (`app/components/page-styles.ts`) — the server inlines them into the SSR
|
|
11
|
+
* output as a @scope(<page-tag>) style block for light roots. Islands carry
|
|
12
|
+
* their own `static styles` too.
|
|
13
|
+
*
|
|
14
|
+
* `--brand` must stay aligned with the ui package tokens (`--violet-6` in a
|
|
15
|
+
* consumer-owned design-system stylesheet).
|
|
16
|
+
*/
|
|
17
|
+
:root {
|
|
18
|
+
--paper: #faf9f6;
|
|
19
|
+
--ink: #1c1b17;
|
|
20
|
+
--ink-2: #5b594f;
|
|
21
|
+
--line: #e5e2d8;
|
|
22
|
+
--gray-0: #f8f9fa;
|
|
23
|
+
--gray-1: #f1f3f5;
|
|
24
|
+
--gray-3: #dee2e6;
|
|
25
|
+
--gray-5: #adb5bd;
|
|
26
|
+
--gray-7: #495057;
|
|
27
|
+
--gray-9: #212529;
|
|
28
|
+
--brand: #8262db;
|
|
29
|
+
--brand-2: #4f8ef7;
|
|
30
|
+
--size-1: 4px;
|
|
31
|
+
--size-2: 8px;
|
|
32
|
+
--size-3: 12px;
|
|
33
|
+
--size-4: 16px;
|
|
34
|
+
--border-size-1: 1px;
|
|
35
|
+
--radius-2: 8px;
|
|
36
|
+
--radius-3: 14px;
|
|
37
|
+
--font-sans: system-ui, -apple-system, sans-serif;
|
|
38
|
+
--font-serif: ui-serif, Georgia, 'Times New Roman', serif;
|
|
39
|
+
--font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
40
|
+
--font-size-0: 0.875rem;
|
|
41
|
+
--font-weight-5: 500;
|
|
42
|
+
--shadow-1: 0 1px 3px 0 rgb(0 0 0 / 0.08);
|
|
43
|
+
--shadow-2: 0 10px 28px rgb(80 70 160 / 0.12);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
body {
|
|
47
|
+
margin: 0;
|
|
48
|
+
background: var(--paper);
|
|
49
|
+
color: var(--ink);
|
|
50
|
+
font-family: var(--font-sans);
|
|
51
|
+
-webkit-font-smoothing: antialiased;
|
|
52
|
+
-moz-osx-font-smoothing: grayscale;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
::selection {
|
|
56
|
+
background: #8262db2e;
|
|
57
|
+
}
|
package/templates/gitignore.tmpl
CHANGED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// openelement.config.ts — framework options have exactly one home: this file.
|
|
2
|
+
//
|
|
3
|
+
// Every option below is OPTIONAL. With an empty object, options come from the
|
|
4
|
+
// file conventions:
|
|
5
|
+
// - design tokens: app/styles/tokens.css (inlined into every document <head>)
|
|
6
|
+
// - app shell: app/islands/app-shell.tsx (auto-registered; the file is
|
|
7
|
+
// deletable and pages still render)
|
|
8
|
+
// - document head: app/head.tsx (structural head content: meta tags, font
|
|
9
|
+
// preloads, icons, inline CSS — the entries a URL list
|
|
10
|
+
// cannot express; `head` below covers the rest)
|
|
11
|
+
// - site title: the "name" field of package.json
|
|
12
|
+
//
|
|
13
|
+
// The conventions follow `dirs`: give the three roots a shared leading
|
|
14
|
+
// directory (src/routes, src/islands, src/components) and the tokens/app-shell/
|
|
15
|
+
// head conventions resolve under that same directory (src/styles/tokens.css,
|
|
16
|
+
// src/islands/app-shell.tsx, src/head.tsx).
|
|
17
|
+
//
|
|
18
|
+
// Passing framework options inline to openElement() while this file carries
|
|
19
|
+
// options is a hard error: framework options cannot have two homes. Unknown
|
|
20
|
+
// keys are rejected with the accepted-key list.
|
|
21
|
+
import { defineConfig } from '@openelement/router';
|
|
22
|
+
|
|
23
|
+
export default defineConfig({
|
|
24
|
+
head: {
|
|
25
|
+
// Titles default to the package.json "name"; this overrides the document
|
|
26
|
+
// title fallback while page routes keep their own `head: { title }`.
|
|
27
|
+
title: 'My openElement App',
|
|
28
|
+
description: 'An openElement starter application.',
|
|
29
|
+
favicon: '/openelement-mark.svg',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "${name}",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"packageManager": "pnpm@12.8.1",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=24.2"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "vite",
|
|
12
|
+
"check": "tsc --noEmit",
|
|
13
|
+
"test": "node --test",
|
|
14
|
+
"build": "node node_modules/@openelement/router/src/cli/build.js",
|
|
15
|
+
"start": "node node_modules/@openelement/router/src/cli/start.js",
|
|
16
|
+
"preview": "node node_modules/@openelement/router/src/cli/start.js --mode=preview"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@hono/vite-dev-server": "^0.25.3",
|
|
20
|
+
"@openelement/element": "${v.element}",
|
|
21
|
+
"@openelement/router": "${v.router}",
|
|
22
|
+
"hono": "^4.12"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@playwright/test": "1.59.1",
|
|
26
|
+
"typescript": "6.0.3",
|
|
27
|
+
"vite": "${v.vite}"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
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.
|
|
14
|
+
═══════════════════════════════════════════════════════════════════════ */
|
|
15
|
+
|
|
16
|
+
@theme {
|
|
17
|
+
/* ── semantic roles (light), over the TW4 default scale.
|
|
18
|
+
Violet-anchored roles (the starter brand reads violet); neutral
|
|
19
|
+
surfaces stay zinc so the page base keeps its near-neutral paper
|
|
20
|
+
feel. ── */
|
|
21
|
+
|
|
22
|
+
--color-background: var(--color-white);
|
|
23
|
+
--color-foreground: var(--color-zinc-950);
|
|
24
|
+
|
|
25
|
+
--color-card: var(--color-white);
|
|
26
|
+
--color-card-foreground: var(--color-zinc-950);
|
|
27
|
+
|
|
28
|
+
--color-popover: var(--color-white);
|
|
29
|
+
--color-popover-foreground: var(--color-zinc-950);
|
|
30
|
+
|
|
31
|
+
--color-primary: var(--color-violet-700);
|
|
32
|
+
--color-primary-foreground: var(--color-violet-50);
|
|
33
|
+
|
|
34
|
+
--color-secondary: var(--color-violet-100);
|
|
35
|
+
--color-secondary-foreground: var(--color-violet-900);
|
|
36
|
+
|
|
37
|
+
--color-muted: var(--color-zinc-100);
|
|
38
|
+
--color-muted-foreground: var(--color-zinc-600);
|
|
39
|
+
|
|
40
|
+
--color-accent: var(--color-violet-100);
|
|
41
|
+
--color-accent-foreground: var(--color-violet-900);
|
|
42
|
+
|
|
43
|
+
--color-destructive: var(--color-red-700);
|
|
44
|
+
--color-destructive-foreground: var(--color-white);
|
|
45
|
+
|
|
46
|
+
--color-border: var(--color-violet-200);
|
|
47
|
+
--color-input: var(--color-violet-200);
|
|
48
|
+
--color-ring: var(--color-violet-500);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Dark pairs (shadcn v4 convention; the selector matches the runtime theme
|
|
52
|
+
attribute the ui package documents). */
|
|
53
|
+
:root[data-theme='dark'],
|
|
54
|
+
:host([data-theme='dark']) {
|
|
55
|
+
--color-background: var(--color-zinc-950);
|
|
56
|
+
--color-foreground: var(--color-zinc-50);
|
|
57
|
+
|
|
58
|
+
--color-card: var(--color-zinc-900);
|
|
59
|
+
--color-card-foreground: var(--color-zinc-50);
|
|
60
|
+
|
|
61
|
+
--color-popover: var(--color-zinc-900);
|
|
62
|
+
--color-popover-foreground: var(--color-zinc-50);
|
|
63
|
+
|
|
64
|
+
--color-primary: var(--color-violet-400);
|
|
65
|
+
--color-primary-foreground: var(--color-violet-950);
|
|
66
|
+
|
|
67
|
+
--color-secondary: var(--color-zinc-800);
|
|
68
|
+
--color-secondary-foreground: var(--color-zinc-100);
|
|
69
|
+
|
|
70
|
+
--color-muted: var(--color-zinc-800);
|
|
71
|
+
--color-muted-foreground: var(--color-zinc-400);
|
|
72
|
+
|
|
73
|
+
--color-accent: var(--color-zinc-800);
|
|
74
|
+
--color-accent-foreground: var(--color-zinc-100);
|
|
75
|
+
|
|
76
|
+
--color-destructive: var(--color-red-400);
|
|
77
|
+
--color-destructive-foreground: var(--color-red-950);
|
|
78
|
+
|
|
79
|
+
--color-border: var(--color-zinc-800);
|
|
80
|
+
--color-input: var(--color-zinc-800);
|
|
81
|
+
--color-ring: var(--color-violet-400);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Forced-colors layer: every role re-seats on a system color. Values are
|
|
85
|
+
system keywords — no author color survives the forcing. */
|
|
86
|
+
@media (forced-colors: active) {
|
|
87
|
+
:root {
|
|
88
|
+
--color-background: Canvas;
|
|
89
|
+
--color-foreground: CanvasText;
|
|
90
|
+
--color-card: Canvas;
|
|
91
|
+
--color-card-foreground: CanvasText;
|
|
92
|
+
--color-popover: Canvas;
|
|
93
|
+
--color-popover-foreground: CanvasText;
|
|
94
|
+
--color-primary: ButtonText;
|
|
95
|
+
--color-primary-foreground: Canvas;
|
|
96
|
+
--color-secondary: ButtonFace;
|
|
97
|
+
--color-secondary-foreground: ButtonText;
|
|
98
|
+
--color-muted: Canvas;
|
|
99
|
+
--color-muted-foreground: GrayText;
|
|
100
|
+
--color-accent: ButtonFace;
|
|
101
|
+
--color-accent-foreground: ButtonText;
|
|
102
|
+
--color-destructive: CanvasText;
|
|
103
|
+
--color-destructive-foreground: Canvas;
|
|
104
|
+
--color-border: CanvasText;
|
|
105
|
+
--color-input: CanvasText;
|
|
106
|
+
--color-ring: Highlight;
|
|
107
|
+
}
|
|
108
|
+
}
|