Components

Calendar

Time-based calendar grid for weekly/daily schedule display

Overview

Calendar is a time-based calendar view compound component. It renders a time grid similar to Google Calendar's weekly/daily view.

  • Compound — Composed of three components: TimeGrid, TimeCell, DayColumnHeaders
  • Auto-scroll — Automatically scrolls to the current time
  • Current time indicator — Displays a red line at the current time
  • Utilities — Provides time calculation utility functions and constants

Basic Usage

import { Calendar } from '@illog/ui'
 
<Calendar.TimeGrid
  columns={7}
  header={
    <Calendar.DayColumnHeaders
      days={[
        { label: 'Mon', dateNum: '17', isToday: false },
        { label: 'Tue', dateNum: '18', isToday: true },
        // ...
      ]}
    />
  }
>
  <Calendar.TimeCell
    id="event-1"
    title="Meeting"
    subtitle="Team standup"
    caption="10:00 - 11:00"
    color={{
      bg: 'backgroundBrandSecondary',
      border: 'var(--background-brand-default)',
      text: 'textBrandDefault',
    }}
    top={600}
    height={60}
    left="64px"
    width="calc(100% / 7)"
    onClick={() => openEvent('event-1')}
  />
</Calendar.TimeGrid>

Sub-components

Calendar.TimeGrid

PropTypeDefaultDescription
columnsnumber1Number of day columns
hourHeightnumber60Height per hour (px)
gutterWidthnumber64Time label area width (px)
scrollHeightstring'calc(100vh - 160px)'Scroll container height
showCurrentTimebooleantrueCurrent time indicator line
currentTimeColumnnumber-1Column for current time line (-1 = all)
headerReactNodeHeader area (DayColumnHeaders)

Calendar.TimeCell

PropTypeDefaultDescription
idstringrequiredEvent ID
titlestringrequiredEvent title
subtitlestringSubtitle (shown when height > 34px)
captionstringCaption (shown when height > 54px)
colorTimeCellColorrequiredColor settings (bg, border, text)
topnumberrequiredTop offset (px)
heightnumberrequiredHeight (px)
leftstringrequiredLeft offset (CSS)
widthstringrequiredWidth (CSS)
onClick() => voidClick handler

Calendar.DayColumnHeaders

PropTypeDefaultDescription
daysDayColumnHeader[]requiredDay data array
gutterWidthnumber64Time label area width
heightnumber40Header height

DayColumnHeader

PropTypeDescription
labelstringDay display (e.g., 'Mon')
dateNumstringDate display (e.g., '21')
isTodaybooleanToday highlight

Utility Functions

import {
  useCurrentTime,
  formatHour,
  formatTimeLabel,
  getMinutesFromMidnight,
  DEFAULT_HOUR_HEIGHT,   // 60
  DEFAULT_GUTTER_WIDTH,  // 64
  HOURS,                 // [0, 1, 2, ..., 23]
} from '@illog/ui'
 
// Current time hook (refreshes every 30 seconds)
const now = useCurrentTime()
 
// Minutes → px conversion example
const topPx = getMinutesFromMidnight(eventStart) * (hourHeight / 60)
const heightPx = (durationMinutes) * (hourHeight / 60)

Guidelines

  • Calculate TimeCell's top and height using getMinutesFromMidnight and hourHeight
  • For overlapping events, adjust left and width to place them side by side
  • Use showCurrentTime={false} to create a static calendar