1+ type MetricsBarProps = {
2+ lineCount : number ;
3+ contextLines : number ;
4+ height : number ;
5+ prepareTime : number | null ;
6+ commitTime : number | null ;
7+ totalTime : number | null ;
8+ } ;
9+
10+ function formatDuration ( value : number | null ) : string {
11+ if ( value === null ) {
12+ return '--' ;
13+ }
14+
15+ if ( value >= 1000 ) {
16+ return `${ ( value / 1000 ) . toFixed ( 2 ) } s` ;
17+ }
18+
19+ return `${ value . toFixed ( 1 ) } ms` ;
20+ }
21+
22+ export default function MetricsBar ( props : MetricsBarProps ) {
23+ const { lineCount, contextLines, height, prepareTime, commitTime, totalTime } = props ;
24+
25+ return (
26+ < section className = "metrics-bar" >
27+ < div className = "metric-card" >
28+ < span className = "metric-card__label" > Lines</ span >
29+ < strong className = "metric-card__value" > { lineCount . toLocaleString ( ) } </ strong >
30+ </ div >
31+
32+ < div className = "metric-card" >
33+ < span className = "metric-card__label" > Context</ span >
34+ < strong className = "metric-card__value" > { contextLines } </ strong >
35+ </ div >
36+
37+ < div className = "metric-card" >
38+ < span className = "metric-card__label" > Height</ span >
39+ < strong className = "metric-card__value" > { height } px</ strong >
40+ </ div >
41+
42+ < div className = "metric-card" >
43+ < span className = "metric-card__label" > Prepare</ span >
44+ < strong className = "metric-card__value" > { formatDuration ( prepareTime ) } </ strong >
45+ </ div >
46+
47+ < div className = "metric-card" >
48+ < span className = "metric-card__label" > Commit</ span >
49+ < strong className = "metric-card__value" > { formatDuration ( commitTime ) } </ strong >
50+ </ div >
51+
52+ < div className = "metric-card" >
53+ < span className = "metric-card__label" > Total</ span >
54+ < strong className = "metric-card__value" > { formatDuration ( totalTime ) } </ strong >
55+ </ div >
56+ </ section >
57+ ) ;
58+ }
0 commit comments