1- import { Check , FileCode } from "lucide-react" ;
1+ import { Check , FileCode , ChevronLeft , ChevronRight } from "lucide-react" ;
22import { cn } from "../cn" ;
33import { Keycap } from "../ui/keycap" ;
44import type { PullRequestFile } from "@/api/types" ;
@@ -8,12 +8,20 @@ interface FileHeaderProps {
88 file : PullRequestFile ;
99 isViewed : boolean ;
1010 onToggleViewed : ( ) => void ;
11+ currentIndex ?: number ;
12+ totalFiles ?: number ;
13+ onPrevFile ?: ( ) => void ;
14+ onNextFile ?: ( ) => void ;
1115}
1216
1317export const FileHeader = memo ( function FileHeader ( {
1418 file,
1519 isViewed,
1620 onToggleViewed,
21+ currentIndex,
22+ totalFiles,
23+ onPrevFile,
24+ onNextFile,
1725} : FileHeaderProps ) {
1826 const fileStatusBadge = ( ( ) => {
1927 switch ( file . status ) {
@@ -40,22 +48,52 @@ export const FileHeader = memo(function FileHeader({
4048 }
4149 } ) ( ) ;
4250
51+ const showNavigation = currentIndex !== undefined && totalFiles !== undefined ;
52+
4353 return (
4454 < div className = "flex items-center justify-between" >
45- < div className = "flex items-center gap-3" >
46- < FileCode className = "w-4 h-4 text-muted-foreground" />
47- < span className = "font-mono text-sm font-medium" > { file . filename } </ span >
55+ < div className = "flex items-center gap-3 min-w-0 flex-1 " >
56+ < FileCode className = "w-4 h-4 text-muted-foreground shrink-0 " />
57+ < span className = "font-mono text-sm font-medium truncate " > { file . filename } </ span >
4858 { fileStatusBadge }
49- < span className = "text-xs text-muted-foreground" >
59+ < span className = "text-xs text-muted-foreground shrink-0 " >
5060 < span className = "text-green-500" > +{ file . additions } </ span > { " " }
5161 < span className = "text-red-500" > −{ file . deletions } </ span >
5262 </ span >
63+ { /* Navigation buttons */ }
64+ { showNavigation && (
65+ < div className = "flex items-center gap-1 shrink-0 ml-2" >
66+ < button
67+ onClick = { onPrevFile }
68+ className = "flex items-center gap-0.5 px-1.5 py-0.5 text-xs rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"
69+ title = "Previous unreviewed file (k)"
70+ >
71+ < ChevronLeft className = "w-3.5 h-3.5" />
72+ < kbd className = "hidden sm:inline-block px-1 py-0.5 bg-muted/60 rounded text-[9px] font-mono" >
73+ k
74+ </ kbd >
75+ </ button >
76+ < span className = "text-xs text-muted-foreground tabular-nums px-1" >
77+ { currentIndex + 1 } /{ totalFiles }
78+ </ span >
79+ < button
80+ onClick = { onNextFile }
81+ className = "flex items-center gap-0.5 px-1.5 py-0.5 text-xs rounded hover:bg-muted transition-colors text-muted-foreground hover:text-foreground"
82+ title = "Next unreviewed file (j)"
83+ >
84+ < kbd className = "hidden sm:inline-block px-1 py-0.5 bg-muted/60 rounded text-[9px] font-mono" >
85+ j
86+ </ kbd >
87+ < ChevronRight className = "w-3.5 h-3.5" />
88+ </ button >
89+ </ div >
90+ ) }
5391 </ div >
5492
5593 < button
5694 onClick = { onToggleViewed }
5795 className = { cn (
58- "flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors" ,
96+ "flex items-center gap-1.5 px-3 py-1.5 text-sm rounded-md transition-colors shrink-0 " ,
5997 isViewed
6098 ? "bg-green-500/20 text-green-500 hover:bg-green-500/30"
6199 : "bg-muted hover:bg-muted/80 text-muted-foreground"
0 commit comments