Blocks / Projects table

Projects table

Projects in rows: health, lead, target date and progress at a glance. Point at a bar for its detail.

import { ProjectsTable } from "@forgeron/ui";
/01 → Default
Name
Progress
Lyon depot
Carrier rates
Year-end closing
import { ProjectsTable } from "@forgeron/ui";

export default function Default() {
  return (
    <div style={{ width: 380 }}>
      <ProjectsTable
        columns={["progress"]}
        projects={[
          {
            id: "lyon",
            name: "Lyon depot",
            color: "var(--accent)",
            status: "started",
            issues: 12,
            done: 5,
            started: 4,
          },
          {
            id: "carriers",
            name: "Carrier rates",
            color: "var(--warning)",
            status: "started",
            issues: 6,
            done: 4,
            started: 1,
          },
          {
            id: "q4",
            name: "Year-end closing",
            color: "var(--success)",
            status: "planned",
            issues: 8,
            done: 0,
          },
        ]}
      />
    </div>
  );
}
/02 → Sortable
Click a row or a header
import { ProjectsTable } from "@forgeron/ui";
import { Folder01Icon, Invoice01Icon, PackageIcon } from "@forgeron/icons";
import { useState } from "react";

const people = [
  { id: "cr", name: "Camille Roy" },
  { id: "hb", name: "Hugo Bernard" },
  { id: "np", name: "Nadia Petit" },
  { id: "tg", name: "Tom Garnier" },
];

export default function Sortable() {
  const [opened, setOpened] = useState("Click a row or a header");
  return (
    <div style={{ width: "100%", display: "grid", gap: 12 }}>
      <ProjectsTable
        people={people}
        today="2026-11-17"
        sortable
        columns={["lead", "target", "issues", "progress", "status"]}
        defaultSort={{ key: "target", direction: "asc" }}
        onOpen={(id) => setOpened(`Open ${id}`)}
        projects={[
          {
            id: "lyon",
            name: "Lyon depot",
            summary: "Everything before the first delivery",
            icon: PackageIcon,
            status: "started",
            health: "risk",
            lead: "tg",
            target: "2026-12-15",
            issues: 12,
            done: 5,
            started: 4,
          },
          {
            id: "q4",
            name: "Year-end closing",
            summary: "Invoices, stock count, accruals",
            icon: Invoice01Icon,
            status: "planned",
            health: "none",
            lead: "np",
            target: "2027-01-31",
            issues: 8,
            done: 0,
          },
          {
            id: "carriers",
            name: "Carrier rates",
            summary: "The 2027 grid in every quote",
            icon: Folder01Icon,
            status: "started",
            health: "track",
            lead: "cr",
            target: "2026-11-28",
            issues: 6,
            done: 4,
            started: 1,
          },
          {
            id: "safety",
            name: "Site safety",
            icon: Folder01Icon,
            status: "paused",
            health: "off",
            lead: null,
            target: "2026-12-01",
            issues: 5,
            done: 1,
          },
          {
            id: "badges",
            name: "Dock badges",
            icon: Folder01Icon,
            status: "completed",
            health: "track",
            lead: "hb",
            target: "2026-10-30",
            issues: 4,
            done: 4,
          },
        ]}
      />
      <span style={{ font: "400 11px/1 var(--font-mono)", color: "var(--ink-dim)" }}>{opened}</span>
    </div>
  );
}
/03 → Health
Name
Health
Lead
Progress
Lyon depotAt riskTom
Carrier ratesOn trackCamille
Site safetyOff trackNo lead
Year-end closingNo updatesNadia
import { ProjectsTable } from "@forgeron/ui";

const people = [
  { id: "cr", name: "Camille Roy" },
  { id: "np", name: "Nadia Petit" },
  { id: "tg", name: "Tom Garnier" },
];

