11import React from 'react' ;
2- import { formatMetricValue , getMetricIcon , getMetricColor , formatLabel } from '../utils/utils' ;
2+ import {
3+ formatMetricValue ,
4+ getMetricIcon ,
5+ getMetricColor ,
6+ formatLabel ,
7+ } from '../utils/utils' ;
38import { styles } from '../utils/styles' ;
49
510interface MetricCardProps {
611 metricKey : string ;
712 value : any ;
813}
914
10- export const MetricCard : React . FC < MetricCardProps > = ( { metricKey, value } ) => {
15+ export const MetricCard : React . FC < MetricCardProps > = ( {
16+ metricKey,
17+ value,
18+ } ) => {
19+ /* 👉 custom display for average_function_size */
20+ const displayValue =
21+ metricKey === 'average_function_size'
22+ ? `${ parseFloat ( value ) . toFixed ( 1 ) } lines`
23+ : formatMetricValue ( metricKey , value ) ;
24+
1125 return (
12- < div
13- style = { {
14- ...styles . metricCard ,
15- background : getMetricColor ( metricKey ) . replace ( '135deg' , '135deg' ) + '20'
26+ < div
27+ style = { {
28+ ...styles . metricCard ,
29+ background :
30+ getMetricColor ( metricKey ) . replace ( '135deg' , '135deg' ) + '20' ,
1631 } }
1732 className = "metric-card"
1833 onMouseEnter = { ( e ) => {
@@ -26,23 +41,22 @@ export const MetricCard: React.FC<MetricCardProps> = ({ metricKey, value }) => {
2641 < span style = { styles . metricIcon } className = "metric-icon" >
2742 { getMetricIcon ( metricKey ) }
2843 </ span >
29- < h3 style = { styles . metricTitle } >
30- { formatLabel ( metricKey ) }
31- </ h3 >
32- </ div >
33- < div style = { styles . metricValue } >
34- { formatMetricValue ( metricKey , value ) }
44+ < h3 style = { styles . metricTitle } > { formatLabel ( metricKey ) } </ h3 >
3545 </ div >
46+
47+ < div style = { styles . metricValue } > { displayValue } </ div >
48+
49+ { /* progress bar only for ratio‑type metrics */ }
3650 { metricKey . includes ( 'ratio' ) && (
3751 < div style = { styles . progressBar } >
38- < div
52+ < div
3953 style = { {
4054 ...styles . progressFill ,
41- width : `${ Math . min ( ( value as number ) * 100 , 100 ) } %`
55+ width : `${ Math . min ( ( value as number ) * 100 , 100 ) } %` ,
4256 } }
4357 > </ div >
4458 </ div >
4559 ) }
4660 </ div >
4761 ) ;
48- } ;
62+ } ;
0 commit comments