ProSchedulerSign in

Scheduler · Drag & drop

External presets

Reusable templates: each drop makes a new event, and the preset stays in the list.

Live demo

Drop a Workshop into Ben's column · Drop another next to it

Fullscreen
import { ExternalDraggable, ProScheduler } from "@andreisaac/pro-scheduler"
import { presets } from "./data/planning"
import { studioResources, studioSessions } from "./data/studio"
import { useEvents } from "./kit"

/** A card in a side list. */
function Card({ color, title, meta }: { color?: string; title: string; meta?: string }) {
  return (
    <div className="flex items-center gap-2 rounded-md border border-border bg-card px-2.5 py-2 text-sm shadow-xs">
      <span className="size-2.5 shrink-0 rounded-full" style={{ backgroundColor: color ?? "var(--primary)" }} />
      <span className="min-w-0 flex-1 truncate font-medium">{title}</span>
      {meta && <span className="shrink-0 text-xs text-muted-foreground">{meta}</span>}
    </div>
  )
}

const minutes = (n = 60) => (n >= 60 ? `${n / 60} h` : `${n} min`)

export function ExternalPresetsDemo() {
  const { events, handlers } = useEvents(() => studioSessions())
  return (
    <div className="flex flex-col gap-3">
      <div className="flex flex-wrap gap-2" role="list" aria-label="Presets">
        {presets.map((preset) => (
          <ExternalDraggable key={preset.title} event={preset} role="listitem">
            <Card color={preset.color} title={preset.title} meta={minutes(preset.duration)} />
          </ExternalDraggable>
        ))}
      </div>
      <ProScheduler
        data={events}
        resources={studioResources.slice(0, 4)}
        view={{ scheduler: { type: "day", resources: true, startTime: "08:00", endTime: "19:00" } }}
        externalDrop
        height={560}
        {...handlers}
      />
    </div>
  )
}

About this demo

Reusable templates: each drop makes a new event, and the preset stays in the list.

Things to try

  • Drop a Workshop into Ben's column
  • Drop another next to it

The props behind it are explained in Selection, drag and drop, links.

Use ProScheduler in your project