Calendar

On this page

phApp.calendar() draws a calendar with month, week, day and list views. Use it for timetables, bookings, rosters and events. It's FullCalendar 6, styled to match Performance Hub and set up with the viewer's language and first day of the week.

Add ph-app-calendar.js after ph-app.js on pages with a calendar:

<script defer src="https://app.performancehub.co/assets/app-kit/v1/ph-app-calendar.js"></script>

Week view

A week timetable with classes and an all-day eventA week timetable with classes and an all-day event

Figure 1: A week timetable, with classes coloured by type and an all-day warning

<article class="ph-card">
  <header class="ph-card-header">
    <div>
      <h2 class="ph-card-title">Class timetable</h2>
      <p class="ph-card-description">Ormsby Point. Drag a class to move it.</p>
    </div>
  </header>
  <div id="timetable"></div>
</article>
const calendar = phApp.calendar('#timetable', {
  initialView: 'timeGridWeek',
  editable: true,
  events: [
    { title: 'Strength', start: '2026-12-07T09:00', end: '2026-12-07T10:00', tone: 1 },
    { title: 'Yoga', start: '2026-12-07T12:00', end: '2026-12-07T13:00', tone: 2 },
    { title: 'Pool closed', start: '2026-12-10', end: '2026-12-12', allDay: true, tone: 'warning' },
  ],
  eventDrop: async (info) => {
    try {
      await phApp.fetchJSON(`api/classes/${info.event.id}`, {
        method: 'PATCH',
        body: { start: info.event.startStr, end: info.event.endStr },
      });
    } catch {
      info.revert();
      phApp.toast("Couldn't move the class", { tone: 'error' });
    }
  },
});

Month view

A month of school eventsA month of school events

Figure 2: The month view, with events in status tones

The month view is the default. Busy days show "+2 more" rather than growing.

Event colours

Give each event a tone:

toneColourUse for
1 to 8Chart colours 1 to 8Categories, such as class types
'success'GreenConfirmed, open
'warning'OrangeChanged, closures
'danger'RedCancelled, problems
'neutral'GreyHolidays, background events
'info' or noneBlueEverything else

What the kit sets up

OptionKit default
initialView'dayGridMonth'
ToolbarPrevious, next and Today on the left; the title in the middle; Month, Week, Day and List on the right
locale and firstDayThe viewer's language, and its first day of the week
height680px for week and day views; month and list views fit their content
dayMaxEventstrue ("+2 more" on busy days)
nowIndicatortrue
scrollTime8:00 am
Time format"9:00 am" style
noEventsText"Nothing scheduled"

Pass any other FullCalendar option in the same object, such as slotMinTime, selectable or eventClick. Your options win over the kit's. phApp.calendar() returns the FullCalendar Calendar, so use its methods (addEvent, refetchEvents, gotoDate) directly.

The month, week, day and list views are included. Other FullCalendar plugins, such as resource views, aren't.

React

import { EventCalendar } from 'ph-app-kit-react/calendar';

<EventCalendar initialView="timeGridWeek" events={classes} editable eventDrop={onMove} />

EventCalendar takes the same options as props. Install the FullCalendar packages listed in the Reference.

Guidelines

  • Load events for the range on screen with the events function form, not the whole year.
  • After a drag, save the change and call info.revert() if the save fails.
  • Use tones 1 to 8 for categories and the status tones for states; don't mix both meanings in one calendar.
  • Put the calendar in a card with a title that says whose calendar it is.