├── .eslintrc.json ├── .gitignore ├── .prettierrc ├── README.md ├── app ├── favicon.ico ├── globals.css ├── layout.tsx └── page.tsx ├── components.json ├── components ├── column.tsx ├── columns.tsx ├── new-todo-dialog.tsx ├── task.tsx └── ui │ ├── button.tsx │ ├── dialog.tsx │ ├── input.tsx │ ├── label.tsx │ └── textarea.tsx ├── lib ├── store.ts └── utils.ts ├── next.config.js ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── public ├── next.svg └── vercel.svg ├── tailwind.config.ts └── tsconfig.json /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "next/core-web-vitals" 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env*.local 30 | 31 | # vercel 32 | .vercel 33 | 34 | # typescript 35 | *.tsbuildinfo 36 | next-env.d.ts 37 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "arrowParens": "avoid", 3 | "singleQuote": true, 4 | "jsxSingleQuote": true, 5 | "tabWidth": 2, 6 | "trailingComma": "none", 7 | "semi": false, 8 | "proseWrap": "always", 9 | "printWidth": 80, 10 | "plugins": ["prettier-plugin-tailwindcss"] 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). 2 | 3 | ## Getting Started 4 | 5 | First, run the development server: 6 | 7 | ```bash 8 | npm run dev 9 | # or 10 | yarn dev 11 | # or 12 | pnpm dev 13 | # or 14 | bun dev 15 | ``` 16 | 17 | Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. 18 | 19 | You can start editing the page by modifying `app/page.tsx`. The page auto-updates as you edit the file. 20 | 21 | This project uses [`next/font`](https://nextjs.org/docs/basic-features/font-optimization) to automatically optimize and load Inter, a custom Google Font. 22 | 23 | ## Learn More 24 | 25 | To learn more about Next.js, take a look at the following resources: 26 | 27 | - [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. 28 | - [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. 29 | 30 | You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! 31 | 32 | ## Deploy on Vercel 33 | 34 | The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. 35 | 36 | Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. 37 | -------------------------------------------------------------------------------- /app/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HamedBahram/next-zustand/e32a1ee394f29e8cf8258d478466aa13e9553ade/app/favicon.ico -------------------------------------------------------------------------------- /app/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | -------------------------------------------------------------------------------- /app/layout.tsx: -------------------------------------------------------------------------------- 1 | import type { Metadata } from 'next' 2 | import { Inter } from 'next/font/google' 3 | import './globals.css' 4 | 5 | const inter = Inter({ subsets: ['latin'] }) 6 | 7 | export const metadata: Metadata = { 8 | title: 'Create Next App', 9 | description: 'Generated by create next app', 10 | } 11 | 12 | export default function RootLayout({ 13 | children, 14 | }: { 15 | children: React.ReactNode 16 | }) { 17 | return ( 18 | 19 | {children} 20 | 21 | ) 22 | } 23 | -------------------------------------------------------------------------------- /app/page.tsx: -------------------------------------------------------------------------------- 1 | import Columns from '@/components/columns' 2 | 3 | export default function Home() { 4 | return ( 5 |
6 |
7 | 8 |
9 |
10 | ) 11 | } 12 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "new-york", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.js", 8 | "css": "app/globals.css", 9 | "baseColor": "gray", 10 | "cssVariables": false 11 | }, 12 | "aliases": { 13 | "components": "@/components", 14 | "utils": "@/lib/utils" 15 | } 16 | } -------------------------------------------------------------------------------- /components/column.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { Status, useTaskStore } from '@/lib/store' 4 | import Task from './task' 5 | import { useEffect, useMemo } from 'react' 6 | 7 | export default function Column({ 8 | title, 9 | status 10 | }: { 11 | title: string 12 | status: Status 13 | }) { 14 | const tasks = useTaskStore(state => state.tasks) 15 | const filteredTasks = useMemo( 16 | () => tasks.filter(task => task.status === status), 17 | [tasks, status] 18 | ) 19 | 20 | const updateTask = useTaskStore(state => state.updateTask) 21 | const dragTask = useTaskStore(state => state.dragTask) 22 | 23 | const draggedTask = useTaskStore(state => state.draggedTask) 24 | 25 | useEffect(() => { 26 | useTaskStore.persist.rehydrate() 27 | }, []) 28 | 29 | const handleDrop = (e: React.DragEvent) => { 30 | if (!draggedTask) return 31 | updateTask(draggedTask, status) 32 | dragTask(null) 33 | } 34 | 35 | return ( 36 |
37 |

{title}

38 | 39 |
e.preventDefault()} 43 | > 44 |
45 | {filteredTasks.map(task => ( 46 | 47 | ))} 48 | 49 | {filteredTasks.length === 0 && status === 'TODO' && ( 50 |
51 |

Create a new task

52 |
53 | )} 54 | 55 | {tasks.length && filteredTasks.length === 0 && status !== 'TODO' ? ( 56 |
57 |

Drag your tasks here

58 |
59 | ) : null} 60 |
61 |
62 |
63 | ) 64 | } 65 | -------------------------------------------------------------------------------- /components/columns.tsx: -------------------------------------------------------------------------------- 1 | import Column from './column' 2 | import NewTodoDialog from './new-todo-dialog' 3 | 4 | export default function Columns() { 5 | return ( 6 |
7 | 8 | 9 |
10 | 11 | 12 | 13 |
14 |
15 | ) 16 | } 17 | -------------------------------------------------------------------------------- /components/new-todo-dialog.tsx: -------------------------------------------------------------------------------- 1 | 'use client' 2 | 3 | import { Button } from '@/components/ui/button' 4 | import { 5 | Dialog, 6 | DialogContent, 7 | DialogDescription, 8 | DialogFooter, 9 | DialogHeader, 10 | DialogTitle, 11 | DialogTrigger 12 | } from '@/components/ui/dialog' 13 | import { Input } from '@/components/ui/input' 14 | import { Textarea } from './ui/textarea' 15 | 16 | import { useTaskStore } from '@/lib/store' 17 | 18 | export default function NewTodoDialog() { 19 | const addTask = useTaskStore(state => state.addTask) 20 | 21 | const handleSubmit = (e: React.FormEvent) => { 22 | e.preventDefault() 23 | 24 | const form = e.currentTarget 25 | const formData = new FormData(form) 26 | const { title, description } = Object.fromEntries(formData) 27 | 28 | if (typeof title !== 'string' || typeof description !== 'string') return 29 | 30 | addTask(title, description) 31 | } 32 | 33 | return ( 34 | 35 | 36 | 39 | 40 | 41 | 42 | Add New Todo 43 | 44 | What do you want to get done today? 45 | 46 | 47 |
52 |
53 | 59 |
60 |
61 |