From 2cddb7aa8f117c8b30628e6885e2decbba1fa561 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 15 Feb 2026 20:28:16 +0200 Subject: [PATCH] feat: add column color, card coverColor, and board background to data model --- src/lib/board-factory.ts | 3 ++- src/lib/import-export.ts | 4 +++- src/lib/schemas.ts | 5 ++++- src/stores/board-store.ts | 13 +++++++++++++ src/types/board.ts | 3 +++ 5 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/lib/board-factory.ts b/src/lib/board-factory.ts index eb2bebc..fb14162 100644 --- a/src/lib/board-factory.ts +++ b/src/lib/board-factory.ts @@ -18,7 +18,7 @@ export function createBoard( columns: [], cards: {}, labels: [], - settings: { attachmentMode: "link" }, + settings: { attachmentMode: "link" as const, background: "none" as const }, }; const col = (t: string, w: ColumnWidth = "standard") => ({ @@ -26,6 +26,7 @@ export function createBoard( title: t, cardIds: [] as string[], width: w, + color: null as string | null, }); if (template === "kanban") { diff --git a/src/lib/import-export.ts b/src/lib/import-export.ts index 41cbdc5..0fe7c93 100644 --- a/src/lib/import-export.ts +++ b/src/lib/import-export.ts @@ -153,6 +153,7 @@ export function importFromTrelloJson(jsonString: string): Board { title: list.name, cardIds: [], width: "standard" as const, + color: null, }; }); @@ -201,6 +202,7 @@ export function importFromTrelloJson(jsonString: string): Board { checklist, dueDate: tCard.due ?? null, attachments: [], + coverColor: null, createdAt: ts, updatedAt: ts, }; @@ -223,7 +225,7 @@ export function importFromTrelloJson(jsonString: string): Board { columns, cards, labels, - settings: { attachmentMode: "link" }, + settings: { attachmentMode: "link", background: "none" }, }; return board; diff --git a/src/lib/schemas.ts b/src/lib/schemas.ts index cf07a06..ab68031 100644 --- a/src/lib/schemas.ts +++ b/src/lib/schemas.ts @@ -27,6 +27,7 @@ export const cardSchema = z.object({ checklist: z.array(checklistItemSchema).default([]), dueDate: z.string().nullable().default(null), attachments: z.array(attachmentSchema).default([]), + coverColor: z.string().nullable().default(null), createdAt: z.string(), updatedAt: z.string(), }); @@ -36,10 +37,12 @@ export const columnSchema = z.object({ title: z.string(), cardIds: z.array(z.string()).default([]), width: z.enum(["narrow", "standard", "wide"]).default("standard"), + color: z.string().nullable().default(null), }); export const boardSettingsSchema = z.object({ attachmentMode: z.enum(["link", "copy"]).default("link"), + background: z.enum(["none", "dots", "grid", "gradient"]).default("none"), }); export const boardSchema = z.object({ @@ -51,7 +54,7 @@ export const boardSchema = z.object({ columns: z.array(columnSchema).default([]), cards: z.record(z.string(), cardSchema).default({}), labels: z.array(labelSchema).default([]), - settings: boardSettingsSchema.default({ attachmentMode: "link" }), + settings: boardSettingsSchema.default({ attachmentMode: "link", background: "none" }), }); export const appSettingsSchema = z.object({ diff --git a/src/stores/board-store.ts b/src/stores/board-store.ts index 946014f..462a70f 100644 --- a/src/stores/board-store.ts +++ b/src/stores/board-store.ts @@ -26,6 +26,7 @@ interface BoardActions { deleteColumn: (columnId: string) => void; moveColumn: (fromIndex: number, toIndex: number) => void; setColumnWidth: (columnId: string, width: ColumnWidth) => void; + setColumnColor: (columnId: string, color: string | null) => void; addCard: (columnId: string, title: string) => string; updateCard: (cardId: string, updates: Partial) => void; @@ -130,6 +131,7 @@ export const useBoardStore = create()( title, cardIds: [], width: "standard" as ColumnWidth, + color: null, }, ], })); @@ -179,6 +181,16 @@ export const useBoardStore = create()( })); }, + setColumnColor: (columnId, color) => { + mutate(get, set, (b) => ({ + ...b, + updatedAt: now(), + columns: b.columns.map((c) => + c.id === columnId ? { ...c, color } : c + ), + })); + }, + // -- Card actions -- addCard: (columnId, title) => { @@ -191,6 +203,7 @@ export const useBoardStore = create()( checklist: [], dueDate: null, attachments: [], + coverColor: null, createdAt: now(), updatedAt: now(), }; diff --git a/src/types/board.ts b/src/types/board.ts index 9b62eaf..36a91a6 100644 --- a/src/types/board.ts +++ b/src/types/board.ts @@ -15,6 +15,7 @@ export interface Column { title: string; cardIds: string[]; width: ColumnWidth; + color: string | null; } export type ColumnWidth = "narrow" | "standard" | "wide"; @@ -27,6 +28,7 @@ export interface Card { checklist: ChecklistItem[]; dueDate: string | null; attachments: Attachment[]; + coverColor: string | null; createdAt: string; updatedAt: string; } @@ -52,6 +54,7 @@ export interface Attachment { export interface BoardSettings { attachmentMode: "link" | "copy"; + background: "none" | "dots" | "grid" | "gradient"; } export interface BoardMeta {