create-thexjs-app 0.1.3 → 0.1.4

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/dist/index.js CHANGED
@@ -180,6 +180,7 @@ function printBanner() {
180
180
  function printTemplateList() {
181
181
  for (const name of TEMPLATE_NAMES) {
182
182
  const meta = TEMPLATES[name];
183
+ if (!meta) continue;
183
184
  const tag = meta.recommended ? dimText(" (recommended)") : "";
184
185
  console.log(` ${name.padEnd(8)} ${meta.description}${tag}`);
185
186
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-thexjs-app",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Scaffold a new x framework app (npm create thexjs-app@latest).",
5
5
  "keywords": [
6
6
  "react",
@@ -1,6 +1,11 @@
1
+ import type { Database } from "bun:sqlite";
2
+ // DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
3
+ // no session expiry. This auth is a placeholder for demos — replace with real
4
+ // credential storage (hashed passwords) before shipping anything production.
1
5
  import { randomUUID } from "node:crypto";
2
- import { join } from "node:path";
3
- import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
6
+ import { mkdirSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
4
9
 
5
10
  const SESSION_COOKIE = "x_session";
6
11
  const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
@@ -12,9 +17,13 @@ export interface Session {
12
17
  username: string;
13
18
  }
14
19
 
15
- function getDb() {
20
+ let db: Database | null = null;
21
+
22
+ function getDb(): Database {
23
+ if (db) return db;
16
24
  const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
17
- const db = connectSQLite({ path: dbPath });
25
+ mkdirSync(dirname(dbPath), { recursive: true });
26
+ db = connectSQLite({ path: dbPath });
18
27
  runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
19
28
  return db;
20
29
  }
@@ -61,10 +70,12 @@ export function parseSessionCookie(cookieHeader: string | null): string | undefi
61
70
  return undefined;
62
71
  }
63
72
 
73
+ const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
74
+
64
75
  export function setSessionCookie(token: string): string {
65
- return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}`;
76
+ return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
66
77
  }
67
78
 
68
79
  export function clearSessionCookie(): string {
69
- return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
80
+ return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
70
81
  }
@@ -55,12 +55,16 @@ export default function LoginPage({ loaderData }: RouteProps) {
55
55
  <h1 className="text-2xl font-bold text-center">Login</h1>
56
56
  <form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-4">
57
57
  <div className="space-y-2">
58
- <label className="text-sm font-medium">Username</label>
59
- <Input name="username" defaultValue="admin" required />
58
+ <label htmlFor="username" className="text-sm font-medium">
59
+ Username
60
+ </label>
61
+ <Input id="username" name="username" defaultValue="admin" required />
60
62
  </div>
61
63
  <div className="space-y-2">
62
- <label className="text-sm font-medium">Password</label>
63
- <Input name="password" type="password" defaultValue="admin" required />
64
+ <label htmlFor="password" className="text-sm font-medium">
65
+ Password
66
+ </label>
67
+ <Input id="password" name="password" type="password" defaultValue="admin" required />
64
68
  </div>
65
69
  {error && (
66
70
  <p id="login-error" className="text-sm text-destructive">
@@ -72,6 +76,9 @@ export default function LoginPage({ loaderData }: RouteProps) {
72
76
  </Button>
73
77
  </form>
74
78
  <p className="text-xs text-muted-foreground text-center">Demo credentials: admin / admin</p>
79
+ <p className="text-xs text-muted-foreground text-center">
80
+ Demo only — replace with real auth before shipping.
81
+ </p>
75
82
  <p className="text-center">
76
83
  <a
77
84
  href="/"
@@ -26,6 +26,7 @@ export default function PlaceholderPage() {
26
26
  <td className="text-right p-3">100</td>
27
27
  <td className="text-right p-3">
28
28
  <button
29
+ type="button"
29
30
  className="fetch-btn text-primary hover:underline text-xs"
30
31
  data-url="/api/placeholder/posts"
31
32
  >
@@ -42,6 +43,7 @@ export default function PlaceholderPage() {
42
43
  <td className="text-right p-3">500</td>
43
44
  <td className="text-right p-3">
44
45
  <button
46
+ type="button"
45
47
  className="fetch-btn text-primary hover:underline text-xs"
46
48
  data-url="/api/placeholder/comments"
47
49
  >
@@ -56,6 +58,7 @@ export default function PlaceholderPage() {
56
58
  <td className="text-right p-3">200</td>
57
59
  <td className="text-right p-3">
58
60
  <button
61
+ type="button"
59
62
  className="fetch-btn text-primary hover:underline text-xs"
60
63
  data-url="/api/placeholder/todos"
61
64
  >
@@ -70,6 +73,7 @@ export default function PlaceholderPage() {
70
73
  <td className="text-right p-3">10</td>
71
74
  <td className="text-right p-3">
72
75
  <button
76
+ type="button"
73
77
  className="fetch-btn text-primary hover:underline text-xs"
74
78
  data-url="/api/placeholder/users"
75
79
  >
@@ -82,7 +86,11 @@ export default function PlaceholderPage() {
82
86
  All endpoints (sequential)
83
87
  </td>
84
88
  <td className="text-right p-3">
85
- <button id="fetch-all" className="fetch-btn text-primary hover:underline text-xs">
89
+ <button
90
+ id="fetch-all"
91
+ type="button"
92
+ className="fetch-btn text-primary hover:underline text-xs"
93
+ >
86
94
  Fetch All
87
95
  </button>
88
96
  </td>
@@ -59,7 +59,10 @@ export default function HomePage() {
59
59
  placeholder="Enter your email"
60
60
  className="flex-1 rounded-lg border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
61
61
  />
62
- <button className="rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90">
62
+ <button
63
+ type="button"
64
+ className="rounded-lg bg-primary px-6 py-2.5 text-sm font-medium text-primary-foreground transition-colors hover:bg-primary/90"
65
+ >
63
66
  Subscribe
64
67
  </button>
65
68
  </div>
@@ -20,7 +20,7 @@ export default function DocPage(_props: RouteProps) {
20
20
  </p>
21
21
  <CodeBlock
22
22
  label="src/lib/db.ts"
23
- code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
23
+ code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
24
24
 
25
25
  const db = connectSQLite("data/app.db");
26
26
 
@@ -96,7 +96,7 @@ export default function Users({ loaderData }: RouteProps<typeof loader>) {
96
96
  </p>
97
97
  <CodeBlock
98
98
  label="src/lib/db.ts"
99
- code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core";
99
+ code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core/data";
100
100
 
101
101
  const db = connectPostgres({
102
102
  connectionString: process.env.DATABASE_URL,
@@ -131,14 +131,14 @@ const html = renderMarkdown(posts[0].body);`}
131
131
  <h2 className="mt-12 text-xl font-bold tracking-tight">Data layer</h2>
132
132
  <CodeBlock
133
133
  label="sqlite"
134
- code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
134
+ code={`import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
135
135
 
136
136
  const db = connectSQLite({ filename: "./data/dev.db" });
137
137
  await runSQLiteMigrations(db, "./data/migrations");`}
138
138
  />
139
139
  <CodeBlock
140
140
  label="postgres"
141
- code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core";
141
+ code={`import { connectPostgres, runPostgresMigrations } from "@thexjs/core/data";
142
142
 
143
143
  const sql = connectPostgres({ url: process.env.DATABASE_URL! });
144
144
  await runPostgresMigrations(sql, "./data/migrations");`}
@@ -10,9 +10,10 @@ export default function DocPage(_props: RouteProps) {
10
10
  </p>
11
11
  <h1 className="mt-4 text-3xl font-bold tracking-tight sm:text-4xl">Server functions</h1>
12
12
  <p className="mt-4 text-lg text-muted-foreground">
13
- Call server-side functions directly from the browser without writing REST endpoints. Server
14
- functions live in <span className="text-foreground">src/actions/</span> and are invoked via
15
- fetch.
13
+ Call server-side functions from the browser without writing REST endpoints. Server functions
14
+ live in <span className="text-foreground">src/actions/</span>. Import one into a client
15
+ component and call it like a normal function, or call it manually with{" "}
16
+ <span className="text-foreground">fetch</span> — both compile down to the same request.
16
17
  </p>
17
18
 
18
19
  <h2 className="mt-12 text-xl font-bold tracking-tight">Defining server functions</h2>
@@ -37,9 +38,58 @@ export async function sendEmail({ to, subject, body }: {
37
38
  }`}
38
39
  />
39
40
 
40
- <h2 className="mt-12 text-xl font-bold tracking-tight">Calling from the browser</h2>
41
+ <h2 className="mt-12 text-xl font-bold tracking-tight">Calling actions directly</h2>
41
42
  <p className="mt-3 text-muted-foreground">
42
- Server functions are called by sending a POST request to{" "}
43
+ Import the function into a client component and call it like any other async function. When
44
+ you run <span className="text-foreground">x build</span>, the bundler swaps the import for a
45
+ generated fetch client before it reaches the browser, so the real implementation, db calls
46
+ and all, never gets bundled.
47
+ </p>
48
+ <CodeBlock
49
+ label="client component"
50
+ code={`"use client";
51
+
52
+ import { useState } from "react";
53
+ import { subscribeUser } from "../actions/subscribe";
54
+
55
+ export default function SubscribeForm() {
56
+ const [status, setStatus] = useState("");
57
+
58
+ async function handleSubmit(e: React.FormEvent) {
59
+ e.preventDefault();
60
+ const form = new FormData(e.target as HTMLFormElement);
61
+ const email = form.get("email") as string;
62
+
63
+ await subscribeUser(email);
64
+ setStatus("Subscribed!");
65
+ }
66
+
67
+ return (
68
+ <form onSubmit={handleSubmit} className="space-y-4">
69
+ <input
70
+ name="email"
71
+ type="email"
72
+ placeholder="you@example.com"
73
+ className="rounded-xl border border-border bg-card px-4 py-2"
74
+ />
75
+ <button type="submit" className="rounded-xl bg-primary px-4 py-2 text-primary-foreground">
76
+ Subscribe
77
+ </button>
78
+ {status && <p className="text-muted-foreground">{status}</p>}
79
+ </form>
80
+ );
81
+ }`}
82
+ />
83
+ <p className="mt-3 text-sm text-muted-foreground">
84
+ Only files under <span className="text-foreground">actionsDir</span> get this treatment.
85
+ Import a regular server-only helper into client code and it bundles as-is; if it leaks a
86
+ secret, the build-time env isolation check catches it instead.
87
+ </p>
88
+
89
+ <h2 className="mt-12 text-xl font-bold tracking-tight">Calling manually with fetch</h2>
90
+ <p className="mt-3 text-muted-foreground">
91
+ This is what the direct-import style compiles down to, and it works the same way in dev and
92
+ in production: a POST request to{" "}
43
93
  <span className="text-foreground">/__x/actions/&lt;filename&gt;/&lt;functionName&gt;</span>.
44
94
  The arguments are sent as JSON in the request body.
45
95
  </p>
@@ -82,6 +132,10 @@ export default function GreetForm() {
82
132
  );
83
133
  }`}
84
134
  />
135
+ <p className="mt-3 text-sm text-muted-foreground">
136
+ Reach for this style directly when you're calling an action from outside an island, or
137
+ anywhere you'd rather see the request explicitly.
138
+ </p>
85
139
 
86
140
  <h2 className="mt-12 text-xl font-bold tracking-tight">Server functions from loaders</h2>
87
141
  <p className="mt-3 text-muted-foreground">
@@ -37,7 +37,7 @@ const allFeatures = [
37
37
  {
38
38
  icon: Server,
39
39
  title: "Server functions",
40
- desc: "Call server-side functions from the browser without writing REST endpoints. Just export async functions from src/actions/ and call them via fetch.",
40
+ desc: "Call server-side functions from the browser without writing REST endpoints. Import them into a client component and call them directly, or by hand with fetch.",
41
41
  },
42
42
  {
43
43
  icon: Shield,
@@ -1,5 +1,10 @@
1
1
  {
2
2
  "extends": "../../tsconfig.base.json",
3
3
  "compilerOptions": { "noEmit": true, "baseUrl": ".", "paths": { "@/*": ["./src/*"] } },
4
- "include": ["src"]
4
+ "include": [
5
+ "src",
6
+ "../../../core/src/build.ts",
7
+ "../../../core/src/client-nav.ts",
8
+ "../../../core/src/createApp.ts"
9
+ ]
5
10
  }
@@ -0,0 +1,31 @@
1
+ // DEMO ONLY: admin/admin with plaintext comparison via the shared
2
+ // authenticate() helper — replace with real credential storage before shipping.
3
+ import { authenticate, setSessionCookie } from "../../lib/auth";
4
+
5
+ export async function POST(req: Request): Promise<Response> {
6
+ try {
7
+ const body = (await req.json()) as { email?: string; password?: string };
8
+ const { email, password } = body;
9
+
10
+ if (!email || !password) {
11
+ return Response.json({ error: "email and password required" }, { status: 400 });
12
+ }
13
+
14
+ const session = authenticate(email, password);
15
+ if (!session) {
16
+ return Response.json({ error: "invalid credentials" }, { status: 401 });
17
+ }
18
+
19
+ const cookie = setSessionCookie(session.token);
20
+ return new Response(JSON.stringify({ user: { username: session.username } }), {
21
+ status: 200,
22
+ headers: {
23
+ "Content-Type": "application/json",
24
+ "Set-Cookie": cookie,
25
+ },
26
+ });
27
+ } catch (err) {
28
+ console.error("[auth] login error:", err);
29
+ return Response.json({ error: "internal error" }, { status: 500 });
30
+ }
31
+ }
@@ -1,6 +1,11 @@
1
+ import type { Database } from "bun:sqlite";
2
+ // DEMO ONLY: hardcoded admin/admin credentials, plaintext password comparison,
3
+ // no session expiry. This auth is a placeholder for demos — replace with real
4
+ // credential storage (hashed passwords) before shipping anything production.
1
5
  import { randomUUID } from "node:crypto";
2
- import { join } from "node:path";
3
- import { connectSQLite, runSQLiteMigrations } from "@thexjs/core";
6
+ import { mkdirSync } from "node:fs";
7
+ import { dirname, join } from "node:path";
8
+ import { connectSQLite, runSQLiteMigrations } from "@thexjs/core/data";
4
9
 
5
10
  const SESSION_COOKIE = "x_session";
6
11
  const SESSION_MAX_AGE = 60 * 60 * 24 * 7;
@@ -12,9 +17,13 @@ export interface Session {
12
17
  username: string;
13
18
  }
14
19
 
15
- function getDb() {
20
+ let db: Database | null = null;
21
+
22
+ function getDb(): Database {
23
+ if (db) return db;
16
24
  const dbPath = join(import.meta.dir, "..", "..", "data", "dev.db");
17
- const db = connectSQLite({ path: dbPath });
25
+ mkdirSync(dirname(dbPath), { recursive: true });
26
+ db = connectSQLite({ path: dbPath });
18
27
  runSQLiteMigrations(db, join(import.meta.dir, "migrations"));
19
28
  return db;
20
29
  }
@@ -35,6 +44,16 @@ export function createSession(username: string): Session {
35
44
  return { id, token, user_id: userId, username };
36
45
  }
37
46
 
47
+ // DEMO ONLY: the single source of truth for the credential check, shared by
48
+ // the login API route and the login page's server fallback. Replace this with
49
+ // real (hashed) password verification before shipping.
50
+ export function authenticate(email: string, password: string): Session | null {
51
+ if (email === "admin" && password === "admin") {
52
+ return createSession(email);
53
+ }
54
+ return null;
55
+ }
56
+
38
57
  export function getSession(token: string | undefined): Session | null {
39
58
  if (!token) return null;
40
59
  const db = getDb();
@@ -61,10 +80,12 @@ export function parseSessionCookie(cookieHeader: string | null): string | undefi
61
80
  return undefined;
62
81
  }
63
82
 
83
+ const SECURE_COOKIE_FLAG = process.env.NODE_ENV === "production" ? "; Secure" : "";
84
+
64
85
  export function setSessionCookie(token: string): string {
65
- return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}`;
86
+ return `${SESSION_COOKIE}=${token}; HttpOnly; SameSite=Lax; Path=/; Max-Age=${SESSION_MAX_AGE}${SECURE_COOKIE_FLAG}`;
66
87
  }
67
88
 
68
89
  export function clearSessionCookie(): string {
69
- return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0`;
90
+ return `${SESSION_COOKIE}=; HttpOnly; SameSite=Lax; Path=/; Max-Age=0${SECURE_COOKIE_FLAG}`;
70
91
  }
@@ -53,7 +53,10 @@ export default function SettingsPage({ loaderData }: RouteProps) {
53
53
  />
54
54
  </div>
55
55
  </div>
56
- <button type="button" className="inline-flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90">
56
+ <button
57
+ type="button"
58
+ className="inline-flex items-center gap-2 rounded-xl bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90"
59
+ >
57
60
  <Save className="h-4 w-4" />
58
61
  Save Changes
59
62
  </button>
@@ -95,7 +98,10 @@ export default function SettingsPage({ loaderData }: RouteProps) {
95
98
  <p className="text-sm text-muted-foreground mb-4">
96
99
  Permanently delete your account and all associated data.
97
100
  </p>
98
- <button type="button" className="rounded-xl border border-destructive/50 bg-destructive/10 px-5 py-2.5 text-sm font-semibold text-destructive transition-all hover:bg-destructive/20">
101
+ <button
102
+ type="button"
103
+ className="rounded-xl border border-destructive/50 bg-destructive/10 px-5 py-2.5 text-sm font-semibold text-destructive transition-all hover:bg-destructive/20"
104
+ >
99
105
  Delete Account
100
106
  </button>
101
107
  </div>
@@ -1,7 +1,60 @@
1
+ import type { LoaderArgs, RouteProps } from "@thexjs/core";
1
2
  import { LogIn } from "lucide-react";
3
+ import { useState } from "react";
4
+ import { Button } from "../components/ui/button";
5
+ import { Input } from "../components/ui/input";
6
+ import { authenticate, setSessionCookie } from "../lib/auth";
2
7
  import { cn } from "../lib/utils";
3
8
 
4
- export default function LoginPage() {
9
+ export async function loader({ request }: LoaderArgs) {
10
+ if (request.method === "POST") {
11
+ const formData = await request.formData();
12
+ const username = formData.get("email") as string | null;
13
+ const password = formData.get("password") as string | null;
14
+ const session = username && password ? authenticate(username, password) : null;
15
+ if (session) {
16
+ return new Response(null, {
17
+ status: 302,
18
+ headers: { Location: "/dashboard", "Set-Cookie": setSessionCookie(session.token) },
19
+ });
20
+ }
21
+ return { error: "Invalid credentials" };
22
+ }
23
+ return {};
24
+ }
25
+
26
+ export default function LoginPage({ loaderData }: RouteProps) {
27
+ const [error, setError] = useState((loaderData?.error as string) ?? "");
28
+ const [loading, setLoading] = useState(false);
29
+
30
+ async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
31
+ e.preventDefault();
32
+ setError("");
33
+ setLoading(true);
34
+ const form = e.currentTarget;
35
+ const data = {
36
+ email: (form.elements.namedItem("email") as HTMLInputElement).value,
37
+ password: (form.elements.namedItem("password") as HTMLInputElement).value,
38
+ };
39
+ try {
40
+ const res = await fetch("/api/auth/login", {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json" },
43
+ body: JSON.stringify(data),
44
+ });
45
+ if (res.ok) {
46
+ window.location.href = "/dashboard";
47
+ } else {
48
+ const err = (await res.json()) as { error?: string };
49
+ setError(err.error || "Login failed");
50
+ }
51
+ } catch {
52
+ setError("Network error");
53
+ } finally {
54
+ setLoading(false);
55
+ }
56
+ }
57
+
5
58
  return (
6
59
  <div className="flex min-h-[calc(100vh-4rem)] items-center justify-center px-4">
7
60
  <div className="w-full max-w-sm">
@@ -15,7 +68,7 @@ export default function LoginPage() {
15
68
  </h1>
16
69
  <p className="mt-2 text-sm text-muted-foreground">Sign in to your account</p>
17
70
  </div>
18
- <form className="space-y-5">
71
+ <form method="POST" action="/login" onSubmit={handleSubmit} className="space-y-5">
19
72
  <div>
20
73
  <label
21
74
  htmlFor="email"
@@ -23,11 +76,16 @@ export default function LoginPage() {
23
76
  >
24
77
  Email
25
78
  </label>
26
- <input
79
+ <Input
27
80
  id="email"
81
+ name="email"
28
82
  type="email"
83
+ defaultValue="admin"
29
84
  placeholder="you@example.com"
30
- className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
85
+ className={cn(
86
+ "h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground",
87
+ )}
88
+ required
31
89
  />
32
90
  </div>
33
91
  <div>
@@ -37,20 +95,35 @@ export default function LoginPage() {
37
95
  >
38
96
  Password
39
97
  </label>
40
- <input
98
+ <Input
41
99
  id="password"
100
+ name="password"
42
101
  type="password"
102
+ defaultValue="admin"
43
103
  placeholder="••••••••"
44
- className="w-full rounded-xl border border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:border-ring focus:outline-none focus:ring-2 focus:ring-ring/20"
104
+ className="h-10 rounded-xl border-input bg-background px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground"
105
+ required
45
106
  />
46
107
  </div>
47
- <button
108
+ {error && (
109
+ <p id="login-error" className="text-sm text-destructive">
110
+ {error}
111
+ </p>
112
+ )}
113
+ <Button
48
114
  type="submit"
49
- className="w-full rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/25"
115
+ disabled={loading}
116
+ className="h-10 w-full rounded-xl bg-primary px-4 py-2.5 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/20 transition-all hover:bg-primary/90 hover:shadow-xl hover:shadow-primary/25"
50
117
  >
51
- Sign in
52
- </button>
118
+ {loading ? "Signing in..." : "Sign in"}
119
+ </Button>
53
120
  </form>
121
+ <p className="mt-4 text-center text-xs text-muted-foreground">
122
+ Demo credentials: <code className="text-foreground">admin / admin</code>
123
+ </p>
124
+ <p className="mt-1 text-center text-[11px] text-muted-foreground">
125
+ Demo only — replace with real auth before shipping.
126
+ </p>
54
127
  <p className="mt-6 text-center text-sm text-muted-foreground">
55
128
  Don&apos;t have an account?{" "}
56
129
  <a
@@ -1,95 +0,0 @@
1
- import { Mail, MapPin, Send } from "lucide-react";
2
-
3
- export default function ContactPage() {
4
- return (
5
- <div className="mx-auto max-w-4xl px-6 py-20">
6
- <div className="mx-auto max-w-2xl text-center">
7
- <p className="text-xs font-semibold uppercase tracking-[0.2em] text-primary">Contact</p>
8
- <h1 className="mt-4 text-4xl font-bold tracking-tight sm:text-5xl">Get in touch</h1>
9
- <p className="mt-4 text-lg text-muted-foreground">
10
- Have a question or want to learn more? We'd love to hear from you.
11
- </p>
12
- </div>
13
-
14
- <div className="mt-16 grid gap-12 sm:grid-cols-5">
15
- <div className="space-y-8 sm:col-span-2">
16
- <div>
17
- <div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
18
- <Mail className="h-5 w-5" />
19
- </div>
20
- <h3 className="mt-4 text-sm font-semibold">Email</h3>
21
- <p className="mt-1 text-sm text-muted-foreground">hello@x-framework.dev</p>
22
- </div>
23
- <div>
24
- <div className="flex h-10 w-10 items-center justify-center rounded-xl bg-primary/10 text-primary">
25
- <MapPin className="h-5 w-5" />
26
- </div>
27
- <h3 className="mt-4 text-sm font-semibold">Location</h3>
28
- <p className="mt-1 text-sm text-muted-foreground">San Francisco, CA</p>
29
- </div>
30
- </div>
31
-
32
- <form className="space-y-5 sm:col-span-3" method="POST" action="/contact">
33
- <div className="grid gap-5 sm:grid-cols-2">
34
- <div>
35
- <label htmlFor="name" className="block text-sm font-medium mb-2">
36
- Name
37
- </label>
38
- <input
39
- id="name"
40
- name="name"
41
- required
42
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
43
- placeholder="Your name"
44
- />
45
- </div>
46
- <div>
47
- <label htmlFor="email" className="block text-sm font-medium mb-2">
48
- Email
49
- </label>
50
- <input
51
- id="email"
52
- name="email"
53
- type="email"
54
- required
55
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
56
- placeholder="you@example.com"
57
- />
58
- </div>
59
- </div>
60
- <div>
61
- <label htmlFor="subject" className="block text-sm font-medium mb-2">
62
- Subject
63
- </label>
64
- <input
65
- id="subject"
66
- name="subject"
67
- required
68
- className="w-full rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
69
- placeholder="How can we help?"
70
- />
71
- </div>
72
- <div>
73
- <label htmlFor="message" className="block text-sm font-medium mb-2">
74
- Message
75
- </label>
76
- <textarea
77
- id="message"
78
- name="message"
79
- rows={5}
80
- required
81
- className="w-full resize-none rounded-xl border border-input bg-card px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring"
82
- placeholder="Tell us more..."
83
- />
84
- </div>
85
- <button
86
- type="submit"
87
- className="inline-flex h-11 items-center gap-2 rounded-xl bg-primary px-6 text-sm font-semibold text-primary-foreground shadow-lg shadow-primary/25 transition-all hover:bg-primary/90"
88
- >
89
- Send message <Send className="h-4 w-4" />
90
- </button>
91
- </form>
92
- </div>
93
- </div>
94
- );
95
- }