Skip to content

Commit

Permalink
web-wallet: Add Speed Option (Gas Settings)
Browse files Browse the repository at this point in the history
Resolves #2437
  • Loading branch information
nortonandreev committed Sep 23, 2024
1 parent 34e931e commit 6fa9c9c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
13 changes: 12 additions & 1 deletion web-wallet/src/lib/components/GasSettings/GasSettings.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script>
import { slide } from "svelte/transition";
import { Button } from "$lib/dusk/components";
import { Button, ExclusiveChoice } from "$lib/dusk/components";
import { GasControls, GasFee } from "$lib/components";
import { areValidGasSettings } from "$lib/contracts";
import { onMount } from "svelte";
Expand All @@ -23,9 +23,17 @@
/** @type {string} */
export let fee;
/** @type {"normal" | "fast"} */
export let speed;
/** @type {boolean} */
let isExpanded = false;
const speedOptions = [
{ disabled: false, label: "Normal", value: "normal" },
{ disabled: false, label: "Fast", value: "fast" },
];
onMount(() => {
if (!areValidGasSettings(price, limit)) {
isExpanded = true;
Expand All @@ -47,8 +55,11 @@
/>
</dd>
</dl>

{#if isExpanded}
<div in:slide|global class="gas-settings">
<ExclusiveChoice options={speedOptions} bind:value={speed} />

<GasControls
on:gasSettings
{limit}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("GasSettings", () => {
expect(container.firstChild).toMatchSnapshot();
});

it("renders the GasSettings component opened", async () => {
it("renders the GasSettings component expanded", async () => {
const { container, getByRole } = render(GasSettings, baseOptions);

const next = getByRole("button", { name: "EDIT" });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ exports[`GasSettings > renders the GasSettings component closed 1`] = `
</div>
`;

exports[`GasSettings > renders the GasSettings component opened 1`] = `
exports[`GasSettings > renders the GasSettings component expanded 1`] = `
<div
class="gas-settings svelte-1daay07"
>
Expand Down Expand Up @@ -129,6 +129,40 @@ exports[`GasSettings > renders the GasSettings component opened 1`] = `
class="gas-settings svelte-1daay07"
style="animation: __svelte_276924520_0 400ms linear 0ms 1 both;"
>
<div
class="dusk-exclusive-choice"
role="radiogroup"
>
<input
class="dusk-exclusive-choice__radio"
id="2d814b13-5fe4-4036-b003-a4383070bebd-normal"
name="2d814b13-5fe4-4036-b003-a4383070bebd"
type="radio"
value="normal"
/>
<label
class="dusk-exclusive-choice__label"
for="2d814b13-5fe4-4036-b003-a4383070bebd-normal"
>
Normal
</label>
<input
class="dusk-exclusive-choice__radio"
id="2d814b13-5fe4-4036-b003-a4383070bebd-fast"
name="2d814b13-5fe4-4036-b003-a4383070bebd"
type="radio"
value="fast"
/>
<label
class="dusk-exclusive-choice__label"
for="2d814b13-5fe4-4036-b003-a4383070bebd-fast"
>
Fast
</label>
</div>
<label
class="gas-control svelte-14slcjg"
>
Expand Down

0 comments on commit 6fa9c9c

Please sign in to comment.