/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ /** * GanttDragTooltip — floating readout pinned near the top of the timeline * during a bar drag. Shows the proposed new start / finish / duration so * the user can see the commit target without staring at the bar itself. * Fixed positioning (not absolute) keeps it above any scroll; `top-16` * anchors below the toolbar region. */ export interface GanttDragTooltipProps { live: { taskGlobalId: string | null; mode: 'shift' | 'resize-start' | 'resize-finish' | null; liveStartMs: number; liveFinishMs: number; }; } export function GanttDragTooltip({ live }: GanttDragTooltipProps) { const durMs = Math.max(0, live.liveFinishMs - live.liveStartMs); const durDays = (durMs / 86_400_000).toFixed(2).replace(/\.?0+$/, ''); const fmt = (ms: number) => { const d = new Date(ms); const pad = (n: number) => n.toString().padStart(2, '0'); return `${d.getUTCFullYear()}-${pad(d.getUTCMonth() + 1)}-${pad(d.getUTCDate())} ${pad(d.getUTCHours())}:${pad(d.getUTCMinutes())}`; }; const modeLabel = live.mode === 'shift' ? 'Shifting' : live.mode === 'resize-start' ? 'Resizing start' : live.mode === 'resize-finish' ? 'Resizing finish' : ''; return (
{modeLabel}
Start {fmt(live.liveStartMs)}
Finish {fmt(live.liveFinishMs)}
Duration {durDays}d
Shift = no snap · Esc = cancel
); }