diff --git a/components/backlog/backlog-card.tsx b/components/backlog/backlog-card.tsx new file mode 100644 index 0000000..81d5c66 --- /dev/null +++ b/components/backlog/backlog-card.tsx @@ -0,0 +1,49 @@ +'use client' + +import { forwardRef } from 'react' +import { cn } from '@/lib/utils' + +export const PRIORITY_BORDER: Record = { + 1: 'border-l-4 border-l-priority-critical', + 2: 'border-l-4 border-l-priority-high', + 3: 'border-l-4 border-l-priority-medium', + 4: 'border-l-4 border-l-priority-low', +} + +interface BacklogCardProps extends React.HTMLAttributes { + title: string + priority: number + isSelected?: boolean + isDragging?: boolean + badge?: React.ReactNode + actions?: React.ReactNode +} + +export const BacklogCard = forwardRef(function BacklogCard( + { title, priority, isSelected, isDragging, badge, actions, className, ...rest }, + ref +) { + return ( +
+

{title}

+ {(badge || actions) && ( +
+
{badge}
+ {actions &&
{actions}
} +
+ )} +
+ ) +}) diff --git a/components/backlog/pbi-list.tsx b/components/backlog/pbi-list.tsx index 4169864..30d2489 100644 --- a/components/backlog/pbi-list.tsx +++ b/components/backlog/pbi-list.tsx @@ -31,6 +31,7 @@ import { deletePbiAction } from '@/actions/pbis' import { reorderPbisAction, updatePbiPriorityAction } from '@/actions/stories' import { cn } from '@/lib/utils' import { PbiDialog, type PbiDialogState } from './pbi-dialog' +import { BacklogCard } from './backlog-card' const PRIORITY_LABELS: Record = { 1: 'Kritiek', @@ -82,37 +83,25 @@ function SortablePbiRow({ const style = { transform: CSS.Transform.toString(transform), transition, - opacity: isDragging ? 0.4 : 1, } return ( -
{ if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onSelect() } }} - className={cn( - 'group flex items-center justify-between px-4 py-2 cursor-pointer transition-colors hover:bg-surface-container focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset', - isSelected && 'bg-primary-container text-primary-container-foreground' - )} - > - {!isDemo && ( - e.stopPropagation()} - > - ⠿ - - )} - {pbi.title} - {!isDemo && ( -
+ onKeyDown={(e: React.KeyboardEvent) => { if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onSelect() } }} + actions={!isDemo ? ( +
- )} -
+ ) : undefined} + /> ) } @@ -286,10 +275,10 @@ export function PbiList({ productId, pbis, isDemo }: PbiListProps) { onDragStart={handleDragStart} onDragEnd={handleDragEnd} > -
+
{visiblePriorities.map(priority => (
-
+
{PRIORITY_LABELS[priority]} @@ -309,6 +298,7 @@ export function PbiList({ productId, pbis, isDemo }: PbiListProps) { items={grouped[priority].map(p => p.id)} strategy={verticalListSortingStrategy} > +
{grouped[priority].map(pbi => ( handleDelete(pbi.id)} /> ))} +
-
))}
{activePbi && ( -
- {activePbi.title} -
+ )}
diff --git a/components/backlog/story-panel.tsx b/components/backlog/story-panel.tsx index bd1de42..4ff82f8 100644 --- a/components/backlog/story-panel.tsx +++ b/components/backlog/story-panel.tsx @@ -29,6 +29,7 @@ import { useSelectionStore } from '@/stores/selection-store' import { usePlannerStore } from '@/stores/planner-store' import { reorderStoriesAction } from '@/actions/stories' import { StoryDialog, type StoryDialogState } from './story-dialog' +import { BacklogCard, PRIORITY_BORDER } from './backlog-card' import { cn } from '@/lib/utils' const PRIORITY_LABELS: Record = { 1: 'Kritiek', 2: 'Hoog', 3: 'Gemiddeld', 4: 'Laag' } @@ -38,12 +39,6 @@ const PRIORITY_COLORS: Record = { 3: 'bg-priority-medium/15 text-priority-medium border-priority-medium/30', 4: 'bg-priority-low/15 text-priority-low border-priority-low/30', } -const PRIORITY_BORDER: Record = { - 1: 'border-l-4 border-l-priority-critical', - 2: 'border-l-4 border-l-priority-high', - 3: 'border-l-4 border-l-priority-medium', - 4: 'border-l-4 border-l-priority-low', -} const STATUS_COLORS: Record = { OPEN: 'bg-status-todo/15 text-status-todo border-status-todo/30', IN_SPRINT: 'bg-status-in-progress/15 text-status-in-progress border-status-in-progress/30', @@ -90,25 +85,21 @@ function SortableStoryBlock({ } return ( -
-

{story.title}

-
+ badge={ {STATUS_LABELS[story.status] ?? story.status} -
-
+ } + /> ) } @@ -290,12 +281,11 @@ export function StoryPanel({ productId, storiesByPbi, isDemo }: StoryPanelProps) {activeDragId && storyMap[activeDragId] && ( -
-

{storyMap[activeDragId].title}

-
+ )}