@gobrand/calendar-core
v0.1.5
Published
Lightweight utility library for building calendars using the Temporal API
Maintainers
Readme
Calendar Core
Framework-agnostic, headless calendar state and projections built directly on the Temporal API.
pnpm add @gobrand/calendar-core @js-temporal/polyfillQuick start
import { Temporal } from '@js-temporal/polyfill'
import { buildMonthView, createCalendar } from '@gobrand/calendar-core'
type Event = {
id: string
title: string
date: Temporal.PlainDate
}
const events: Event[] = [
{ id: 'launch', title: 'Launch', date: Temporal.Now.plainDateISO() },
]
const calendar = createCalendar({
views: { month: true },
})
const month = buildMonthView({
calendar,
items: events,
getDate: event => event.date,
})
for (const day of month.weeks.flat()) {
console.log(day.date.toString(), day.items.map(event => event.title))
}The controller owns the current date, active view, timezone-aware visible range, and navigation.
buildMonthView, buildWeekView, and buildDayView add your events to the dates you render.
MIT © Ruben Costa / Go Brand
