Creative agency resource planning
A designer is double-booked. Hand two tasks to a colleague in one drag, check what they unblock, and take it back.
- Creative agency
- Studio North
- Summary rows
- Minimap
- Progress bars
- React render slots
- Dependencies
- Multi-selection
- Zoom slider
- Row columns
- Theming
- Demo with synthetic data
Mission
0 of 3 steps doneFriday, 2 PM at the studio: Mira is booked at 120% this sprint, two Kestrel tasks overlap her Fernhill packaging.
Select “Logo refinement” and “Key visuals” on Mira’s row. — To do
Click the first one, then Ctrl/⌘+click the second. The panel sums up the selection and the campaign’s dependencies appear.
Drag either of them down to Jonas: both move together. — To do
Dates stay the same and the links follow. Mira’s load drops to 70%. Dropping them on a copywriter is refused; the hand-over button on a card moves one task to the least loaded designer.
Undo the reassignment. — To do
One step brings both tasks back: the toolbar arrow, or Ctrl/⌘+Z while the board has focus.
About 30 seconds. Steps tick off as you complete them.
Keyboard: focus the grid, then use arrow keys, Enter and Alt+arrows to move.
Preview of the first frameLive: the real Pro engine, running in your browserAbout 30 seconds. Steps tick off as you complete them. Keyboard: focus the grid, then use arrow keys, Enter and Alt+arrows to move.
The situation.
Studio North is a fictional agency where strategists, designers, copywriters and a producer work on three client campaigns at once. Every campaign is a chain of tasks: no key visuals before the logo is refined, no launch kit before the client signs off the review.
In a spreadsheet the trouble shows up late: a designer quietly booked on two campaigns, a review that cannot move, a task handed to someone who cannot do it. The board has to show each person’s load, keep dependencies visible while work changes hands, and make a rebalancing easy to undo.
Each client has its own colour across the board, and the plan is read on Friday afternoon: what is done, what is in progress, and who carries more than a full week. A red day on someone’s row means two tasks on the same day.
What you will do
You will select two tasks, hand them to another designer in one drag, watch the load column rebalance while the links follow, and undo the whole move in one step.
Where the library ends and your application begins.
SuperScheduler provides
- A day scale with weekends hidden (showNonBusiness: false, eventMoveSkipNonBusiness), zoomed by pinch, Ctrl+wheel or Ctrl +/− (zoomGesture, keyboardOptions.zoomKeys) and by the zoom-ui slider (createZoomSlider), with lod thresholds; the week switch scrolls (scrollTo) and follows the viewport topic of super-scheduler/hooks (subscribeScheduler).
- A team tree with two row-header columns (rowHeaderColumns, rowHeaderColumnsMergeParents) written by onBeforeRowHeaderRender: avatars, roles and load pills that change with every move.
- A frozen summary row (frozen: 'top') for the team’s capacity per day and a load heat on every person’s days, both from onBeforeCellRender and recomputed after each change.
- Double-booked cards piled up with eventStackingLineHeight (allowEventOverlap), progress bars from durationBarMode: 'PercentComplete' and complete, and a hover action area (visibility: 'Hover', action: 'None') that hands a task over.
- Click and Ctrl/⌘+click selection, the multiselect API and a multi-row move recorded as one undo step (createHistory, controlled events through onEventsChange), with curved finish-to-start links that follow the tasks.
- React cards (renderEvent) and hover cards (eventHover) from super-scheduler/react-render, a separator for the studio’s clock, custom time headers (onBeforeTimeHeaderRender), the drag card and a context menu.
- The minimap of super-scheduler/minimap under the board, fed with the team’s load per day over the four weeks (a series over a fixed range), a tone per day and translated labels; its brush pans and zooms the board, and the board opens on the sprint (cellWidth measured before mount).
This example’s code decides
- Which role can take which discipline, and the refusal message when it cannot.
- Sprint load per person, the team’s capacity used in the sprint and on each day, who is overbooked, and each client’s colour.
- Task dependencies, when one is broken, which links are drawn (the selected campaigns, or all) and what the hover card lists.
- The studio’s clock (Friday 23 October, 2 PM, fixed for the demo), the progress reported on each task, fixed client reviews and the least loaded colleague for a hand-over.
- The product bar, the client legend, the selection summary, the mission and every label in this page.
- The team’s load day by day for the strip, the days someone is double-booked, the peak day, and the sprint the board opens on.
The code behind this demo.
These are the files this page runs, not a simplified copy. They compile against the public SuperScheduler Pro exports.
The integration: day scale and zoom bounds, row-header columns with avatars and load pills, the capacity row and daily heat from the cell hook, piled cards with progress and a hover action, links, multiselection, and the callbacks where the rules accept or refuse a move.
/**
* Studio North resource plan: the team over a four-week window, one colour per client.
*
* Library: a day scale with weekends hidden and a free zoom (zoomGesture, driven by the zoom-ui
* slider), a team tree with two row-header columns written by onBeforeRowHeaderRender, a frozen
* summary row and per-day load heat from onBeforeCellRender, overlapping cards cascaded with
* eventStackingLineHeight, PercentComplete duration bars, a hover action area, multiselection and
* a multi-row move, curved dependency links, a separator for the studio's clock, undo history,
* keyboard, React cards and hover cards through `super-scheduler/react-render`, the drag card and
* a context menu.
* Application: who can take which task, moving a selection together, sprint and daily load, when a
* dependency is broken, and every figure on the board. Those rules live in ./rules and run inside
* the callbacks below.
*/
import { useCallback, useEffect, useMemo, type RefObject } from 'react'
import { SuperScheduler } from 'super-scheduler'
import type {
SchedulerBeforeTimeHeaderRenderArgs,
SchedulerEventsChangeArgs,
SchedulerProps,
} from 'super-scheduler'
import type { SchedulerHistory } from 'super-scheduler/history'
import { SuperSchedulerComponent } from 'super-scheduler/react-render'
import { format } from '~/i18n/format'
import { DAY, parseCivil } from '../../scheduler/civil'
import { headerLabel } from '../../scheduler/header-format'
import { unitOfSpan } from '../../scheduler/live-headers'
import { createEventMenu } from '../kit/context-menu'
import { useEventHover } from '../kit/hover-card'
import { KEYS } from '../kit/keys'
import { useDropRefusal } from '../kit/use-drop-refusal'
import { createDragCard } from '../kit/verdict'
import { skinClass, skinMenuTheme } from '../registry'
import type { DemoCommon } from '../types'
import {
GEOMETRY,
LOD,
SUMMARY_ROW,
ZOOM,
civilOf,
clientOf,
initialsOf,
isSpecialistId,
isTaskId,
readTaskFields,
rowHeaderWidth,
specialistName,
toResources,
type TaskEvent,
} from './adapter'
import {
SPECIALISTS,
SPRINT,
STUDIO_NOW,
TEAM_IDS,
WINDOW,
type CampaignId,
type Discipline,
type SpecialistId,
type Task,
type TaskId,
} from './model'
import {
TEAM,
capacityUsed,
dayAllocation,
handOverCandidate,
isoWeek,
moveProblem,
planGroupMove,
teamDayLoad,
workingDays,
type DependencyIssue,
type GroupMovePlan,
type MoveProblem,
type PlannedMove,
} from './rules'
import { cardParts, type CardParts, type CardSize } from './card-parts'
import { TaskCard, cardHtml, taskCard } from './task-card'
import type { StudioNorthText } from './text'
import './tokens.css'
import './studio.css'
/** What the board asks the demo to do (context menu, hover action). */
export type TaskAction = 'details' | 'hand-over' | 'select-campaign'
const SLUG = 'agency-campaigns'
const NOW = parseCivil(STUDIO_NOW)
const TODAY = NOW - (NOW % DAY)
export interface StudioNorthSchedulerProps {
readonly events: TaskEvent[]
readonly tasks: readonly Task[]
readonly issues: readonly DependencyIssue[]
/** Sprint load per specialist (1 = 100 %), computed by the rules. */
readonly loads: ReadonlyMap<SpecialistId, number>
readonly text: StudioNorthText
readonly common: DemoCommon
/** BCP 47 tag for labels, and the scheduler locale id. */
readonly tag: string
readonly schedulerLocale: string
/** Phones: narrower row-header columns (chosen once by the demo). */
readonly compact: boolean
/** The narrowest day width: the whole window fills the board. */
readonly minZoom: number
/** The day width on mount: the sprint's ten working days fill the board. */
readonly initialZoom: number
/** Every dependency, or only those of the campaigns in `focus` (the selection). */
readonly showAllLinks: boolean
readonly focus: ReadonlySet<CampaignId>
readonly history: SchedulerHistory
readonly controlRef: RefObject<SuperScheduler.Scheduler | null>
readonly onEventsChange: (args: SchedulerEventsChangeArgs) => void
readonly onSelectionChange: (ids: TaskId[]) => void
readonly onMoved: (id: TaskId) => void
/** A selection dropped together: the application applies and records it as one change. */
readonly onGroupMove: (moves: readonly PlannedMove[]) => void
readonly onResized: (id: TaskId) => void
readonly onRefused: (id: string, message: string) => void
readonly onAction: (action: TaskAction, id: TaskId) => void
}
/** A selected task gets a ring (red when it starts too early); `sn-selected` is the e2e contract. */
const SELECTED_CLASS = 'sn-selected'
function cardSize(width: number): CardSize {
return width < 84 ? 'tiny' : width < 140 ? 'compact' : 'full'
}
/** Why one task cannot go to `resource` (a team row, the wrong role, a fixed review), or null. */
function singleProblem(
data: object,
resource: SuperScheduler.ResourceId,
): { problem: MoveProblem; discipline: Discipline } | null {
const fields = readTaskFields(data)
if (fields === null) return null
if (!isSpecialistId(resource)) return { problem: 'wrong-role', discipline: fields.discipline }
const problem = moveProblem(fields, resource)
return problem === null ? null : { problem, discipline: fields.discipline }
}
/**
* Time headers: weeks with their ISO number, days with the studio's today in ink. Labels are the
* preview's (`headerLabel`), so the swap does not jump; cached per cell, the hook runs per cell.
*/
function createHeaderHook(
tag: string,
weekLabel: string,
): (args: SchedulerBeforeTimeHeaderRenderArgs) => void {
const cache = new Map<string, { html: string; css: string; areas: SuperScheduler.AreaData[] }>()
return (args) => {
const start = args.header.start.getTime()
const end = args.header.end.getTime()
const width = args.control.cellWidth ?? GEOMETRY.day
const level = args.header.level === 0 ? 'group' : 'cell'
const unit = unitOfSpan(end - start, level)
const key = `${level}:${unit}:${start}:${width < 52 ? 'n' : 'w'}`
let entry = cache.get(key)
if (entry === undefined) {
const escape = SuperScheduler.Util.escapeHtml
const label = escape(headerLabel(start, unit, tag, level, width))
if (level === 'group') {
const week =
unit === 'week'
? `<span class="sn-th-week">${escape(format(weekLabel, { week: isoWeek(start) }))}</span>`
: ''
entry = { html: `<span class="sn-th-group">${label}${week}</span>`, css: '', areas: [] }
} else {
const today = unit === 'day' && start === TODAY
entry = {
html: `<span class="sn-th-day">${label}</span>`,
css: today ? 'sn-th--today' : '',
// The studio's clock inside its day, as a share of the cell: it follows every zoom.
areas:
start <= NOW && NOW < end
? [
{
left: `${((NOW - start) / (end - start)) * 100}%`,
bottom: 0,
height: 6,
width: 2,
cssClass: 'sn-th-now',
},
]
: [],
}
}
cache.set(key, entry)
}
args.header.html = entry.html
args.header.cssClass = entry.css
args.header.areas = entry.areas
}
}
/** Load pill of a person: calm under 80 %, full at 100 %, red above. */
function loadLevel(value: number): 'low' | 'ok' | 'full' | 'over' {
return value > 1 ? 'over' : value >= 0.95 ? 'full' : value >= 0.5 ? 'ok' : 'low'
}
export function StudioNorthScheduler(props: StudioNorthSchedulerProps) {
const {
events,
tasks,
issues,
loads,
text,
common,
tag,
schedulerLocale,
compact,
minZoom,
initialZoom,
showAllLinks,
focus,
history,
controlRef,
} = props
const {
onEventsChange,
onSelectionChange,
onMoved,
onGroupMove,
onResized,
onRefused,
onAction,
} = props
const resources = useMemo(() => toResources(text), [text])
// A refused drop (role, fixed review) is said once the pointer is released.
const refusal = useDropRefusal(onRefused)
const headerHook = useMemo(() => createHeaderHook(tag, text.week.short), [tag, text])
const late = useMemo(() => new Set<string>(issues.map((issue) => issue.task)), [issues])
// Columns are part of the configuration: titles from the page text, widths chosen once.
const rowHeaderColumns = useMemo<SuperScheduler.RowHeaderColumnData[]>(() => {
const [person, load] = compact ? GEOMETRY.compactColumns : GEOMETRY.columns
return [
{ title: text.columns.specialist, width: person, nonresizable: true },
{ title: text.columns.load, width: load, nonresizable: true },
]
}, [text, compact])
// Finish-to-start links come from the business model, not from the scheduler. By default only
// the selected campaigns show theirs, so a busy board stays readable.
const links = useMemo<SuperScheduler.LinkData[]>(() => {
return tasks.flatMap((task) =>
!showAllLinks && !focus.has(task.campaign)
? []
: task.after.map((before) => ({
id: `${before}->${task.id}`,
from: before,
to: task.id,
type: 'FinishToStart' as const,
...(issues.some((issue) => issue.task === task.id && issue.waitsFor === before)
? { cssClass: 'ss-link--late' }
: {}),
})),
)
}, [tasks, issues, showAllLinks, focus])
const config = useMemo<SchedulerProps>(() => {
const reason = (found: { problem: MoveProblem; discipline: Discipline }) =>
found.problem === 'fixed' ? text.rules.fixed : text.rules.wrongRole[found.discipline]
const parts = new Map<string, CardParts>()
const escape = SuperScheduler.Util.escapeHtml
const percent = new Intl.NumberFormat(tag, { style: 'percent' })
const sprintUse = capacityUsed(tasks, SPRINT)
// The selected tasks move together when the dragged one is part of a multiple selection.
const groupPlan = (
dragged: SuperScheduler.EventId,
start: SuperScheduler.Date,
resource: SuperScheduler.ResourceId,
): GroupMovePlan | null => {
const ids = new Set(controlRef.current?.multiselect.events().map((event) => event.id()))
if (ids.size < 2 || !ids.has(dragged) || !isTaskId(dragged)) return null
const selection = tasks.filter((task) => ids.has(task.id))
return planGroupMove(selection, dragged, civilOf(start), String(resource))
}
return {
locale: schedulerLocale,
cssClass: `${skinClass(SLUG)} sn-board`,
startDate: WINDOW.start,
days: 28,
weekStarts: 1,
scale: 'Day',
// The sprint fills the board on mount (56 px per day at least); the slider, the week switch
// and the minimap's brush zoom out to the whole window.
cellWidth: initialZoom,
timeHeaders: [{ groupBy: 'Week' }, { groupBy: 'Day' }],
headerHeight: GEOMETRY.header,
// Pinch and Ctrl+wheel zoom between the whole window and wide days; cards adapt far out.
zoomGesture: { min: minZoom, max: ZOOM.max, wheel: 'ctrl' },
lod: LOD,
// Weekends stay hidden: the plan counts working days only.
showNonBusiness: false,
useEventBoxes: 'Never',
// Moves keep a task's working days: dropping a Thursday–Friday task on Friday ends it Monday.
eventMoveSkipNonBusiness: true,
height: '100%',
treeEnabled: true,
treePreventParentUsage: true,
treeIndent: compact ? 8 : 12,
rowHeaderColumns,
rowHeaderColumnsMergeParents: true,
rowHeaderWidth: rowHeaderWidth(compact),
rowHeaderWidthAutoFit: false,
eventHeight: GEOMETRY.event,
rowMarginTop: GEOMETRY.inset,
rowMarginBottom: GEOMETRY.inset,
// A double-booked person's cards pile up instead of stacking in separate lanes.
eventStackingLineHeight: GEOMETRY.stacking,
eventBorderRadius: 9,
// People can be double-booked; the load column and the heat make it visible instead.
allowEventOverlap: true,
// Click selects, Ctrl/Cmd+click adds to the selection.
eventClickHandling: 'Select',
allowMultiSelect: true,
timeRangeSelectedHandling: 'Disabled',
conflictHighlight: true,
// Progress reported by the owner, as a bar along the card's foot.
durationBarVisible: true,
durationBarMode: 'PercentComplete',
durationBarHeight: 3,
// The studio's clock: Friday 23 October, 2 PM.
separators: [{ location: STUDIO_NOW, cssClass: 'sn-now', layer: 'BelowEvents', width: 2 }],
showToolTip: false,
keyboardEnabled: true,
keyboardTarget: 'component',
keyboardMode: 'Full',
keyboardOptions: { zoomKeys: true },
history,
controlRef,
onEventsChange,
onBeforeTimeHeaderRender: headerHook,
// Row headers: avatar, name and role; the load pill; team rows and the summary's average.
onBeforeRowHeaderRender: (args) => {
const id = args.row.id
const [first, second] = args.row.columns
if (id === SUMMARY_ROW) {
args.row.cssClass = 'sn-row--summary'
if (first !== undefined)
first.html = `<span class="sn-rh"><span class="sn-rh__text"><span class="sn-rh__name">${escape(text.summary.label)}</span><span class="sn-rh__role">${escape(format(text.summary.meta, { people: TEAM.length }))}</span></span></span>`
if (second !== undefined) {
second.html = `<span class="sn-load" data-level="${loadLevel(sprintUse)}">${escape(percent.format(sprintUse))}</span>`
second.horizontalAlignment = 'right'
}
return
}
const team = TEAM_IDS.find((candidate) => candidate === id)
if (team !== undefined) {
args.row.cssClass = 'sn-row--team'
const count = SPECIALISTS.filter((person) => person.team === team).length
if (first !== undefined)
first.html = `<span class="sn-team">${escape(text.teams[team])}<span class="sn-team__count">${count}</span></span>`
return
}
if (!isSpecialistId(id)) return
args.row.cssClass = ''
const person = SPECIALISTS.find((candidate) => candidate.id === id)
if (person === undefined || first === undefined) return
const name = specialistName(id, text)
const avatar =
person.role === 'client'
? '<span class="sn-avatar sn-avatar--client" aria-hidden="true"><svg viewBox="0 0 20 20"><path d="M10 1.8c.5 4.6 3.6 7.7 8.2 8.2-4.6.5-7.7 3.6-8.2 8.2-.5-4.6-3.6-7.7-8.2-8.2 4.6-.5 7.7-3.6 8.2-8.2z" fill="currentColor"/></svg></span>'
: `<span class="sn-avatar" data-team="${person.team}" aria-hidden="true">${escape(initialsOf(name))}</span>`
first.html = `<span class="sn-rh">${avatar}<span class="sn-rh__text"><span class="sn-rh__name">${escape(name)}</span><span class="sn-rh__role">${escape(text.roles[person.role])}</span></span></span>`
const value = loads.get(id)
if (second === undefined || value === undefined) return
const label = escape(format(text.loadTitle, { value: Math.round(value * 100) }))
second.html = `<span class="sn-load" data-level="${loadLevel(value)}" title="${label}">${escape(percent.format(value))}</span>`
second.horizontalAlignment = 'right'
},
// Per-day load: the summary row counts the team's booked capacity, each person's day is
// tinted by how many tasks it holds (two or more: overbooked).
onBeforeCellRender: (args) => {
const { cell } = args
const day = cell.start.getTime()
if (cell.resource === SUMMARY_ROW) {
const value = teamDayLoad(tasks, day)
const over = value > 1
cell.properties.cssClass = over ? 'sn-cap sn-cap--over' : 'sn-cap'
cell.properties.html = `<span class="sn-cap__value">${escape(percent.format(value))}</span><progress class="sn-cap__meter" max="100" value="${Math.min(100, Math.round(value * 100))}"></progress>`
return
}
const owner = cell.resource
if (cell.isParent || !isSpecialistId(owner) || owner === 'client-desk') return
const count = dayAllocation(owner, tasks, day)
const classes = [count >= 2 ? 'sn-heat-over' : count === 1 ? 'sn-heat-1' : '']
if (day === TODAY) classes.push('sn-today')
cell.properties.cssClass = classes.join(' ')
},
onBeforeEventRender: (args) => {
const fields = readTaskFields(args.data)
const id = args.data.id
if (fields === null || !isTaskId(id)) return
const start = civilOf(args.data.start)
const end = civilOf(args.data.end)
const isLate = late.has(id)
const key = `${id}|${start}|${end}|${isLate}`
let content = parts.get(key)
if (content === undefined) {
content = cardParts({ id, ...fields, start, end }, isLate, text, tag)
parts.set(key, content)
}
const width = workingDays(start, end) * (args.control.cellWidth ?? GEOMETRY.day)
// HTML fallback painted until the React card (renderEvent) mounts: the same markup.
args.data.html = cardHtml(content, cardSize(width))
const classes = ['sn-ev', `sn-c-${fields.campaign}`]
if (fields.fixed === true) classes.push('sn-ev--fixed')
else if (content.done) classes.push('sn-ev--done')
if (isLate) classes.push('sn-ev--late')
// Selected tasks get a ring; the control re-runs this hook on selection changes.
if (args.control.multiselect.events().some((event) => event.id() === id))
classes.push(SELECTED_CLASS)
args.data.cssClass = classes.join(' ')
args.data.ariaLabel = `${clientOf(fields.campaign)}, ${content.title}, ${content.meta}`
// Progress between start and done fills the bar at the card's foot.
if (fields.fixed !== true && fields.progress > 0 && fields.progress < 100)
args.data.complete = fields.progress
else args.data.barHidden = true
// A hover button hands the task to the least loaded colleague who can take it.
const owner = args.data.resource
const task = tasks.find((candidate) => candidate.id === id)
const target =
task === undefined || !isSpecialistId(owner)
? null
: handOverCandidate({ ...task, owner }, tasks, SPRINT)
args.data.areas =
target === null || width < 100
? []
: [
{
right: 5,
top: (GEOMETRY.event - 26) / 2,
width: 26,
height: 26,
visibility: 'Hover',
action: 'None',
cssClass: 'sn-act',
html: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M15 20v-1.5A3.5 3.5 0 0 0 11.5 15h-5A3.5 3.5 0 0 0 3 18.5V20"/><circle cx="9" cy="8" r="3.5"/><path d="M17 8h5M19.5 5.5 22 8l-2.5 2.5"/></svg>',
toolTip: format(text.actions.handOver, { owner: specialistName(target, text) }),
onClick: () => onAction('hand-over', id),
},
]
},
// Role compatibility while dragging, for the dragged task and the selection that follows it.
onEventMoving: (args) => {
const plan = groupPlan(args.e.id(), args.start, args.resource)
const found =
plan === null ? singleProblem(args.e.data, args.resource) : plan.ok ? null : plan
refusal.track(String(args.e.id()), found === null ? null : reason(found))
if (found !== null) {
args.allowed = false
args.message = reason(found)
}
},
// Final check before the commit (also covers keyboard moves). A selection is moved by the
// application: the library commit is cancelled and the whole plan becomes one change.
onEventMove: (args) => {
const id = String(args.e.id())
const plan = groupPlan(args.e.id(), args.newStart, args.newResource)
if (plan !== null) {
args.preventDefault()
refusal.clear()
if (plan.ok) onGroupMove(plan.moves)
else onRefused(id, reason(plan))
return
}
const found = singleProblem(args.e.data, args.newResource)
if (found !== null) {
args.preventDefault()
refusal.clear()
onRefused(id, reason(found))
}
},
onEventMoved: (args) => {
refusal.clear()
const id = args.e.id()
if (isTaskId(id)) onMoved(id)
},
onEventResized: (args) => {
refusal.clear()
const id = args.e.id()
if (isTaskId(id)) onResized(id)
},
// The control owns the selection; React keeps a copy of the ids for the detail panel.
onEventSelected: () => {
const selected = controlRef.current?.multiselect.events() ?? []
onSelectionChange(selected.map((event) => event.id()).filter(isTaskId))
},
}
}, [
history,
controlRef,
late,
loads,
tasks,
compact,
minZoom,
initialZoom,
rowHeaderColumns,
onEventsChange,
onMoved,
onGroupMove,
onRefused,
onResized,
onSelectionChange,
onAction,
refusal,
schedulerLocale,
headerHook,
tag,
text,
])
// React cards: the same parts as the HTML fallback.
const renderEvent = useMemo<NonNullable<SchedulerProps['renderEvent']>>(
() =>
({ e, data, width }) => {
const id = e.id()
const fields = readTaskFields(data)
if (!isTaskId(id) || fields === null) return e.text()
const parts = cardParts(
{ id, ...fields, start: civilOf(data.start), end: civilOf(data.end) },
late.has(id),
text,
tag,
)
return <TaskCard parts={parts} size={cardSize(width)} />
},
[late, text, tag],
)
// Hover card: owner, effort, progress, overlaps and dependencies, from the model (./task-card).
const card = useCallback(
(event: SuperScheduler.Event) => {
const task = tasks.find((candidate) => candidate.id === event.id())
if (task === undefined) return null
return taskCard({
task,
tasks,
issues,
load: loads.get(task.owner),
text,
common,
tag,
})
},
[tasks, issues, loads, text, common, tag],
)
const { eventHover, suppressHover } = useEventHover(card)
// Drag verdict on a day board: roles refuse, double-booking and dependencies warn.
const dragCard = useMemo(
() =>
createDragCard({
tag,
common,
days: true,
overlapAllowed: true,
rowName: (id) => (isSpecialistId(id) ? specialistName(id, text) : null),
warn: (info) => {
const task = tasks.find((candidate) => candidate.id === info.eventId)
if (task === undefined) return null
const before = tasks.find(
(candidate) =>
task.after.includes(candidate.id) && info.start.getTime() < parseCivil(candidate.end),
)
if (before !== undefined) return format(text.card.early, { other: text.tasks[before.id] })
const next = tasks.find(
(candidate) =>
candidate.after.includes(task.id) && parseCivil(candidate.start) < info.end.getTime(),
)
return next === undefined
? null
: format(text.card.cascade, { other: text.tasks[next.id] })
},
}),
[tag, common, text, tasks],
)
// Context menu: rebuilt when the plan changes, so its labels name the real hand-over.
const contextMenu = useMemo(
() =>
createEventMenu({
theme: skinMenuTheme(SLUG),
title: (event) => format(common.kit.menuTitle, { name: event.text() }),
onOpenChange: (open) => suppressHover(open),
entries: (event) => {
const id = event.id()
const task = tasks.find((candidate) => candidate.id === id)
if (task === undefined || !isTaskId(id)) return []
const target = handOverCandidate(task, tasks, SPRINT)
return [
{
label: common.kit.openDetails,
icon: 'details',
keys: KEYS.details,
run: () => onAction('details', id),
},
{
label:
target === null
? text.actions.noOne
: format(text.actions.handOver, { owner: specialistName(target, text) }),
icon: 'handover',
primary: true,
disabled: target === null,
run: () => onAction('hand-over', id),
},
'separator',
{
label: format(text.actions.selectCampaign, { campaign: clientOf(task.campaign) }),
icon: 'layers',
run: () => onAction('select-campaign', id),
},
]
},
}),
[tasks, common, text, onAction, suppressHover],
)
// Imperative and once: a scroll prop would be re-applied on every update.
useEffect(() => {
controlRef.current?.scrollTo(WINDOW.start, false, 'left')
}, [controlRef])
return (
<SuperSchedulerComponent
{...config}
resources={resources}
events={events}
links={links}
renderEvent={renderEvent}
eventHover={eventHover}
dragCard={dragCard}
contextMenu={contextMenu}
/>
)
}The archive contains this example’s files and a README. It does not include SuperScheduler Pro or any download key.