From d51161d424921ee002812cf69d40f5ee27a464ad Mon Sep 17 00:00:00 2001 From: Francisco Ramos Date: Mon, 10 Jul 2023 08:20:38 +0200 Subject: [PATCH] feat(bridge-ui-v2): switch chain (#14117) Co-authored-by: David Co-authored-by: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com> --- packages/bridge-ui-v2/package.json | 1 + .../AccountConnectionToast.svelte | 23 +++++ .../AccountConnectionToast/index.ts | 1 + .../components/Activities/Activities.svelte | 3 +- .../components/AmountInput/AmountInput.svelte | 6 +- .../src/components/Bridge/Bridge.svelte | 31 +++++-- .../ChainSelector/ChainSelector.svelte | 37 +++++--- .../ConnectButton/ConnectButton.svelte | 51 +++++++++++ .../src/components/ConnectButton/index.ts | 1 + .../src/components/Faucet/Faucet.svelte | 3 +- .../src/components/Header/Header.svelte | 50 +---------- .../src/components/Icon/Icon.svelte | 9 +- .../NotificationToast/ItemToast.svelte | 69 +++++++++++++++ .../NotificationToast.svelte | 88 +++++++++++++++++++ .../src/components/NotificationToast/index.ts | 2 + .../src/components/NotificationToast/types.ts | 1 + .../ProcessingFee/ProcessingFee.svelte | 5 +- .../SideNavigation/SideNavigation.svelte | 10 ++- .../TokenDropdown/TokenDropdown.svelte | 2 +- packages/bridge-ui-v2/src/i18n/en.json | 8 ++ .../src/libs/connect/web3modal.ts | 3 + .../bridge-ui-v2/src/libs/emitter/emitter.ts | 3 + .../bridge-ui-v2/src/libs/emitter/index.ts | 1 + .../bridge-ui-v2/src/libs/wagmi/watcher.ts | 8 +- .../bridge-ui-v2/src/routes/+layout.svelte | 11 ++- packages/bridge-ui-v2/src/stores/network.ts | 4 +- packages/bridge-ui-v2/src/styles/base.css | 9 ++ packages/bridge-ui-v2/tailwind.config.js | 24 ++++- pnpm-lock.yaml | 54 ++++++++---- 29 files changed, 416 insertions(+), 102 deletions(-) create mode 100644 packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte create mode 100644 packages/bridge-ui-v2/src/components/AccountConnectionToast/index.ts create mode 100644 packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte create mode 100644 packages/bridge-ui-v2/src/components/ConnectButton/index.ts create mode 100644 packages/bridge-ui-v2/src/components/NotificationToast/ItemToast.svelte create mode 100644 packages/bridge-ui-v2/src/components/NotificationToast/NotificationToast.svelte create mode 100644 packages/bridge-ui-v2/src/components/NotificationToast/index.ts create mode 100644 packages/bridge-ui-v2/src/components/NotificationToast/types.ts create mode 100644 packages/bridge-ui-v2/src/libs/emitter/emitter.ts create mode 100644 packages/bridge-ui-v2/src/libs/emitter/index.ts diff --git a/packages/bridge-ui-v2/package.json b/packages/bridge-ui-v2/package.json index cc98a80b971..f15afd23151 100644 --- a/packages/bridge-ui-v2/package.json +++ b/packages/bridge-ui-v2/package.json @@ -49,6 +49,7 @@ "@wagmi/core": "^1.3.6", "@web3modal/ethereum": "^2.6.2", "@web3modal/html": "^2.6.2", + "@zerodevx/svelte-toast": "^0.9.5", "abitype": "^0.8.2", "debug": "^4.3.4", "svelte-i18n": "^3.6.0", diff --git a/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte b/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte new file mode 100644 index 00000000000..4dfec03c35d --- /dev/null +++ b/packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte @@ -0,0 +1,23 @@ + diff --git a/packages/bridge-ui-v2/src/components/AccountConnectionToast/index.ts b/packages/bridge-ui-v2/src/components/AccountConnectionToast/index.ts new file mode 100644 index 00000000000..6a773136263 --- /dev/null +++ b/packages/bridge-ui-v2/src/components/AccountConnectionToast/index.ts @@ -0,0 +1 @@ +export { default as AccountConnectionToast } from './AccountConnectionToast.svelte'; diff --git a/packages/bridge-ui-v2/src/components/Activities/Activities.svelte b/packages/bridge-ui-v2/src/components/Activities/Activities.svelte index fb51e91a2ac..4582e168672 100644 --- a/packages/bridge-ui-v2/src/components/Activities/Activities.svelte +++ b/packages/bridge-ui-v2/src/components/Activities/Activities.svelte @@ -3,6 +3,7 @@ import { Card } from '$components/Card'; import { ChainSelector } from '$components/ChainSelector'; + import { srcChain } from '$stores/network'; import ListWithDetailsView from './ListWithDetailsView.svelte'; import TableView from './TableView.svelte'; @@ -10,7 +11,7 @@
- +
diff --git a/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte b/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte index 2ee55238db9..7f92fdf456f 100644 --- a/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte +++ b/packages/bridge-ui-v2/src/components/AmountInput/AmountInput.svelte @@ -8,9 +8,9 @@
-
- -
+
+ +
{$t('amount_input.balance')}: 399.92 ETH
diff --git a/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte b/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte index 163b9e11b03..0907877d42d 100644 --- a/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte +++ b/packages/bridge-ui-v2/src/components/Bridge/Bridge.svelte @@ -1,4 +1,5 @@ -
- +
-
- +
diff --git a/packages/bridge-ui-v2/src/components/ChainSelector/ChainSelector.svelte b/packages/bridge-ui-v2/src/components/ChainSelector/ChainSelector.svelte index 2a1e91ea097..ec192b9a57f 100644 --- a/packages/bridge-ui-v2/src/components/ChainSelector/ChainSelector.svelte +++ b/packages/bridge-ui-v2/src/components/ChainSelector/ChainSelector.svelte @@ -1,15 +1,20 @@ + + +{#if connected} + +{:else} + + +{/if} diff --git a/packages/bridge-ui-v2/src/components/ConnectButton/index.ts b/packages/bridge-ui-v2/src/components/ConnectButton/index.ts new file mode 100644 index 00000000000..8689eb3417a --- /dev/null +++ b/packages/bridge-ui-v2/src/components/ConnectButton/index.ts @@ -0,0 +1 @@ +export { default as ConnectButton } from './ConnectButton.svelte'; diff --git a/packages/bridge-ui-v2/src/components/Faucet/Faucet.svelte b/packages/bridge-ui-v2/src/components/Faucet/Faucet.svelte index ffbb8b9e3a9..d338844357b 100644 --- a/packages/bridge-ui-v2/src/components/Faucet/Faucet.svelte +++ b/packages/bridge-ui-v2/src/components/Faucet/Faucet.svelte @@ -7,12 +7,13 @@ import { ChainSelector } from '$components/ChainSelector'; import { TokenDropdown } from '$components/TokenDropdown'; import { testERC20Tokens } from '$libs/token'; + import { srcChain } from '$stores/network';
- +
diff --git a/packages/bridge-ui-v2/src/components/Header/Header.svelte b/packages/bridge-ui-v2/src/components/Header/Header.svelte index 283b148df20..843a80c5e8c 100644 --- a/packages/bridge-ui-v2/src/components/Header/Header.svelte +++ b/packages/bridge-ui-v2/src/components/Header/Header.svelte @@ -1,33 +1,9 @@
- - {#if connected} - - {:else} - - - {/if} +
-
+ +
diff --git a/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte b/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte index 5ef36f806d2..bfbcbb6b78b 100644 --- a/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte +++ b/packages/bridge-ui-v2/src/components/SideNavigation/SideNavigation.svelte @@ -26,6 +26,10 @@ closeDrawer(); } } + + function getIconFillClass(active: boolean) { + return active ? 'fill-white' : 'fill-primary-icon'; + }
@@ -67,19 +71,19 @@