@@ -13,13 +13,15 @@ interface EngagementScoreProps {
1313 score : number ;
1414 breakdown : ScoreBreakdown ;
1515 monthlyRank : number ;
16+ allTimeRank ?: number ;
1617 weeklyTopN ?: number ;
1718}
1819
1920export function EngagementScore ( {
2021 score,
2122 breakdown,
2223 monthlyRank,
24+ allTimeRank,
2325 weeklyTopN,
2426} : EngagementScoreProps ) {
2527 const [ period , setPeriod ] = useState < "month" | "alltime" > ( "month" ) ;
@@ -74,9 +76,10 @@ export function EngagementScore({
7476 </ div >
7577
7678 { /* Period toggle */ }
77- < div className = "flex gap-4 text-sm mt-1" >
79+ < div className = "flex gap-4 text-sm mt-1" role = "group" aria-label = "Score period" >
7880 < button
7981 onClick = { ( ) => setPeriod ( "month" ) }
82+ aria-pressed = { period === "month" }
8083 className = { `pb-1 transition-colors ${
8184 period === "month"
8285 ? "text-brand-cyan border-b-2 border-brand-cyan font-semibold"
@@ -87,6 +90,7 @@ export function EngagementScore({
8790 </ button >
8891 < button
8992 onClick = { ( ) => setPeriod ( "alltime" ) }
93+ aria-pressed = { period === "alltime" }
9094 className = { `pb-1 transition-colors ${
9195 period === "alltime"
9296 ? "text-brand-cyan border-b-2 border-brand-cyan font-semibold"
@@ -100,9 +104,15 @@ export function EngagementScore({
100104
101105 { /* Leaderboard position */ }
102106 < div className = "flex flex-wrap items-center gap-3 mb-5" >
103- < span className = "text-brand-cyan font-medium text-sm" >
104- You're ranked #{ monthlyRank } this month
105- </ span >
107+ { period === "month" ? (
108+ < span className = "text-brand-cyan font-medium text-sm" >
109+ You're ranked #{ monthlyRank } this month
110+ </ span >
111+ ) : allTimeRank !== undefined ? (
112+ < span className = "text-brand-cyan font-medium text-sm" >
113+ You're ranked #{ allTimeRank } all-time
114+ </ span >
115+ ) : null }
106116 { weeklyTopN !== undefined && (
107117 < span className = "text-brand-purple font-medium text-sm" >
108118 Top { weeklyTopN } this week!
0 commit comments