feat: add column color, card coverColor, and board background to data model

This commit is contained in:
Your Name
2026-02-15 20:28:16 +02:00
parent 16ea05cfe0
commit 2cddb7aa8f
5 changed files with 25 additions and 3 deletions

View File

@@ -18,7 +18,7 @@ export function createBoard(
columns: [], columns: [],
cards: {}, cards: {},
labels: [], labels: [],
settings: { attachmentMode: "link" }, settings: { attachmentMode: "link" as const, background: "none" as const },
}; };
const col = (t: string, w: ColumnWidth = "standard") => ({ const col = (t: string, w: ColumnWidth = "standard") => ({
@@ -26,6 +26,7 @@ export function createBoard(
title: t, title: t,
cardIds: [] as string[], cardIds: [] as string[],
width: w, width: w,
color: null as string | null,
}); });
if (template === "kanban") { if (template === "kanban") {

View File

@@ -153,6 +153,7 @@ export function importFromTrelloJson(jsonString: string): Board {
title: list.name, title: list.name,
cardIds: [], cardIds: [],
width: "standard" as const, width: "standard" as const,
color: null,
}; };
}); });
@@ -201,6 +202,7 @@ export function importFromTrelloJson(jsonString: string): Board {
checklist, checklist,
dueDate: tCard.due ?? null, dueDate: tCard.due ?? null,
attachments: [], attachments: [],
coverColor: null,
createdAt: ts, createdAt: ts,
updatedAt: ts, updatedAt: ts,
}; };
@@ -223,7 +225,7 @@ export function importFromTrelloJson(jsonString: string): Board {
columns, columns,
cards, cards,
labels, labels,
settings: { attachmentMode: "link" }, settings: { attachmentMode: "link", background: "none" },
}; };
return board; return board;

View File

@@ -27,6 +27,7 @@ export const cardSchema = z.object({
checklist: z.array(checklistItemSchema).default([]), checklist: z.array(checklistItemSchema).default([]),
dueDate: z.string().nullable().default(null), dueDate: z.string().nullable().default(null),
attachments: z.array(attachmentSchema).default([]), attachments: z.array(attachmentSchema).default([]),
coverColor: z.string().nullable().default(null),
createdAt: z.string(), createdAt: z.string(),
updatedAt: z.string(), updatedAt: z.string(),
}); });
@@ -36,10 +37,12 @@ export const columnSchema = z.object({
title: z.string(), title: z.string(),
cardIds: z.array(z.string()).default([]), cardIds: z.array(z.string()).default([]),
width: z.enum(["narrow", "standard", "wide"]).default("standard"), width: z.enum(["narrow", "standard", "wide"]).default("standard"),
color: z.string().nullable().default(null),
}); });
export const boardSettingsSchema = z.object({ export const boardSettingsSchema = z.object({
attachmentMode: z.enum(["link", "copy"]).default("link"), attachmentMode: z.enum(["link", "copy"]).default("link"),
background: z.enum(["none", "dots", "grid", "gradient"]).default("none"),
}); });
export const boardSchema = z.object({ export const boardSchema = z.object({
@@ -51,7 +54,7 @@ export const boardSchema = z.object({
columns: z.array(columnSchema).default([]), columns: z.array(columnSchema).default([]),
cards: z.record(z.string(), cardSchema).default({}), cards: z.record(z.string(), cardSchema).default({}),
labels: z.array(labelSchema).default([]), labels: z.array(labelSchema).default([]),
settings: boardSettingsSchema.default({ attachmentMode: "link" }), settings: boardSettingsSchema.default({ attachmentMode: "link", background: "none" }),
}); });
export const appSettingsSchema = z.object({ export const appSettingsSchema = z.object({

View File

@@ -26,6 +26,7 @@ interface BoardActions {
deleteColumn: (columnId: string) => void; deleteColumn: (columnId: string) => void;
moveColumn: (fromIndex: number, toIndex: number) => void; moveColumn: (fromIndex: number, toIndex: number) => void;
setColumnWidth: (columnId: string, width: ColumnWidth) => void; setColumnWidth: (columnId: string, width: ColumnWidth) => void;
setColumnColor: (columnId: string, color: string | null) => void;
addCard: (columnId: string, title: string) => string; addCard: (columnId: string, title: string) => string;
updateCard: (cardId: string, updates: Partial<Card>) => void; updateCard: (cardId: string, updates: Partial<Card>) => void;
@@ -130,6 +131,7 @@ export const useBoardStore = create<BoardState & BoardActions>()(
title, title,
cardIds: [], cardIds: [],
width: "standard" as ColumnWidth, width: "standard" as ColumnWidth,
color: null,
}, },
], ],
})); }));
@@ -179,6 +181,16 @@ export const useBoardStore = create<BoardState & BoardActions>()(
})); }));
}, },
setColumnColor: (columnId, color) => {
mutate(get, set, (b) => ({
...b,
updatedAt: now(),
columns: b.columns.map((c) =>
c.id === columnId ? { ...c, color } : c
),
}));
},
// -- Card actions -- // -- Card actions --
addCard: (columnId, title) => { addCard: (columnId, title) => {
@@ -191,6 +203,7 @@ export const useBoardStore = create<BoardState & BoardActions>()(
checklist: [], checklist: [],
dueDate: null, dueDate: null,
attachments: [], attachments: [],
coverColor: null,
createdAt: now(), createdAt: now(),
updatedAt: now(), updatedAt: now(),
}; };

View File

@@ -15,6 +15,7 @@ export interface Column {
title: string; title: string;
cardIds: string[]; cardIds: string[];
width: ColumnWidth; width: ColumnWidth;
color: string | null;
} }
export type ColumnWidth = "narrow" | "standard" | "wide"; export type ColumnWidth = "narrow" | "standard" | "wide";
@@ -27,6 +28,7 @@ export interface Card {
checklist: ChecklistItem[]; checklist: ChecklistItem[];
dueDate: string | null; dueDate: string | null;
attachments: Attachment[]; attachments: Attachment[];
coverColor: string | null;
createdAt: string; createdAt: string;
updatedAt: string; updatedAt: string;
} }
@@ -52,6 +54,7 @@ export interface Attachment {
export interface BoardSettings { export interface BoardSettings {
attachmentMode: "link" | "copy"; attachmentMode: "link" | "copy";
background: "none" | "dots" | "grid" | "gradient";
} }
export interface BoardMeta { export interface BoardMeta {