"use client"; import { LifecycleButton, type LifecycleState } from "@/components/piece/Lifecycle"; import { usePhone } from "@/components/shell/phone"; import { badgeVariants } from "@/components/ui/badge"; import { buttonVariants } from "@/components/ui/button"; import { cn } from "@/lib/utils"; import Menu from "./Menu"; // The piece's lifecycle in its head (canvas "Piece · Overview", `Active ▾`): // the state as a chip, and the moves out of it -- Park and Mark done while it // is active, Reactivate (and Mark done) while it is parked, Reactivate once it // is done. The same POST and Undo bar as the Inbox's (components/piece/ // Lifecycle.tsx); the page re-reads on a change. // // On a phone it sits in the page's ⋯ sheet as THREE LABELLED BUTTONS -- Active, // Parked, Done -- the current one marked and not pressable, so the state is read // before it is changed and a change is one deliberate press with the Undo bar // after it. A menu inside a sheet would be a second tap for no gain. const WORD: Record = { active: "Active", parked: "Parked", done: "Done" }; const STATES: LifecycleState[] = ["active", "parked", "done"]; export default function LifecycleChip({ piece, title, state }: { piece: string; title: string; state: LifecycleState }) { const phone = usePhone(); if (phone) { return (
Lifecycle
{STATES.map((to) => to === state ? ( {WORD[to]} now ) : ( ), )}
); } return ( {WORD[state]} } label={`Lifecycle: ${WORD[state]}`} triggerClassName={cn(badgeVariants({ variant: state === "active" ? "neutral" : "on", size: "md" }), "cursor-pointer disabled:opacity-60")} > {state !== "active" && } {state === "active" && } {state !== "done" && } ); }