@@ -14,6 +14,7 @@ import { normalizePubkey } from "@/shared/lib/pubkey";
1414import { Tooltip , TooltipContent , TooltipTrigger } from "@/shared/ui/tooltip" ;
1515import { UserAvatar } from "@/shared/ui/UserAvatar" ;
1616import { OverviewRailSection } from "./ProjectOverviewPanel" ;
17+ import { ProjectsContributionGraph } from "./ProjectsContributionGraph" ;
1718
1819export type ProjectsOverviewSection =
1920 | "repositories"
@@ -30,8 +31,8 @@ type ProjectsOverviewPanelProps = {
3031 summaries ?: Record < string , ProjectActivitySummary > ;
3132} ;
3233
33- function pluralize ( count : number , singular : string , plural = `${ singular } s` ) {
34- return ` ${ count } ${ count === 1 ? singular : plural } ` ;
34+ function unitLabel ( count : number , singular : string , plural = `${ singular } s` ) {
35+ return count === 1 ? singular : plural ;
3536}
3637
3738function projectPeople (
@@ -78,34 +79,52 @@ function overviewStats(
7879 ) ;
7980}
8081
82+ function overviewActivityByDay (
83+ projects : Project [ ] ,
84+ summaries : Record < string , ProjectActivitySummary > | undefined ,
85+ ) {
86+ const merged : Record < string , number > = { } ;
87+ for ( const project of projects ) {
88+ const byDay = summaries ?. [ project . repoAddress ] ?. activityByDay ;
89+ if ( ! byDay ) continue ;
90+ for ( const [ day , count ] of Object . entries ( byDay ) ) {
91+ merged [ day ] = ( merged [ day ] ?? 0 ) + count ;
92+ }
93+ }
94+ return merged ;
95+ }
96+
8197function StatPill ( {
98+ count,
8299 icon : Icon ,
83100 label,
84101 onClick,
85- value ,
102+ unit ,
86103} : {
104+ count : number ;
87105 icon : React . ComponentType < { className ?: string } > ;
88106 label : string ;
89107 onClick : ( ) => void ;
90- value : string ;
108+ unit : string ;
91109} ) {
92110 return (
93111 < button
94- className = "flex items-center gap-3 rounded-xl bg-card px-3 py-2.5 text-left shadow-xs transition-colors hover:bg-muted/40"
112+ className = "flex flex-col rounded-xl bg-card px-3.5 py-3 text-left shadow-xs transition-colors hover:bg-muted/40"
95113 onClick = { onClick }
96114 type = "button"
97115 >
98- < span className = "flex h-9 w-9 shrink-0 items-center justify-center rounded-full bg-muted/60" >
99- < Icon className = "h-4 w-4 text-muted-foreground" />
100- </ span >
101- < div className = "min-w-0" >
102- < span className = "block text-xs font-medium text-foreground" >
116+ < span className = "flex w-full items-center justify-between gap-2" >
117+ < span className = "text-xs font-medium text-muted-foreground" >
103118 { label }
104119 </ span >
105- < span className = "mt-0.5 block truncate text-sm text-muted-foreground" >
106- { value }
120+ < Icon className = "h-3.5 w-3.5 text-muted-foreground/70" />
121+ </ span >
122+ < span className = "mt-2 flex min-w-0 items-baseline gap-1.5" >
123+ < span className = "text-2xl font-semibold leading-none tracking-tight text-foreground" >
124+ { count }
107125 </ span >
108- </ div >
126+ < span className = "truncate text-xs text-muted-foreground" > { unit } </ span >
127+ </ span >
109128 </ button >
110129 ) ;
111130}
@@ -120,46 +139,67 @@ export function ProjectsOverviewPanel({
120139} : ProjectsOverviewPanelProps ) {
121140 const stats = overviewStats ( projects , summaries ) ;
122141 const people = overviewPeople ( projects , summaries ) ;
142+ const activityByDay = overviewActivityByDay ( projects , summaries ) ;
123143
124144 return (
125145 < section className = "mb-4 grid gap-4 xl:grid-cols-[minmax(0,1fr)_18rem]" >
126- < div className = "overflow-hidden rounded-2xl border border-border/50 bg-muted/20 p-4" >
127- < div className = "flex min-w-0 items-start gap-3" >
128- < WorkspaceEmojiIcon className = "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-muted/60 text-2xl" />
129- < div className = "-mt-1 min-w-0 flex-1 space-y-0.5" >
130- < h2 className = "text-xl font-semibold leading-7 tracking-tight text-foreground" >
131- { relayName } Projects
132- </ h2 >
133- < p className = "max-w-2xl text-sm font-normal text-muted-foreground" >
134- Browse shared repositories, pull requests, and local project
135- checkouts in this workspace.
136- </ p >
146+ < div className = "min-w-0 space-y-4" >
147+ < div className = "overflow-hidden rounded-2xl border border-border/50 bg-muted/20 p-4" >
148+ < div className = "flex min-w-0 items-start gap-3" >
149+ < WorkspaceEmojiIcon className = "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-muted/60 text-2xl" />
150+ < div className = "-mt-1 min-w-0 flex-1 space-y-0.5" >
151+ < h2 className = "text-xl font-semibold leading-7 tracking-tight text-foreground" >
152+ { relayName } Projects
153+ </ h2 >
154+ < p className = "max-w-2xl text-sm font-normal text-muted-foreground" >
155+ Browse shared repositories, pull requests, and local project
156+ checkouts in this workspace.
157+ </ p >
158+ </ div >
159+ </ div >
160+ < div className = "mt-4 grid gap-2 sm:grid-cols-2 xl:grid-cols-4" >
161+ < StatPill
162+ count = { projects . length }
163+ icon = { FolderGit2 }
164+ label = "Repositories"
165+ onClick = { ( ) => onSelectSection ( "repositories" ) }
166+ unit = { unitLabel ( projects . length , "project" ) }
167+ />
168+ < StatPill
169+ count = { stats . prs }
170+ icon = { GitPullRequest }
171+ label = "Pull requests"
172+ onClick = { ( ) => onSelectSection ( "prs" ) }
173+ unit = { unitLabel ( stats . prs , "PR" ) }
174+ />
175+ < StatPill
176+ count = { localRepositoryCount }
177+ icon = { Radio }
178+ label = "Local"
179+ onClick = { ( ) => onSelectSection ( "local" ) }
180+ unit = { unitLabel ( localRepositoryCount , "checkout" ) }
181+ />
182+ < StatPill
183+ count = { stats . issues }
184+ icon = { CircleDot }
185+ label = "Issues"
186+ onClick = { ( ) => onSelectSection ( "issues" ) }
187+ unit = { unitLabel ( stats . issues , "issue" ) }
188+ />
137189 </ div >
138190 </ div >
139- < div className = "mt-4 grid gap-2 sm:grid-cols-2 xl:grid-cols-4" >
140- < StatPill
141- icon = { FolderGit2 }
142- label = "Repositories"
143- onClick = { ( ) => onSelectSection ( "repositories" ) }
144- value = { pluralize ( projects . length , "project" ) }
145- />
146- < StatPill
147- icon = { GitPullRequest }
148- label = "Pull requests"
149- onClick = { ( ) => onSelectSection ( "prs" ) }
150- value = { pluralize ( stats . prs , "PR" ) }
151- />
152- < StatPill
153- icon = { Radio }
154- label = "Local"
155- onClick = { ( ) => onSelectSection ( "local" ) }
156- value = { pluralize ( localRepositoryCount , "checkout" ) }
157- />
158- < StatPill
159- icon = { CircleDot }
160- label = "Issues"
161- onClick = { ( ) => onSelectSection ( "issues" ) }
162- value = { pluralize ( stats . issues , "issue" ) }
191+ < div className = "overflow-hidden rounded-2xl border border-border/50 bg-muted/20 p-4" >
192+ < div className = "flex items-center justify-between gap-2" >
193+ < h3 className = "text-sm font-semibold text-foreground" >
194+ Contribution activity
195+ </ h3 >
196+ < span className = "text-xs text-muted-foreground" >
197+ Commits, PRs & issues across all projects
198+ </ span >
199+ </ div >
200+ < ProjectsContributionGraph
201+ activityByDay = { activityByDay }
202+ className = "mt-3"
163203 />
164204 </ div >
165205 </ div >
0 commit comments