@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.
- package/README.md +49 -44
- package/package.json +1 -1
- package/src/cli.js +177 -45
- 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 +6 -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 +74 -12
- package/templates/openelement.config.ts.tmpl +11 -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,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
|
-
});
|