"use client"; import { FolderKanban, ListChecks, Users } from "lucide-react"; import { BaseBoxShapeUtil, HTMLContainer, T, type TLBaseShape, toDomPrecision, } from "tldraw"; import { cn } from "@/lib/utils"; export type ProjectCardShape = TLBaseShape< "project-card", { w: number; h: number; objectId: string; title: string; taskCount: number; memberCount: number; progress: number; } >; declare module "@tldraw/tlschema" { interface TLGlobalShapePropsMap { "project-card": ProjectCardShape["props"]; } } function clampProgress(n: number): number { if (Number.isNaN(n)) return 0; return Math.min(100, Math.max(0, n)); } function ProjectCardBody({ shape }: { shape: ProjectCardShape }) { const { title, taskCount, memberCount, progress } = shape.props; const pct = clampProgress(progress); return ( {title || "Untitled project"} {taskCount} tasks {memberCount} members Progress {pct}% Project ); } export class ProjectCardShapeUtil extends BaseBoxShapeUtil { static override type = "project-card"; static override props = { w: T.number, h: T.number, objectId: T.string, title: T.string, taskCount: T.number, memberCount: T.number, progress: T.number, }; override getDefaultProps(): ProjectCardShape["props"] { return { w: 260, h: 180, objectId: "", title: "Project", taskCount: 0, memberCount: 0, progress: 0, }; } override getAriaDescriptor(shape: ProjectCardShape) { return shape.props.title; } override component(shape: ProjectCardShape) { return ; } override indicator(shape: ProjectCardShape) { return ( ); } override useLegacyIndicator() { return false; } override getIndicatorPath(shape: ProjectCardShape) { const p = new Path2D(); p.roundRect(0, 0, shape.props.w, shape.props.h, 10); return p; } }