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
Sub-components
Calendar.TimeGrid
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
columns | number | '1' | No | Number of day columns (TimeGrid) |
hourHeight | number | '60' | No | Height of one hour in px (TimeGrid) |
gutterWidth | number | '64' | No | Width of the hour labels in px (TimeGrid) |
scrollHeight | string | 'calc(100vh - 160px)' | No | Height of the scroll area (TimeGrid) |
showCurrentTime | boolean | true | No | Draws the current time line (TimeGrid) |
currentTimeColumn | number | '-1' | No | Column of today for the current time line, -1 for none (TimeGrid) |
header | ReactNode | - | No | Usually Calendar.DayColumnHeaders (TimeGrid) |
children | ReactNode | - | No | Calendar.TimeCell items (TimeGrid) |
Calendar.TimeCell
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
id | string | - | Yes | Event id |
title | string | - | Yes | First line |
subtitle | string | - | No | Second line |
caption | string | - | No | Small text such as the time range |
color | { bg: BackgroundColorToken; border: string; text: TextColorToken } | - | Yes | Background token, left bar CSS color and text token |
top | number | - | Yes | Offset from midnight in px |
height | number | - | Yes | Height in px |
left | string | - | Yes | CSS left of the cell |
width | string | - | Yes | CSS width of the cell |
onClick | () => void | - | No | Renders the cell as a button and is called when it is pressed |
titleFontSize | number | - | No | Title font size in px |
subtitleFontSize | number | - | No | Subtitle font size in px |
style | CSSProperties | - | No | Inline style |
children | ReactNode | - | No | Extra content |
Calendar.DayColumnHeaders
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
days | { label: string; dateNum: string; isToday?: boolean }[] | - | Yes | One header per column |
gutterWidth | number | '64' | No | Width of the hour labels in px |
height | number | '40' | No | Header 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
| 상태 | 요소 | 속성 | 값 |
|---|---|---|---|
| enabled | grid | backgroundColor | $color.background.default.default |
| enabled | grid | borderRadius | $size.radius.200 |
| enabled | grid | borderWidth | $size.stroke.border |
| enabled | grid | borderColor | $color.border.default.default |
| enabled | line | borderColor | $color.border.default.default |
| enabled | line | borderWidth | $size.stroke.border |
| enabled | hourLabel | typography | $text.caption |
| enabled | hourLabel | color | $color.text.default.secondary |
| enabled | dayLabel | typography | $text.caption |
| enabled | dayLabel | color | $color.text.default.secondary |
| enabled | todayDate | backgroundColor | $color.background.brand.default |
| enabled | todayDate | color | $color.text.brand.onBrand |
| enabled | todayDate | borderRadius | $size.radius.full |
| enabled | todayDate | typography | $text.captionStrong |
| enabled | cell | borderRadius | $size.radius.200 |
| enabled | cell | paddingY | $size.space.100 |
| enabled | cell | paddingX | $size.space.200 |
| enabled | cell | borderLeftWidth | 4px토큰 아님 — color bar; no sizing token |
| enabled | nowLabel | backgroundColor | $color.background.brand.default |
| enabled | nowLabel | color | $color.text.brand.onBrand |
| enabled | nowLabel | typography | $text.caption |
| hover | cell | filter | brightness(0.95)토큰 아님 — each cell has its own color, so hover darkens instead of changing color |
| focusVisible | cell | outlineWidth | $size.stroke.focus |
| focusVisible | cell | outlineStyle | solid토큰 아님 — no line style token |
| focusVisible | cell | outlineColor | $color.border.focus.default |
| focusVisible | cell | outlineOffset | -2px토큰 아님 — inside ring; no ring offset token |
Guidelines
- Calculate TimeCell's
topandheightusinggetMinutesFromMidnightandhourHeight - For overlapping events, adjust
leftandwidthto place them side by side - Use
showCurrentTime={false}to create a static calendar