Blocks / Resource schedule

Resource schedule

Rows per person or resource over days: blocks as bars, clashes marked. A thin preset on the Timeline, not a second engine.

import { ResourceSchedule, scheduleConflicts, findConflicts } from "@forgeron/ui";
/01 → Leave
Conflict with another block. Leave
Conflict with another block. Training
Night shifts
// Leave and shifts per person; the two blocks of Ana that overlap are marked.
import { ResourceSchedule } from "@forgeron/ui";

const blocks = [
  {
    id: "1",
    name: "Leave",
    resource: "ana",
    start: "2026-11-16",
    end: "2026-11-20",
    color: "var(--success)",
  },
  {
    id: "2",
    name: "Training",
    resource: "ana",
    start: "2026-11-19",
    end: "2026-11-24",
    color: "var(--accent)",
  },
  {
    id: "3",
    name: "Night shifts",
    resource: "bob",
    start: "2026-11-18",
    end: "2026-11-22",
    color: "var(--warning)",
  },
];

export default function Leave() {
  return (
    <div style={{ width: "100%", height: 260, display: "flex", border: "1px solid var(--line)" }}>
      <ResourceSchedule
        resources={[
          { id: "ana", name: "Ana" },
          { id: "bob", name: "Bob" },
          { id: "cy", name: "Cy" },
        ]}
        blocks={blocks}
        today="2026-11-18"
        defaultZoom="weeks"
        labelWidth={160}
      />
    </div>
  );
}
API → Props
PropTypeDefaultDescription
resources{ id, name, glyph? }[]—One section each, initials in front by default.
blocksT[]—Leave, shifts, bookings: a row under their resource.
getResource / getStart / getEnd(record) => stringresource, start, endDays are YYYY-MM-DD, last day included.
getId / getLabel / getColor(record) => stringid, title or name, colorAs the Timeline.
isShared(record) => boolean—A block that may overlap others (a holiday) and is never a clash.
onConflicts(Map<id, id[]>) => void—The clashes, whenever they change.
onChange(id, { start, end }) => void—Drag or Alt and arrows, as the Timeline; the resource does not change.
…Timeline propszoom, today, selected, onOpen, collapsed, toolbar, labelWidth, renderBar…—All pass through. Timeline covers it: one bar per row, so several blocks of a resource are rows under its section. Hours of a day belong to the TimeGrid with resources.