Skip to content

Commit

Permalink
feat: Improve Currency component
Browse files Browse the repository at this point in the history
  • Loading branch information
mateoroldos committed Jun 9, 2023
1 parent 562faa9 commit 1b7d675
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/lib/components/Currency/Currency.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,23 @@
</script>

<div style={`font-size: ${fontSize}; color: var(--clr-${color}-main)`}>
{#if amount < 0}
<span>-</span>
{/if}
{#if moneyPrefix}
<span class="prefix">$</span>
{/if}
{#if amount >= 0}
<span class="amount"
>{`${moneyPrefix ? '$' : ''}${amount.toLocaleString('en-US', {
>{`${amount.toLocaleString('en-US', {
style: 'decimal',
maximumFractionDigits: decimalNumbers,
minimumFractionDigits: decimalNumbers
})}`}</span
>
{:else}
<span class="amount"
>{`-$${Math.abs(amount).toLocaleString('en-US', {
>{`${Math.abs(amount).toLocaleString('en-US', {
style: 'decimal',
maximumFractionDigits: decimalNumbers,
minimumFractionDigits: decimalNumbers
Expand All @@ -31,6 +37,10 @@
</div>

<style type="scss">
.prefix {
--font-weight: var(--font-weight-thin);
}
.currency {
font-size: 0.6em;
}
Expand Down

0 comments on commit 1b7d675

Please sign in to comment.