Apps
Calendar
Month, week, day and agenda views with multi-day events, quick add, overlapping layout and an event popover.
Events may span days (endDate) and carry location, meetingUrl, description and attendees. eventsByDate repeats a multi-day event on each day and CalendarEventChip joins it across cells.
Every app follows the same pattern: typed models in types/models/, demo data in mocks/, state and actions in a composable under composables/apps/, page-only components in components/pages/<app>/ and UI strings in locales/<code>/apps.json. Read the apps overview once and every app looks familiar.
Files
File | Role |
|---|---|
pages/calendar.vue | The page: toolbar, views and the day panel. |
composables/apps/useCalendar.ts | Events, visible calendars, range, quick add and layout helpers. |
types/models/calendar.ts | Events, views and the provider. |
config/calendar.config.ts | Calendars, default view, visible hours and the first weekday. |
mocks/calendar.mock.ts | Demo events and createCalendarMockProvider(). |
components/pages/calendar/ | CalendarMonthView, CalendarTimeGrid, CalendarAgendaView, CalendarDayPanel, CalendarDaySlot, CalendarEventChip, CalendarEventPopover. |
Data and provider
export interface CalendarProvider {
list: () => Promise<CalendarEvent[]>
save: (event: CalendarEvent) => Promise<void>
remove: (id: string) => Promise<void>
}
Connect your backend
The page calls useCalendar() with the mock provider. Write a provider that calls your API with useApi() and pass it in the page. The composable loads it through useAsyncData and applies every change optimistically, so the interface does not wait for the server.
import type { CalendarEvent, CalendarProvider } from '~/types/models/calendar'
export function createCalendarApiProvider(): CalendarProvider {
const api = useApi()
return {
list: () => api<CalendarEvent[]>('/events'),
save: (event) => api(`/events/${event.id}`, { method: 'PUT', body: event }),
remove: (id) => api(`/events/${id}`, { method: 'DELETE' }),
}
}
<script setup lang="ts">
import { createCalendarApiProvider } from '~/providers/calendar'
const { ... } = useCalendar({ provider: createCalendarApiProvider() })
</script>
Keep ids in your data and labels in the locales: folders, labels and tags resolve their names through apps.<app>.* unless you give them a raw title. See Connect your API for the token, validation errors and the actions the demo only fakes.
Configuration
CALENDARS
Calendars with their color and an optional raw title; otherwise apps.calendar.ids.<id>.
const CALENDARS: CalendarConfig[]
CALENDAR_DEFAULT_VIEW
The first view. The user’s choice persists in the calendar-view cookie.
const CALENDAR_DEFAULT_VIEW: CalendarViewSettings
CALENDAR_HOURS
The first and last hour of the week and day grids.
const CALENDAR_HOURS: CalendarHours
CALENDAR_WEEK_STARTS_ON
The first day of the week (0 is Sunday).
const CALENDAR_WEEK_STARTS_ON: 1
Rules
Pure functions in utils/, unit tested. Use them in your backend too if you want the same answers.
placeEvents()
Lays overlapping events side by side in the time grid.
placeEvents(events: CalendarEvent[]): CalendarPlacedEvent[]
How it works
- The page is a
BaseSplitView(mode="none") whoseasideisCalendarDayPanel: the selected day, a current-time line and the quick add field, parsed byquickAdd. - Below
lg, picking a day opens the day view. The month grid shows dots instead of chips whenever a cell is narrower than 104px, so a laptop with the sidebar open gets dots too, and the calendar filter keeps only its dots while the toolbar is under 560px. - Clicking an event opens
CalendarEventPopover, aBaseMenuanchored withtarget, with join, edit, duplicate and delete. - The calendar filter is a
BaseMenuOptionswithcheckboxanddotColor. - Clicking an empty slot of the week or day grid creates an event at that half hour.