Timeline · Resources
Drag to reorder resources
resourceReorder adds a grip to each row: drag it to move the resource among its siblings. onResourceOrderChange hands back the whole tree in its new order.
Live demo
Move Gus to the top of Post-production · Reorder the departments
Fullscreenimport { useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { studioSessions, studioTeams } from "./data/studio"
import { useEvents } from "./kit"
export function ResourceReorderDemo() {
const { events, handlers } = useEvents(() => studioSessions())
const [resources, setResources] = useState(studioTeams)
return (
<ProScheduler
data={events}
resources={resources}
resourceReorder
onResourceOrderChange={({ resources: next }) => setResources(next)}
view={{ timeline: { type: "week", resolutionHorizontal: "hour", startTime: "08:00", endTime: "19:00" } }}
styleConfig={{ unitWidthPx: 24, fitToWidth: false, resourceColWidth: 200 }}
height={560}
{...handlers}
/>
)
}// data/studio.ts — sample data, relative to the current week or month.
import type { SchedulerResource } from "@andreisaac/pro-scheduler"
export type StudioResource = SchedulerResource & {
id: string
name: string
role: string
color: string
}
export const studioResources: StudioResource[] = [
{ id: "ada", name: "Ada Moreno", role: "Director", color: "#2563eb" },
{ id: "ben", name: "Ben Okafor", role: "Producer", color: "#059669" },
{ id: "chloe", name: "Chloé Martin", role: "Editor", color: "#d97706" },
{ id: "dev", name: "Dev Patel", role: "Colourist", color: "#7c3aed" },
{ id: "elin", name: "Elin Berg", role: "Sound", color: "#db2777" },
{ id: "farah", name: "Farah Haddad", role: "Camera", color: "#0891b2" },
{ id: "gus", name: "Gus Almeida", role: "Motion", color: "#65a30d" },
{ id: "hana", name: "Hana Sato", role: "Designer", color: "#dc2626" },
]
/** The same eight people, grouped into departments (a resource tree). */
export const studioTeams: SchedulerResource[] = [
{ id: "direction", name: "Direction", children: studioResources.filter((r) => ["ada", "ben"].includes(r.id)) },
{
id: "post",
name: "Post-production",
children: studioResources.filter((r) => ["chloe", "dev", "elin", "gus"].includes(r.id)),
},
{ id: "camera", name: "Camera & design", children: studioResources.filter((r) => ["farah", "hana"].includes(r.id)) },
]About this demo
resourceReorder adds a grip to each row: drag it to move the resource among its siblings. onResourceOrderChange hands back the whole tree in its new order.
Things to try
- Move Gus to the top of Post-production
- Reorder the departments
The props behind it are explained in Selection, drag and drop, links.