create-thexjs-app 1.0.0 → 1.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.
- package/README.md +56 -915
- package/dist/index.js +265 -196
- package/package.json +5 -1
- package/templates/{basic → addons/auth}/src/api/auth/login.ts +1 -3
- package/templates/{basic → addons/auth}/src/lib/auth.ts +13 -9
- package/templates/{basic → addons/auth}/src/lib/migrations/001_create_sessions.sql +1 -3
- package/templates/addons/auth/src/pages/dashboard/index.tsx +39 -0
- package/templates/addons/auth/src/pages/login.tsx +72 -0
- package/templates/addons/content/content/hello-world.md +13 -0
- package/templates/addons/content/src/pages/blog.tsx +29 -0
- package/templates/{basic → addons/shadcn}/components.json +1 -1
- package/templates/addons/shadcn/src/components/ui/badge.tsx +17 -0
- package/templates/addons/shadcn/src/components/ui/button.tsx +36 -0
- package/templates/addons/shadcn/src/components/ui/card.tsx +33 -0
- package/templates/addons/shadcn/src/components/ui/input.tsx +18 -0
- package/templates/addons/tailwind/src/styles/globals.css +32 -0
- package/templates/base/src/pages/index.tsx +29 -0
- package/templates/base/src/styles/globals.css +22 -0
- package/templates/base/tsconfig.json +24 -0
- package/templates/basic/content/blog/hello.md +0 -8
- package/templates/basic/public/favicon.ico +0 -0
- package/templates/basic/src/actions/dashboard/greet.ts +0 -3
- package/templates/basic/src/api/placeholder/comments.ts +0 -17
- package/templates/basic/src/api/placeholder/posts.ts +0 -20
- package/templates/basic/src/api/placeholder/todos.ts +0 -21
- package/templates/basic/src/api/placeholder/users.ts +0 -12
- package/templates/basic/src/components/Head.tsx +0 -21
- package/templates/basic/src/components/Image.tsx +0 -27
- package/templates/basic/src/components/Link.tsx +0 -10
- package/templates/basic/src/components/ui/badge.tsx +0 -49
- package/templates/basic/src/components/ui/button.tsx +0 -58
- package/templates/basic/src/components/ui/card.tsx +0 -88
- package/templates/basic/src/components/ui/input.tsx +0 -20
- package/templates/basic/src/layouts/main.tsx +0 -38
- package/templates/basic/src/lib/placeholder-data.ts +0 -176
- package/templates/basic/src/pages/_404.tsx +0 -17
- package/templates/basic/src/pages/about.tsx +0 -22
- package/templates/basic/src/pages/blog.tsx +0 -41
- package/templates/basic/src/pages/dashboard/index.tsx +0 -84
- package/templates/basic/src/pages/index.tsx +0 -54
- package/templates/basic/src/pages/login.tsx +0 -92
- package/templates/basic/src/pages/placeholder.tsx +0 -203
- package/templates/basic/src/pages/posts/[id].tsx +0 -17
- package/templates/basic/src/styles/globals.css +0 -90
- package/templates/basic/src/x-routes.ts +0 -29
- package/templates/basic/tsconfig.json +0 -11
- package/templates/basic/x.config.ts +0 -10
- package/templates/blog/components.json +0 -20
- package/templates/blog/content/posts/getting-started.md +0 -38
- package/templates/blog/content/posts/hello-world.md +0 -21
- package/templates/blog/content/posts/tailwind-v4.md +0 -31
- package/templates/blog/public/favicon.ico +0 -0
- package/templates/blog/src/components/ui/avatar.tsx +0 -91
- package/templates/blog/src/components/ui/badge.tsx +0 -49
- package/templates/blog/src/components/ui/button.tsx +0 -58
- package/templates/blog/src/components/ui/card.tsx +0 -88
- package/templates/blog/src/components/ui/input.tsx +0 -20
- package/templates/blog/src/layouts/blog.tsx +0 -46
- package/templates/blog/src/layouts/main.tsx +0 -32
- package/templates/blog/src/lib/utils.ts +0 -5
- package/templates/blog/src/pages/about.tsx +0 -36
- package/templates/blog/src/pages/blog/[slug].tsx +0 -56
- package/templates/blog/src/pages/blog/index.tsx +0 -70
- package/templates/blog/src/pages/index.tsx +0 -73
- package/templates/blog/src/styles/globals.css +0 -90
- package/templates/blog/src/x-routes.ts +0 -20
- package/templates/blog/tsconfig.json +0 -5
- package/templates/blog/x.config.ts +0 -6
- package/templates/default/components.json +0 -19
- package/templates/default/src/layouts/main.tsx +0 -28
- package/templates/default/src/pages/index.tsx +0 -66
- package/templates/default/src/styles/globals.css +0 -55
- package/templates/default/src/x-routes.ts +0 -17
- package/templates/default/tsconfig.json +0 -5
- package/templates/default/x.config.ts +0 -6
- package/templates/landing/components.json +0 -20
- package/templates/landing/public/favicon.ico +0 -0
- package/templates/landing/src/components/code-block.tsx +0 -118
- package/templates/landing/src/components/ui/avatar.tsx +0 -91
- package/templates/landing/src/components/ui/badge.tsx +0 -49
- package/templates/landing/src/components/ui/button.tsx +0 -58
- package/templates/landing/src/components/ui/card.tsx +0 -88
- package/templates/landing/src/components/ui/input.tsx +0 -20
- package/templates/landing/src/layouts/main.tsx +0 -78
- package/templates/landing/src/lib/syntax.tsx +0 -366
- package/templates/landing/src/lib/utils.ts +0 -5
- package/templates/landing/src/pages/docs/_layout.tsx +0 -139
- package/templates/landing/src/pages/docs/api-routes.tsx +0 -113
- package/templates/landing/src/pages/docs/build-deploy.tsx +0 -124
- package/templates/landing/src/pages/docs/configuration.tsx +0 -121
- package/templates/landing/src/pages/docs/content-collections.tsx +0 -130
- package/templates/landing/src/pages/docs/data-layer.tsx +0 -142
- package/templates/landing/src/pages/docs/getting-started.tsx +0 -129
- package/templates/landing/src/pages/docs/index.tsx +0 -187
- package/templates/landing/src/pages/docs/installation.tsx +0 -143
- package/templates/landing/src/pages/docs/introduction.tsx +0 -114
- package/templates/landing/src/pages/docs/layouts.tsx +0 -114
- package/templates/landing/src/pages/docs/middleware.tsx +0 -124
- package/templates/landing/src/pages/docs/packages/cli.tsx +0 -133
- package/templates/landing/src/pages/docs/packages/core.tsx +0 -176
- package/templates/landing/src/pages/docs/packages/env.tsx +0 -128
- package/templates/landing/src/pages/docs/pages.tsx +0 -135
- package/templates/landing/src/pages/docs/routing.tsx +0 -123
- package/templates/landing/src/pages/docs/server-functions.tsx +0 -177
- package/templates/landing/src/pages/features.tsx +0 -129
- package/templates/landing/src/pages/index.tsx +0 -159
- package/templates/landing/src/styles/globals.css +0 -136
- package/templates/landing/src/x-routes.ts +0 -31
- package/templates/landing/tsconfig.json +0 -10
- package/templates/landing/x.config.ts +0 -2
- package/templates/saas/components.json +0 -20
- package/templates/saas/public/favicon.ico +0 -0
- package/templates/saas/src/actions/dashboard.ts +0 -3
- package/templates/saas/src/api/auth/login.ts +0 -31
- package/templates/saas/src/components/ui/avatar.tsx +0 -91
- package/templates/saas/src/components/ui/badge.tsx +0 -49
- package/templates/saas/src/components/ui/button.tsx +0 -58
- package/templates/saas/src/components/ui/card.tsx +0 -88
- package/templates/saas/src/components/ui/input.tsx +0 -20
- package/templates/saas/src/layouts/dashboard.tsx +0 -67
- package/templates/saas/src/layouts/main.tsx +0 -38
- package/templates/saas/src/lib/auth.ts +0 -91
- package/templates/saas/src/lib/migrations/001_create_sessions.sql +0 -9
- package/templates/saas/src/lib/utils.ts +0 -5
- package/templates/saas/src/pages/dashboard/_middleware.ts +0 -9
- package/templates/saas/src/pages/dashboard/analytics.tsx +0 -68
- package/templates/saas/src/pages/dashboard/index.tsx +0 -86
- package/templates/saas/src/pages/dashboard/settings.tsx +0 -111
- package/templates/saas/src/pages/index.tsx +0 -110
- package/templates/saas/src/pages/login.tsx +0 -140
- package/templates/saas/src/pages/pricing.tsx +0 -121
- package/templates/saas/src/styles/globals.css +0 -90
- package/templates/saas/src/x-routes.ts +0 -22
- package/templates/saas/tsconfig.json +0 -5
- package/templates/saas/x.config.ts +0 -7
- /package/templates/{basic → addons/auth}/src/api/auth/logout.ts +0 -0
- /package/templates/{basic → addons/auth}/src/pages/dashboard/_middleware.ts +0 -0
- /package/templates/{basic → addons/shadcn}/src/lib/utils.ts +0 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
export default function Login() {
|
|
4
|
+
const [error, setError] = useState("");
|
|
5
|
+
const [loading, setLoading] = useState(false);
|
|
6
|
+
|
|
7
|
+
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
|
|
8
|
+
e.preventDefault();
|
|
9
|
+
setError("");
|
|
10
|
+
setLoading(true);
|
|
11
|
+
const form = e.currentTarget;
|
|
12
|
+
const data = { username: form.username.value, password: form.password.value };
|
|
13
|
+
try {
|
|
14
|
+
const res = await fetch("/api/auth/login", {
|
|
15
|
+
method: "POST",
|
|
16
|
+
headers: { "Content-Type": "application/json" },
|
|
17
|
+
body: JSON.stringify(data),
|
|
18
|
+
});
|
|
19
|
+
if (res.ok) {
|
|
20
|
+
window.location.href = "/dashboard";
|
|
21
|
+
} else {
|
|
22
|
+
const err = (await res.json()) as { error?: string };
|
|
23
|
+
setError(err.error ?? "Login failed");
|
|
24
|
+
}
|
|
25
|
+
} catch {
|
|
26
|
+
setError("Network error");
|
|
27
|
+
} finally {
|
|
28
|
+
setLoading(false);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<main style={{ maxWidth: 360, margin: "0 auto", padding: "4rem 1.5rem" }}>
|
|
34
|
+
<h1 style={{ fontSize: "1.5rem", marginBottom: "1rem" }}>Sign in</h1>
|
|
35
|
+
<form onSubmit={handleSubmit} style={{ display: "grid", gap: "0.75rem" }}>
|
|
36
|
+
<label style={{ display: "grid", gap: "0.25rem" }}>
|
|
37
|
+
Username
|
|
38
|
+
<input name="username" defaultValue="admin" required style={field} />
|
|
39
|
+
</label>
|
|
40
|
+
<label style={{ display: "grid", gap: "0.25rem" }}>
|
|
41
|
+
Password
|
|
42
|
+
<input name="password" type="password" defaultValue="admin" required style={field} />
|
|
43
|
+
</label>
|
|
44
|
+
{error && <p style={{ color: "#dc2626", fontSize: "0.85rem" }}>{error}</p>}
|
|
45
|
+
<button type="submit" disabled={loading} style={submit}>
|
|
46
|
+
{loading ? "Signing in..." : "Sign in"}
|
|
47
|
+
</button>
|
|
48
|
+
</form>
|
|
49
|
+
<p style={{ fontSize: "0.8rem", color: "#64748b", marginTop: "1rem" }}>
|
|
50
|
+
Demo credentials: <code>admin</code> / <code>admin</code>
|
|
51
|
+
</p>
|
|
52
|
+
</main>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const field: React.CSSProperties = {
|
|
57
|
+
padding: "0.6rem 0.75rem",
|
|
58
|
+
border: "1px solid #cbd5e1",
|
|
59
|
+
borderRadius: 8,
|
|
60
|
+
fontSize: "0.95rem",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const submit: React.CSSProperties = {
|
|
64
|
+
padding: "0.65rem 1rem",
|
|
65
|
+
background: "#0f172a",
|
|
66
|
+
color: "#fff",
|
|
67
|
+
border: "none",
|
|
68
|
+
borderRadius: 8,
|
|
69
|
+
fontSize: "0.95rem",
|
|
70
|
+
fontWeight: 600,
|
|
71
|
+
cursor: "pointer",
|
|
72
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Hello from content collections
|
|
3
|
+
description: Markdown with frontmatter becomes a route automatically.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
This page is rendered from a markdown file in `content/` — no route file needed.
|
|
7
|
+
|
|
8
|
+
Content collections let you write blog posts, docs, and marketing pages as
|
|
9
|
+
plain markdown with YAML frontmatter. Each `.md` / `.mdx` file becomes a route
|
|
10
|
+
at its path (`content/hello-world.md` -> `/hello-world`).
|
|
11
|
+
|
|
12
|
+
Use `scanContent()` and `renderMarkdown()` in loaders to build indexes and
|
|
13
|
+
dynamic pages on top of your content.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { type ContentEntry, scanContent } from "@thexjs/core";
|
|
3
|
+
|
|
4
|
+
const CONTENT_DIR = process.env.X_CONTENT_DIR ?? "content";
|
|
5
|
+
|
|
6
|
+
function listContent(): ContentEntry[] {
|
|
7
|
+
return scanContent(join(process.cwd(), CONTENT_DIR));
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export default function Blog() {
|
|
11
|
+
const posts = listContent();
|
|
12
|
+
return (
|
|
13
|
+
<main style={{ maxWidth: 680, margin: "0 auto", padding: "4rem 1.5rem" }}>
|
|
14
|
+
<h1 style={{ fontSize: "2rem", marginBottom: "1.5rem" }}>Content</h1>
|
|
15
|
+
<ul style={{ listStyle: "none", padding: 0, display: "grid", gap: "0.75rem" }}>
|
|
16
|
+
{posts.map((post) => (
|
|
17
|
+
<li key={post.routePath}>
|
|
18
|
+
<a
|
|
19
|
+
href={post.routePath}
|
|
20
|
+
style={{ textDecoration: "none", color: "#0f172a", fontWeight: 600 }}
|
|
21
|
+
>
|
|
22
|
+
{post.frontmatter.title ?? post.slug}
|
|
23
|
+
</a>
|
|
24
|
+
</li>
|
|
25
|
+
))}
|
|
26
|
+
</ul>
|
|
27
|
+
</main>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
function Badge({ className, ...props }: React.ComponentProps<"span">) {
|
|
6
|
+
return (
|
|
7
|
+
<span
|
|
8
|
+
className={cn(
|
|
9
|
+
"inline-flex items-center rounded-full border border-border px-2.5 py-0.5 text-xs font-semibold text-muted-foreground",
|
|
10
|
+
className,
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { Badge };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type VariantProps, cva } from "class-variance-authority";
|
|
2
|
+
import type * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "@/lib/utils";
|
|
5
|
+
|
|
6
|
+
const buttonVariants = cva(
|
|
7
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default: "bg-foreground text-background hover:bg-foreground/90",
|
|
12
|
+
outline: "border border-border bg-transparent hover:bg-muted",
|
|
13
|
+
destructive: "bg-red-600 text-white hover:bg-red-700",
|
|
14
|
+
},
|
|
15
|
+
size: {
|
|
16
|
+
default: "h-10 px-4 py-2",
|
|
17
|
+
sm: "h-9 rounded-md px-3",
|
|
18
|
+
lg: "h-11 rounded-md px-8",
|
|
19
|
+
icon: "h-10 w-10",
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
defaultVariants: {
|
|
23
|
+
variant: "default",
|
|
24
|
+
size: "default",
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
export function Button({
|
|
30
|
+
className,
|
|
31
|
+
variant,
|
|
32
|
+
size,
|
|
33
|
+
...props
|
|
34
|
+
}: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants>) {
|
|
35
|
+
return <button className={cn(buttonVariants({ variant, size, className }))} {...props} />;
|
|
36
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
function Card({ className, ...props }: React.ComponentProps<"div">) {
|
|
6
|
+
return (
|
|
7
|
+
<div
|
|
8
|
+
className={cn(
|
|
9
|
+
"rounded-xl border border-border bg-muted/40 text-foreground shadow-sm",
|
|
10
|
+
className,
|
|
11
|
+
)}
|
|
12
|
+
{...props}
|
|
13
|
+
/>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function CardHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
18
|
+
return <div className={cn("flex flex-col space-y-1.5 p-6", className)} {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function CardTitle({ className, ...props }: React.ComponentProps<"h3">) {
|
|
22
|
+
return <h3 className={cn("font-semibold leading-none tracking-tight", className)} {...props} />;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function CardDescription({ className, ...props }: React.ComponentProps<"p">) {
|
|
26
|
+
return <p className={cn("text-sm text-muted-foreground", className)} {...props} />;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function CardContent({ className, ...props }: React.ComponentProps<"div">) {
|
|
30
|
+
return <div className={cn("p-6 pt-0", className)} {...props} />;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export { Card, CardHeader, CardTitle, CardDescription, CardContent };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "@/lib/utils";
|
|
4
|
+
|
|
5
|
+
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
6
|
+
return (
|
|
7
|
+
<input
|
|
8
|
+
type={type}
|
|
9
|
+
className={cn(
|
|
10
|
+
"flex h-10 w-full rounded-md border border-border bg-background px-3 py-2 text-sm outline-none transition-colors placeholder:text-muted-foreground focus-visible:border-foreground disabled:cursor-not-allowed disabled:opacity-50",
|
|
11
|
+
className,
|
|
12
|
+
)}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Input };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
|
|
3
|
+
@theme inline {
|
|
4
|
+
--color-background: var(--background);
|
|
5
|
+
--color-foreground: var(--foreground);
|
|
6
|
+
--color-muted: var(--muted);
|
|
7
|
+
--color-muted-foreground: var(--muted-foreground);
|
|
8
|
+
--color-border: var(--border);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:root {
|
|
12
|
+
--background: 255 255 255;
|
|
13
|
+
--foreground: 15 23 42;
|
|
14
|
+
--muted: 241 245 249;
|
|
15
|
+
--muted-foreground: 100 116 139;
|
|
16
|
+
--border: 226 232 240;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
@media (prefers-color-scheme: dark) {
|
|
20
|
+
:root {
|
|
21
|
+
--background: 2 6 23;
|
|
22
|
+
--foreground: 241 245 249;
|
|
23
|
+
--muted: 30 41 59;
|
|
24
|
+
--muted-foreground: 148 163 184;
|
|
25
|
+
--border: 30 41 59;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
body {
|
|
30
|
+
background: rgb(var(--background));
|
|
31
|
+
color: rgb(var(--foreground));
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default function Home() {
|
|
2
|
+
return (
|
|
3
|
+
<main style={{ maxWidth: 680, margin: "0 auto", padding: "5rem 1.5rem" }}>
|
|
4
|
+
<p style={{ fontWeight: 700, letterSpacing: "0.08em", color: "#e8942f" }}>THE X FRAMEWORK</p>
|
|
5
|
+
<h1 style={{ fontSize: "2.6rem", lineHeight: 1.1, margin: "0.5rem 0" }}>
|
|
6
|
+
You're up and running.
|
|
7
|
+
</h1>
|
|
8
|
+
<p style={{ fontSize: "1.15rem", lineHeight: 1.6, color: "#64748b" }}>
|
|
9
|
+
This is a freshly scaffolded x app. Open <code>src/pages/index.tsx</code> and start building
|
|
10
|
+
— save to hot-reload in development.
|
|
11
|
+
</p>
|
|
12
|
+
<div style={{ display: "flex", gap: "0.75rem", marginTop: "2rem" }}>
|
|
13
|
+
<a href="/about" style={btn}>
|
|
14
|
+
Next steps →
|
|
15
|
+
</a>
|
|
16
|
+
</div>
|
|
17
|
+
</main>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const btn: React.CSSProperties = {
|
|
22
|
+
display: "inline-block",
|
|
23
|
+
background: "#0f172a",
|
|
24
|
+
color: "#fff",
|
|
25
|
+
padding: "0.7rem 1.2rem",
|
|
26
|
+
borderRadius: 999,
|
|
27
|
+
textDecoration: "none",
|
|
28
|
+
fontWeight: 600,
|
|
29
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
html,
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
|
|
10
|
+
sans-serif;
|
|
11
|
+
color: #0f172a;
|
|
12
|
+
background: #ffffff;
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
code {
|
|
17
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
18
|
+
background: #f1f5f9;
|
|
19
|
+
padding: 0.15rem 0.35rem;
|
|
20
|
+
border-radius: 4px;
|
|
21
|
+
font-size: 0.9em;
|
|
22
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"lib": ["ESNext", "DOM"],
|
|
7
|
+
"jsx": "react-jsx",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"exactOptionalPropertyTypes": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"esModuleInterop": true,
|
|
13
|
+
"forceConsistentCasingInFileNames": true,
|
|
14
|
+
"isolatedModules": true,
|
|
15
|
+
"verbatimModuleSyntax": true,
|
|
16
|
+
"noEmit": true,
|
|
17
|
+
"types": ["bun"],
|
|
18
|
+
"baseUrl": ".",
|
|
19
|
+
"paths": {
|
|
20
|
+
"@/*": ["./src/*"]
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"include": ["src", "x.config.ts"]
|
|
24
|
+
}
|
|
Binary file
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Link as XLink, type LinkProps as XLinkProps } from "@thexjs/core";
|
|
2
|
-
import type { ReactNode } from "react";
|
|
3
|
-
|
|
4
|
-
type LinkProps = XLinkProps;
|
|
5
|
-
|
|
6
|
-
export default function Link(props: LinkProps) {
|
|
7
|
-
return <XLink {...props} />;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type { LinkProps };
|
|
@@ -1,49 +0,0 @@
|
|
|
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 };
|
|
@@ -1,58 +0,0 @@
|
|
|
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 };
|