fix(widget): format stock values and changes for better readability (#2836)

This commit is contained in:
Andrea
2025-04-12 17:53:40 +02:00
committed by GitHub
parent 71d8f7920d
commit a29556ee8e

View File

@@ -67,12 +67,13 @@ export default function StockPriceWidget({ options, width, height }: WidgetCompo
</Stack>
<Title pos="absolute" bottom={10} right={10} order={width > 280 ? 1 : 2} fw={700}>
{round(stockValues[stockValues.length - 1] ?? 0)}
{new Intl.NumberFormat().format(round(stockValues[stockValues.length - 1] ?? 0))}
</Title>
{width > 280 && (
<Text pos="absolute" top={10} right={10} size="xl" fw={700}>
{Math.abs(stockValuesChange)} ({Math.abs(stockValuesChangePercentage)}%)
{new Intl.NumberFormat().format(stockValuesChange)} ({stockValuesChange > 0 ? "+" : ""}
{new Intl.NumberFormat().format(stockValuesChangePercentage)}%)
</Text>
)}