create-thexjs-app 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1026 -0
  3. package/dist/index.js +224 -0
  4. package/package.json +30 -0
  5. package/templates/basic/components.json +21 -0
  6. package/templates/basic/content/blog/hello.md +8 -0
  7. package/templates/basic/public/favicon.ico +0 -0
  8. package/templates/basic/src/actions/dashboard/greet.ts +3 -0
  9. package/templates/basic/src/api/auth/login.ts +30 -0
  10. package/templates/basic/src/api/auth/logout.ts +12 -0
  11. package/templates/basic/src/api/placeholder/comments.ts +17 -0
  12. package/templates/basic/src/api/placeholder/posts.ts +20 -0
  13. package/templates/basic/src/api/placeholder/todos.ts +21 -0
  14. package/templates/basic/src/api/placeholder/users.ts +12 -0
  15. package/templates/basic/src/components/Head.tsx +21 -0
  16. package/templates/basic/src/components/Image.tsx +27 -0
  17. package/templates/basic/src/components/Link.tsx +16 -0
  18. package/templates/basic/src/components/ui/badge.tsx +49 -0
  19. package/templates/basic/src/components/ui/button.tsx +58 -0
  20. package/templates/basic/src/components/ui/card.tsx +88 -0
  21. package/templates/basic/src/components/ui/input.tsx +20 -0
  22. package/templates/basic/src/layouts/main.tsx +38 -0
  23. package/templates/basic/src/lib/auth.ts +70 -0
  24. package/templates/basic/src/lib/migrations/001_create_sessions.sql +9 -0
  25. package/templates/basic/src/lib/placeholder-data.ts +176 -0
  26. package/templates/basic/src/lib/utils.ts +6 -0
  27. package/templates/basic/src/pages/_404.tsx +17 -0
  28. package/templates/basic/src/pages/about.tsx +22 -0
  29. package/templates/basic/src/pages/blog.tsx +41 -0
  30. package/templates/basic/src/pages/dashboard/_middleware.ts +16 -0
  31. package/templates/basic/src/pages/dashboard/index.tsx +84 -0
  32. package/templates/basic/src/pages/index.tsx +54 -0
  33. package/templates/basic/src/pages/login.tsx +85 -0
  34. package/templates/basic/src/pages/placeholder.tsx +194 -0
  35. package/templates/basic/src/pages/posts/[id].tsx +17 -0
  36. package/templates/basic/src/styles/globals.css +90 -0
  37. package/templates/basic/src/x-routes.ts +29 -0
  38. package/templates/basic/tsconfig.json +11 -0
  39. package/templates/basic/x.config.ts +10 -0
  40. package/templates/blog/components.json +20 -0
  41. package/templates/blog/content/posts/getting-started.md +38 -0
  42. package/templates/blog/content/posts/hello-world.md +21 -0
  43. package/templates/blog/content/posts/tailwind-v4.md +31 -0
  44. package/templates/blog/public/favicon.ico +0 -0
  45. package/templates/blog/src/components/ui/avatar.tsx +91 -0
  46. package/templates/blog/src/components/ui/badge.tsx +49 -0
  47. package/templates/blog/src/components/ui/button.tsx +58 -0
  48. package/templates/blog/src/components/ui/card.tsx +88 -0
  49. package/templates/blog/src/components/ui/input.tsx +20 -0
  50. package/templates/blog/src/layouts/blog.tsx +46 -0
  51. package/templates/blog/src/layouts/main.tsx +32 -0
  52. package/templates/blog/src/lib/utils.ts +5 -0
  53. package/templates/blog/src/pages/about.tsx +36 -0
  54. package/templates/blog/src/pages/blog/[slug].tsx +56 -0
  55. package/templates/blog/src/pages/blog/index.tsx +70 -0
  56. package/templates/blog/src/pages/index.tsx +70 -0
  57. package/templates/blog/src/styles/globals.css +90 -0
  58. package/templates/blog/src/x-routes.ts +20 -0
  59. package/templates/blog/tsconfig.json +5 -0
  60. package/templates/blog/x.config.ts +6 -0
  61. package/templates/landing/components.json +20 -0
  62. package/templates/landing/public/favicon.ico +0 -0
  63. package/templates/landing/src/components/code-block.tsx +24 -0
  64. package/templates/landing/src/components/ui/avatar.tsx +91 -0
  65. package/templates/landing/src/components/ui/badge.tsx +49 -0
  66. package/templates/landing/src/components/ui/button.tsx +58 -0
  67. package/templates/landing/src/components/ui/card.tsx +88 -0
  68. package/templates/landing/src/components/ui/input.tsx +20 -0
  69. package/templates/landing/src/layouts/main.tsx +48 -0
  70. package/templates/landing/src/lib/syntax.tsx +366 -0
  71. package/templates/landing/src/lib/utils.ts +5 -0
  72. package/templates/landing/src/pages/contact.tsx +95 -0
  73. package/templates/landing/src/pages/docs/_layout.tsx +109 -0
  74. package/templates/landing/src/pages/docs/api-routes.tsx +113 -0
  75. package/templates/landing/src/pages/docs/build-deploy.tsx +124 -0
  76. package/templates/landing/src/pages/docs/configuration.tsx +121 -0
  77. package/templates/landing/src/pages/docs/content-collections.tsx +130 -0
  78. package/templates/landing/src/pages/docs/data-layer.tsx +142 -0
  79. package/templates/landing/src/pages/docs/getting-started.tsx +119 -0
  80. package/templates/landing/src/pages/docs/index.tsx +123 -0
  81. package/templates/landing/src/pages/docs/layouts.tsx +114 -0
  82. package/templates/landing/src/pages/docs/middleware.tsx +124 -0
  83. package/templates/landing/src/pages/docs/pages.tsx +135 -0
  84. package/templates/landing/src/pages/docs/routing.tsx +123 -0
  85. package/templates/landing/src/pages/docs/server-functions.tsx +123 -0
  86. package/templates/landing/src/pages/features.tsx +129 -0
  87. package/templates/landing/src/pages/index.tsx +175 -0
  88. package/templates/landing/src/styles/globals.css +100 -0
  89. package/templates/landing/src/x-routes.ts +31 -0
  90. package/templates/landing/tsconfig.json +5 -0
  91. package/templates/landing/x.config.ts +2 -0
  92. package/templates/saas/components.json +20 -0
  93. package/templates/saas/public/favicon.ico +0 -0
  94. package/templates/saas/src/actions/dashboard.ts +3 -0
  95. package/templates/saas/src/components/ui/avatar.tsx +91 -0
  96. package/templates/saas/src/components/ui/badge.tsx +49 -0
  97. package/templates/saas/src/components/ui/button.tsx +58 -0
  98. package/templates/saas/src/components/ui/card.tsx +88 -0
  99. package/templates/saas/src/components/ui/input.tsx +20 -0
  100. package/templates/saas/src/layouts/dashboard.tsx +67 -0
  101. package/templates/saas/src/layouts/main.tsx +38 -0
  102. package/templates/saas/src/lib/auth.ts +70 -0
  103. package/templates/saas/src/lib/migrations/001_create_sessions.sql +9 -0
  104. package/templates/saas/src/lib/utils.ts +5 -0
  105. package/templates/saas/src/pages/dashboard/_middleware.ts +9 -0
  106. package/templates/saas/src/pages/dashboard/analytics.tsx +68 -0
  107. package/templates/saas/src/pages/dashboard/index.tsx +86 -0
  108. package/templates/saas/src/pages/dashboard/settings.tsx +105 -0
  109. package/templates/saas/src/pages/index.tsx +110 -0
  110. package/templates/saas/src/pages/login.tsx +67 -0
  111. package/templates/saas/src/pages/pricing.tsx +121 -0
  112. package/templates/saas/src/styles/globals.css +90 -0
  113. package/templates/saas/src/x-routes.ts +22 -0
  114. package/templates/saas/tsconfig.json +5 -0
  115. package/templates/saas/x.config.ts +7 -0
