Files
paperclip/ui/src/components/PriorityIcon.tsx
Forgotten ab9828ae95 refactor(ui): standardize status/priority colors and improve text legibility
Create shared status-colors.ts module as single source of truth for all
status and priority color definitions. Replace hardcoded color classes in
StatusIcon, StatusBadge, PriorityIcon, NewIssueDialog, Agents, AgentDetail,
and DesignGuide. Fix inconsistent hues (in_progress was yellow in StatusIcon
but indigo in StatusBadge, blocked was red vs amber). Bump identifier text
from text-xs to text-sm and improve MetricCard label legibility.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 19:52:43 -06:00

78 lines
2.7 KiB
TypeScript

import { useState } from "react";
import { ArrowUp, ArrowDown, Minus, AlertTriangle } from "lucide-react";
import { cn } from "../lib/utils";
import { priorityColor, priorityColorDefault } from "../lib/status-colors";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Button } from "@/components/ui/button";
const priorityConfig: Record<string, { icon: typeof ArrowUp; color: string; label: string }> = {
critical: { icon: AlertTriangle, color: priorityColor.critical ?? priorityColorDefault, label: "Critical" },
high: { icon: ArrowUp, color: priorityColor.high ?? priorityColorDefault, label: "High" },
medium: { icon: Minus, color: priorityColor.medium ?? priorityColorDefault, label: "Medium" },
low: { icon: ArrowDown, color: priorityColor.low ?? priorityColorDefault, label: "Low" },
};
const allPriorities = ["critical", "high", "medium", "low"];
interface PriorityIconProps {
priority: string;
onChange?: (priority: string) => void;
className?: string;
showLabel?: boolean;
}
export function PriorityIcon({ priority, onChange, className, showLabel }: PriorityIconProps) {
const [open, setOpen] = useState(false);
const config = priorityConfig[priority] ?? priorityConfig.medium!;
const Icon = config.icon;
const icon = (
<span
className={cn(
"inline-flex items-center justify-center shrink-0",
config.color,
onChange && !showLabel && "cursor-pointer",
className
)}
>
<Icon className="h-3.5 w-3.5" />
</span>
);
if (!onChange) return showLabel ? <span className="inline-flex items-center gap-1.5">{icon}<span className="text-sm">{config.label}</span></span> : icon;
const trigger = showLabel ? (
<button className="inline-flex items-center gap-1.5 cursor-pointer hover:bg-accent/50 rounded px-1 -mx-1 py-0.5 transition-colors">
{icon}
<span className="text-sm">{config.label}</span>
</button>
) : icon;
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>{trigger}</PopoverTrigger>
<PopoverContent className="w-36 p-1" align="start">
{allPriorities.map((p) => {
const c = priorityConfig[p]!;
const PIcon = c.icon;
return (
<Button
key={p}
variant="ghost"
size="sm"
className={cn("w-full justify-start gap-2 text-xs", p === priority && "bg-accent")}
onClick={() => {
onChange(p);
setOpen(false);
}}
>
<PIcon className={cn("h-3.5 w-3.5", c.color)} />
{c.label}
</Button>
);
})}
</PopoverContent>
</Popover>
);
}