ProSchedulerSign in

Timeline · Use cases

Meal planner

Meals as rows and days as columns. A click on an empty day adds a dish for the whole day.

Live demo

Click an empty cell to add a dish · Drag lunch to another day

Fullscreen
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { mealPlan, mealSlots } from "./data/operations"
import { useEvents } from "./kit"

export function MealPlannerDemo() {
  const { events, handlers } = useEvents(mealPlan)

  return (
    <ProScheduler
      data={events}
      resources={mealSlots}
      view={{ timeline: { type: "week", resolutionHorizontal: "day" } }}
      styleConfig={{ laneHeight: 40, minRowHeight: 64, resourceColWidth: 140 }}
      clickToCreate
      extendDefaultEvent={({ start, resource }) => ({
        // A dish lasts the whole day it's planned for.
        start: new Date(start.getFullYear(), start.getMonth(), start.getDate()),
        end: new Date(start.getFullYear(), start.getMonth(), start.getDate() + 1),
        allDay: true,
        color: mealSlots.find((m) => m.id === resource)?.color,
      })}
      renderResource={(slot) => (
        <span className="flex items-center gap-2 text-sm font-semibold">
          <span className="h-6 w-1 rounded-full" style={{ background: String(slot.color) }} />
          {slot.name}
        </span>
      )}
      height={400}
      {...handlers}
    />
  )
}

About this demo

Meals as rows and days as columns. A click on an empty day adds a dish for the whole day.

Things to try

  • Click an empty cell to add a dish
  • Drag lunch to another day

The props behind it are explained in Drag, resize & create.

Use ProScheduler in your project