From 2b9ee7c316cc9409491b78a14583cae30f21d6af Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 10 Nov 2025 18:36:01 +0100 Subject: [PATCH] Better stuff --- src/app/layout.tsx | 2 +- src/app/workspace/page.tsx | 90 ++++++++++++++++++++------------------ src/lib/ui/color.ts | 63 ++++++++++++++++++++++++++ 3 files changed, 112 insertions(+), 43 deletions(-) create mode 100644 src/lib/ui/color.ts diff --git a/src/app/layout.tsx b/src/app/layout.tsx index f7fa87e..11234a9 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -25,7 +25,7 @@ export default function RootLayout({ return ( {children} diff --git a/src/app/workspace/page.tsx b/src/app/workspace/page.tsx index b027db9..7cfbf61 100644 --- a/src/app/workspace/page.tsx +++ b/src/app/workspace/page.tsx @@ -7,20 +7,21 @@ import { CardTitle, CardContent, CardFooter, + CardDescription, } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Trash } from "lucide-react"; import { DragDropContext, Droppable, Draggable } from "@hello-pangea/dnd"; +import { Color, getColor } from "@/lib/ui/color"; type Task = { id: string; title: string; description?: string; + tags?: { name: string; color: Color }[]; }; -type ColumnKey = "todo" | "inprogress" | "done"; - -const columnLabels: Record = { +const columnLabels: Record = { todo: "To do", inprogress: "In progress", done: "Done", @@ -30,7 +31,7 @@ const id = (prefix = "t") => `${prefix}_${Math.random().toString(36).slice(2, 9)}`; export default function Workspace() { - const [columns, setColumns] = useState>({ + const [columns, setColumns] = useState>({ todo: [], inprogress: [], done: [], @@ -42,7 +43,20 @@ export default function Workspace() { { id: id(), title: "Buy groceries" }, { id: id(), title: "Plan sprint" }, ], - inprogress: [{ id: id(), title: "Build header" }], + inprogress: [ + { + id: id(), + title: "Build header", + description: "A simple description", + tags: [ + { name: "Website", color: "pink" }, + { name: "Development", color: "blue" }, + { name: "API", color: "green" }, + { name: "App", color: "purple" }, + { name: "Rust", color: "orange" }, + ], + }, + ], done: [{ id: id(), title: "Set up repo" }], }); }, []); @@ -52,16 +66,12 @@ export default function Workspace() { if (!mounted) return null; - function removeTask(col: ColumnKey, taskId: string) { - setColumns((c) => ({ ...c, [col]: c[col].filter((t) => t.id !== taskId) })); - } - function onDragEnd(result: any) { const { source, destination } = result; if (!destination) return; - const sourceCol = source.droppableId as ColumnKey; - const destCol = destination.droppableId as ColumnKey; + const sourceCol = source.droppableId; + const destCol = destination.droppableId; if (sourceCol === destCol) { const items = Array.from(columns[sourceCol]); @@ -85,13 +95,13 @@ export default function Workspace() {
- {(Object.keys(columnLabels) as ColumnKey[]).map((colKey) => ( + {Object.keys(columnLabels).map((colKey) => ( {(provided) => ( @@ -110,59 +120,55 @@ export default function Workspace() { index={index} > {(provided) => ( -
-
-
- - {task.title} - - {task.description ? ( -

- {task.description} -

- ) : null} -
- -
-
+ + {task.title} + + {task.description} + + + + {task.tags?.map((tag, i) => ( + + {tag.name} + + ))} + +
)} ))} {provided.placeholder} {columns[colKey].length === 0 && (

- No tasks — try adding one! + No tasks

)}
- - Quick actions -
diff --git a/src/lib/ui/color.ts b/src/lib/ui/color.ts new file mode 100644 index 0000000..d628397 --- /dev/null +++ b/src/lib/ui/color.ts @@ -0,0 +1,63 @@ +export type Color = + | "default" + | "gray" + | "brown" + | "orange" + | "yellow" + | "green" + | "blue" + | "purple" + | "pink" + | "red"; + +interface ColorStyle { + backgroundColor: string; + color: string; +} + +export function getColor(color: Color): ColorStyle { + const colors: Record = { + default: { + backgroundColor: "rgba(47, 52, 55, 0.27)", + color: "#FFFFFF", + }, + gray: { + backgroundColor: "rgba(151, 154, 155, 0.27)", + color: "#979A9B", + }, + brown: { + backgroundColor: "rgba(147, 114, 100, 0.27)", + color: "#937264", + }, + orange: { + backgroundColor: "rgba(255, 163, 68, 0.27)", + color: "#FFA344", + }, + yellow: { + backgroundColor: "rgba(255, 220, 73, 0.27)", + color: "#FFDC49", + }, + green: { + backgroundColor: "rgba(77, 171, 154, 0.27)", + color: "#4DAB9A", + }, + blue: { + backgroundColor: "rgba(82, 156, 202, 0.27)", + color: "#529CCA", + }, + purple: { + backgroundColor: "rgba(154, 109, 215, 0.27)", + color: "#9A6DD7", + }, + pink: { + backgroundColor: "rgba(226, 85, 161, 0.27)", + color: "#E255A1", + }, + red: { + backgroundColor: "rgba(255, 115, 105, 0.27)", + color: "#FF7369", + }, + }; + + return colors[color]; +}