mirror of
https://github.com/vercel/commerce.git
synced 2025-03-14 14:42:31 +00:00
20 lines
479 B
TypeScript
20 lines
479 B
TypeScript
const Price = ({
|
|
amount,
|
|
currencyCode = 'USD',
|
|
...props
|
|
}: {
|
|
amount: string;
|
|
currencyCode: string;
|
|
} & React.ComponentProps<'p'>) => (
|
|
<p suppressHydrationWarning={true} {...props}>
|
|
{`${new Intl.NumberFormat(undefined, {
|
|
style: 'currency',
|
|
currency: currencyCode,
|
|
currencyDisplay: 'narrowSymbol'
|
|
}).format(parseFloat(amount))}`}
|
|
<span className="hidden @[275px]/label:inline">{` ${currencyCode}`}</span>
|
|
</p>
|
|
);
|
|
|
|
export default Price;
|