add app shell with top bar, view routing, and board factory
This commit is contained in:
44
src/lib/board-factory.ts
Normal file
44
src/lib/board-factory.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { ulid } from "ulid";
|
||||
import type { Board, ColumnWidth } from "@/types/board";
|
||||
|
||||
type Template = "blank" | "kanban" | "sprint";
|
||||
|
||||
export function createBoard(
|
||||
title: string,
|
||||
color: string,
|
||||
template: Template = "blank"
|
||||
): Board {
|
||||
const ts = new Date().toISOString();
|
||||
const board: Board = {
|
||||
id: ulid(),
|
||||
title,
|
||||
color,
|
||||
createdAt: ts,
|
||||
updatedAt: ts,
|
||||
columns: [],
|
||||
cards: {},
|
||||
labels: [],
|
||||
settings: { attachmentMode: "link" },
|
||||
};
|
||||
|
||||
const col = (t: string, w: ColumnWidth = "standard") => ({
|
||||
id: ulid(),
|
||||
title: t,
|
||||
cardIds: [] as string[],
|
||||
width: w,
|
||||
});
|
||||
|
||||
if (template === "kanban") {
|
||||
board.columns = [col("To Do"), col("In Progress"), col("Done")];
|
||||
} else if (template === "sprint") {
|
||||
board.columns = [
|
||||
col("Backlog"),
|
||||
col("To Do"),
|
||||
col("In Progress", "wide"),
|
||||
col("Review"),
|
||||
col("Done", "narrow"),
|
||||
];
|
||||
}
|
||||
|
||||
return board;
|
||||
}
|
||||
Reference in New Issue
Block a user