Skip to content

Commit 85120fc

Browse files
Merge pull request #91 from rahul-vyas-dev/fix/contributor-repo-page
Fix/contributor repo page
2 parents c04d3a4 + af334bc commit 85120fc

7 files changed

Lines changed: 108 additions & 113 deletions

File tree

src/components/Navbar.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default function Navbar() {
2222
return (
2323
<nav style={{
2424
position: 'sticky', top: 0, zIndex: 100,
25-
background: 'rgba(13,13,13,.97)',
25+
background: 'var(--bg)',
2626
backdropFilter: 'blur(10px)',
2727
borderBottom: '1px solid var(--border)',
2828
padding: '0 24px',

src/context/AppContext.jsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createContext, useContext, useState, useCallback, useEffect } from 'react'
22
import { fetchOrg, fetchRepos, fetchContributors, fetchIssues, } from '../services/github'
3-
import { buildAnalyticalModel } from '../services/analytics'
3+
import { buildAnalyticalModel, getTopRepositories } from '../services/analytics'
44

55
const Ctx = createContext(null)
66

@@ -58,7 +58,7 @@ export function AppProvider({ children }) {
5858

5959
return () => clearTimeout(timeout)
6060
}, [rateLimit])
61-
61+
const [totalRepo, setTotalRepo] = useState(0);
6262
const savePat = useCallback(token => {
6363
setPat(token)
6464
token ? localStorage.setItem('oe_pat', token) : localStorage.removeItem('oe_pat')
@@ -80,12 +80,20 @@ export function AppProvider({ children }) {
8080
reposPerOrg[org.login] = await fetchRepos(org.login, org.public_repos, pat)
8181
}))
8282

83+
const total = Object.values(reposPerOrg).reduce(
84+
(sum, repos) => sum + repos.length,
85+
0
86+
);
87+
88+
setTotalRepo(total);
89+
8390
setLoadMsg('Fetching contributor data for top repositories...')
8491
const contribsPerRepo = {}
8592
for (const org of validOrgs) {
86-
const top = pat ? (reposPerOrg[org.login] || []) : (reposPerOrg[org.login] || [])
87-
.sort((a, b) => b.stargazers_count - a.stargazers_count)
88-
.slice(0, 10)
93+
94+
const top = pat ? (reposPerOrg[org.login] || []) : getTopRepositories(reposPerOrg[org.login] || [], 10);
95+
reposPerOrg[org.login] = top; // Update to only include top repos
96+
8997
await Promise.allSettled(top.map(async repo => {
9098
contribsPerRepo[`${org.login}/${repo.name}`] = await fetchContributors(org.login, repo.name, pat)
9199
}))
@@ -131,7 +139,7 @@ export function AppProvider({ children }) {
131139
return (
132140
<Ctx.Provider value={{
133141
pat, savePat, orgs, model, issuesData,
134-
rateLimit, loading, loadMsg, govLoading, error,
142+
rateLimit, loading, loadMsg, govLoading, error, totalRepo,
135143
explore, runAudit, setError,
136144
}}>
137145
{children}

src/pages/ContributorsPage.jsx

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useSortedData } from '../hooks/useSortedData'
66
import { computeBusFactor, exportContributorsCSV } from '../services/analytics'
77
import { useNavigate } from 'react-router-dom'
88
import EmptyStateCard from '../components/EmptyStateCard'
9-
import { BsFillInfoSquareFill } from "react-icons/bs";
9+
import { AiOutlineInfoCircle } from "react-icons/ai";
1010

1111
export default function ContributorsPage() {
1212
const { model } = useApp()
@@ -92,12 +92,11 @@ export default function ContributorsPage() {
9292
<p>Bus Factor Risk</p>
9393

9494
<button
95-
onClick={() =>
96-
setOpenInfo(openInfo === 'busfactor' ? null : 'busfactor')
97-
}
98-
className="p-2 rounded-full hover:bg-zinc-800 transition"
95+
onMouseEnter={()=>setOpenInfo("busfactor")}
96+
onMouseLeave={()=>setOpenInfo(null)}
97+
className="p-2 rounded-full hover:bg-(--bg) transition"
9998
>
100-
<BsFillInfoSquareFill className="text-white cursor-pointer" />
99+
<AiOutlineInfoCircle className="text-(--text) cursor-pointer" />
101100
</button>
102101

103102
{openInfo === 'busfactor' && (
@@ -154,12 +153,11 @@ export default function ContributorsPage() {
154153
<p>Freshness Index</p>
155154

156155
<button
157-
onClick={() =>
158-
setOpenInfo(openInfo === 'freshness' ? null : 'freshness')
159-
}
160-
className="p-2 rounded-full hover:bg-zinc-800 transition"
156+
onMouseEnter={()=>setOpenInfo("freshness")}
157+
onMouseLeave={()=>setOpenInfo(null)}
158+
className="p-2 rounded-full hover:bg-(--bg) transition"
161159
>
162-
<BsFillInfoSquareFill className="text-white cursor-pointer" />
160+
<AiOutlineInfoCircle className="text-(--text) cursor-pointer" />
163161
</button>
164162

165163
{openInfo === 'freshness' && (
@@ -260,12 +258,11 @@ export default function ContributorsPage() {
260258
<p>SIGNALS</p>
261259

262260
<button
263-
onClick={() =>
264-
setOpenInfo(openInfo === 'signals' ? null : 'signals')
265-
}
266-
className="p-2 rounded-full hover:bg-zinc-800 transition"
261+
onMouseEnter={()=>setOpenInfo("signals")}
262+
onMouseLeave={()=>setOpenInfo(null)}
263+
className="p-2 rounded-full hover:bg-(--bg) transition"
267264
>
268-
<BsFillInfoSquareFill className="text-white cursor-pointer" />
265+
<AiOutlineInfoCircle className="text-(--text) cursor-pointer" />
269266
</button>
270267

271268
{openInfo === 'signals' && (
@@ -308,10 +305,23 @@ export default function ContributorsPage() {
308305
{visible.map((c, i) => (
309306
<tr key={c.login} style={{ borderBottom: '1px solid var(--border)', background: i % 2 ? 'var(--surface2)' : 'transparent' }}>
310307
<td style={{ padding: '10px 14px' }}>
308+
<a
309+
href={`https://github.com/${c.login}`}
310+
target="_blank"
311+
rel="noopener noreferrer"
312+
style={{
313+
display: 'inline-flex',
314+
alignItems: 'center',
315+
gap: 8,
316+
textDecoration: 'none',
317+
color: 'inherit',
318+
}}
319+
>
311320
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
312321
<img src={c.avatar_url} alt={c.login} style={{ width: 28, height: 28, borderRadius: '50%' }} />
313322
<span style={{ fontSize: 13, fontWeight: 500 }}>{c.login}</span>
314323
</div>
324+
</a>
315325
</td>
316326
<td style={{ padding: '10px 14px' }}>
317327
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>

src/pages/NetworkPage.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function NetworkPage() {
2828

2929
// Top repos and contributors for performance
3030
const topRepos = model.allRepos.slice(0, 30)
31-
const topContribs = model.contributors.slice(0, 40)
31+
const topContribs = model.contributors
3232

3333
const nodes = []
3434
if (showRepos) topRepos.forEach(r => nodes.push({ id: `repo:${r.name}`, type: 'repo', data: r, ts: new Date(r.pushed_at).getTime() }))

src/pages/OverviewPage.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@ import { useNavigate } from 'react-router-dom'
33
import { FiExternalLink, FiShare2, FiArrowRight } from 'react-icons/fi'
44
import { useApp } from '../context/AppContext'
55
import { C, StatCard, HealthBar } from '../components/UI'
6-
import { BsFillInfoSquareFill } from "react-icons/bs";
76
import SocialShareButton from '../components/SocialShareButton';
7+
import { AiOutlineInfoCircle } from "react-icons/ai";
8+
89

910
const LANG_COLORS = ['#22c55e', '#f5c518', '#3b82f6', '#ef4444', '#a855f7', '#f97316', '#06b6d4']
1011
const fmt = n => n > 999 ? (n / 1000).toFixed(1) + 'k' : String(n)
1112

1213
export default function OverviewPage() {
13-
const { orgs, model } = useApp()
14+
const { orgs, model, totalRepo } = useApp()
1415
const navigate = useNavigate()
1516
const [open, setOpen] = useState(false)
1617
const infoRef = useRef(null)
@@ -71,7 +72,7 @@ export default function OverviewPage() {
7172
</div>
7273
) : (
7374
orgs[0]?.avatar_url && (
74-
<img src={orgs[0].avatar_url} alt="" style={{ width: 56, height: 56, borderRadius: '50%', border: '2px solid var(--border)' }} />
75+
<img src={orgs[0].avatar_url} alt="" style={{ width: 56, height: 56 }} />
7576
)
7677
)}
7778
<div style={{ flex: 1 }}>
@@ -102,10 +103,10 @@ export default function OverviewPage() {
102103

103104
{/* Stats */}
104105
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4,1fr)', gap: 12, marginBottom: 24 }}>
105-
<StatCard label="Total Repos" value={allRepos.length.toLocaleString()} />
106+
<StatCard label="Total Repos" value={totalRepo.toLocaleString()} />
106107
<StatCard label="Total Stars" value={fmt(totalStars)} />
107108
<StatCard label="Total Forks" value={fmt(totalForks)} />
108-
<StatCard label="Active Repos" value={activeRepos} sub={`${Math.round(activeRepos / allRepos.length * 100)}% of total`} />
109+
<StatCard label="Active Repos" value={activeRepos} sub={`${Math.round(activeRepos / totalRepo * 100)}% of total`} />
109110
</div>
110111

111112
{/* Language + top repos */}
@@ -138,16 +139,17 @@ export default function OverviewPage() {
138139
<p>High Impact Repositories</p>
139140

140141
<button
141-
onClick={() => setOpen(prev => !prev)}
142-
className="p-3 rounded-full hover:bg-zinc-800 transition"
142+
onMouseEnter={()=>setOpen(true)}
143+
onMouseLeave={()=>setOpen(false)}
144+
className="p-3 rounded-full hover:bg-(--bg) transition"
143145
>
144-
<BsFillInfoSquareFill />
146+
<AiOutlineInfoCircle className="text-(--text) cursor-pointer" />
145147
</button>
146148
</div>
147149

148150
{open && (
149151
<div
150-
className="absolute top-16 right-2 w-80 z-50 rounded-lg border-2 border-(--border) bg-zinc-900 p-4 shadow-xl text-xs"
152+
className="absolute top-16 right-2 w-80 z-50 rounded-lg border-2 border-(--border) bg-(--surface) p-4 shadow-xl text-xs"
151153
>
152154
<strong>Health Score</strong> estimates the overall health of a repository on a scale of 0 – 100.
153155

@@ -163,7 +165,7 @@ export default function OverviewPage() {
163165
</li>
164166
</ul>
165167

166-
<p className="mt-2 text-zinc-400">
168+
<p className="mt-2 text-xs text-(--text2)">
167169
Higher scores indicate healthier and more actively maintained repositories.
168170
</p>
169171
</div>

0 commit comments

Comments
 (0)