@openelement/create 1.0.0-alpha.8 → 1.0.0-alpha.9

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 CHANGED
@@ -16,20 +16,23 @@ pages. The generated project is a plain Node/pnpm project.
16
16
  ## Usage (1.0 Alpha)
17
17
 
18
18
  ```bash
19
- npm exec @openelement/create@alpha -- my-app
19
+ npm create @openelement@alpha my-app
20
20
  cd my-app
21
21
  pnpm install
22
22
  pnpm dev
23
23
  ```
24
24
 
25
- The version `@alpha` resolves to is registered in
26
- `the tracked release-state manifest` (currently `1.0.0-alpha.7`, a new baseline —
25
+ `npm create @openelement@alpha` rides npm's initializer alias: a bare `@scope`
26
+ resolves to `@scope/create` at the same tag, so the canonical spelling names
27
+ the scope, and npm runs this package's generator. The version `@alpha` resolves
28
+ to is registered in
29
+ `the tracked release-state manifest` (currently `1.0.0-alpha.8`, a new baseline —
27
30
  not a 0.x upgrade, with no migration path from 0.x). Pin that exact version
28
31
  when reproducibility matters (verify against the live registry with
29
32
  `npm view @openelement/create dist-tags.alpha`):
30
33
 
31
34
  ```bash
32
- npm exec @openelement/create@1.0.0-alpha.7 -- my-app
35
+ npm create @openelement@1.0.0-alpha.8 my-app
33
36
  ```
34
37
 
35
38
  The generated starter pins the exact `@openelement/*` versions it was built
@@ -37,12 +40,32 @@ from in its `package.json` dependencies.
37
40
 
38
41
  The canonical install command is exported from `@openelement/create/install-command` (one builder, every documented copy derives from it).
39
42
 
43
+ ## Tailwind form (the one scaffold question)
44
+
45
+ The scaffold ships the **Tailwind-ON starter by default**: a preset-wired
46
+ `vite.config.ts` (the `@openelement/router` Tailwind preset), the
47
+ `app/styles/theme.css` `@theme` role sheet (semantic roles over the Tailwind
48
+ default scale), and exact `tailwindcss` / `@tailwindcss/vite` pins in
49
+ `devDependencies`. Interactively the CLI asks exactly one question —
50
+ `Enable Tailwind CSS + @theme role sheet? (Y/n)` — and every non-interactive
51
+ run (CI, packed consumers) takes the same `Y` default. Pass a flag to skip the
52
+ question; the flags reach the generator through the spellings that forward
53
+ trailing arguments (`npx`, `pnpm dlx`, or a directly invoked bin):
54
+
55
+ ```bash
56
+ npx @openelement/create@alpha my-app --no-tailwind # the minimal starter
57
+ npx @openelement/create@alpha my-app --tailwind # explicit ON (the default)
58
+ ```
59
+
60
+ `--no-tailwind` generates the pre-#1524 minimal starter: no Tailwind
61
+ dependency surface, no preset wiring, no role sheet.
62
+
40
63
  ## The bootstrap is a plain npm invocation; the generated project is Node
41
64
 
42
- The documented bootstrap runs the generator through `npm exec` (or the `npx`
43
- short form, or `pnpm dlx`) — plain Node tooling, no second runtime. Node.js
44
- 24.2+ is the only host requirement for both the bootstrap and the generated
45
- project. The packed package ships two equivalent npm bins
65
+ The documented bootstrap runs the generator through `npm create` (or the
66
+ `npx` short form, or `pnpm dlx`) — plain Node tooling, no second runtime.
67
+ Node.js 24.2+ is the only host requirement for both the bootstrap and the
68
+ generated project. The packed package ships two equivalent npm bins
46
69
  (`openelement-create`, `create-openelement`, both the same entry), so the pnpm
47
70
  form must name one explicitly:
48
71
 
@@ -61,7 +84,7 @@ A versionless install resolves the npm `latest` dist-tag to it; pin the line
61
84
  explicitly instead:
62
85
 
63
86
  ```bash
64
- npm exec @openelement/create@0.43 -- my-app
87
+ npm create @openelement@0.43 my-app
65
88
  ```
66
89
 
67
90
  ## Requirements
@@ -75,11 +98,15 @@ npm exec @openelement/create@0.43 -- my-app
75
98
  ## What It Creates
76
99
 
77
100
  - `package.json` - starter dependencies (exact `@openelement/*` release pins)
78
- and the lifecycle scripts (`dev`/`check`/`test`/`build`/`start`/`preview`)
101
+ and the lifecycle scripts (`dev`/`check`/`test`/`build`/`start`/`preview`);
102
+ the default (Tailwind-ON) form adds the exact `tailwindcss` and
103
+ `@tailwindcss/vite` dev pins
79
104
  - `tsconfig.json` - the type-check surface for `pnpm check`: JSX authoring
80
105
  through the element import source, whole-`app/` coverage
81
- - `vite.config.ts` - Vite build configuration; the plugin call is plain
82
- `openElement()`, because framework options have exactly one home:
106
+ - `vite.config.ts` - Vite build configuration. On the default (Tailwind-ON)
107
+ form it also applies the router's public Tailwind preset so the role sheet
108
+ compiles into the linked bundle; framework options still have exactly one
109
+ home:
83
110
  - `openelement.config.ts` - the framework options. It is OPTIONAL and nearly
84
111
  empty by default; every option it omits comes from a file convention —
85
112
  design tokens from `app/styles/tokens.css`, the app shell from
@@ -87,7 +114,8 @@ npm exec @openelement/create@0.43 -- my-app
87
114
  `app/head.tsx`, the site title from `package.json`. Passing framework
88
115
  options inline to `openElement()` while this file carries options is a hard
89
116
  error, and an unknown key fails the build with the accepted-key list.
90
- - `app/` - application directory with starter pages and islands
117
+ - `app/` - application directory with starter pages and islands; the
118
+ Tailwind-ON form adds `app/styles/theme.css`, the `@theme` role sheet
91
119
  - `app/routes/blog/` - the sample blog as compiled page routes (`index` list
92
120
  and `welcome` post), prerendered at build time
93
121
  - `public/` - static assets
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openelement/create",
3
- "version": "1.0.0-alpha.8",
3
+ "version": "1.0.0-alpha.9",
4
4
  "type": "module",
5
5
  "main": "./src/cli.js",
6
6
  "types": "./src/cli.d.ts",
package/src/cli.js CHANGED
@@ -3,6 +3,7 @@ import { buildTemplates, resolveVersions, validateProjectName } from "./template
3
3
  import { createInstallCommand } from "./install-command.js";
4
4
  import { mkdir, stat, writeFile } from "node:fs/promises";
5
5
  import process from "node:process";
6
+ import readline from "node:readline/promises";
6
7
  //#region src/cli.ts
7
8
  /**
8
9
  * @openelement/create - Minimal project scaffold for openElement framework.
@@ -12,7 +13,11 @@ import process from "node:process";
12
13
  * string, so the documented command cannot drift from the shipped flags.
13
14
  *
14
15
  * openElement Architecture: Keep It Simple, Stupid.
15
- * One template, zero prompts, instant start.
16
+ * One template, one question, instant start. The single question is the
17
+ * Tailwind form (#1524): the default (and every non-interactive run) ships
18
+ * the Tailwind-ON starter — preset-wired vite config, @theme role sheet, and
19
+ * the exact tailwindcss/@tailwindcss/vite pins; `--no-tailwind` keeps the
20
+ * pre-#1524 minimal template.
16
21
  *
17
22
  * L9: every failure mode exits 1 with one actionable message — never a
18
23
  * runtime stack trace.
@@ -41,13 +46,54 @@ function dirnameOf(path) {
41
46
  if (idx <= 0) return ".";
42
47
  return path.slice(0, idx);
43
48
  }
49
+ /** The CLI flags and the project-name positional, parsed without a library. */
50
+ function parseArgs(argv) {
51
+ let name;
52
+ let tailwind;
53
+ for (const arg of argv) if (arg === "--tailwind") tailwind = true;
54
+ else if (arg === "--no-tailwind") tailwind = false;
55
+ else if (arg.startsWith("-")) continue;
56
+ else if (name === void 0) name = arg;
57
+ return {
58
+ name,
59
+ tailwind
60
+ };
61
+ }
62
+ /**
63
+ * Resolve the Tailwind form: a flag wins without prompting; otherwise a TTY
64
+ * asks the one scaffold question (default Y), and a non-TTY run (CI, packed
65
+ * consumers) takes the same default without prompting.
66
+ */
67
+ async function resolveTailwindForm(flag) {
68
+ if (flag !== void 0) return flag;
69
+ if (!process.stdin.isTTY || !process.stdout.isTTY) return true;
70
+ const rl = readline.createInterface({
71
+ input: process.stdin,
72
+ output: process.stdout
73
+ });
74
+ try {
75
+ for (;;) {
76
+ const answer = (await rl.question("Enable Tailwind CSS + @theme role sheet? (Y/n) ")).trim().toLowerCase();
77
+ if (answer === "" || answer === "y" || answer === "yes") return true;
78
+ if (answer === "n" || answer === "no") return false;
79
+ console.info(" please answer y (default) or n");
80
+ }
81
+ } finally {
82
+ rl.close();
83
+ }
84
+ }
44
85
  async function main() {
45
- const name = process.argv[2];
86
+ const argv = process.argv.slice(2);
87
+ const { name: positionalName, tailwind: tailwindFlag } = parseArgs(argv);
88
+ const name = positionalName;
46
89
  if (!name || name === "--help" || name === "-h") {
47
90
  console.log(`Usage (Alpha): ${createInstallCommand()}`);
48
91
  console.log("(a versionless install resolves the stable 0.43 line)");
92
+ console.log(" --tailwind ship the Tailwind-ON starter (default)");
93
+ console.log(" --no-tailwind ship the minimal starter without Tailwind");
49
94
  process.exit(name ? 0 : 1);
50
95
  }
96
+ if (argv.includes("--tailwind") && argv.includes("--no-tailwind")) fail("--tailwind and --no-tailwind are mutually exclusive.");
51
97
  const invalid = validateProjectName(name);
52
98
  if (invalid) fail(`Invalid project name "${name}". ${invalid}`);
53
99
  const targetDir = `${process.cwd().replace(/\/+$/, "")}/${name}`;
@@ -59,10 +105,11 @@ async function main() {
59
105
  } catch (error) {
60
106
  if (!isNotFound(error)) throw new Error(`Could not inspect target directory "${name}": ${errorMessage(error)}`);
61
107
  }
108
+ const tailwind = await resolveTailwindForm(tailwindFlag);
62
109
  const v = resolveVersions();
63
110
  try {
64
111
  await mkdir(targetDir, { recursive: true });
65
- const TPL = await buildTemplates(v, name);
112
+ const TPL = await buildTemplates(v, name, { tailwind });
66
113
  for (const [path, content] of Object.entries(TPL)) {
67
114
  const fullPath = joinPosix(targetDir, path);
68
115
  await mkdir(dirnameOf(fullPath), { recursive: true });
@@ -74,6 +121,7 @@ async function main() {
74
121
  throw new Error(`Failed to write project files in "${name}": ${detail} Remove the partially created directory before retrying.`);
75
122
  }
76
123
  console.info(`\nopenElement project created at ./${relativeTarget}/`);
124
+ console.info(tailwind ? " Tailwind: ON — app/styles/theme.css carries the @theme role sheet." : " Tailwind: OFF — minimal starter, no Tailwind dependency surface.");
77
125
  console.info(`\n cd ${relativeTarget}`);
78
126
  console.info(" pnpm install");
79
127
  console.info(" pnpm dev");
@@ -15,6 +15,13 @@
15
15
  */
16
16
  /** The npm specifier the generator is published under. */
17
17
  export declare const CREATE_PACKAGE_SPECIFIER = "@openelement/create";
18
+ /**
19
+ * The scope `npm create` resolves to {@linkcode CREATE_PACKAGE_SPECIFIER}:
20
+ * npm's initializer alias maps a bare `@scope` (optionally `@scope@<tag>`) to
21
+ * `@scope/create` at the same tag, so the canonical spelling never repeats the
22
+ * `/create` suffix (owner-verified against npm's init alias rules).
23
+ */
24
+ export declare const CREATE_NPM_CREATE_SCOPE = "@openelement";
18
25
  /** The dist-tag the documented install resolves; the exact version is registry truth. */
19
26
  export declare const CREATE_INSTALL_TAG = "alpha";
20
27
  /** Placeholder the usage text and the docs use in place of a project name. */
@@ -23,7 +30,10 @@ export declare const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
23
30
  * The documented install command shapes, all verified against the published
24
31
  * two-bin artifact (bins `openelement-create` and `create-openelement`, both
25
32
  * `src/cli.js`; npm 11 / pnpm 12):
26
- * - canonical: `npm exec <pkg>@<tag> -- <name>`
33
+ * - canonical: `npm create @openelement@<tag> <name>` — npm's `@scope`
34
+ * initializer alias resolves it to `@openelement/create@<tag>` (#1507
35
+ * revision, 2026-10-05; the former canonical `npm exec <pkg>@<tag> -- <name>`
36
+ * remains a verified spelling through the same artifact)
27
37
  * - short form: `npx <pkg>@<tag> <name>`
28
38
  * - pnpm: `pnpm dlx --package=<pkg>@<tag> openelement-create <name>` — the
29
39
  * explicit `--package` plus bin is required because the packed package
@@ -15,6 +15,13 @@
15
15
  */
16
16
  /** The npm specifier the generator is published under. */
17
17
  const CREATE_PACKAGE_SPECIFIER = "@openelement/create";
18
+ /**
19
+ * The scope `npm create` resolves to {@linkcode CREATE_PACKAGE_SPECIFIER}:
20
+ * npm's initializer alias maps a bare `@scope` (optionally `@scope@<tag>`) to
21
+ * `@scope/create` at the same tag, so the canonical spelling never repeats the
22
+ * `/create` suffix (owner-verified against npm's init alias rules).
23
+ */
24
+ const CREATE_NPM_CREATE_SCOPE = "@openelement";
18
25
  /** The dist-tag the documented install resolves; the exact version is registry truth. */
19
26
  const CREATE_INSTALL_TAG = "alpha";
20
27
  /** Placeholder the usage text and the docs use in place of a project name. */
@@ -23,7 +30,10 @@ const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
23
30
  * The documented install command shapes, all verified against the published
24
31
  * two-bin artifact (bins `openelement-create` and `create-openelement`, both
25
32
  * `src/cli.js`; npm 11 / pnpm 12):
26
- * - canonical: `npm exec <pkg>@<tag> -- <name>`
33
+ * - canonical: `npm create @openelement@<tag> <name>` — npm's `@scope`
34
+ * initializer alias resolves it to `@openelement/create@<tag>` (#1507
35
+ * revision, 2026-10-05; the former canonical `npm exec <pkg>@<tag> -- <name>`
36
+ * remains a verified spelling through the same artifact)
27
37
  * - short form: `npx <pkg>@<tag> <name>`
28
38
  * - pnpm: `pnpm dlx --package=<pkg>@<tag> openelement-create <name>` — the
29
39
  * explicit `--package` plus bin is required because the packed package
@@ -36,7 +46,7 @@ const CREATE_PROJECT_PLACEHOLDER = "<project-name>";
36
46
  */
37
47
  function createInstallCommand(projectName = CREATE_PROJECT_PLACEHOLDER, options = {}) {
38
48
  const tag = options.tag ?? "alpha";
39
- return `npm exec ${CREATE_PACKAGE_SPECIFIER}@${tag} -- ${projectName}`;
49
+ return `npm create ${CREATE_NPM_CREATE_SCOPE}@${tag} ${projectName}`;
40
50
  }
41
51
  //#endregion
42
- export { CREATE_INSTALL_TAG, CREATE_PACKAGE_SPECIFIER, CREATE_PROJECT_PLACEHOLDER, createInstallCommand };
52
+ export { CREATE_INSTALL_TAG, CREATE_NPM_CREATE_SCOPE, CREATE_PACKAGE_SPECIFIER, CREATE_PROJECT_PLACEHOLDER, createInstallCommand };
@@ -1,4 +1,4 @@
1
- import { CREATE_VERSION, VITE_STARTER_PIN } from "./version.js";
1
+ import { CREATE_VERSION, TAILWIND_STARTER_PIN, VITE_STARTER_PIN } from "./version.js";
2
2
  import { readFile } from "node:fs/promises";
3
3
  //#region src/template-builder.ts
4
4
  const MAX_PROJECT_NAME_LENGTH = 214;
@@ -61,30 +61,80 @@ const TEMPLATE_FILES = [
61
61
  ["app/islands/my-counter.tsx.tmpl", "app/islands/my-counter.tsx"],
62
62
  ["app/islands/only-ticker.tsx.tmpl", "app/islands/only-ticker.tsx"]
63
63
  ];
64
+ /**
65
+ * The Tailwind-ON overlay (#1524): the default scaffold replaces the plain
66
+ * vite config with the preset-wired one and adds the @theme role sheet. The
67
+ * overlay lives in templates/tailwind/ so the OFF form stays exactly the
68
+ * pre-#1524 minimal starter. theme.css carries no scaffold tokens (like
69
+ * tokens.css), so it ships as a plain payload file.
70
+ */
71
+ const TAILWIND_TEMPLATE_FILES = [["tailwind/vite.config.ts.tmpl", "vite.config.ts"], ["tailwind/theme.css", "app/styles/theme.css"]];
72
+ /** The README section token the Tailwind-ON prose replaces (OFF removes it). */
73
+ const TAILWIND_README_TOKEN = "${tailwind.section}";
74
+ /** The devDependencies the Tailwind-ON scaffold adds (exact pins, no ranges). */
75
+ const TAILWIND_DEV_DEPENDENCIES = {
76
+ "@tailwindcss/vite": TAILWIND_STARTER_PIN,
77
+ tailwindcss: TAILWIND_STARTER_PIN
78
+ };
64
79
  function versionTokens(v) {
65
80
  return {
66
81
  ["${v.router}"]: v.router,
67
82
  ["${v.element}"]: v.element
68
83
  };
69
84
  }
70
- async function buildTemplates(v, projectName) {
85
+ async function buildTemplates(v, projectName, options = {}) {
71
86
  assertUnifiedProductVersions(v);
72
87
  const invalid = validateProjectName(projectName);
73
88
  if (invalid) throw new Error(`Invalid project name "${projectName}". ${invalid}`);
89
+ const tailwind = options.tailwind ?? true;
74
90
  const templatesBase = new URL("../templates/", import.meta.url);
75
91
  const tokens = {
76
92
  ...versionTokens(v),
77
93
  ["${v.vite}"]: VITE_STARTER_PIN,
78
- ["${name}"]: projectName
94
+ ["${name}"]: projectName,
95
+ [TAILWIND_README_TOKEN]: tailwind ? tailwindReadmeSection() : ""
79
96
  };
80
- const entries = await Promise.all(TEMPLATE_FILES.map(async ([source, target]) => {
97
+ const files = tailwind ? [...TEMPLATE_FILES, ...TAILWIND_TEMPLATE_FILES] : TEMPLATE_FILES;
98
+ const entries = await Promise.all(files.map(async ([source, target]) => {
81
99
  let content = await readFile(new URL(source, templatesBase), "utf8");
82
100
  for (const [token, value] of Object.entries(tokens)) if (content.includes(token)) content = content.split(token).join(value);
83
- if (content.includes("${v.") || content.includes("${name}")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
101
+ if (content.includes("${v.") || content.includes("${name}") || content.includes("${tailwind.")) throw new Error(`Unresolved scaffold token in starter template: ${source}`);
84
102
  return [target, content];
85
103
  }));
86
- entries.sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0);
87
- return Object.fromEntries(entries);
104
+ const byTarget = new Map(entries);
105
+ if (tailwind) {
106
+ const manifestPath = "package.json";
107
+ const manifest = JSON.parse(byTarget.get(manifestPath));
108
+ manifest.devDependencies = Object.fromEntries(Object.entries({
109
+ ...manifest.devDependencies,
110
+ ...TAILWIND_DEV_DEPENDENCIES
111
+ }).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
112
+ byTarget.set(manifestPath, `${JSON.stringify(manifest, null, 2)}\n`);
113
+ }
114
+ const out = Object.fromEntries(byTarget);
115
+ return Object.fromEntries(Object.entries(out).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
116
+ }
117
+ /**
118
+ * The README prose the Tailwind-ON scaffold injects (the OFF form removes the
119
+ * token line). One source here, so the generated README and the tests cannot
120
+ * drift apart. The leading/trailing newline keeps the injected heading
121
+ * blank-line separated in both replacements.
122
+ */
123
+ function tailwindReadmeSection() {
124
+ return `
125
+ ## Tailwind and the @theme role sheet
126
+
127
+ This project was scaffolded with Tailwind enabled (pass \`--no-tailwind\` to
128
+ \`@openelement/create\` for a starter without it). \`app/styles/theme.css\` is
129
+ the @theme role sheet: semantic roles (background, primary, muted, ...) over
130
+ the Tailwind default scale, with dark pairs and a forced-colors layer. The
131
+ router's Tailwind preset compiles the sheet into one linked bundle during
132
+ \`pnpm build\` and references it from every rendered page; the custom
133
+ properties inherit into every shadow root, so pages and islands can consume
134
+ the roles directly. \`pnpm dev\` serves the tokens convention instead — the
135
+ compiled bundle exists in the build output. Extend the sheet by adding role
136
+ lines; \`@openelement/ui\`'s theme.css documents the same contract.
137
+ `;
88
138
  }
89
139
  //#endregion
90
- export { assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
140
+ export { TAILWIND_DEV_DEPENDENCIES, TAILWIND_README_TOKEN, assertUnifiedProductVersions, buildTemplates, resolveVersions, validateProjectName };
package/src/version.js CHANGED
@@ -1,12 +1,23 @@
1
1
  //#region src/version.ts
2
2
  /** The published CLI version, embedded so packed npm installs are self-contained. */
3
- const CREATE_VERSION = "1.0.0-alpha.8";
3
+ const CREATE_VERSION = "1.0.0-alpha.9";
4
4
  /**
5
- * The Vite dev release stamped into the generated starter's import map and
6
- * dev task. Embedded for the same reason as CREATE_VERSION (packed npm
7
- * installs are self-contained); the repository's Vite-pin check anchors this
8
- * copy to the canonical dev pin.
5
+ * The Vite release pinned into the generated starter's package.json (the
6
+ * `${v.vite}` scaffold token in the npm/pnpm starter). Embedded for the same
7
+ * reason as CREATE_VERSION (packed npm installs are self-contained); the
8
+ * repository's Vite-pin check (deps:vite-check in the repo tooling package) anchors this copy
9
+ * to the canonical dev pin.
9
10
  */
10
11
  const VITE_STARTER_PIN = "8.0.16";
12
+ /**
13
+ * The Tailwind line pinned into the generated starter's devDependencies (the
14
+ * Tailwind-ON scaffold, #1524): both `tailwindcss` and `@tailwindcss/vite`,
15
+ * exactly, aligned with the router's own dev pins. The 4.3.x line is the
16
+ * preset's supported line (the v3-lts line is forbidden — see the router's
17
+ * preset-tailwind module). Embedded like the other pins so packed npm
18
+ * installs stay self-contained; the create tests anchor this copy to the
19
+ * router manifest the way deps:vite-check anchors VITE_STARTER_PIN.
20
+ */
21
+ const TAILWIND_STARTER_PIN = "4.3.3";
11
22
  //#endregion
12
- export { CREATE_VERSION, VITE_STARTER_PIN };
23
+ export { CREATE_VERSION, TAILWIND_STARTER_PIN, VITE_STARTER_PIN };
@@ -17,7 +17,7 @@ roots and own their rules in `static styles`
17
17
  the SSR output as a `@scope(<page-tag>)` style block, so pages are fully styled
18
18
  with zero client JavaScript. The shell and the islands hydrate in the browser
19
19
  and carry their own `static styles`.
20
-
20
+ ${tailwind.section}
21
21
  ## Where options live
22
22
 
23
23
  Framework options have exactly one home: `openelement.config.ts`. It is
@@ -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
+ }
@@ -0,0 +1,38 @@
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
+ });