2024-04-14 12:52:37 +02:00
|
|
|
'use client'
|
|
|
|
|
2024-04-09 14:46:15 +02:00
|
|
|
import { TriangleUpIcon, TriangleDownIcon } from '@radix-ui/react-icons'
|
|
|
|
import styles from './PriceChange.module.css'
|
2024-04-16 12:20:29 +02:00
|
|
|
import { useLocale } from '@/features/prices/hooks/use-locale'
|
2024-04-09 14:46:15 +02:00
|
|
|
|
|
|
|
export function PriceChange({ priceChange }: { priceChange: number }) {
|
2024-04-16 12:20:29 +02:00
|
|
|
const locale = useLocale()
|
2024-04-09 14:46:15 +02:00
|
|
|
const styleClasses = priceChange > 0 ? styles.positive : styles.negative
|
|
|
|
|
|
|
|
return (
|
2024-04-14 12:52:37 +02:00
|
|
|
<span
|
|
|
|
className={`${styles.change} ${styleClasses}`}
|
|
|
|
title="24h change"
|
|
|
|
data-locale={locale}
|
|
|
|
>
|
2024-04-09 14:46:15 +02:00
|
|
|
{priceChange > 0 ? <TriangleUpIcon /> : <TriangleDownIcon />}
|
|
|
|
{Math.abs(priceChange).toFixed(1)}%
|
|
|
|
</span>
|
|
|
|
)
|
|
|
|
}
|