create-sordo 0.5.0 → 1.0.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 (62) hide show
  1. package/CHANGELOG.md +5 -125
  2. package/README.md +3 -49
  3. package/bin/create-sordo.ts +1 -10
  4. package/package.json +7 -13
  5. package/src/index.ts +0 -697
  6. package/src/probes.ts +0 -28
  7. package/src/prompts.ts +0 -141
  8. package/src/readme.ts +0 -74
  9. package/src/ui.ts +0 -152
  10. package/src/versions.ts +0 -3
  11. package/templates/_backend/app/routes/api/todos.ts +0 -27
  12. package/templates/_claude/.claude/commands/sordo-init.md +0 -64
  13. package/templates/_claude/.claude/hooks/biome-check.sh +0 -17
  14. package/templates/_claude/.claude/rules/build-time-discovery.md +0 -17
  15. package/templates/_claude/.claude/rules/bun-native.md +0 -28
  16. package/templates/_claude/.claude/rules/filesystem-routing.md +0 -31
  17. package/templates/_claude/.claude/rules/islands.md +0 -46
  18. package/templates/_claude/.claude/rules/optional-ai.md +0 -16
  19. package/templates/_claude/.claude/rules/web-standards-boundary.md +0 -25
  20. package/templates/_claude/.claude/settings.json +0 -22
  21. package/templates/_claude/.claude/skills/sordo/SKILL.md +0 -120
  22. package/templates/_claude/.claude/skills/sordo-cli/SKILL.md +0 -112
  23. package/templates/_claude/CLAUDE.md +0 -28
  24. package/templates/_codex/.codex/README.md +0 -10
  25. package/templates/_codex/.codex/rules/build-time-discovery.md +0 -17
  26. package/templates/_codex/.codex/rules/bun-native.md +0 -28
  27. package/templates/_codex/.codex/rules/filesystem-routing.md +0 -31
  28. package/templates/_codex/.codex/rules/islands.md +0 -46
  29. package/templates/_codex/.codex/rules/optional-ai.md +0 -15
  30. package/templates/_codex/.codex/rules/sordo-cli.md +0 -108
  31. package/templates/_codex/.codex/rules/sordo-patterns.md +0 -121
  32. package/templates/_codex/.codex/rules/web-standards-boundary.md +0 -25
  33. package/templates/_codex/AGENTS.md +0 -27
  34. package/templates/_container/.dockerignore +0 -7
  35. package/templates/_container/Dockerfile +0 -27
  36. package/templates/_monorepo/packages/README.md +0 -18
  37. package/templates/_shared/sordo-patterns.md +0 -121
  38. package/templates/default/README-template.md +0 -174
  39. package/templates/default/app/islands/TodoApp.tsx +0 -83
  40. package/templates/default/app/routes/api/health.ts +0 -8
  41. package/templates/default/app/routes/index.tsx +0 -29
  42. package/templates/default/app/server.ts +0 -28
  43. package/templates/default/gitignore +0 -8
  44. package/templates/default/sordo.config.ts +0 -5
  45. package/templates/default/tsconfig.json +0 -14
  46. package/templates/ui-shadcn/components/button.tsx +0 -63
  47. package/templates/ui-shadcn/components/dialog.tsx +0 -158
  48. package/templates/ui-shadcn/demo/index.tsx +0 -58
  49. package/templates/ui-starter/_internal/cn.ts +0 -6
  50. package/templates/ui-starter/_internal/slot.ts +0 -50
  51. package/templates/ui-starter/_internal/variants.ts +0 -1
  52. package/templates/ui-starter/button.tsx +0 -60
  53. package/templates/ui-starter/card.tsx +0 -92
  54. package/templates/ui-starter/demo/TodoApp.tsx +0 -86
  55. package/templates/ui-starter/demo/index.tsx +0 -41
  56. package/templates/ui-starter/input.tsx +0 -20
  57. package/templates/ui-starter/label.tsx +0 -18
  58. package/templates/ui-starter/themes/neutral/tokens.css +0 -46
  59. package/templates/ui-starter/themes/slate/tokens.css +0 -46
  60. package/templates/ui-starter/themes/stone/tokens.css +0 -46
  61. package/templates/ui-starter/themes/zinc/tokens.css +0 -46
  62. package/templates/ui-starter/tokens.css +0 -46
