Skip to content

Commit

Permalink
Hide WalletInfo dialog when user clicks on account ID, copies EVM add…
Browse files Browse the repository at this point in the history
…ress, or selects an account.

Signed-off-by: Simon Viénot <[email protected]>
  • Loading branch information
svienot committed Nov 29, 2023
1 parent c502aec commit ea07ba8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/components/Copyable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,12 @@ export default defineComponent({
default: true
},
},
setup(props) {
emits: ['copyMade'],
setup(props, context) {
const copyToClipboard = (): void => {
if (props.contentToCopy?.length) {
navigator.clipboard.writeText(props.contentToCopy)
context.emit('copyMade')
}
}
return {
Expand Down
2 changes: 1 addition & 1 deletion src/components/TopNavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
<WalletInfo
:connected="connected"
:accountIds="accountIds"
:showWalletInfo="showWalletInfo"
v-model:show-wallet-info="showWalletInfo"
:accountId="accountId || undefined"
:walletIconURL="walletIconURL || undefined"
@wallet-disconnect="disconnectFromWallet"
Expand Down
12 changes: 9 additions & 3 deletions src/components/wallet/WalletInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</figure>

<!-- accountID-checksum -->
<div class="is-flex is-align-items-baseline ml-3" style="font-size: 1.35rem;">
<div @click="hideWalletInfo" class="is-flex is-align-items-baseline ml-3" style="font-size: 1.35rem;">
<AccountLink :account-id="accountId"/>
<span class="has-text-grey h-is-smaller">
-{{ accountChecksum }}
Expand All @@ -45,7 +45,7 @@
<div class="p-2" style="border: 0.5px solid white;">
<p class="has-text-grey h-is-smaller">EVM ADDRESS</p>

<Copyable :content-to-copy="accountEthereumAddress ?? ''">
<Copyable @copy-made="hideWalletInfo" :content-to-copy="accountEthereumAddress ?? ''">
<template v-slot:content>
<div class="is-flex is-align-items-center" style="gap: 0.5rem">
<p v-if="accountEthereumAddress">
Expand Down Expand Up @@ -136,7 +136,7 @@ export default defineComponent({
default: undefined,
},
},
emit: ['walletDisconnect', 'changeAccount'],
emit: ['walletDisconnect', 'changeAccount', 'update:showWalletInfo'],

setup(props, ctx) {
const isSmallScreen = inject('isSmallScreen', true)
Expand Down Expand Up @@ -185,6 +185,7 @@ export default defineComponent({
const changeAccount = (accountId: string) => {
ctx.emit('changeAccount', accountId)
showAccountIdsModal.value = false;
hideWalletInfo()
}

//
Expand All @@ -195,6 +196,10 @@ export default defineComponent({
showAccountIdsModal.value = false;
}

const hideWalletInfo = () => {
ctx.emit('update:showWalletInfo', false)
}

return {
accountRoute,
isTouchDevice,
Expand All @@ -205,6 +210,7 @@ export default defineComponent({
chosenAccountId,
showAccountIdsModal,
disconnectFromWallet,
hideWalletInfo,
accountEthereumAddress,
tbarBalance: balanceAnalyzer.hbarBalance,
accountChecksum: accountLocParser.accountChecksum,
Expand Down

0 comments on commit ea07ba8

Please sign in to comment.