Skip to content

Commit 33adc66

Browse files
initial - no copilot
1 parent d1c81cd commit 33adc66

19 files changed

+1349
-283
lines changed

app/globals.css

Lines changed: 59 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,68 @@
22
@tailwind components;
33
@tailwind utilities;
44

5-
:root {
6-
--foreground-rgb: 0, 0, 0;
7-
--background-start-rgb: 214, 219, 220;
8-
--background-end-rgb: 255, 255, 255;
9-
}
10-
11-
@media (prefers-color-scheme: dark) {
5+
@layer base {
126
:root {
13-
--foreground-rgb: 255, 255, 255;
14-
--background-start-rgb: 0, 0, 0;
15-
--background-end-rgb: 0, 0, 0;
7+
--background: 0 0% 100%;
8+
--foreground: 0 0% 3.9%;
9+
--card: 0 0% 100%;
10+
--card-foreground: 0 0% 3.9%;
11+
--popover: 0 0% 100%;
12+
--popover-foreground: 0 0% 3.9%;
13+
--primary: 0 0% 9%;
14+
--primary-foreground: 0 0% 98%;
15+
--secondary: 0 0% 96.1%;
16+
--secondary-foreground: 0 0% 9%;
17+
--muted: 0 0% 96.1%;
18+
--muted-foreground: 0 0% 45.1%;
19+
--accent: 0 0% 96.1%;
20+
--accent-foreground: 0 0% 9%;
21+
--destructive: 0 84.2% 60.2%;
22+
--destructive-foreground: 0 0% 98%;
23+
--border: 0 0% 89.8%;
24+
--input: 0 0% 89.8%;
25+
--ring: 0 0% 3.9%;
26+
--radius: 0.5rem;
27+
--chart-1: 12 76% 61%;
28+
--chart-2: 173 58% 39%;
29+
--chart-3: 197 37% 24%;
30+
--chart-4: 43 74% 66%;
31+
--chart-5: 27 87% 67%;
1632
}
17-
}
1833

19-
body {
20-
color: rgb(var(--foreground-rgb));
21-
background: linear-gradient(
22-
to bottom,
23-
transparent,
24-
rgb(var(--background-end-rgb))
25-
)
26-
rgb(var(--background-start-rgb));
34+
.dark {
35+
--background: 0 0% 3.9%;
36+
--foreground: 0 0% 98%;
37+
--card: 0 0% 3.9%;
38+
--card-foreground: 0 0% 98%;
39+
--popover: 0 0% 3.9%;
40+
--popover-foreground: 0 0% 98%;
41+
--primary: 0 0% 98%;
42+
--primary-foreground: 0 0% 9%;
43+
--secondary: 0 0% 14.9%;
44+
--secondary-foreground: 0 0% 98%;
45+
--muted: 0 0% 14.9%;
46+
--muted-foreground: 0 0% 63.9%;
47+
--accent: 0 0% 14.9%;
48+
--accent-foreground: 0 0% 98%;
49+
--destructive: 0 62.8% 30.6%;
50+
--destructive-foreground: 0 0% 98%;
51+
--border: 0 0% 14.9%;
52+
--input: 0 0% 14.9%;
53+
--ring: 0 0% 83.1%;
54+
--chart-1: 220 70% 50%;
55+
--chart-2: 160 60% 45%;
56+
--chart-3: 30 80% 55%;
57+
--chart-4: 280 65% 60%;
58+
--chart-5: 340 75% 55%;
59+
}
2760
}
2861

29-
@layer utilities {
30-
.text-balance {
31-
text-wrap: balance;
62+
@layer base {
63+
* {
64+
@apply border-border;
3265
}
33-
}
66+
body {
67+
@apply bg-background text-foreground;
68+
}
69+
}

app/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Metadata } from "next";
22
import { Inter } from "next/font/google";
33
import "./globals.css";
4+
import { Toaster } from "@/components/ui/toaster";
45

56
const inter = Inter({ subsets: ["latin"] });
67

@@ -16,7 +17,10 @@ export default function RootLayout({
1617
}>) {
1718
return (
1819
<html lang="en">
19-
<body className={inter.className}>{children}</body>
20+
<body className={inter.className}>
21+
{children}
22+
<Toaster />
23+
</body>
2024
</html>
2125
);
2226
}

app/page.tsx

Lines changed: 7 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,12 @@
1-
import Image from "next/image";
1+
"use client";
2+
3+
import { TasksList } from "@/components/TasksList";
4+
import { TasksProvider } from "@/lib/hooks/use-tasks";
25

36
export default function Home() {
47
return (
5-
<main className="flex min-h-screen flex-col items-center justify-between p-24">
6-
<div className="z-10 w-full max-w-5xl items-center justify-between font-mono text-sm lg:flex">
7-
<p className="fixed left-0 top-0 flex w-full justify-center border-b border-gray-300 bg-gradient-to-b from-zinc-200 pb-6 pt-8 backdrop-blur-2xl dark:border-neutral-800 dark:bg-zinc-800/30 dark:from-inherit lg:static lg:w-auto lg:rounded-xl lg:border lg:bg-gray-200 lg:p-4 lg:dark:bg-zinc-800/30">
8-
Get started by editing&nbsp;
9-
<code className="font-mono font-bold">app/page.tsx</code>
10-
</p>
11-
<div className="fixed bottom-0 left-0 flex h-48 w-full items-end justify-center bg-gradient-to-t from-white via-white dark:from-black dark:via-black lg:static lg:size-auto lg:bg-none">
12-
<a
13-
className="pointer-events-none flex place-items-center gap-2 p-8 lg:pointer-events-auto lg:p-0"
14-
href="https://vercel.com?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
15-
target="_blank"
16-
rel="noopener noreferrer"
17-
>
18-
By{" "}
19-
<Image
20-
src="/vercel.svg"
21-
alt="Vercel Logo"
22-
className="dark:invert"
23-
width={100}
24-
height={24}
25-
priority
26-
/>
27-
</a>
28-
</div>
29-
</div>
30-
31-
<div className="relative z-[-1] flex place-items-center before:absolute before:h-[300px] before:w-full before:-translate-x-1/2 before:rounded-full before:bg-gradient-radial before:from-white before:to-transparent before:blur-2xl before:content-[''] after:absolute after:-z-20 after:h-[180px] after:w-full after:translate-x-1/3 after:bg-gradient-conic after:from-sky-200 after:via-blue-200 after:blur-2xl after:content-[''] before:dark:bg-gradient-to-br before:dark:from-transparent before:dark:to-blue-700 before:dark:opacity-10 after:dark:from-sky-900 after:dark:via-[#0141ff] after:dark:opacity-40 sm:before:w-[480px] sm:after:w-[240px] before:lg:h-[360px]">
32-
<Image
33-
className="relative dark:drop-shadow-[0_0_0.3rem_#ffffff70] dark:invert"
34-
src="/next.svg"
35-
alt="Next.js Logo"
36-
width={180}
37-
height={37}
38-
priority
39-
/>
40-
</div>
41-
42-
<div className="mb-32 grid text-center lg:mb-0 lg:w-full lg:max-w-5xl lg:grid-cols-4 lg:text-left">
43-
<a
44-
href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
45-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
46-
target="_blank"
47-
rel="noopener noreferrer"
48-
>
49-
<h2 className="mb-3 text-2xl font-semibold">
50-
Docs{" "}
51-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
52-
-&gt;
53-
</span>
54-
</h2>
55-
<p className="m-0 max-w-[30ch] text-sm opacity-50">
56-
Find in-depth information about Next.js features and API.
57-
</p>
58-
</a>
59-
60-
<a
61-
href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
62-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
63-
target="_blank"
64-
rel="noopener noreferrer"
65-
>
66-
<h2 className="mb-3 text-2xl font-semibold">
67-
Learn{" "}
68-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
69-
-&gt;
70-
</span>
71-
</h2>
72-
<p className="m-0 max-w-[30ch] text-sm opacity-50">
73-
Learn about Next.js in an interactive course with&nbsp;quizzes!
74-
</p>
75-
</a>
76-
77-
<a
78-
href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
79-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
80-
target="_blank"
81-
rel="noopener noreferrer"
82-
>
83-
<h2 className="mb-3 text-2xl font-semibold">
84-
Templates{" "}
85-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
86-
-&gt;
87-
</span>
88-
</h2>
89-
<p className="m-0 max-w-[30ch] text-sm opacity-50">
90-
Explore starter templates for Next.js.
91-
</p>
92-
</a>
93-
94-
<a
95-
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template&utm_campaign=create-next-app"
96-
className="group rounded-lg border border-transparent px-5 py-4 transition-colors hover:border-gray-300 hover:bg-gray-100 hover:dark:border-neutral-700 hover:dark:bg-neutral-800/30"
97-
target="_blank"
98-
rel="noopener noreferrer"
99-
>
100-
<h2 className="mb-3 text-2xl font-semibold">
101-
Deploy{" "}
102-
<span className="inline-block transition-transform group-hover:translate-x-1 motion-reduce:transform-none">
103-
-&gt;
104-
</span>
105-
</h2>
106-
<p className="m-0 max-w-[30ch] text-balance text-sm opacity-50">
107-
Instantly deploy your Next.js site to a shareable URL with Vercel.
108-
</p>
109-
</a>
110-
</div>
111-
</main>
8+
<TasksProvider>
9+
<TasksList />
10+
</TasksProvider>
11211
);
11312
}

components.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"$schema": "https://ui.shadcn.com/schema.json",
3+
"style": "default",
4+
"rsc": true,
5+
"tsx": true,
6+
"tailwind": {
7+
"config": "tailwind.config.ts",
8+
"css": "app/globals.css",
9+
"baseColor": "neutral",
10+
"cssVariables": true,
11+
"prefix": ""
12+
},
13+
"aliases": {
14+
"components": "@/components",
15+
"utils": "@/lib/utils"
16+
}
17+
}

