Problem
Implement a Google Calendar day view.
Requirements
- Show meetings color-coded by their
color. - The calendar should start at the earliest event time (don't render empty hours before the first meeting).
- Lay out overlapping events side by side (split width among concurrent events).
Event format:
export const events = [
{ title: "Scrum meeting", start: "09:30", end: "11:00", color: "rgba(0,123,255,0.8)" },
{ title: "Chill", start: "10:30", end: "12:00", color: "rgba(255,193,7,0.8)" },
{ title: "Client Call", start: "15:00", end: "16:00", color: "rgba(220,53,69,0.8)" },
{ title: "Project Review",start: "15:30", end: "17:00", color: "rgba(108,117,125,0.8)" },
{ title: "Conflict", start: "15:50", end: "17:45", color: "rgba(255,193,7,0.8)" },
{ title: "Focus time", start: "18:00", end: "21:00", color: "rgba(255,99,132,0.8)" },
];
Hints / Approach
- Convert
HH:MMto minutes; position each event withtop = (start - dayStart) * pxPerMinute,height = duration * pxPerMinute. - Overlap layout: sort by start, group events that overlap into "columns" (interval-graph coloring). Each event's width =
containerWidth / columnsInGroup,left = columnIndex * width. - A greedy column assignment (place each event in the first column whose last event ended) gives the classic side-by-side layout.