From 9f6a283aef914efcf2284a93337179c402ee64ec Mon Sep 17 00:00:00 2001 From: Korbinian Date: Thu, 24 Aug 2023 22:26:33 +0200 Subject: [PATCH] feat(bridge-ui-v2): AddressInput component (#14572) --- .../src/components/Bridge/AddressInput.svelte | 25 ++++---- .../src/components/Bridge/Amount.svelte | 2 +- .../Bridge/ProcessingFee/ProcessingFee.svelte | 8 +-- .../src/components/Bridge/Recipient.svelte | 63 ++++++++----------- .../src/components/InputBox/InputBox.svelte | 2 +- packages/bridge-ui-v2/src/i18n/en.json | 8 ++- .../src/libs/token/getAddress.test.ts | 2 +- .../bridge-ui-v2/src/styles/components.css | 3 + 8 files changed, 55 insertions(+), 58 deletions(-) diff --git a/packages/bridge-ui-v2/src/components/Bridge/AddressInput.svelte b/packages/bridge-ui-v2/src/components/Bridge/AddressInput.svelte index fa013c8a842..730de82d478 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/AddressInput.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/AddressInput.svelte @@ -4,7 +4,8 @@ import { t } from 'svelte-i18n'; import type { Address } from 'viem'; - import { Alert } from '$components/Alert'; + import FlatAlert from '$components/Alert/FlatAlert.svelte'; + import { Icon } from '$components/Icon'; import { uid } from '$libs/util/uid'; let input: HTMLInputElement; @@ -21,9 +22,11 @@ if (address && address instanceof EventTarget) { address = (address as HTMLInputElement).value; } + const addr = address as string; if (addr.length < 42) { tooShort = true; + isValidEthereumAddress = false; } else { tooShort = false; isValidEthereumAddress = isAddress(addr); @@ -46,26 +49,24 @@
-
+
validateEthereumAddress(e.target)} - class="w-full input-box outline-none py-6 pr-16 px-[26px] title-subsection-bold placeholder:text-tertiary-content" /> + class="w-full input-box py-6 pr-16 px-[26px] title-subsection-bold placeholder:text-tertiary-content" /> +
-
+
{#if !isValidEthereumAddress && !tooShort} - - -

Invalid address

-

This doesn't seem to be a valid Ethereum address

-
+ {:else if isValidEthereumAddress && !tooShort && showAlert} - -

Valid address format

-
+ {/if}
diff --git a/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte b/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte index 3f12dd87e9c..0f128a0cdd0 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Amount.svelte @@ -220,7 +220,7 @@ error={$insufficientBalance} on:input={inputAmount} bind:this={inputBox} - class="py-6 pr-16 px-[26px] title-subsection-bold" /> + class="py-6 pr-16 px-[26px] title-subsection-bold border-0" /> +
+
@@ -117,7 +104,11 @@ class="px-[28px] py-[10px] rounded-full w-auto bg-transparent !border border-primary-brand hover:border-primary-interactive-hover"> {$t('common.cancel')} -
diff --git a/packages/bridge-ui-v2/src/components/InputBox/InputBox.svelte b/packages/bridge-ui-v2/src/components/InputBox/InputBox.svelte index 9183c06a661..ef782df17df 100644 --- a/packages/bridge-ui-v2/src/components/InputBox/InputBox.svelte +++ b/packages/bridge-ui-v2/src/components/InputBox/InputBox.svelte @@ -6,7 +6,7 @@ let input: HTMLInputElement; let classes = classNames( - 'w-full input-box placeholder:text-tertiary-content bg-neutral-background border-0 shadow-none outline-none font-bold text-2xl', + 'w-full input-box placeholder:text-tertiary-content bg-neutral-background shadow-none font-bold text-2xl', $$props.class, ); diff --git a/packages/bridge-ui-v2/src/i18n/en.json b/packages/bridge-ui-v2/src/i18n/en.json index ecd492fb32e..bf0515e14c2 100644 --- a/packages/bridge-ui-v2/src/i18n/en.json +++ b/packages/bridge-ui-v2/src/i18n/en.json @@ -72,7 +72,7 @@ "none": { "label": "None", "text": "Use ETH to manually claim your bridged token later", - "warning": "This option cannot be selected. You have not enough ETH to cover the gas fees for claiming." + "warning": "Insufficient ETH to cover the gas fees for claiming." }, "custom": { "label": "Custom", @@ -189,7 +189,11 @@ }, "address_input": { "label": "Address", - "placeholder": "Enter an address" + "placeholder": "Enter an address", + "errors": { + "invalid": "Invalid address format" + }, + "success": "Valid address format" }, "amount": { "label": "Amount", diff --git a/packages/bridge-ui-v2/src/libs/token/getAddress.test.ts b/packages/bridge-ui-v2/src/libs/token/getAddress.test.ts index bc11325cd8c..d40df436e5c 100644 --- a/packages/bridge-ui-v2/src/libs/token/getAddress.test.ts +++ b/packages/bridge-ui-v2/src/libs/token/getAddress.test.ts @@ -1,4 +1,4 @@ -import { type Address, getContract, type GetContractResult } from '@wagmi/core'; +import { getContract, type GetContractResult } from '@wagmi/core'; import { PUBLIC_L1_CHAIN_ID, PUBLIC_L2_CHAIN_ID } from '$env/static/public'; diff --git a/packages/bridge-ui-v2/src/styles/components.css b/packages/bridge-ui-v2/src/styles/components.css index ef2295e18ed..ffab1c62969 100644 --- a/packages/bridge-ui-v2/src/styles/components.css +++ b/packages/bridge-ui-v2/src/styles/components.css @@ -165,5 +165,8 @@ backdrop-filter: blur(10px); } + input { + border: 1px solid var(--border-dark-primary, #5d636f); + } /* TODO: add more components here */ }