diff --git a/apps/frontend/src/renderer/components/github-issues/components/IssueDetail.tsx b/apps/frontend/src/renderer/components/github-issues/components/IssueDetail.tsx index 2e9dcaff..794fdc82 100644 --- a/apps/frontend/src/renderer/components/github-issues/components/IssueDetail.tsx +++ b/apps/frontend/src/renderer/components/github-issues/components/IssueDetail.tsx @@ -192,27 +192,19 @@ export function IssueDetail({ {onAddLabels && onRemoveLabels && repoLabels ? ( l.name)} - repoLabels={repoLabels} + repoLabels={[...repoLabels, ...issue.labels.filter(il => !repoLabels.some(rl => rl.name === il.name))]} onAddLabel={(label) => onAddLabels([label])} onRemoveLabel={(label) => onRemoveLabels([label])} /> ) : issue.labels.length > 0 ? (
{issue.labels.map((label) => { - const bg = `#${label.color}`; - const lum = (() => { - const r = Number.parseInt(label.color.substring(0, 2), 16); - const g = Number.parseInt(label.color.substring(2, 4), 16); - const b = Number.parseInt(label.color.substring(4, 6), 16); - return (0.299 * r + 0.587 * g + 0.114 * b) / 255; - })(); - const textColor = lum > 0.5 ? '#24292f' : '#ffffff'; + const color = `#${label.color}`; return ( {label.name} diff --git a/apps/frontend/src/renderer/components/github-issues/components/IssueListItem.tsx b/apps/frontend/src/renderer/components/github-issues/components/IssueListItem.tsx index 1a76dc6b..099678ce 100644 --- a/apps/frontend/src/renderer/components/github-issues/components/IssueListItem.tsx +++ b/apps/frontend/src/renderer/components/github-issues/components/IssueListItem.tsx @@ -98,16 +98,12 @@ export const IssueListItem = memo(function IssueListItem({ {issue.labels.length > 0 && (
{issue.labels.slice(0, 3).map((label) => { - const bg = `#${label.color}`; - const r = Number.parseInt(label.color.substring(0, 2), 16); - const g = Number.parseInt(label.color.substring(2, 4), 16); - const b = Number.parseInt(label.color.substring(4, 6), 16); - const textColor = (0.299 * r + 0.587 * g + 0.114 * b) / 255 > 0.5 ? '#24292f' : '#ffffff'; + const color = `#${label.color}`; return ( {label.name} diff --git a/apps/frontend/src/renderer/components/github-issues/components/LabelManager.tsx b/apps/frontend/src/renderer/components/github-issues/components/LabelManager.tsx index 384cce11..f4f08ab7 100644 --- a/apps/frontend/src/renderer/components/github-issues/components/LabelManager.tsx +++ b/apps/frontend/src/renderer/components/github-issues/components/LabelManager.tsx @@ -4,18 +4,6 @@ import { Plus, X, Check } from 'lucide-react'; import { Button } from '../../ui/button'; import { Badge } from '../../ui/badge'; -/** - * Returns white or dark text color for readable contrast against a hex background. - * Uses perceived luminance formula (ITU-R BT.601). - */ -function getContrastTextColor(hexColor: string): string { - const hex = hexColor.replace('#', ''); - const r = Number.parseInt(hex.substring(0, 2), 16); - const g = Number.parseInt(hex.substring(2, 4), 16); - const b = Number.parseInt(hex.substring(4, 6), 16); - const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255; - return luminance > 0.5 ? '#24292f' : '#ffffff'; -} interface LabelManagerProps { currentLabels: string[]; @@ -70,17 +58,16 @@ export function LabelManager({
{currentLabels.map((label) => { const repoLabel = repoLabels.find((rl) => rl.name === label); - const bgColor = repoLabel ? `#${repoLabel.color}` : undefined; - const textColor = repoLabel ? getContrastTextColor(repoLabel.color) : undefined; + const labelColor = repoLabel ? `#${repoLabel.color}` : undefined; return ( {label} @@ -90,7 +77,7 @@ export function LabelManager({ className="ml-0.5 opacity-70 hover:opacity-100" onClick={() => onRemoveLabel(label)} aria-label={`Remove label ${label}`} - style={textColor ? { color: textColor } : undefined} + style={labelColor ? { color: labelColor } : undefined} >