@objectifthunes/whiteboard
DATES

WeekView

A week of columns with positioned event blocks. Overlaps share width per cluster, via layoutWeekEvents.


PREVIEW
Aug 17 – Aug 23, 2026
Mon17
Tue18
Wed19
Thu20
Fri21
Sat22
Sun23
Standup09:15
Onboarding — Acme10:00 – 11:30
Design review11:00 – 12:30
Billing sync11:30
Deploy window14:00 – 17:00
Interview09:00 – 10:00
Retro16:00 – 17:00
Runs past the window18:30

Click an event, or an empty slot to create one. Tuesday shows two overlapping events sharing the column; Friday evening shows one clipped to the visible window.

SOURCE
import { WeekView, type CalendarEvent } from '@objectifthunes/whiteboard'

const events: CalendarEvent[] = [
  { id: '1', title: 'Standup', start: at(9, 15), end: at(9, 30) },
  { id: '2', title: 'Deploy window', start: at(14), end: at(17), tone: 'danger' },
]

<WeekView
  events={events}
  date={anchor}                 // any day inside the week to show
  onDateChange={setAnchor}
  onEventClick={openEvent}
  onSlotClick={slot => createAt(slot)}
  startHour={8}
  endHour={19}
/>

// the layout maths on its own
layoutWeekEvents(events, days, 8, 19)
// → [{ event, dayIndex, topPct, heightPct, lane, laneCount }, …]
NOTES

Overlaps are resolved per cluster, not per day. Two events that clash at 11am share that column between them without squeezing an unrelated 4pm event into half a column — which is what a naive per-day lane count does.

Only the hours you ask for are rendered. A SaaS calendar showing 3am wastes two thirds of its height, so startHour and endHour default to 8 and 20. Events running past the window are clipped to it, and ones entirely outside are dropped.

layoutWeekEvents is exported and pure, so you can test the placement or reuse it for a single-day view without touching this component.

Events are generic over your own type: WeekView<MyBooking> keeps onEventClick typed as your record, so you get the whole booking back rather than just an id to look up.