ProSchedulerSign in

Scheduler · Look & feel

Cell hover summary

onCellHoverIn and onCellHoverOut report the half-hour under the pointer; the line above shows who's busy and how many are free.

Live demo

Hover across a busy morning

Fullscreen
import { useMemo, useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { studioResources, studioSessions } from "./data/studio"
import { useEvents, when } from "./kit"

export function CellHoverDemo() {
  const { events, handlers } = useEvents(studioSessions)
  const [cell, setCell] = useState<Date | null>(null)

  const summary = useMemo(() => {
    if (!cell) return "Hover the grid to see who's busy in that half-hour."
    const t = cell.getTime()
    const busy = events.filter((e) => new Date(e.start).getTime() <= t && new Date(e.end!).getTime() > t)
    const free = studioResources.filter((r) => !busy.some((e) => e.resource === r.id))
    return `${when(cell)} — ${busy.length ? busy.map((e) => e.title).join(", ") : "nothing booked"} · ${free.length} of ${studioResources.length} people free`
  }, [cell, events])

  return (
    <div className="docs-demo__stack">
      <p className="demo-status">{summary}</p>
      <ProScheduler
        data={events}
        resources={studioResources}
        view={{ scheduler: { type: "week", startTime: "07:00", endTime: "20:00", timeCellStep: 30 } }}
        onCellHoverIn={({ date }) => setCell(date)}
        onCellHoverOut={() => setCell(null)}
        height={560}
        {...handlers}
      />
    </div>
  )
}

About this demo

onCellHoverIn and onCellHoverOut report the half-hour under the pointer; the line above shows who's busy and how many are free.

Things to try

  • Hover across a busy morning

The props behind it are explained in Rules and backgrounds.

Use ProScheduler in your project