Skip to content

Commit

Permalink
web-wallet: Refactor dashboard to use routes
Browse files Browse the repository at this point in the history
Resolves #2075
  • Loading branch information
kieranhall committed Aug 20, 2024
1 parent b34d758 commit dc5ac18
Show file tree
Hide file tree
Showing 14 changed files with 1,030 additions and 1,424 deletions.
1 change: 1 addition & 0 deletions web-wallet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ VITE_TESTNET_NODE="https://nodes.dusk.network/"
VITE_TESTNET_PROVER_NODE="https://provers.dusk.network/"
VITE_TRANSFER_CONTRACT="0100000000000000000000000000000000000000000000000000000000000000"
VITE_GET_QUOTE_API_ENDPOINT="https://api.dusk.network/v1/quote"
VITE_MOONLIGHT_DISABLED=true
```

To run a local node different steps are needed, so please read the [related section](#running-a-local-rusk-node).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
import { createEventDispatcher } from "svelte";
import {
mdiArrowDownBoldBoxOutline,
mdiArrowLeft,
mdiArrowUpBoldBoxOutline,
mdiDatabaseArrowDownOutline,
mdiDatabaseOutline,
mdiHelpCircleOutline,
} from "@mdi/js";
import { AppAnchorButton } from "$lib/components";
import { Button } from "$lib/dusk/components";
/** @type {ContractOperation[]} */
Expand Down Expand Up @@ -44,6 +46,18 @@
/>
</li>
{/each}
<li class="contract-operations__operation">
<AppAnchorButton
className="contract-operations__operation-button"
href="/dashboard"
icon={{ path: mdiArrowLeft }}
on:click={() => {
dispatch("operationChange", "");
}}
text="Back"
variant="tertiary"
/>
</li>
</menu>

<style lang="postcss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,37 @@
exports[`ContractOperations > should be able to render the component without items 1`] = `
<menu
class="contract-operations svelte-1v0rjcd"
/>
>
<li
class="contract-operations__operation svelte-1v0rjcd"
>
<a
aria-disabled="false"
class="dusk-anchor dusk-anchor--on-surface dusk-anchor-button dusk-anchor-button--variant--tertiary dusk-anchor-button--size--default dusk-icon-button--labeled contract-operations__operation-button"
href="/some-base-path/dashboard"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-anchor-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"
/>
</svg>
<span
class="dusk-anchor-button__text"
>
Back
</span>
</a>
</li>
</menu>
`;

exports[`ContractOperations > should render the \`ContractOperations\` component 1`] = `
Expand Down Expand Up @@ -35,7 +65,6 @@ exports[`ContractOperations > should render the \`ContractOperations\` component
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
Expand All @@ -62,7 +91,6 @@ exports[`ContractOperations > should render the \`ContractOperations\` component
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
Expand Down Expand Up @@ -90,7 +118,6 @@ exports[`ContractOperations > should render the \`ContractOperations\` component
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
Expand All @@ -117,7 +144,6 @@ exports[`ContractOperations > should render the \`ContractOperations\` component
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
Expand All @@ -144,7 +170,35 @@ exports[`ContractOperations > should render the \`ContractOperations\` component
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
>
<a
aria-disabled="false"
class="dusk-anchor dusk-anchor--on-surface dusk-anchor-button dusk-anchor-button--variant--tertiary dusk-anchor-button--size--default dusk-icon-button--labeled contract-operations__operation-button"
href="/some-base-path/dashboard"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-anchor-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"
/>
</svg>
<span
class="dusk-anchor-button__text"
>
Back
</span>
</a>
</li>
</menu>
`;
Expand Down Expand Up @@ -178,7 +232,35 @@ exports[`ContractOperations > should use a default icon if the operation is not
</span>
</button>
</li>
<li
class="contract-operations__operation svelte-1v0rjcd"
>
<a
aria-disabled="false"
class="dusk-anchor dusk-anchor--on-surface dusk-anchor-button dusk-anchor-button--variant--tertiary dusk-anchor-button--size--default dusk-icon-button--labeled contract-operations__operation-button"
href="/some-base-path/dashboard"
>
<svg
class="dusk-icon dusk-icon--size--default dusk-anchor-button__icon"
role="graphics-symbol"
viewBox="0 0 24 24"
>
<path
d="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"
/>
</svg>
<span
class="dusk-anchor-button__text"
>
Back
</span>
</a>
</li>
</menu>
`;
42 changes: 38 additions & 4 deletions web-wallet/src/routes/(app)/dashboard/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
} from "@mdi/js";
import { Button, Icon, ProgressBar } from "$lib/dusk/components";
import { settingsStore, walletStore } from "$lib/stores";
import { AppAnchorButton } from "$lib/components";
import { AddressPicker, AppAnchorButton, Balance } from "$lib/components";
$: ({ network } = $settingsStore);
$: ({ isSyncing, error } = $walletStore);
/** @type {import('./$types').LayoutData} */
export let data;
/** @type {string} */
let syncStatus = "";
Expand All @@ -22,6 +22,17 @@
/** @type {string} */
let iconVariant = "";
/** @type {number | undefined} */
let fiatPrice;
data.currentPrice.then((prices) => {
fiatPrice = prices[currency.toLowerCase()];
});
const { currency, language } = $settingsStore;
$: ({ network } = $settingsStore);
$: ({ balance, currentAddress, addresses, isSyncing, error } = $walletStore);
$: if (isSyncing) {
iconVariant = "warning";
networkStatusIconPath = mdiTimerSand;
Expand All @@ -44,7 +55,21 @@
/>

<section class="dashboard">
<slot />
<div class="dashboard-content">
<h2 class="sr-only">Dashboard</h2>

<AddressPicker {addresses} {currentAddress} />

<Balance
fiatCurrency={currency}
{fiatPrice}
locale={language}
tokenCurrency="DUSK"
tokens={balance.value}
/>

<slot />
</div>
<footer class="footer">
<nav class="footer__navigation">
<div class="footer__network-status">
Expand Down Expand Up @@ -103,6 +128,15 @@
max-height: 100%;
}
.dashboard-content {
width: 100%;
display: flex;
flex-direction: column;
gap: 1.375rem;
overflow-y: auto;
flex: 1;
}
.footer {
width: 100%;
Expand Down
Loading

0 comments on commit dc5ac18

Please sign in to comment.