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

Mon

13

Tue

14

Wed

15

Thu

16

Fri

17

12 AM

1 AM

2 AM

3 AM

4 AM

5 AM

6 AM

7 AM

8 AM

9 AM

10 AM

11 AM

12 PM

1 PM

2 PM

3 PM

4 PM

5 PM

6 PM

7 PM

8 PM

9 PM

10 PM

11 PM

Sub-components

Calendar.TimeGrid

PropTypeDefaultRequiredDescription
columnsnumber'1'NoNumber of day columns (TimeGrid)
hourHeightnumber'60'NoHeight of one hour in px (TimeGrid)
gutterWidthnumber'64'NoWidth of the hour labels in px (TimeGrid)
scrollHeightstring'calc(100vh - 160px)'NoHeight of the scroll area (TimeGrid)
showCurrentTimebooleantrueNoDraws the current time line (TimeGrid)
currentTimeColumnnumber'-1'NoColumn of today for the current time line, -1 for none (TimeGrid)
headerReactNode-NoUsually Calendar.DayColumnHeaders (TimeGrid)
childrenReactNode-NoCalendar.TimeCell items (TimeGrid)

Calendar.TimeCell

PropTypeDefaultRequiredDescription
idstring-YesEvent id
titlestring-YesFirst line
subtitlestring-NoSecond line
captionstring-NoSmall text such as the time range
color{ bg: BackgroundColorToken; border: string; text: TextColorToken }-YesBackground token, left bar CSS color and text token
topnumber-YesOffset from midnight in px
heightnumber-YesHeight in px
leftstring-YesCSS left of the cell
widthstring-YesCSS width of the cell
onClick() => void-NoRenders the cell as a button and is called when it is pressed
titleFontSizenumber-NoTitle font size in px
subtitleFontSizenumber-NoSubtitle font size in px
styleCSSProperties-NoInline style
childrenReactNode-NoExtra content

Calendar.DayColumnHeaders

PropTypeDefaultRequiredDescription
days{ label: string; dateNum: string; isToday?: boolean }[]-YesOne header per column
gutterWidthnumber'64'NoWidth of the hour labels in px
heightnumber'40'NoHeader height in px

DayColumnHeader

export type DayColumnHeader = {
  label: string
  dateNum: string
  isToday?: boolean
}

Utility Functions

import {
  DEFAULT_HOUR_HEIGHT,
  formatHour,
  formatTimeLabel,
  getMinutesFromMidnight,
  useCurrentTime
} from '@illog/ui'
 
// Where an event sits on the grid: minutes from midnight → px
export function useEventPosition(start: Date, durationMinutes: number) {
  const now = useCurrentTime() // refreshes every 30 seconds
  const pxPerMinute = DEFAULT_HOUR_HEIGHT / 60
 
  return {
    top: getMinutesFromMidnight(start) * pxPerMinute,
    height: durationMinutes * pxPerMinute,
    hourLabel: formatHour(start.getHours()),
    nowLabel: formatTimeLabel(now)
  }
}

Specification

base

상태요소속성값
enabledgridbackgroundColor$color.background.default.default
enabledgridborderRadius$size.radius.200
enabledgridborderWidth$size.stroke.border
enabledgridborderColor$color.border.default.default
enabledlineborderColor$color.border.default.default
enabledlineborderWidth$size.stroke.border
enabledhourLabeltypography$text.caption
enabledhourLabelcolor$color.text.default.secondary
enableddayLabeltypography$text.caption
enableddayLabelcolor$color.text.default.secondary
enabledtodayDatebackgroundColor$color.background.brand.default
enabledtodayDatecolor$color.text.brand.onBrand
enabledtodayDateborderRadius$size.radius.full
enabledtodayDatetypography$text.captionStrong
enabledcellborderRadius$size.radius.200
enabledcellpaddingY$size.space.100
enabledcellpaddingX$size.space.200
enabledcellborderLeftWidth4px토큰 아님 — color bar; no sizing token
enablednowLabelbackgroundColor$color.background.brand.default
enablednowLabelcolor$color.text.brand.onBrand
enablednowLabeltypography$text.caption
hovercellfilterbrightness(0.95)토큰 아님 — each cell has its own color, so hover darkens instead of changing color
focusVisiblecelloutlineWidth$size.stroke.focus
focusVisiblecelloutlineStylesolid토큰 아님 — no line style token
focusVisiblecelloutlineColor$color.border.focus.default
focusVisiblecelloutlineOffset-2px토큰 아님 — inside ring; no ring offset token

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