2022-09-07 18:52:47 -07:00
|
|
|
import { DownTriangle, UpTriangle } from './DirectionTriangles'
|
2023-01-23 17:26:14 -08:00
|
|
|
import FormatNumericValue from './FormatNumericValue'
|
2022-09-07 18:52:47 -07:00
|
|
|
|
2022-10-05 22:11:28 -07:00
|
|
|
const Change = ({
|
2022-09-19 17:12:30 -07:00
|
|
|
change,
|
2023-02-10 04:55:06 -08:00
|
|
|
decimals,
|
2023-11-02 17:27:20 -07:00
|
|
|
isPrivate,
|
2022-12-06 03:58:22 -08:00
|
|
|
prefix,
|
2022-09-19 17:12:30 -07:00
|
|
|
size,
|
2022-12-06 03:58:22 -08:00
|
|
|
suffix,
|
2022-09-19 17:12:30 -07:00
|
|
|
}: {
|
|
|
|
change: number | typeof NaN
|
2023-02-10 04:55:06 -08:00
|
|
|
decimals?: number
|
2023-11-02 17:27:20 -07:00
|
|
|
isPrivate?: boolean
|
2022-12-06 03:58:22 -08:00
|
|
|
prefix?: string
|
2023-10-17 04:28:43 -07:00
|
|
|
size?: 'small' | 'large'
|
2022-12-06 03:58:22 -08:00
|
|
|
suffix?: string
|
2022-09-19 17:12:30 -07:00
|
|
|
}) => {
|
2023-06-14 17:43:33 -07:00
|
|
|
return !isNaN(change) ? (
|
2022-09-07 19:49:12 -07:00
|
|
|
<div className="flex items-center space-x-1.5">
|
|
|
|
{change > 0 ? (
|
2022-09-20 23:13:14 -07:00
|
|
|
<div className="mt-[1px]">
|
|
|
|
<UpTriangle size={size} />
|
|
|
|
</div>
|
2022-09-07 19:49:12 -07:00
|
|
|
) : change < 0 ? (
|
2022-09-20 23:13:14 -07:00
|
|
|
<div className="mt-[1px]">
|
|
|
|
<DownTriangle size={size} />
|
|
|
|
</div>
|
2023-11-07 03:26:17 -08:00
|
|
|
) : null}
|
2022-09-07 18:52:47 -07:00
|
|
|
<p
|
2022-09-22 03:46:51 -07:00
|
|
|
className={`font-mono font-normal ${
|
2023-10-17 04:28:43 -07:00
|
|
|
size === 'small'
|
|
|
|
? 'text-xs'
|
|
|
|
: size === 'large'
|
|
|
|
? 'text-base'
|
|
|
|
: 'text-sm'
|
2022-09-19 17:12:30 -07:00
|
|
|
} ${
|
2022-09-07 18:52:47 -07:00
|
|
|
change > 0
|
2022-11-30 19:32:32 -08:00
|
|
|
? 'text-th-up'
|
2022-09-07 18:52:47 -07:00
|
|
|
: change < 0
|
2022-11-30 19:32:32 -08:00
|
|
|
? 'text-th-down'
|
2023-07-27 19:44:43 -07:00
|
|
|
: 'text-th-fgd-2'
|
2022-09-07 18:52:47 -07:00
|
|
|
}`}
|
|
|
|
>
|
2022-12-06 03:58:22 -08:00
|
|
|
{prefix ? prefix : ''}
|
2023-01-23 17:26:14 -08:00
|
|
|
<FormatNumericValue
|
|
|
|
value={isNaN(change) ? '0.00' : Math.abs(change)}
|
2023-02-10 04:55:06 -08:00
|
|
|
decimals={decimals ? decimals : 2}
|
2023-11-02 17:27:20 -07:00
|
|
|
isPrivate={isPrivate}
|
2023-01-23 17:26:14 -08:00
|
|
|
/>
|
2022-12-06 03:58:22 -08:00
|
|
|
{suffix ? suffix : ''}
|
2022-09-07 18:52:47 -07:00
|
|
|
</p>
|
|
|
|
</div>
|
2023-06-14 17:43:33 -07:00
|
|
|
) : (
|
2023-11-19 18:24:49 -08:00
|
|
|
<p
|
|
|
|
className={`font-mono font-normal ${
|
|
|
|
size === 'small'
|
|
|
|
? 'text-xs'
|
|
|
|
: size === 'large'
|
|
|
|
? 'text-base'
|
|
|
|
: 'text-sm'
|
|
|
|
}`}
|
|
|
|
>
|
|
|
|
{prefix ? prefix : ''}
|
|
|
|
<FormatNumericValue
|
|
|
|
value="0.00"
|
|
|
|
decimals={decimals ? decimals : 2}
|
|
|
|
isPrivate={isPrivate}
|
2023-10-30 15:41:18 -07:00
|
|
|
/>
|
2023-11-19 18:24:49 -08:00
|
|
|
{suffix ? suffix : ''}
|
|
|
|
</p>
|
2022-09-07 18:52:47 -07:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2022-10-05 22:11:28 -07:00
|
|
|
export default Change
|