'use client'; import { useState } from 'react'; import type { BeadIssue } from '../../lib/types'; /** Props for the EpicChipStrip component. */ interface EpicChipStripProps { /** List of all epic issues to display as selectable chips. */ epics: BeadIssue[]; /** Currently selected epic ID, or null if none selected. */ selectedEpicId: string | null; /** Map of epic ID to total bead (task) count. */ beadCounts: Map; /** Callback fired when the user clicks an epic chip. */ onSelect: (epicId: string) => void; } /** * Returns the label and color for an epic's status. */ function statusStyle(status: BeadIssue['status']): { label: string; dot: string } { switch (status) { case 'open': return { label: 'Open', dot: 'bg-sky-400' }; case 'in_progress': return { label: 'In Progress', dot: 'bg-amber-400' }; case 'blocked': return { label: 'Blocked', dot: 'bg-rose-500' }; case 'closed': return { label: 'Done', dot: 'bg-emerald-400' }; case 'deferred': return { label: 'Deferred', dot: 'bg-slate-400' }; default: return { label: status, dot: 'bg-zinc-500' }; } } /** * Renders an epic selector as a dropdown button that expands an inline selection panel. * When collapsed: shows the selected epic's title as a button. * When expanded: shows a horizontal strip of epic cards with ID, title, and status, * pushing page content down naturally. */ export function EpicChipStrip({ epics, selectedEpicId, beadCounts, onSelect }: EpicChipStripProps) { // Track whether the epic selector panel is expanded const [expanded, setExpanded] = useState(false); // Find the currently selected epic for the button label const selectedEpic = epics.find((epic) => epic.id === selectedEpicId); return (
{/* Collapsed state: button showing selected epic */} {/* Expanded state: horizontal card strip */} {expanded ? (
{/* "All Epics" option */} {epics.map((epic) => { // Determine if this card is the currently selected epic const isSelected = epic.id === selectedEpicId; // Closed epics get a muted visual treatment const isClosed = epic.status === 'closed'; const style = statusStyle(epic.status); const count = beadCounts.get(epic.id) ?? 0; return ( ); })}
) : null}
); }