diff --git a/src/lib/components/elements/asset.svelte b/src/lib/components/elements/asset.svelte index 44f7b0dc..ac068218 100644 --- a/src/lib/components/elements/asset.svelte +++ b/src/lib/components/elements/asset.svelte @@ -6,7 +6,7 @@ interface AssetProps extends HTMLAttributes { value?: Asset; - variant?: 'value' | 'quantity' | 'full'; + variant?: 'value' | 'full'; fallback?: string; } @@ -17,14 +17,18 @@ fallback = '0', ...props }: AssetProps = $props(); + + function formatAssetValue(value?: Asset) { + return Number(value?.value || fallback).toLocaleString(languageTag(), { + minimumFractionDigits: value?.symbol.precision + }); + } {#if variant === 'full'} - {value ? `${value.quantity} ${value.symbol.name}` : fallback} + {value ? `${formatAssetValue(value)} ${value.symbol.name}` : fallback} {:else} - {Number(value?.value || fallback).toLocaleString(languageTag(), { - minimumFractionDigits: value?.symbol.precision - })} + {formatAssetValue(value)} {/if}