ScheduleGrid: compact view, time only on cards
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
2cc94b9bd7
commit
1cad1831b1
|
|
@ -3,6 +3,7 @@ import { PlusIcon } from "lucide-react"
|
|||
|
||||
import { cn } from "../lib/utils"
|
||||
import { ScrollArea } from "../ui/scroll-area"
|
||||
import { Tooltip, TooltipContent, TooltipTrigger } from "../ui/tooltip"
|
||||
import type { StatusTone } from "./status-badge"
|
||||
|
||||
/** Время «ЧЧ:ММ». */
|
||||
|
|
@ -86,6 +87,7 @@ const clock = (m: number) => `${String(Math.floor(m / 60)).padStart(2, "0")}:${S
|
|||
* Шапка и шкала времени липкие; при открытии сетка прокручивается к первой записи или к текущему времени.
|
||||
* Короткий день шкала дотягивает до низа окна — дальше штриховка нерабочего времени, без пустоты под сеткой.
|
||||
* Мышью сетку можно таскать: зажать и вести в сторону.
|
||||
* `compact` — на плашках только время, колонки уже; ФИО — в подсказке и для скринридера.
|
||||
*/
|
||||
export function ScheduleGrid({
|
||||
resources,
|
||||
|
|
@ -93,6 +95,7 @@ export function ScheduleGrid({
|
|||
from,
|
||||
to,
|
||||
minuteHeight = 1.8,
|
||||
compact = false,
|
||||
now,
|
||||
selectedId,
|
||||
onEventClick,
|
||||
|
|
@ -108,6 +111,8 @@ export function ScheduleGrid({
|
|||
to?: Clock
|
||||
/** Высота минуты в пикселях. */
|
||||
minuteHeight?: number
|
||||
/** Компактный вид: на плашке только время, колонки уже. ФИО и статус — в подсказке при наведении. */
|
||||
compact?: boolean
|
||||
/** Текущее время — красная линия; только для сегодняшнего дня. */
|
||||
now?: Clock
|
||||
selectedId?: React.Key | null
|
||||
|
|
@ -226,7 +231,7 @@ export function ScheduleGrid({
|
|||
<div
|
||||
ref={grid}
|
||||
className="grid min-w-full"
|
||||
style={{ gridTemplateColumns: `3.5rem repeat(${resources.length}, minmax(11rem, 1fr))` }}
|
||||
style={{ gridTemplateColumns: `3.5rem repeat(${resources.length}, minmax(${compact ? "8rem" : "11rem"}, 1fr))` }}
|
||||
>
|
||||
<div className="sticky top-0 left-0 z-30 border-r border-b bg-card" />
|
||||
{resources.map((r) => (
|
||||
|
|
@ -301,7 +306,7 @@ export function ScheduleGrid({
|
|||
.map((e) => {
|
||||
const place = lanes.get(e.id) ?? { lane: 0, lanes: 1 }
|
||||
const h = (minutes(e.end) - minutes(e.start)) * minuteHeight
|
||||
return (
|
||||
const card = (
|
||||
<button
|
||||
key={e.id}
|
||||
type="button"
|
||||
|
|
@ -319,13 +324,45 @@ export function ScheduleGrid({
|
|||
width: `calc(${100 / place.lanes}% - 8px)`,
|
||||
}}
|
||||
>
|
||||
{compact ? (
|
||||
<div
|
||||
className={cn(
|
||||
"truncate font-mono text-2xs font-semibold tabular",
|
||||
h >= 30 ? "pt-1" : "pt-px",
|
||||
e.muted && "line-through",
|
||||
)}
|
||||
>
|
||||
{e.start}
|
||||
<span className="sr-only">
|
||||
{" "}
|
||||
{e.title}
|
||||
{e.subtitle && <>, {e.subtitle}</>}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
<div className={cn("flex min-w-0 items-baseline gap-1.5", h >= 30 ? "pt-1" : "pt-px")}>
|
||||
<span className="shrink-0 font-mono text-2xs text-muted-foreground tabular">{e.start}</span>
|
||||
<span className={cn("truncate font-semibold", e.muted && "line-through")}>{e.title}</span>
|
||||
</div>
|
||||
{e.subtitle && h >= 40 && <div className="truncate text-2xs text-muted-foreground">{e.subtitle}</div>}
|
||||
</>
|
||||
)}
|
||||
</button>
|
||||
)
|
||||
if (!compact) return card
|
||||
return (
|
||||
<Tooltip key={e.id} delayDuration={300}>
|
||||
<TooltipTrigger asChild>{card}</TooltipTrigger>
|
||||
<TooltipContent side="right">
|
||||
<div className="font-semibold">{e.title}</div>
|
||||
<div className="font-mono text-2xs opacity-75 tabular">
|
||||
{e.start}–{e.end}
|
||||
{e.subtitle && <span className="font-sans"> · {e.subtitle}</span>}
|
||||
</div>
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
)
|
||||
})}
|
||||
|
||||
{nowY != null && (
|
||||
|
|
|
|||
Loading…
Reference in New Issue