Files
fusion/packages/dashboard/app/components/GitHubBadge.tsx
gsxdsm 8ecb11011f feat(FN-1032): replace hardcoded colors with CSS custom properties across dashboard components
- Add CSS custom properties and modifier classes for all status colors (open, closed, merged, draft, review, in-progress, etc.)
- Remove hardcoded hex colors from GitHubBadge, replace with CSS classes
- Remove hardcoded colors from PrSection, use CSS classes and Lucide icons
- Remove COLUMN_COLOR_MAP and inline styles from TaskCard, use CSS classes
- Add theme-safety regression tests ensuring components never use inline color styles
- Update existing GitHubBadge and TaskCard tests for class-based styling
2026-04-06 15:37:45 -07:00

57 lines
1.7 KiB
TypeScript

import { GitPullRequest, CircleDot } from "lucide-react";
import type { IssueInfo, PrInfo } from "@fusion/core";
import type { ToastType } from "../hooks/useToast";
interface GitHubBadgeProps {
prInfo?: PrInfo;
issueInfo?: IssueInfo;
onIssueRefresh?: () => void;
addToast?: (message: string, type?: ToastType) => void;
}
function getIssueModifierClass(state: string, stateReason?: string): string {
if (state === "open") return "card-github-badge--open";
if (stateReason === "completed") return "card-github-badge--completed";
if (stateReason === "not_planned") return "card-github-badge--not-planned";
return "card-github-badge--closed";
}
export function GitHubBadge({ prInfo, issueInfo, onIssueRefresh }: GitHubBadgeProps) {
const handlePrClick = () => {
if (prInfo?.url) {
window.open(prInfo.url, "_blank", "noopener,noreferrer");
}
};
const handleIssueClick = () => {
if (issueInfo?.url) {
window.open(issueInfo.url, "_blank", "noopener,noreferrer");
}
};
return (
<>
{prInfo && (
<span
className={`card-github-badge card-github-badge--${prInfo.status}`}
title={`PR #${prInfo.number}: ${prInfo.title}`}
onClick={handlePrClick}
>
<GitPullRequest size={12} />
<span>#{prInfo.number}</span>
</span>
)}
{issueInfo && (
<span
className={`card-github-badge ${getIssueModifierClass(issueInfo.state, issueInfo.stateReason)}`}
title={`Issue #${issueInfo.number}: ${issueInfo.title}`}
onClick={handleIssueClick}
>
<CircleDot size={12} />
<span>#{issueInfo.number}</span>
</span>
)}
</>
);
}