Skip to content

Commit d5c9e00

Browse files
committed
Add repository language color indicators
1 parent 6c6bc3e commit d5c9e00

1 file changed

Lines changed: 63 additions & 2 deletions

File tree

src/pages/Tracker/Tracker.tsx

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import {
2828
MenuItem,
2929
FormControl,
3030
InputLabel,
31+
Tooltip,
3132
} from "@mui/material";
3233
import { useTheme } from "@mui/material/styles";
3334
import { useGitHubAuth } from "../../hooks/useGitHubAuth";
@@ -46,6 +47,36 @@ interface GitHubItem {
4647
html_url: string;
4748
}
4849

50+
const LANGUAGE_COLORS: Record<string, string> = {
51+
JavaScript: "#f1e05a",
52+
TypeScript: "#3178c6",
53+
Python: "#3572A5",
54+
Java: "#b07219",
55+
HTML: "#e34c26",
56+
CSS: "#563d7c",
57+
C: "#555555",
58+
"C++": "#f34b7d",
59+
"C#": "#178600",
60+
PHP: "#4F5D95",
61+
Ruby: "#701516",
62+
Go: "#00ADD8",
63+
Rust: "#dea584",
64+
Kotlin: "#A97BFF",
65+
Swift: "#F05138",
66+
};
67+
68+
const getLanguageFromRepo = (repoName: string): string => {
69+
const lowerRepo = repoName.toLowerCase();
70+
71+
if (lowerRepo.includes("react") || lowerRepo.includes("js")) return "JavaScript";
72+
if (lowerRepo.includes("ts") || lowerRepo.includes("typescript")) return "TypeScript";
73+
if (lowerRepo.includes("python") || lowerRepo.includes("py")) return "Python";
74+
if (lowerRepo.includes("java")) return "Java";
75+
if (lowerRepo.includes("html")) return "HTML";
76+
if (lowerRepo.includes("css")) return "CSS";
77+
78+
return "Unknown";
79+
};
4980
const Home: React.FC = () => {
5081

5182
const theme = useTheme();
@@ -369,8 +400,38 @@ const Home: React.FC = () => {
369400

370401

371402
<TableCell align="center">
372-
{item.repository_url.split("/").slice(-1)[0]}
373-
</TableCell>
403+
{(() => {
404+
const repoName = item.repository_url.split("/").slice(-1)[0];
405+
const language = getLanguageFromRepo(repoName);
406+
const color = LANGUAGE_COLORS[language] || "#9ca3af";
407+
408+
return (
409+
<Tooltip title={`Language: ${language}`} arrow>
410+
<Box
411+
component="span"
412+
sx={{
413+
display: "inline-flex",
414+
alignItems: "center",
415+
justifyContent: "center",
416+
gap: 1,
417+
}}
418+
>
419+
<Box
420+
component="span"
421+
sx={{
422+
width: 10,
423+
height: 10,
424+
borderRadius: "50%",
425+
backgroundColor: color,
426+
display: "inline-block",
427+
}}
428+
/>
429+
{repoName}
430+
</Box>
431+
</Tooltip>
432+
);
433+
})()}
434+
</TableCell>
374435

375436
<TableCell align="center">
376437
{item.pull_request?.merged_at ? "merged" : item.state}

0 commit comments

Comments
 (0)