Skip to content

Commit

Permalink
web-wallet: Add UsageIndicator to Balance component
Browse files Browse the repository at this point in the history
Resolves #2234
  • Loading branch information
kieranhall committed Aug 31, 2024
1 parent 8879b48 commit 9b19fc9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion web-wallet/src/lib/components/Allocate/Allocate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@
flex-direction: column;
justify-content: center;
align-items: flex-start;
gap: var(--gap-medium);
gap: var(--medium-gap);
align-self: stretch;
border-radius: var(--fieldset-border-radius);
Expand Down
22 changes: 12 additions & 10 deletions web-wallet/src/lib/components/Balance/Balance.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

<script>
import { Icon, Tooltip } from "$lib/dusk/components";
import { UsageIndicator } from "$lib/components";
import { logo } from "$lib/dusk/icons";
import { makeClassName } from "$lib/dusk/string";
import { createCurrencyFormatter } from "$lib/dusk/currency";
Expand All @@ -27,32 +28,33 @@
/** @type {number} */
export let tokens;
/** @type {number} */
export let shieldedTokens = 100;
$: classes = makeClassName(["dusk-balance", className]);
$: duskFormatter = createCurrencyFormatter(locale, tokenCurrency, 9);
$: fiatFormatter = createCurrencyFormatter(locale, fiatCurrency, 2);
</script>

<article {...$$restProps} class={classes}>
<header class="dusk-balance__header">
<h2>Your Balance:</h2>
<h2 class="sr-only">Your Balance:</h2>
</header>
<p class="dusk-balance__dusk">
<strong>{duskFormatter(tokens)}</strong>
<Icon
className="dusk-balance__icon"
path={logo}
data-tooltip-id="balance-tooltip"
data-tooltip-text={tokenCurrency}
data-tooltip-place="right"
/>
<strong>{tokenCurrency}</strong>
</p>
<p
class="dusk-balance__fiat"
class:dusk-balance__fiat--visible={fiatPrice !== undefined && tokens}
>
<strong>
({fiatFormatter(fiatPrice ? fiatPrice * tokens : 0)})
{fiatFormatter(fiatPrice ? fiatPrice * tokens : 0)}
</strong>
</p>
<Tooltip id="balance-tooltip" />
{#if !!import.meta.env.VITE_CONTRACT_ALLOCATE_DISABLED}
<div class="dusk-balance__usage">
<UsageIndicator value={shieldedTokens} />
</div>
{/if}
</article>
10 changes: 6 additions & 4 deletions web-wallet/src/style/dusk-components/balance.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.dusk-balance {
display: flex;
flex-direction: column;
text-align: center;
}

.dusk-balance__header > h2 {
Expand All @@ -13,6 +14,7 @@
display: flex;
align-items: center;
gap: 0.5em;
justify-content: center;
}

.dusk-balance__dusk > strong {
Expand All @@ -28,14 +30,14 @@
line-height: 150%;
letter-spacing: -0.01em;
visibility: hidden;
color: var(--muted-color);
}

.dusk-balance__fiat--visible > strong {
visibility: unset;
}

.dusk-icon.dusk-balance__icon {
width: 1.3125em;
height: 1.3125em;
flex-shrink: 0;
.dusk-balance__usage {
padding: 0.62em 0.75em;
margin-top: 0.62em;
}
1 change: 1 addition & 0 deletions web-wallet/src/style/dusk/language.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
--success-color: var(--success-500);
--success-color-variant-dark: var(--success-700);
--warning-color: var(--warning);
--muted-color: var(--granite-grey);

--on-background-color: var(--smokey-black);
--on-primary-color: var(--light-grey);
Expand Down

0 comments on commit 9b19fc9

Please sign in to comment.