@@ -1,28 +0,0 @@
1
- import { type DevServer, setupDevClient } from "sordo/dev";
2
- import { createRenderer } from "sordo/render";
3
- import { createRouter } from "sordo/router";
4
- import { startServer } from "sordo/server";
5
-
6
- interface StartOpts {
7
- devServer: DevServer;
8
- port: number;
9
- host: string;
10
- appDir: string;
11
- }
12
-
13
- export default async function start(opts: StartOpts): Promise<void> {
14
- // Bundle islands and serve their chunks under `/_sordo/client/*`.
15
- // `manifest` tells the renderer which <script> to inject so islands hydrate.
16
- const devClient = await setupDevClient({ appDir: opts.appDir });
17
- const renderer = createRenderer({ manifest: devClient.manifest, dev: true });
18
- const router = await createRouter({ appDir: opts.appDir, renderer });
19
-
20
- startServer({
21
- port: opts.port,
22
- hostname: opts.host,
23
- dev: true,
24
- devServer: opts.devServer,
25
- routes: { ...devClient.routes, ...router.routes },
26
- fallback: router.fallback,
27
- });
28
- }
@@ -1,8 +0,0 @@
1
- node_modules
2
- .sordo
3
- sordo-gen
4
- dist
5
- .env
6
- .env.local
7
- *.log
8
- .DS_Store
@@ -1,5 +0,0 @@
1
- import { defineConfig } from "sordo/config";
2
-
3
- export default defineConfig({
4
- target: "bun",
5
- });
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2022",
4
- "module": "ESNext",
5
- "moduleResolution": "Bundler",
6
- "jsx": "react-jsx",
7
- "strict": true,
8
- "skipLibCheck": true,
9
- "noEmit": true,
10
- "allowImportingTsExtensions": true,
11
- "types": ["bun-types", "react", "react-dom"]
12
- },
13
- "include": ["app", "sordo.config.ts"]
14
- }
@@ -1,63 +0,0 @@
1
- import * as React from "react"
2
- import { cva, type VariantProps } from "class-variance-authority"
3
- import { cn } from "cn"
4
- import { Slot } from "radix-ui"
5
-
6
- const buttonVariants = cva(
7
- "inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 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/90",
12
- destructive:
13
- "bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
14
- outline:
15
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
16
- secondary:
17
- "bg-secondary text-secondary-foreground hover:bg-secondary/80",
18
- ghost:
19
- "hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",
20
- link: "text-primary underline-offset-4 hover:underline",
21
- },
22
- size: {
23
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
24
- xs: "h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",
25
- sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
26
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
27
- icon: "size-9",
28
- "icon-xs": "size-6 rounded-md [&_svg:not([class*='size-'])]:size-3",
29
- "icon-sm": "size-8",
30
- "icon-lg": "size-10",
31
- },
32
- },
33
- defaultVariants: {
34
- variant: "default",
35
- size: "default",
36
- },
37
- }
38
- )
39
-
40
- function Button({
41
- className,
42
- variant = "default",
43
- size = "default",
44
- asChild = false,
45
- ...props
46
- }: React.ComponentProps<"button"> &
47
- VariantProps<typeof buttonVariants> & {
48
- asChild?: boolean
49
- }) {
50
- const Comp = asChild ? Slot.Root : "button"
51
-
52
- return (
53
- <Comp
54
- data-slot="button"
55
- data-variant={variant}
56
- data-size={size}
57
- className={cn(buttonVariants({ variant, size, className }))}
58
- {...props}
59
- />
60
- )
61
- }
62
-
63
- export { Button, buttonVariants }
@@ -1,158 +0,0 @@
1
- "use client"
2
-
3
- import * as React from "react"
4
- import { cn } from "cn"
5
- import { XIcon } from "lucide-react"
6
- import { Dialog as DialogPrimitive } from "radix-ui"
7
-
8
- import { Button } from "@/components/ui/button"
9
-
10
- function Dialog({
11
- ...props
12
- }: React.ComponentProps<typeof DialogPrimitive.Root>) {
13
- return <DialogPrimitive.Root data-slot="dialog" {...props} />
14
- }
15
-
16
- function DialogTrigger({
17
- ...props
18
- }: React.ComponentProps<typeof DialogPrimitive.Trigger>) {
19
- return <DialogPrimitive.Trigger data-slot="dialog-trigger" {...props} />
20
- }
21
-
22
- function DialogPortal({
23
- ...props
24
- }: React.ComponentProps<typeof DialogPrimitive.Portal>) {
25
- return <DialogPrimitive.Portal data-slot="dialog-portal" {...props} />
26
- }
27
-
28
- function DialogClose({
29
- ...props
30
- }: React.ComponentProps<typeof DialogPrimitive.Close>) {
31
- return <DialogPrimitive.Close data-slot="dialog-close" {...props} />
32
- }
33
-
34
- function DialogOverlay({
35
- className,
36
- ...props
37
- }: React.ComponentProps<typeof DialogPrimitive.Overlay>) {
38
- return (
39
- <DialogPrimitive.Overlay
40
- data-slot="dialog-overlay"
41
- className={cn(
42
- "fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0",
43
- className
44
- )}
45
- {...props}
46
- />
47
- )
48
- }
49
-
50
- function DialogContent({
51
- className,
52
- children,
53
- showCloseButton = true,
54
- ...props
55
- }: React.ComponentProps<typeof DialogPrimitive.Content> & {
56
- showCloseButton?: boolean
57
- }) {
58
- return (
59
- <DialogPortal data-slot="dialog-portal">
60
- <DialogOverlay />
61
- <DialogPrimitive.Content
62
- data-slot="dialog-content"
63
- className={cn(
64
- "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-background p-6 shadow-lg duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg",
65
- className
66
- )}
67
- {...props}
68
- >
69
- {children}
70
- {showCloseButton && (
71
- <DialogPrimitive.Close
72
- data-slot="dialog-close"
73
- className="absolute top-4 right-4 rounded-xs opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4"
74
- >
75
- <XIcon />
76
- <span className="sr-only">Close</span>
77
- </DialogPrimitive.Close>
78
- )}
79
- </DialogPrimitive.Content>
80
- </DialogPortal>
81
- )
82
- }
83
-
84
- function DialogHeader({ className, ...props }: React.ComponentProps<"div">) {
85
- return (
86
- <div
87
- data-slot="dialog-header"
88
- className={cn("flex flex-col gap-2 text-center sm:text-left", className)}
89
- {...props}
90
- />
91
- )
92
- }
93
-
94
- function DialogFooter({
95
- className,
96
- showCloseButton = false,
97
- children,
98
- ...props
99
- }: React.ComponentProps<"div"> & {
100
- showCloseButton?: boolean
101
- }) {
102
- return (
103
- <div
104
- data-slot="dialog-footer"
105
- className={cn(
106
- "flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",
107
- className
108
- )}
109
- {...props}
110
- >
111
- {children}
112
- {showCloseButton && (
113
- <DialogPrimitive.Close asChild>
114
- <Button variant="outline">Close</Button>
115
- </DialogPrimitive.Close>
116
- )}
117
- </div>
118
- )
119
- }
120
-
121
- function DialogTitle({
122
- className,
123
- ...props
124
- }: React.ComponentProps<typeof DialogPrimitive.Title>) {
125
- return (
126
- <DialogPrimitive.Title
127
- data-slot="dialog-title"
128
- className={cn("text-lg leading-none font-semibold", className)}
129
- {...props}
130
- />
131
- )
132
- }
133
-
134
- function DialogDescription({
135
- className,
136
- ...props
137
- }: React.ComponentProps<typeof DialogPrimitive.Description>) {
138
- return (
139
- <DialogPrimitive.Description
140
- data-slot="dialog-description"
141
- className={cn("text-sm text-muted-foreground", className)}
142
- {...props}
143
- />
144
- )
145
- }
146
-
147
- export {
148
- Dialog,
149
- DialogClose,
150
- DialogContent,
151
- DialogDescription,
152
- DialogFooter,
153
- DialogHeader,
154
- DialogOverlay,
155
- DialogPortal,
156
- DialogTitle,
157
- DialogTrigger,
158
- }
@@ -1,58 +0,0 @@
1
- import * as React from "react";
2
- import { Button } from "@/components/ui/button";
3
- import {
4
- Dialog,
5
- DialogClose,
6
- DialogContent,
7
- DialogDescription,
8
- DialogFooter,
9
- DialogHeader,
10
- DialogTitle,
11
- DialogTrigger,
12
- } from "@/components/ui/dialog";
13
-
14
- // Whole-tree hydration: this page's entire React tree hydrates in the browser,
15
- // so upstream shadcn/ui components work as written — function props, shared
16
- // context, no island wrappers. Pages without this export ship zero JS.
17
- export const hydrate = true;
18
-
19
- export const meta = {
20
- title: "Welcome to Sordo",
21
- description: "A Bun-native full-stack meta-framework.",
22
- };
23
-
24
- export default function Index() {
25
- const [saved, setSaved] = React.useState(0);
26
- return (
27
- <main className="mx-auto max-w-2xl space-y-4 p-8">
28
- <h1 className="font-semibold text-2xl">Welcome to Sordo</h1>
29
- <p className="text-muted-foreground">
30
- This page is server-rendered, then hydrated as one React tree. The
31
- dialog below is upstream shadcn/ui, stamped verbatim into{" "}
32
- <code>app/components/ui/</code>.
33
- </p>
34
- <Dialog>
35
- <DialogTrigger asChild>
36
- <Button>Open dialog</Button>
37
- </DialogTrigger>
38
- <DialogContent>
39
- <DialogHeader>
40
- <DialogTitle>Hello from shadcn/ui</DialogTitle>
41
- <DialogDescription>
42
- Function props and shared context cross no island boundary here.
43
- </DialogDescription>
44
- </DialogHeader>
45
- <DialogFooter>
46
- <DialogClose asChild>
47
- <Button onClick={() => setSaved((n) => n + 1)}>Save</Button>
48
- </DialogClose>
49
- </DialogFooter>
50
- </DialogContent>
51
- </Dialog>
52
- <p className="text-muted-foreground text-sm">Saved {saved} time(s).</p>
53
- <p className="text-muted-foreground text-sm">
54
- Add more with <code>bunx sordo add @shadcn/&lt;name&gt;</code>.
55
- </p>
56
- </main>
57
- );
58
- }
@@ -1,6 +0,0 @@
1
- import { type ClassValue, clsx } from "clsx";
2
- import { twMerge } from "tailwind-merge";
3
-
4
- export function cn(...inputs: ClassValue[]): string {
5
- return twMerge(clsx(inputs));
6
- }
@@ -1,50 +0,0 @@
1
- import {
2
- Children,
3
- cloneElement,
4
- isValidElement,
5
- type ReactElement,
6
- type ReactNode,
7
- } from "react";
8
-
9
- interface SlotProps {
10
- children?: ReactNode;
11
- [key: string]: unknown;
12
- }
13
-
14
- export function Slot({
15
- children,
16
- ...slotProps
17
- }: SlotProps): ReactElement | null {
18
- const child = Children.only(children);
19
- if (!isValidElement(child)) return null;
20
- const childEl = child as ReactElement<Record<string, unknown>>;
21
- return cloneElement(childEl, mergeProps(slotProps, childEl.props));
22
- }
23
-
24
- function mergeProps(
25
- parent: Record<string, unknown>,
26
- child: Record<string, unknown>,
27
- ): Record<string, unknown> {
28
- const merged: Record<string, unknown> = { ...parent };
29
- for (const key of Object.keys(child)) {
30
- const parentVal = parent[key];
31
- const childVal = child[key];
32
- if (
33
- key.startsWith("on") &&
34
- typeof parentVal === "function" &&
35
- typeof childVal === "function"
36
- ) {
37
- merged[key] = (...args: unknown[]) => {
38
- (childVal as (...a: unknown[]) => unknown)(...args);
39
- (parentVal as (...a: unknown[]) => unknown)(...args);
40
- };
41
- } else if (key === "className") {
42
- merged[key] = [parentVal, childVal].filter(Boolean).join(" ");
43
- } else if (key === "style") {
44
- merged[key] = { ...(parentVal as object), ...(childVal as object) };
45
- } else {
46
- merged[key] = childVal;
47
- }
48
- }
49
- return merged;
50
- }
@@ -1 +0,0 @@
1
- export { cva, type VariantProps } from "class-variance-authority";
@@ -1,60 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { cn } from "./_internal/cn.ts";
3
- import { Slot } from "./_internal/slot.ts";
4
- import { cva, type VariantProps } from "./_internal/variants.ts";
5
-
6
- export const island = "subtree" as const;
7
-
8
- export const buttonVariants = cva(
9
- "inline-flex shrink-0 items-center justify-center gap-2 whitespace-nowrap rounded-md font-medium text-sm outline-none transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 [&_svg]:shrink-0",
10
- {
11
- variants: {
12
- variant: {
13
- default:
14
- "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
15
- destructive:
16
- "bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20",
17
- outline:
18
- "border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",
19
- secondary:
20
- "bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",
21
- ghost: "hover:bg-accent hover:text-accent-foreground",
22
- link: "text-primary underline-offset-4 hover:underline",
23
- },
24
- size: {
25
- default: "h-9 px-4 py-2 has-[>svg]:px-3",
26
- sm: "h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",
27
- lg: "h-10 rounded-md px-6 has-[>svg]:px-4",
28
- icon: "size-9",
29
- },
30
- },
31
- defaultVariants: { variant: "default", size: "default" },
32
- },
33
- );
34
-
35
- export type ButtonVariant = NonNullable<
36
- VariantProps<typeof buttonVariants>["variant"]
37
- >;
38
- export type ButtonSize = NonNullable<
39
- VariantProps<typeof buttonVariants>["size"]
40
- >;
41
-
42
- type ButtonProps = ComponentProps<"button"> &
43
- VariantProps<typeof buttonVariants> & { asChild?: boolean };
44
-
45
- export function Button({
46
- className,
47
- variant,
48
- size,
49
- asChild = false,
50
- ...props
51
- }: ButtonProps) {
52
- const Comp = asChild ? Slot : "button";
53
- return (
54
- <Comp
55
- data-slot="button"
56
- className={cn(buttonVariants({ variant, size }), className)}
57
- {...props}
58
- />
59
- );
60
- }
@@ -1,92 +0,0 @@
1
- import type { ComponentProps } from "react";
2
- import { cn } from "./_internal/cn.ts";
3
- import { Slot } from "./_internal/slot.ts";
4
-
5
- export const island = false as const;
6
-
7
- export function Card({ className, ...props }: ComponentProps<"div">) {
8
- return (
9
- <div
10
- data-slot="card"
11
- className={cn(
12
- "flex flex-col gap-6 rounded-xl border bg-card py-6 text-card-foreground shadow-sm",
13
- className,
14
- )}
15
- {...props}
16
- />
17
- );
18
- }
19
-
20
- export function CardHeader({ className, ...props }: ComponentProps<"div">) {
21
- return (
22
- <div
23
- data-slot="card-header"
24
- className={cn(
25
- "@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto]",
26
- className,
27
- )}
28
- {...props}
29
- />
30
- );
31
- }
32
-
33
- export function CardTitle({
34
- className,
35
- asChild = false,
36
- ...props
37
- }: ComponentProps<"div"> & { asChild?: boolean }) {
38
- const Comp = asChild ? Slot : "div";
39
- return (
40
- <Comp
41
- data-slot="card-title"
42
- className={cn("font-semibold leading-none", className)}
43
- {...props}
44
- />
45
- );
46
- }
47
-
48
- export function CardDescription({
49
- className,
50
- ...props
51
- }: ComponentProps<"div">) {
52
- return (
53
- <div
54
- data-slot="card-description"
55
- className={cn("text-muted-foreground text-sm", className)}
56
- {...props}
57
- />
58
- );
59
- }
60
-
61
- export function CardAction({ className, ...props }: ComponentProps<"div">) {
62
- return (
63
- <div
64
- data-slot="card-action"
65
- className={cn(
66
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
67
- className,
68
- )}
69
- {...props}
70
- />
71
- );
72
- }
73
-
74
- export function CardContent({ className, ...props }: ComponentProps<"div">) {
75
- return (
76
- <div
77
- data-slot="card-content"
78
- className={cn("px-6", className)}
79
- {...props}
80
- />
81
- );
82
- }
83
-
84
- export function CardFooter({ className, ...props }: ComponentProps<"div">) {
85
- return (
86
- <div
87
- data-slot="card-footer"
88
- className={cn("flex items-center px-6 [.border-t]:pt-6", className)}
89
- {...props}
90
- />
91
- );
92
- }
@@ -1,86 +0,0 @@
1
- "use client";
2
-
3
- import { useState } from "react";
4
- import { Button } from "../components/ui/button.tsx";
5
- import { Input } from "../components/ui/input.tsx";
6
-
7
- interface Todo {
8
- id: number;
9
- text: string;
10
- done: boolean;
11
- }
12
-
13
- export default function TodoApp() {
14
- const [todos, setTodos] = useState<Todo[]>([
15
- { id: 1, text: "edit app/routes/index.tsx", done: false },
16
- { id: 2, text: "edit app/islands/TodoApp.tsx", done: false },
17
- { id: 3, text: "add a component with `sordo add`", done: false },
18
- ]);
19
- const [draft, setDraft] = useState("");
20
-
21
- function add(): void {
22
- const text = draft.trim();
23
- if (!text) return;
24
- setTodos([...todos, { id: Date.now(), text, done: false }]);
25
- setDraft("");
26
- }
27
-
28
- function toggle(id: number): void {
29
- setTodos(todos.map((t) => (t.id === id ? { ...t, done: !t.done } : t)));
30
- }
31
-
32
- function remove(id: number): void {
33
- setTodos(todos.filter((t) => t.id !== id));
34
- }
35
-
36
- return (
37
- <section aria-label="Todo demo" className="flex flex-col gap-3">
38
- <form
39
- className="flex gap-2"
40
- onSubmit={(e) => {
41
- e.preventDefault();
42
- add();
43
- }}
44
- >
45
- <Input
46
- type="text"
47
- value={draft}
48
- onChange={(e) => setDraft(e.target.value)}
49
- placeholder="What needs doing?"
50
- aria-label="New todo"
51
- />
52
- <Button type="submit">Add</Button>
53
- </form>
54
- <ul className="flex flex-col gap-2">
55
- {todos.map((t) => (
56
- <li key={t.id} className="flex items-center gap-2">
57
- <label className="flex flex-1 items-center gap-2">
58
- <input
59
- type="checkbox"
60
- checked={t.done}
61
- onChange={() => toggle(t.id)}
62
- />
63
- <span
64
- className={t.done ? "text-muted-foreground line-through" : ""}
65
- >
66
- {t.text}
67
- </span>
68
- </label>
69
- <Button
70
- type="button"
71
- variant="ghost"
72
- size="sm"
73
- onClick={() => remove(t.id)}
74
- aria-label="Remove"
75
- >
76
- ×
77
- </Button>
78
- </li>
79
- ))}
80
- </ul>
81
- <p className="text-muted-foreground text-sm">
82
- {todos.filter((t) => !t.done).length} of {todos.length} remaining
83
- </p>
84
- </section>
85
- );
86
- }
@@ -1,41 +0,0 @@
1
- import { Island } from "sordo/render";
2
- import {
3
- Card,
4
- CardContent,
5
- CardDescription,
6
- CardHeader,
7
- CardTitle,
8
- } from "../components/ui/card.tsx";
9
- import TodoApp from "../islands/TodoApp.tsx";
10
-
11
- export const meta = {
12
- title: "Welcome to Sordo",
13
- description: "A Bun-native full-stack meta-framework.",
14
- };
15
-
16
- export default function Index() {
17
- return (
18
- <main className="mx-auto max-w-2xl p-8">
19
- <Card>
20
- <CardHeader>
21
- <CardTitle>Welcome to Sordo</CardTitle>
22
- <CardDescription>
23
- This page is server-rendered with UI components. The list below is a
24
- client island — <code>app/islands/TodoApp.tsx</code> — hydrated in
25
- the browser.
26
- </CardDescription>
27
- </CardHeader>
28
- <CardContent>
29
- <Island name="TodoApp">
30
- <TodoApp />
31
- </Island>
32
- </CardContent>
33
- </Card>
34
- <p className="mt-4 text-muted-foreground text-sm">
35
- Components live in <code>app/components/ui/</code>. Add more with
36
- <code>sordo add</code>, or ask your coding agent via <code>/sordo</code>
37
- .
38
- </p>
39
- </main>
40
- );
41
- }