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 f303d61677
commit 1556529307
5 changed files with 25 additions and 3 deletions

View File

@@ -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") {

View File

@@ -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;

View File

@@ -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({

View File

@@ -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<Card>) => void;
@@ -130,6 +131,7 @@ export const useBoardStore = create<BoardState & BoardActions>()(
title,
cardIds: [],
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 --
addCard: (columnId, title) => {
@@ -191,6 +203,7 @@ export const useBoardStore = create<BoardState & BoardActions>()(
checklist: [],
dueDate: null,
attachments: [],
coverColor: null,
createdAt: now(),
updatedAt: now(),
};

View File

@@ -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 {