Skip to content

Commit 3dc4cdc

Browse files
committed
✨ Add color code to the repositories
1 parent a5dd00c commit 3dc4cdc

4 files changed

Lines changed: 28 additions & 4 deletions

File tree

by-type.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
escapeHtml,
66
formatReactions,
77
getTotalReactions,
8+
getRepoColor,
89
setupCommonUI,
910
setupLoadButton,
1011
setupAutoLoad,
@@ -207,7 +208,7 @@ function renderItems(items) {
207208
<a href="${item.html_url}" class="item-title-link" target="_blank" rel="noopener noreferrer" onclick="event.stopPropagation();">↗️</a>
208209
</div>
209210
<div class="item-meta">
210-
<span class="label repo-badge">${escapeHtml(item.repoName)}</span>
211+
<span class="label repo-badge" style="--repo-bg: ${getRepoColor(item.repoName)}">${escapeHtml(item.repoName)}</span>
211212
<span class="item-state">${stateIcon} ${item.state}</span>
212213
<span class="item-dates">📅 ${createdDate} • 🔄 ${updatedDate}</span>
213214
${milestone}

main.mjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
classifyItem,
77
fetchRepositoryData,
88
getContrastColor,
9+
getRepoColor,
910
showError,
1011
escapeHtml,
1112
formatReactions,
@@ -171,7 +172,7 @@ function renderSwimlane(repoData) {
171172
const [owner, repoName] = repo.split('/');
172173

173174
swimlane.innerHTML = `
174-
<div class="swimlane-header">
175+
<div class="swimlane-header" style="--repo-bg: ${getRepoColor(repo)}; background: var(--repo-bg, transparent); border-radius: 6px; padding: 15px;">
175176
<div class="swimlane-title">
176177
<div class="swimlane-title-main">
177178
<span class="collapse-icon">▼</span>

shared.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,28 @@ export function setGitHubToken(token) {
2929
githubToken = token;
3030
}
3131

32+
/**
33+
* Generate a consistent color for a repository name
34+
*/
35+
export function getRepoColor(repoName) {
36+
// Better hash function with more distribution
37+
// Use golden ratio to spread values across the spectrum
38+
let hash = 0;
39+
for (let i = 0; i < repoName.length; i++) {
40+
const char = repoName.charCodeAt(i);
41+
hash = ((hash << 5) - hash) + char;
42+
hash = hash & hash; // Convert to 32bit integer
43+
}
44+
45+
// Use golden ratio (0.618033988749895) for better distribution
46+
const goldenRatio = 0.618033988749895;
47+
const hue = (Math.abs(hash) * goldenRatio * 360) % 360;
48+
49+
// Use high saturation and moderate lightness for vibrant colors
50+
// Return as HSL with moderate opacity for background
51+
return `hsla(${Math.round(hue)}, 80%, 60%, 0.25)`;
52+
}
53+
3254
/**
3355
* Get the GitHub token
3456
*/

styles.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,8 @@ button:disabled {
10451045
}
10461046

10471047
.repo-badge {
1048-
background: #0d1117;
1049-
color: #8b949e;
1048+
background: var(--repo-bg, #161b22);
1049+
color: #c9d1d9;
10501050
border: 1px solid #30363d;
10511051
}
10521052

0 commit comments

Comments
 (0)