WeekView
A week of columns with positioned event blocks. Overlaps share width per cluster, via layoutWeekEvents.
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.
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 }, …]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.