package/dist/index.js ADDED
@@ -0,0 +1,224 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { spawnSync } from "child_process";
5
+ import { existsSync, mkdirSync, readdirSync, writeFileSync, cpSync } from "fs";
6
+ import { createInterface } from "readline/promises";
7
+ import { dirname, join, resolve } from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ // src/templates.ts
11
+ var TEMPLATES = {
12
+ basic: {
13
+ label: "Basic",
14
+ description: "Minimal starter: pages, an API route, auth, and a dashboard.",
15
+ dependencies: {
16
+ "@base-ui/react": "^1.6.0",
17
+ "@tailwindcss/cli": "^4.3.3",
18
+ "class-variance-authority": "^0.7.1",
19
+ clsx: "^2.1.1",
20
+ "lucide-react": "^1.27.0",
21
+ react: "^19.0.0",
22
+ "react-dom": "^19.0.0",
23
+ shadcn: "^4.15.0",
24
+ "tailwind-merge": "^3.6.0",
25
+ tailwindcss: "^4.3.3",
26
+ "tw-animate-css": "^1.4.0"
27
+ },
28
+ devDependencies: {
29
+ "@types/react": "^19.0.0",
30
+ "@types/react-dom": "^19.0.0"
31
+ }
32
+ },
33
+ blog: {
34
+ label: "Blog",
35
+ description: "Markdown content collections, post listing, and post pages.",
36
+ dependencies: {
37
+ react: "^19.1.0",
38
+ "react-dom": "^19.1.0",
39
+ shadcn: "^4.2.0",
40
+ "class-variance-authority": "^0.7.1",
41
+ clsx: "^2.1.1",
42
+ "tailwind-merge": "^3.2.0",
43
+ "lucide-react": "^0.511.0",
44
+ "tw-animate-css": "^1.2.0",
45
+ "@base-ui/react": "^1.6.0"
46
+ },
47
+ devDependencies: {
48
+ "@tailwindcss/cli": "^4.3.3",
49
+ "@types/react": "^19.1.0",
50
+ "@types/react-dom": "^19.1.0",
51
+ tailwindcss: "^4.3.3",
52
+ typescript: "^5.8.0"
53
+ }
54
+ },
55
+ saas: {
56
+ label: "SaaS",
57
+ description: "Dashboard, settings, pricing, auth, and a data layer example.",
58
+ dependencies: {
59
+ react: "^19.1.0",
60
+ "react-dom": "^19.1.0",
61
+ shadcn: "^4.2.0",
62
+ "class-variance-authority": "^0.7.1",
63
+ clsx: "^2.1.1",
64
+ "tailwind-merge": "^3.2.0",
65
+ "lucide-react": "^0.511.0",
66
+ "tw-animate-css": "^1.2.0",
67
+ "@base-ui/react": "^1.6.0"
68
+ },
69
+ devDependencies: {
70
+ "@tailwindcss/cli": "^4.3.3",
71
+ "@types/react": "^19.1.0",
72
+ "@types/react-dom": "^19.1.0",
73
+ tailwindcss: "^4.3.3",
74
+ typescript: "^5.8.0"
75
+ }
76
+ },
77
+ landing: {
78
+ label: "Landing",
79
+ description: "Marketing site with docs pages, styled with shadcn/Tailwind.",
80
+ dependencies: {
81
+ react: "^19.1.0",
82
+ "react-dom": "^19.1.0",
83
+ shadcn: "^4.2.0",
84
+ "class-variance-authority": "^0.7.1",
85
+ clsx: "^2.1.1",
86
+ "tailwind-merge": "^3.2.0",
87
+ "lucide-react": "^0.511.0",
88
+ "tw-animate-css": "^1.2.0",
89
+ "@base-ui/react": "^1.6.0"
90
+ },
91
+ devDependencies: {
92
+ "@tailwindcss/cli": "^4.3.3",
93
+ "@types/react": "^19.1.0",
94
+ "@types/react-dom": "^19.1.0",
95
+ tailwindcss: "^4.3.3",
96
+ typescript: "^5.8.0"
97
+ }
98
+ }
99
+ };
100
+ var TEMPLATE_NAMES = Object.keys(TEMPLATES);
101
+
102
+ // src/index.ts
103
+ var __dirname = dirname(fileURLToPath(import.meta.url));
104
+ var TEMPLATES_ROOT = join(__dirname, "..", "templates");
105
+ var FALLBACK_CORE_VERSION = "0.1.0";
106
+ function slugify(name) {
107
+ return name.trim().toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "thexjs-app";
108
+ }
109
+ async function fetchLatestVersion(pkg) {
110
+ try {
111
+ const controller = new AbortController();
112
+ const timeout = setTimeout(() => controller.abort(), 3e3);
113
+ const res = await fetch(`https://registry.npmjs.org/${pkg}/latest`, {
114
+ signal: controller.signal
115
+ });
116
+ clearTimeout(timeout);
117
+ if (!res.ok) return null;
118
+ const data = await res.json();
119
+ return data.version ?? null;
120
+ } catch {
121
+ return null;
122
+ }
123
+ }
124
+ async function prompt(question, fallback) {
125
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
126
+ const suffix = fallback ? ` (${fallback})` : "";
127
+ const answer = await rl.question(`${question}${suffix}: `);
128
+ rl.close();
129
+ return answer.trim() || fallback || "";
130
+ }
131
+ function printBanner() {
132
+ console.log("");
133
+ console.log(" create-thexjs-app");
134
+ console.log(" ------------------");
135
+ console.log("");
136
+ }
137
+ function printTemplateList() {
138
+ for (const name of TEMPLATE_NAMES) {
139
+ const meta = TEMPLATES[name];
140
+ console.log(` ${name.padEnd(8)} ${meta.description}`);
141
+ }
142
+ }
143
+ async function main() {
144
+ printBanner();
145
+ const argv = process.argv.slice(2);
146
+ const positional = argv.filter((a) => !a.startsWith("--"));
147
+ const templateFlagIndex = argv.findIndex((a) => a === "--template" || a === "-t");
148
+ let templateArg = templateFlagIndex !== -1 ? argv[templateFlagIndex + 1] : void 0;
149
+ let projectName = positional[0];
150
+ if (!projectName) {
151
+ projectName = await prompt("Project name", "my-thexjs-app");
152
+ }
153
+ const slug = slugify(projectName);
154
+ const targetDir = resolve(process.cwd(), slug);
155
+ if (existsSync(targetDir) && readdirSync(targetDir).length > 0) {
156
+ console.error(`
157
+ [create-thexjs-app] Directory "${slug}" already exists and is not empty.`);
158
+ process.exit(1);
159
+ }
160
+ if (!templateArg || !TEMPLATES[templateArg]) {
161
+ console.log("\n Available templates:\n");
162
+ printTemplateList();
163
+ console.log("");
164
+ templateArg = await prompt(`Choose a template (${TEMPLATE_NAMES.join("/")})`, "basic");
165
+ }
166
+ if (!TEMPLATES[templateArg]) {
167
+ console.error(`
168
+ [create-thexjs-app] Unknown template "${templateArg}".`);
169
+ process.exit(1);
170
+ }
171
+ const meta = TEMPLATES[templateArg];
172
+ const templateDir = join(TEMPLATES_ROOT, templateArg);
173
+ console.log(`
174
+ [create-thexjs-app] Scaffolding "${slug}" from the "${templateArg}" template...`);
175
+ mkdirSync(targetDir, { recursive: true });
176
+ cpSync(templateDir, targetDir, { recursive: true });
177
+ console.log("[create-thexjs-app] Resolving latest @thexjs package versions...");
178
+ const coreVersion = await fetchLatestVersion("@thexjs/core") ?? FALLBACK_CORE_VERSION;
179
+ const cliVersion = await fetchLatestVersion("@thexjs/cli") ?? FALLBACK_CORE_VERSION;
180
+ const pkgJson = {
181
+ name: slug,
182
+ private: true,
183
+ type: "module",
184
+ scripts: {
185
+ dev: "x dev",
186
+ build: "x build",
187
+ start: "x start"
188
+ },
189
+ dependencies: {
190
+ "@thexjs/core": `^${coreVersion}`,
191
+ ...meta.dependencies
192
+ },
193
+ devDependencies: {
194
+ "@thexjs/cli": `^${cliVersion}`,
195
+ ...meta.devDependencies
196
+ }
197
+ };
198
+ writeFileSync(join(targetDir, "package.json"), `${JSON.stringify(pkgJson, null, 2)}
199
+ `);
200
+ console.log(`[create-thexjs-app] Created ${slug}/`);
201
+ const hasBun = spawnSync("bun", ["--version"], { stdio: "ignore" }).status === 0;
202
+ if (hasBun) {
203
+ console.log("[create-thexjs-app] Installing dependencies with bun install...");
204
+ const result = spawnSync("bun", ["install"], { cwd: targetDir, stdio: "inherit" });
205
+ if (result.status !== 0) {
206
+ console.warn("[create-thexjs-app] bun install failed \u2014 you can retry manually.");
207
+ }
208
+ } else {
209
+ console.warn(
210
+ "[create-thexjs-app] Bun was not found on your PATH. Install it from https://bun.sh, then run `bun install` inside the project \u2014 the x framework requires Bun to run."
211
+ );
212
+ }
213
+ console.log("");
214
+ console.log(" Done! Next steps:");
215
+ console.log("");
216
+ console.log(` cd ${slug}`);
217
+ if (!hasBun) console.log(" bun install");
218
+ console.log(" bun run dev");
219
+ console.log("");
220
+ }
221
+ main().catch((err) => {
222
+ console.error(err);
223
+ process.exit(1);
224
+ });
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "create-thexjs-app",
3
+ "version": "0.1.0",
4
+ "description": "Scaffold a new x framework app (npm create thexjs-app@latest).",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "bin": {
8
+ "create-thexjs-app": "./dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "templates",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "scripts": {
20
+ "build": "tsup src/index.ts --format esm --clean --target node18 --shims false --no-splitting",
21
+ "prepublishOnly": "bun run build"
22
+ },
23
+ "engines": {
24
+ "node": ">=18"
25
+ },
26
+ "devDependencies": {
27
+ "@types/node": "^22.0.0",
28
+ "tsup": "^8.3.0"
29
+ }
30
+ }
@@ -0,0 +1,21 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "base-nova",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/styles/globals.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "aliases": {
14
+ "components": "@/components",
15
+ "utils": "@/lib/utils",
16
+ "ui": "@/components/ui",
17
+ "lib": "@/lib",
18
+ "hooks": "@/hooks"
19
+ },
20
+ "iconLibrary": "lucide"
21
+ }
@@ -0,0 +1,8 @@
1
+ ---
2
+ title: Hello from content collections
3
+ ---
4
+
5
+ This page is rendered from a markdown file in `content/`.
6
+
7
+ Content collections let you write blog posts, docs, and marketing pages as
8
+ plain markdown with frontmatter — no route files needed.
@@ -0,0 +1,3 @@
1
+ export async function greet(name: string): Promise<string> {
2
+ return `Hello, ${name}! The server time is ${new Date().toLocaleTimeString()}.`;
3
+ }
@@ -0,0 +1,30 @@
1
+ import type { RouteProps } from "@thexjs/core";
2
+ import { createSession, setSessionCookie } from "../../lib/auth";
3
+
4
+ export async function POST(req: Request): Promise<Response> {
5
+ try {
6
+ const body = (await req.json()) as { username?: string; password?: string };
7
+ const { username, password } = body;
8
+
9
+ if (!username || !password) {
10
+ return Response.json({ error: "username and password required" }, { status: 400 });
11
+ }
12
+
13
+ if (username !== "admin" || password !== "admin") {
14
+ return Response.json({ error: "invalid credentials" }, { status: 401 });
15
+ }
16
+
17
+ const session = createSession(username);
18
+ const cookie = setSessionCookie(session.token);
19
+ return new Response(JSON.stringify({ user: { username: session.username } }), {
20
+ status: 200,
21
+ headers: {
22
+ "Content-Type": "application/json",
23
+ "Set-Cookie": cookie,
24
+ },
25
+ });
26
+ } catch (err) {
27
+ console.error("[auth] login error:", err);
28
+ return Response.json({ error: "internal error" }, { status: 500 });
29
+ }
30
+ }
@@ -0,0 +1,12 @@
1
+ import { clearSessionCookie, deleteSession, parseSessionCookie } from "../../lib/auth";
2
+
3
+ export async function POST(req: Request): Promise<Response> {
4
+ const token = parseSessionCookie(req.headers.get("Cookie"));
5
+ if (token) {
6
+ deleteSession(token);
7
+ }
8
+ return new Response("OK", {
9
+ status: 200,
10
+ headers: { "Set-Cookie": clearSessionCookie() },
11
+ });
12
+ }
@@ -0,0 +1,17 @@
1
+ import { data } from "../../lib/placeholder-data";
2
+
3
+ export function GET(req: Request): Response {
4
+ const url = new URL(req.url);
5
+ const postId = url.searchParams.get("postId");
6
+ if (postId) return Response.json(data.comments.filter((c) => c.postId === Number(postId)));
7
+
8
+ const page = Math.max(1, Number(url.searchParams.get("page")) || 1);
9
+ const limit = Math.min(500, Math.max(1, Number(url.searchParams.get("limit")) || 20));
10
+ const start = (page - 1) * limit;
11
+ return Response.json({
12
+ total: data.comments.length,
13
+ page,
14
+ limit,
15
+ data: data.comments.slice(start, start + limit),
16
+ });
17
+ }
@@ -0,0 +1,20 @@
1
+ import { data } from "../../lib/placeholder-data";
2
+
3
+ export function GET(req: Request): Response {
4
+ const url = new URL(req.url);
5
+ const id = url.searchParams.get("id");
6
+ if (id) {
7
+ const post = data.posts.find((p) => p.id === Number(id));
8
+ if (!post) return Response.json({ error: "not found" }, { status: 404 });
9
+ return Response.json(post);
10
+ }
11
+ const page = Math.max(1, Number(url.searchParams.get("page")) || 1);
12
+ const limit = Math.min(100, Math.max(1, Number(url.searchParams.get("limit")) || 20));
13
+ const start = (page - 1) * limit;
14
+ return Response.json({
15
+ total: data.posts.length,
16
+ page,
17
+ limit,
18
+ data: data.posts.slice(start, start + limit),
19
+ });
20
+ }
@@ -0,0 +1,21 @@
1
+ import { data } from "../../lib/placeholder-data";
2
+
3
+ export function GET(req: Request): Response {
4
+ const url = new URL(req.url);
5
+ const userId = url.searchParams.get("userId");
6
+ let items = data.todos;
7
+ if (userId) items = items.filter((t) => t.userId === Number(userId));
8
+ const completedParam = url.searchParams.get("completed");
9
+ if (completedParam !== null)
10
+ items = items.filter((t) => t.completed === (completedParam === "true"));
11
+
12
+ const page = Math.max(1, Number(url.searchParams.get("page")) || 1);
13
+ const limit = Math.min(200, Math.max(1, Number(url.searchParams.get("limit")) || 20));
14
+ const start = (page - 1) * limit;
15
+ return Response.json({
16
+ total: items.length,
17
+ page,
18
+ limit,
19
+ data: items.slice(start, start + limit),
20
+ });
21
+ }
@@ -0,0 +1,12 @@
1
+ import { data } from "../../lib/placeholder-data";
2
+
3
+ export function GET(req: Request): Response {
4
+ const url = new URL(req.url);
5
+ const id = url.searchParams.get("id");
6
+ if (id) {
7
+ const user = data.users.find((u) => u.id === Number(id));
8
+ if (!user) return Response.json({ error: "not found" }, { status: 404 });
9
+ return Response.json(user);
10
+ }
11
+ return Response.json(data.users);
12
+ }
@@ -0,0 +1,21 @@
1
+ interface HeadProps {
2
+ title: string;
3
+ description?: string;
4
+ ogImage?: string;
5
+ ogType?: string;
6
+ children?: React.ReactNode;
7
+ }
8
+
9
+ export default function Head({ title, description, ogImage, ogType, children }: HeadProps) {
10
+ return (
11
+ <>
12
+ <title>{title}</title>
13
+ <meta property="og:title" content={title} />
14
+ {description && <meta name="description" content={description} />}
15
+ {description && <meta property="og:description" content={description} />}
16
+ {ogImage && <meta property="og:image" content={ogImage} />}
17
+ {ogType && <meta property="og:type" content={ogType} />}
18
+ {children}
19
+ </>
20
+ );
21
+ }
@@ -0,0 +1,27 @@
1
+ interface ImageProps {
2
+ src: string;
3
+ alt: string;
4
+ width?: number;
5
+ height?: number;
6
+ lazy?: boolean;
7
+ className?: string;
8
+ }
9
+
10
+ export default function Image({ src, alt, width, height, lazy = true, className }: ImageProps) {
11
+ return (
12
+ <img
13
+ src={src}
14
+ alt={alt}
15
+ width={width}
16
+ height={height}
17
+ loading={lazy ? "lazy" : "eager"}
18
+ decoding="async"
19
+ className={className}
20
+ style={{
21
+ maxWidth: "100%",
22
+ height: "auto",
23
+ ...(width && height ? { aspectRatio: `${width}/${height}` } : {}),
24
+ }}
25
+ />
26
+ );
27
+ }
@@ -0,0 +1,16 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ interface LinkProps {
4
+ href: string;
5
+ children: ReactNode;
6
+ className?: string;
7
+ prefetch?: boolean;
8
+ }
9
+
10
+ export default function Link({ href, children, className, prefetch = true }: LinkProps) {
11
+ return (
12
+ <a href={href} className={className} data-no-nav={prefetch ? undefined : ""}>
13
+ {children}
14
+ </a>
15
+ );
16
+ }
@@ -0,0 +1,49 @@
1
+ import { mergeProps } from "@base-ui/react/merge-props";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { type VariantProps, cva } from "class-variance-authority";
4
+
5
+ import { cn } from "@/lib/utils";
6
+
7
+ const badgeVariants = cva(
8
+ "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",
9
+ {
10
+ variants: {
11
+ variant: {
12
+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
13
+ secondary: "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",
14
+ destructive:
15
+ "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",
16
+ outline: "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",
17
+ ghost: "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",
18
+ link: "text-primary underline-offset-4 hover:underline",
19
+ },
20
+ },
21
+ defaultVariants: {
22
+ variant: "default",
23
+ },
24
+ },
25
+ );
26
+
27
+ function Badge({
28
+ className,
29
+ variant = "default",
30
+ render,
31
+ ...props
32
+ }: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
33
+ return useRender({
34
+ defaultTagName: "span",
35
+ props: mergeProps<"span">(
36
+ {
37
+ className: cn(badgeVariants({ variant }), className),
38
+ },
39
+ props,
40
+ ),
41
+ render,
42
+ state: {
43
+ slot: "badge",
44
+ variant,
45
+ },
46
+ });
47
+ }
48
+
49
+ export { Badge, badgeVariants };
@@ -0,0 +1,58 @@
1
+ import { Button as ButtonPrimitive } from "@base-ui/react/button";
2
+ import { type VariantProps, cva } from "class-variance-authority";
3
+
4
+ import { cn } from "@/lib/utils";
5
+
6
+ const buttonVariants = cva(
7
+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default: "bg-primary text-primary-foreground hover:bg-primary/80",
12
+ outline:
13
+ "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
14
+ secondary:
15
+ "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
16
+ ghost:
17
+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
18
+ destructive:
19
+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
20
+ link: "text-primary underline-offset-4 hover:underline",
21
+ },
22
+ size: {
23
+ default:
24
+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
25
+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
26
+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
27
+ lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
28
+ icon: "size-8",
29
+ "icon-xs":
30
+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
31
+ "icon-sm":
32
+ "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
33
+ "icon-lg": "size-9",
34
+ },
35
+ },
36
+ defaultVariants: {
37
+ variant: "default",
38
+ size: "default",
39
+ },
40
+ },
41
+ );
42
+
43
+ function Button({
44
+ className,
45
+ variant = "default",
46
+ size = "default",
47
+ ...props
48
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
49
+ return (
50
+ <ButtonPrimitive
51
+ data-slot="button"
52
+ className={cn(buttonVariants({ variant, size, className }))}
53
+ {...props}
54
+ />
55
+ );
56
+ }
57
+
58
+ export { Button, buttonVariants };
@@ -0,0 +1,88 @@
1
+ import type * as React from "react";
2
+
3
+ import { cn } from "@/lib/utils";
4
+
5
+ function Card({
6
+ className,
7
+ size = "default",
8
+ ...props
9
+ }: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
10
+ return (
11
+ <div
12
+ data-slot="card"
13
+ data-size={size}
14
+ className={cn(
15
+ "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-xl *:[img:last-child]:rounded-b-xl",
16
+ className,
17
+ )}
18
+ {...props}
19
+ />
20
+ );
21
+ }
22
+
23
+ function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
24
+ return (
25
+ <div
26
+ data-slot="card-header"
27
+ className={cn(
28
+ "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
29
+ className,
30
+ )}
31
+ {...props}
32
+ />
33
+ );
34
+ }
35
+
36
+ function CardTitle({ className, ...props }: React.ComponentProps<"div">) {
37
+ return (
38
+ <div
39
+ data-slot="card-title"
40
+ className={cn(
41
+ "text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",
42
+ className,
43
+ )}
44
+ {...props}
45
+ />
46
+ );
47
+ }
48
+
49
+ function CardDescription({ className, ...props }: React.ComponentProps<"div">) {
50
+ return (
51
+ <div
52
+ data-slot="card-description"
53
+ className={cn("text-sm text-muted-foreground", className)}
54
+ {...props}
55
+ />
56
+ );
57
+ }
58
+
59
+ function CardAction({ className, ...props }: React.ComponentProps<"div">) {
60
+ return (
61
+ <div
62
+ data-slot="card-action"
63
+ className={cn("col-start-2 row-span-2 row-start-1 self-start justify-self-end", className)}
64
+ {...props}
65
+ />
66
+ );
67
+ }
68
+
69
+ function CardContent({ className, ...props }: React.ComponentProps<"div">) {
70
+ return (
71
+ <div data-slot="card-content" className={cn("px-(--card-spacing)", className)} {...props} />
72
+ );
73
+ }
74
+
75
+ function CardFooter({ className, ...props }: React.ComponentProps<"div">) {
76
+ return (
77
+ <div
78
+ data-slot="card-footer"
79
+ className={cn(
80
+ "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",
81
+ className,
82
+ )}
83
+ {...props}
84
+ />
85
+ );
86
+ }
87
+
88
+ export { Card, CardHeader, CardFooter, CardTitle, CardAction, CardDescription, CardContent };