export default function Health() {
  return (
    <div style={{ width: "100%" }}>
      <ProjectsTable
        people={people}
        columns={["health", "lead", "progress"]}
        projects={[
          {
            id: "lyon",
            name: "Lyon depot",
            color: "var(--accent)",
            status: "started",
            health: "risk",
            lead: "tg",
            issues: 12,
            done: 5,
            started: 4,
          },
          {
            id: "carriers",
            name: "Carrier rates",
            color: "var(--warning)",
            status: "started",
            health: "track",
            lead: "cr",
            issues: 6,
            done: 4,
            started: 1,
          },
          {
            id: "safety",
            name: "Site safety",
            color: "var(--danger)",
            status: "paused",
            health: "off",
            lead: null,
            issues: 5,
            done: 1,
          },
          {
            id: "q4",
            name: "Year-end closing",
            color: "var(--success)",
            status: "planned",
            health: "none",
            lead: "np",
            issues: 8,
            done: 0,
          },
        ]}
      />
    </div>
  );
}
/04 → Editable
Name
Health
Lead
Target date
Status
Actions
Click a field to change it; right-click a row for its menu
import { Folder01Icon } from "@forgeron/icons";
import { ProjectsTable, type ProjectItem } from "@forgeron/ui";
import { useState } from "react";

const people = [
  { id: "cr", name: "Camille Roy" },
  { id: "hb", name: "Hugo Bernard" },
  { id: "lm", name: "Léa Martin" },
];
const start: ProjectItem[] = [
  {
    id: "lyon",
    name: "Lyon depot",
    icon: Folder01Icon,
    status: "started",
    health: "risk",
    lead: "hb",
    target: "2026-12-15",
    issues: 12,
    done: 5,
    started: 4,
  },
  {
    id: "carriers",
    name: "Carrier rates",
    color: "var(--warning)",
    status: "started",
    health: "track",
    lead: "cr",
    target: "2026-11-28",
    issues: 6,
    done: 4,
    started: 1,
  },
  {
    id: "q4",
    name: "Year-end closing",
    color: "var(--success)",
    status: "planned",
    lead: null,
    target: "2027-01-31",
    issues: 8,
    done: 0,
  },
];

export default function Editable() {
  const [projects, setProjects] = useState(start);
  const [last, setLast] = useState("Click a field to change it; right-click a row for its menu");
  return (
    <div style={{ width: "100%", display: "grid", gap: 12 }}>
      <ProjectsTable
        projects={projects}
        people={people}
        today="2026-11-17"
        columns={["health", "lead", "target", "status"]}
        editors={{ lead: { me: "cr" } }}
        onProjectChange={(id, patch) => {
          setProjects((all) => all.map((p) => (p.id === id ? { ...p, ...patch } : p)));
          setLast(`${id}: ${Object.keys(patch).join(", ")} changed`);
        }}
        onOpen={(id) => setLast(`Open ${id}`)}
        rowMenu={(p) => [
          { id: "open", label: `Open ${p.name}` },
          { separator: true },
          { id: "archive", label: "Archive", danger: true },
        ]}
        onRowAction={(id, action) => setLast(`${action} on ${id}`)}
      />
      <span style={{ font: "400 11px/1 var(--font-mono)", color: "var(--ink-dim)" }}>{last}</span>
    </div>
  );
}
API → Props
PropTypeDefaultDescription
projectsProjectItem[]—{ id, name, summary?, icon?, color?, status, health?, lead?, target?, issues, done, started? }.
people{ id, name, src? }[]—The people issues are assigned to.
todaystring—YYYY-MM-DD: target dates of another year write the year.
columns("health" | "lead" | "target" | "issues" | "progress" | "status")[]allThe columns after the name. Health shows only when a project has one.
sortablebooleanfalseMakes the headers buttons that sort the rows.
sort / defaultSort{ key, direction: "asc" | "desc" } | null—The order of the rows. Controlled or not.
onSortChange(sort) => void—When a header is clicked.
onOpen(id: string) => void—A click on a row.
href(project) => string—Makes each row a link to its page.
onProjectChange(id: string, patch: Partial<ProjectItem>) => void—Turns editing on: status, health, lead and target open their pickers. Absent: read-only.
editors{ status?, health?, lead?, target? }—Per field: false for read-only; options (statuses, people, me, noneLabel, presets, clearable); render(project, change) for your own.
rowMenu(project) => ActionMenuEntry[]—The actions of a project: right click, Shift+F10, or a ⋯ column.
onRowAction(id: string, actionId: string) => void—The action chosen in rowMenu.
classNamestring—Extra classes.