diff --git a/.vscode/settings.json b/.vscode/settings.json index 3919393..0b6aff0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,6 +55,12 @@ "shortcut": "c", "command": "export IS_SANDBOX=1 && claude --dangerously-skip-permissions", "useVsCodeApi": false + }, + { + "name": "Rebuild", + "color": "orange", + "command": "just rebuild", + "useVsCodeApi": false } ], "quickCommandButtons.refreshButton": { diff --git a/public/styles.css b/public/styles.css index a3a915d..21deb30 100644 --- a/public/styles.css +++ b/public/styles.css @@ -9,23 +9,3 @@ color: white; vertical-align: middle; } - -.status-backlog { - background-color: #6e7781; -} - -.status-ready { - background-color: #0969da; -} - -.status-in-progress { - background-color: #bf8700; -} - -.status-in-review { - background-color: #8250df; -} - -.status-done { - background-color: #1a7f37; -} diff --git a/src/background.ts b/src/background.ts index b1ae2f4..004866c 100644 --- a/src/background.ts +++ b/src/background.ts @@ -3,16 +3,9 @@ pat: string; }; - type ProjectStatus = - | "Backlog" - | "Ready" - | "In progress" - | "In review" - | "Done"; - type IssueStatus = { number: number; - status: ProjectStatus | null; + status: string | null; }; type GraphQLResponse = { @@ -96,7 +89,7 @@ }; const buildIssueStatusMap = (issues: IssueNode[]) => { - const issueStatusMap = new Map(); + const issueStatusMap = new Map(); issues.forEach((issue) => { if (!issue.number || !issue.projectItems.nodes.length) return; @@ -107,7 +100,7 @@ ); if (statusField?.name) { - issueStatusMap.set(issue.number, statusField.name as ProjectStatus); + issueStatusMap.set(issue.number, statusField.name); } }); diff --git a/src/content.ts b/src/content.ts index 520adb0..b4dd39b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1,20 +1,34 @@ (() => { - type ProjectStatus = - | "Backlog" - | "Ready" - | "In progress" - | "In review" - | "Done"; - type IssueStatus = { number: number; - status: ProjectStatus | null; + status: string | null; }; const GITHUB_ISSUES_URL_PATTERN = /https:\/\/github\.com\/[^/]+\/[^/]+\/issues/; const BADGE_CLASS = "project-status-badge"; + const STATUS_COLORS = [ + "#0969da", // blue + "#1a7f37", // green + "#bf8700", // yellow + "#8250df", // purple + "#cf222e", // red + "#fb8500", // orange + "#0550ae", // dark blue + "#116329", // dark green + "#6e7781", // gray + ]; + + const getStatusColor = (status: string): string => { + let hash = 0; + for (let i = 0; i < status.length; i++) { + hash = (hash << 5) - hash + status.charCodeAt(i); + hash = hash & hash; + } + return STATUS_COLORS[Math.abs(hash) % STATUS_COLORS.length]; + }; + const getIssueNumbers = (): number[] => { const issueElements = document.querySelectorAll( '[data-testid="issue-pr-title-link"]' @@ -43,7 +57,7 @@ return numbers; }; - const addStatusBadge = (issueNumber: number, status: ProjectStatus) => { + const addStatusBadge = (issueNumber: number, status: string) => { const issueLinks = document.querySelectorAll( '[data-testid="issue-pr-title-link"]' ); @@ -68,11 +82,9 @@ } const badge = document.createElement("span"); - badge.className = `${BADGE_CLASS} status-${status - .toLowerCase() - .replace(/\s+/g, "-")}`; + badge.className = BADGE_CLASS; badge.textContent = status; - badge.style.marginLeft = "8px"; + badge.style.backgroundColor = getStatusColor(status); parent.appendChild(badge); console.log(