Timeline · Configuring the view
Dependencies
links draws arrows between events — finish-to-start by default, or start-start, finish-finish, start-finish — routed around bars when a task starts before its predecessor ends. They follow a task while you drag it; onLinkClick reports clicks.
Live demo
Drag Build API later · Click an arrow
Fullscreenimport { useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { projectLinks, projectPlan, projectTeam } from "./data/planning"
import { useEvents } from "./kit"
export function DependenciesDemo() {
const { events, handlers } = useEvents(() => projectPlan())
const [selected, setSelected] = useState<string | null>(null)
return (
<>
<ProScheduler
data={events}
resources={projectTeam}
links={projectLinks}
onLinkClick={(link) => setSelected(`${link.from} → ${link.to} (${link.type ?? "finish-start"})`)}
// four weeks from this Monday: the whole plan
view={{ timeline: { type: "week", size: 4, resolutionHorizontal: "day" } }}
styleConfig={{ unitWidthPx: 48, fitToWidth: false }}
height={400}
{...handlers}
/>
<p className="mt-2 text-sm text-muted-foreground" aria-live="polite">
{selected ? `Link: ${selected}` : "Click an arrow, or drag a task and watch its links follow."}
</p>
</>
)
}// data/planning.ts — sample data, relative to the current week or month.
import type { PschLink, SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
import { weekStart } from "./studio"
const at = (base: Date, day: number, hour: number, minute = 0) =>
new Date(base.getFullYear(), base.getMonth(), base.getDate() + day, hour, minute)
export const projectTeam: SchedulerResource[] = [
{ id: "pm", name: "Product", color: "#2563eb" },
{ id: "design", name: "Design", color: "#d97706" },
{ id: "backend", name: "Backend", color: "#059669" },
{ id: "frontend", name: "Frontend", color: "#7c3aed" },
{ id: "qa", name: "QA", color: "#dc2626" },
]
export function projectPlan(base = weekStart()): SchedulerEvent[] {
return [
{ id: "brief", title: "Brief", start: at(base, 0, 0), end: at(base, 2, 0), resource: "pm" },
{ id: "wires", title: "Wireframes", start: at(base, 2, 0), end: at(base, 5, 0), resource: "design" },
{ id: "api", title: "API design", start: at(base, 2, 0), end: at(base, 6, 0), resource: "backend" },
{ id: "ui", title: "Visual design", start: at(base, 5, 0), end: at(base, 9, 0), resource: "design" },
{ id: "build-api", title: "Build API", start: at(base, 7, 0), end: at(base, 14, 0), resource: "backend" },
{ id: "build-ui", title: "Build UI", start: at(base, 9, 0), end: at(base, 16, 0), resource: "frontend" },
{ id: "test", title: "Test", start: at(base, 16, 0), end: at(base, 19, 0), resource: "qa" },
{ id: "launch", title: "Launch", start: at(base, 19, 0), end: at(base, 20, 0), resource: "pm" },
]
}
export const projectLinks: PschLink[] = [
{ from: "brief", to: "wires" },
{ from: "brief", to: "api" },
{ from: "wires", to: "ui" },
{ from: "api", to: "build-api" },
{ from: "ui", to: "build-ui" },
{ from: "build-api", to: "build-ui", type: "start-start", color: "#059669" },
{ from: "build-ui", to: "test" },
{ from: "build-api", to: "test" },
{ from: "test", to: "launch", color: "#dc2626" },
]About this demo
links draws arrows between events — finish-to-start by default, or start-start, finish-finish, start-finish — routed around bars when a task starts before its predecessor ends. They follow a task while you drag it; onLinkClick reports clicks.
Things to try
- Drag Build API later
- Click an arrow
The props behind it are explained in Selection, drag and drop, links.