@openelement/create 1.0.0-alpha.10 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -60
- package/package.json +1 -1
- package/src/cli.js +177 -45
- package/src/install-command.d.ts +18 -10
- package/src/install-command.js +19 -12
- package/src/pm.js +30 -0
- package/src/template-builder.js +21 -71
- package/src/version.js +2 -12
- package/templates/README.tmpl +84 -48
- package/templates/app/components/badges.css +5 -0
- package/templates/app/components/page-404.css +7 -0
- package/templates/app/components/page-404.tsx.tmpl +32 -11
- package/templates/app/components/page-about.css +15 -0
- package/templates/app/components/page-about.tsx.tmpl +93 -0
- package/templates/app/components/page-home.css +23 -0
- package/templates/app/components/page-home.tsx.tmpl +113 -39
- package/templates/app/components/site-chrome.css +15 -0
- package/templates/app/head.tsx.tmpl +5 -15
- package/templates/app/islands/live-timer.css +9 -0
- package/templates/app/islands/live-timer.tsx.tmpl +54 -0
- package/templates/app/islands/my-counter.css +11 -0
- package/templates/app/islands/my-counter.tsx.tmpl +5 -21
- package/templates/app/routes/about.tsx.tmpl +10 -0
- package/templates/app/routes/api/ping.ts.tmpl +12 -0
- package/templates/app/routes/index.tsx.tmpl +2 -2
- package/templates/app/styles/recipes.css +43 -0
- package/templates/{tailwind → app/styles}/theme.css +83 -12
- package/templates/openelement.config.ts.tmpl +13 -3
- package/templates/package.json.tmpl +2 -0
- package/templates/tsconfig.json.tmpl +1 -0
- package/templates/vite.config.ts.tmpl +3 -3
- package/templates/app/components/page-blog-index.tsx.tmpl +0 -39
- package/templates/app/components/page-blog-welcome.tsx.tmpl +0 -57
- package/templates/app/components/page-contact.tsx.tmpl +0 -49
- package/templates/app/components/page-freshness.tsx.tmpl +0 -26
- package/templates/app/components/page-styles.ts.tmpl +0 -123
- package/templates/app/islands/app-shell.tsx.tmpl +0 -83
- package/templates/app/islands/only-ticker.tsx.tmpl +0 -51
- package/templates/app/routes/api/health.ts.tmpl +0 -7
- package/templates/app/routes/blog/index.tsx.tmpl +0 -10
- package/templates/app/routes/blog/welcome.tsx.tmpl +0 -7
- package/templates/app/routes/contact.tsx.tmpl +0 -36
- package/templates/app/routes/freshness.tsx.tmpl +0 -17
- package/templates/app/styles/tokens.css +0 -57
- package/templates/tailwind/vite.config.ts.tmpl +0 -38
|
@@ -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
|
-
];
|
|
@@ -1,83 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/** Static blog index (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/router';
|
|
3
|
-
import BlogIndexPage from '../../components/page-blog-index.tsx';
|
|
4
|
-
|
|
5
|
-
export default definePage(BlogIndexPage, {
|
|
6
|
-
head: {
|
|
7
|
-
title: 'Blog — My openElement App',
|
|
8
|
-
description: 'Posts from app/routes/blog',
|
|
9
|
-
},
|
|
10
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Static blog post page (default renderIntent mode 'static'). */
|
|
2
|
-
import { definePage } from '@openelement/router';
|
|
3
|
-
import BlogWelcomePage from '../../components/page-blog-welcome.tsx';
|
|
4
|
-
|
|
5
|
-
export default definePage(BlogWelcomePage, {
|
|
6
|
-
head: { title: 'Welcome — My openElement App' },
|
|
7
|
-
});
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /contact — a request-time route exercising the WC Application Loop: the
|
|
3
|
-
* plain HTML form works without JavaScript (422 echo / 303 PRG), and
|
|
4
|
-
* data-open-enhance morphs the page when JS is present. The props projector
|
|
5
|
-
* is the single deterministic seam mapping request scope onto the compiled
|
|
6
|
-
* page properties.
|
|
7
|
-
*/
|
|
8
|
-
import { definePage, fail, type OpenElementActionFailure, redirect } from '@openelement/router';
|
|
9
|
-
import ContactPage from '../components/page-contact.tsx';
|
|
10
|
-
|
|
11
|
-
interface ContactActionData {
|
|
12
|
-
error?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function action(ctx: { formData: FormData }): OpenElementActionFailure<ContactActionData> {
|
|
17
|
-
const email = String(ctx.formData.get('email') ?? '').trim();
|
|
18
|
-
if (!/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(email)) {
|
|
19
|
-
return fail(422, { error: 'a valid email is required', email });
|
|
20
|
-
}
|
|
21
|
-
throw redirect(`/contact?subscribed=${encodeURIComponent(email)}`);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export default definePage(ContactPage, {
|
|
25
|
-
renderIntent: { mode: 'dynamic' },
|
|
26
|
-
head: { title: 'Contact — openElement' },
|
|
27
|
-
props({ request, actionData }) {
|
|
28
|
-
const subscribed = request ? new URL(request.url).searchParams.get('subscribed') : undefined;
|
|
29
|
-
const result = actionData as ContactActionData | undefined;
|
|
30
|
-
return {
|
|
31
|
-
email: result?.email ?? '',
|
|
32
|
-
errorText: result?.error ?? '',
|
|
33
|
-
subscribedText: subscribed ? `subscribed=${subscribed}` : '',
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
});
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* /freshness — static prerender proof route. The page is prerendered once at
|
|
3
|
-
* build time like any other static route; v0.44 ships no route-level cache
|
|
4
|
-
* revalidation semantics (ISR was removed, see issue #1217).
|
|
5
|
-
*/
|
|
6
|
-
import { definePage } from '@openelement/router';
|
|
7
|
-
import FreshnessPage from '../components/page-freshness.tsx';
|
|
8
|
-
|
|
9
|
-
export default definePage(FreshnessPage, {
|
|
10
|
-
head: {
|
|
11
|
-
title: 'Freshness proof',
|
|
12
|
-
description: 'Generated openElement static prerender route',
|
|
13
|
-
},
|
|
14
|
-
renderIntent: {
|
|
15
|
-
mode: 'static',
|
|
16
|
-
},
|
|
17
|
-
});
|
|
@@ -1,57 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { applyTailwindPreset, openElement } from '@openelement/router/vite';
|
|
2
|
-
import { defineConfig, type Plugin, type ResolvedConfig } from 'vite';
|
|
3
|
-
|
|
4
|
-
// Vite configuration only. Framework options live in openelement.config.ts —
|
|
5
|
-
// the plugin reads that file itself, so the plugin call stays
|
|
6
|
-
// `openElement()`. The JSX transform is owned by the plugin's compiler pass
|
|
7
|
-
// (TSX → Part Program); nothing JSX-related needs configuring here.
|
|
8
|
-
//
|
|
9
|
-
// Tailwind role sheet (scaffolded ON): the roles in app/styles/theme.css are
|
|
10
|
-
// compiled into the preset's linked, layer-ordered bundle at build time and
|
|
11
|
-
// referenced from every rendered page with <link rel="stylesheet">. The role
|
|
12
|
-
// file is declared relative to the preset's build-time staging entry (it is
|
|
13
|
-
// @import-ed from .openElement/tailwind-preset/), which is why the path
|
|
14
|
-
// climbs out of that directory. `pnpm dev` serves the tokens convention
|
|
15
|
-
// (app/styles/tokens.css); the compiled bundle exists in the build output.
|
|
16
|
-
// No node: imports here on purpose — the starter's `check` surface has no
|
|
17
|
-
// @types/node, and vite resolves `root` to an absolute path already.
|
|
18
|
-
|
|
19
|
-
function tailwindPreset(): Plugin {
|
|
20
|
-
let config: ResolvedConfig | undefined;
|
|
21
|
-
return {
|
|
22
|
-
name: 'starter:tailwind-preset',
|
|
23
|
-
apply: 'build',
|
|
24
|
-
configResolved(resolved) {
|
|
25
|
-
config = resolved;
|
|
26
|
-
},
|
|
27
|
-
async closeBundle() {
|
|
28
|
-
if (!config || config.command !== 'build') return;
|
|
29
|
-
const outDir = `${config.root}/${config.build.outDir || 'dist'}`;
|
|
30
|
-
await applyTailwindPreset({ theme: ['../../app/styles/theme.css'] }, config, outDir);
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default defineConfig({
|
|
36
|
-
base: '/',
|
|
37
|
-
plugins: [...openElement(), tailwindPreset()],
|
|
38
|
-
});
|