components/AddTodo.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Input } from "@/components/ui/input";
2+
import { Button } from "@/components/ui/button";
3+
import { useState } from "react";
4+
import { useTasks } from "@/lib/hooks/use-tasks";
5+
6+
export function AddTodo() {
7+
const [title, setTitle] = useState("");
8+
const { addTask } = useTasks();
9+
10+
const handleAddTask = () => {
11+
addTask(title);
12+
setTitle("");
13+
};
14+
15+
return (
16+
<form onSubmit={(e) => e.preventDefault()}>
17+
<div className="flex items-center mb-4">
18+
<Input
19+
value={title}
20+
onChange={(e) => setTitle(e.target.value)}
21+
type="text"
22+
placeholder="Add a new todo..."
23+
className="flex-1 mr-2 bg-muted text-muted-foreground rounded-md px-4 py-2"
24+
/>
25+
<Button type="submit" disabled={!title} onClick={handleAddTask}>
26+
Add
27+
</Button>
28+
</div>
29+
</form>
30+
);
31+
}

components/Task.tsx

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { Checkbox } from "@/components/ui/checkbox";
2+
import { Label } from "@/components/ui/label";
3+
import { Button } from "@/components/ui/button";
4+
import { TrashIcon } from "lucide-react";
5+
import { cn } from "@/lib/utils";
6+
import { TaskStatus, useTasks, type Task } from "@/lib/hooks/use-tasks";
7+
import { motion } from "framer-motion";
8+
9+
export function Task({ task: { id, title, status } }: { task: Task }) {
10+
const { setTaskStatus, deleteTask } = useTasks();
11+
12+
return (
13+
<motion.div
14+
key={`${id}_${status}`}
15+
initial={{ opacity: 0, y: -20 }}
16+
animate={{ opacity: 1, y: 0 }}
17+
exit={{ opacity: 0, y: -20 }}
18+
className="flex items-center gap-4 p-2 rounded-md bg-muted"
19+
>
20+
<Checkbox
21+
id={`task_${id}`}
22+
onClick={() => setTaskStatus(id, status === TaskStatus.done ? TaskStatus.todo : TaskStatus.done)}
23+
checked={status === TaskStatus.done}
24+
/>
25+
<div className="text-sm text-neutral-500 font-medium">TASK-{id}</div>
26+
<Label
27+
htmlFor={`task_${id}`}
28+
className={cn(
29+
"flex-1 text-sm text-muted-foreground",
30+
status === TaskStatus.done && "line-through"
31+
)}
32+
>
33+
{title}
34+
</Label>
35+
<Button variant="ghost" size="sm" onClick={() => deleteTask(id)}>
36+
<TrashIcon className="w-4 h-4" />
37+
<span className="sr-only">Delete</span>
38+
</Button>
39+
</motion.div>
40+
);
41+
}

components/TasksList.tsx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"use client";
2+
3+
import { AddTodo } from "@/components/AddTodo";
4+
import { Task } from "@/components/Task";
5+
import { TaskStatus, useTasks } from "@/lib/hooks/use-tasks";
6+
import { AnimatePresence } from "framer-motion";
7+
8+
export function TasksList() {
9+
const { tasks } = useTasks();
10+
11+
return (
12+
<main className="flex min-h-screen flex-col items-center justify-between p-24">
13+
<div className="flex flex-col gap-4 min-w-[500px]">
14+
<h1 className="text-2xl font-bold">My Todos</h1>
15+
<AddTodo />
16+
17+
<AnimatePresence>
18+
{tasks
19+
.sort((a, b) => {
20+
if (a.status === b.status) {
21+
return a.id - b.id;
22+
}
23+
return a.status === TaskStatus.todo ? -1 : 1;
24+
})
25+
.map((task) => (
26+
<Task key={task.id} task={task} />
27+
))}
28+
</AnimatePresence>
29+
</div>
30+
</main>
31+
);
32+
}

0 commit comments

Comments
 (0)