1- import { useMemo } from 'react' ;
21import {
32 SpeakerHighIcon ,
4- CaretUpIcon ,
5- CaretDownIcon ,
6- MinusIcon ,
73} from '@phosphor-icons/react' ;
84import { getTailwindStyle } from '@irdashies/utils/colors' ;
95import { formatTime } from '@irdashies/utils/time' ;
@@ -18,7 +14,7 @@ interface DriverRowInfoProps {
1814 delta ?: number ;
1915 position : number ;
2016 badge : React . ReactNode ;
21- iratingChange ?: number ;
17+ iratingChange ?: React . ReactNode ;
2218 lastTime ?: number ;
2319 fastestTime ?: number ;
2420 onPitRoad ?: boolean ;
@@ -51,30 +47,6 @@ export const DriverInfoRow = ({
5147 const lastTimeString = formatTime ( lastTime ) ;
5248 const fastestTimeString = formatTime ( fastestTime ) ;
5349
54- const iratingChangeDisplay = useMemo ( ( ) => {
55- if ( iratingChange === undefined || isNaN ( iratingChange ) ) {
56- return { text : '-' , color : 'text-gray-400' } ;
57- }
58- const roundedChange = Math . round ( iratingChange ) ;
59- let text : string ;
60- let color = 'text-gray-400' ;
61- let icon : React . ReactNode ;
62-
63- if ( roundedChange > 0 ) {
64- text = `${ roundedChange } ` ;
65- color = 'text-green-400' ;
66- icon = < CaretUpIcon size = { 10 } /> ;
67- } else if ( roundedChange < 0 ) {
68- text = `${ Math . abs ( roundedChange ) } ` ;
69- color = 'text-red-400' ;
70- icon = < CaretDownIcon size = { 10 } /> ;
71- } else {
72- text = `${ roundedChange } ` ;
73- icon = < MinusIcon size = { 10 } /> ;
74- }
75- return { text, color, icon } ;
76- } , [ iratingChange ] ) ;
77-
7850 return (
7951 < tr
8052 key = { carIdx }
@@ -115,11 +87,8 @@ export const DriverInfoRow = ({
11587 </ td >
11688 < td > { badge } </ td >
11789 { iratingChange !== undefined && (
118- < td className = { `px-2 text-left ${ iratingChangeDisplay . color } ` } >
119- < span className = "flex items-center gap-0.5" >
120- { iratingChangeDisplay . icon }
121- { iratingChangeDisplay . text }
122- </ span >
90+ < td className = "px-2 text-left" >
91+ { iratingChange }
12392 </ td >
12493 ) }
12594 < td className = { `px-2` } > { delta ?. toFixed ( 1 ) } </ td >
0 commit comments