-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bridge-ui-v2): switch chain (#14117)
Co-authored-by: David <[email protected]> Co-authored-by: dave | d1onys1us <[email protected]>
- Loading branch information
1 parent
2f4a0be
commit d51161d
Showing
29 changed files
with
416 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
packages/bridge-ui-v2/src/components/AccountConnectionToast/AccountConnectionToast.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import { t } from 'svelte-i18n'; | ||
import { successToast, warningToast } from '$components/NotificationToast'; | ||
import { account } from '$stores/account'; | ||
let prevAccount = $account; | ||
// Listen to changes in the account state and notify the user | ||
// when the account is connected or disconnected via toast | ||
account.subscribe((_account) => { | ||
if (_account?.isConnected) { | ||
successToast($t('messages.account.connected')); | ||
} else if (prevAccount && _account?.isDisconnected) { | ||
// We check if there was previous account, if not | ||
// the user just hit the app, and there is no need | ||
// to show the message. | ||
warningToast($t('messages.account.disconnected')); | ||
} | ||
prevAccount = _account; | ||
}); | ||
</script> |
1 change: 1 addition & 0 deletions
1
packages/bridge-ui-v2/src/components/AccountConnectionToast/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as AccountConnectionToast } from './AccountConnectionToast.svelte'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
packages/bridge-ui-v2/src/components/ConnectButton/ConnectButton.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script lang="ts"> | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { noop } from 'svelte/internal'; | ||
import { t } from 'svelte-i18n'; | ||
import { Button } from '$components/Button'; | ||
import { Icon } from '$components/Icon'; | ||
import { Spinner } from '$components/Spinner'; | ||
import { web3modal } from '$libs/connect'; | ||
export let connected = false; | ||
let web3modalOpen = false; | ||
let unsubscribeWeb3Modal = noop; | ||
function connectWallet() { | ||
web3modal.openModal(); | ||
} | ||
function onWeb3Modal(state: { open: boolean }) { | ||
web3modalOpen = state.open; | ||
} | ||
onMount(() => { | ||
unsubscribeWeb3Modal = web3modal.subscribeModal(onWeb3Modal); | ||
}); | ||
onDestroy(unsubscribeWeb3Modal); | ||
</script> | ||
|
||
<!-- | ||
We are gonna make use of Web3Modal core button when we are connected, | ||
which comes with interesting features out of the box. | ||
https://docs.walletconnect.com/2.0/web/web3modal/html/wagmi/components | ||
--> | ||
{#if connected} | ||
<w3m-core-button balance="show" /> | ||
{:else} | ||
<!-- TODO: fixing the width for English. i18n? --> | ||
<Button class="px-[20px] py-2 rounded-full w-[215px]" type="neutral" on:click={connectWallet}> | ||
<span class="body-regular f-items-center space-x-2"> | ||
{#if web3modalOpen} | ||
<Spinner /> | ||
<span>{$t('wallet.status.connecting')}</span> | ||
{:else} | ||
<Icon type="user-circle" class="md-show-block" /> | ||
<span>{$t('wallet.connect')}</span> | ||
{/if} | ||
</span> | ||
</Button> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as ConnectButton } from './ConnectButton.svelte'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.