Skip to content

Commit

Permalink
demo: change to <script setup>
Browse files Browse the repository at this point in the history
  • Loading branch information
johnson86tw committed Nov 13, 2021
1 parent 8c6fc81 commit d22266e
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 40 deletions.
6 changes: 1 addition & 5 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
{
"recommendations": [
"octref.vetur",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode"
]
"recommendations": ["johnsoncodehk.volar"]
}
56 changes: 21 additions & 35 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { defineComponent } from 'vue'
<script setup lang="ts">
import {
useBoard,
useEthers,
Expand All @@ -9,53 +8,40 @@ import {
shortenAddress,
} from 'vue-dapp'
export default defineComponent({
name: 'App',
setup() {
const { open } = useBoard()
const { status, disconnect, error } = useWallet()
const { address, balance, chainId, isActivated } = useEthers()
return {
isActivated,
address,
status,
error,
chainId,
balance,
open,
disconnect,
displayEther,
displayChainName,
shortenAddress,
}
},
})
const { open } = useBoard()
const { status, disconnect, error } = useWallet()
const { address, balance, chainId, isActivated } = useEthers()
</script>

<template>
<div class="h-full flex flex-col justify-center items-center">
<p v-if="error" class="text-red-500">{{ error }}</p>

<p
v-if="error"
class="text-red-500"
>{{ error }}</p>

<div
v-if="isActivated"
class="text-center"
>
<div v-if="isActivated" class="text-center">
<p>{{ shortenAddress(address) }}</p>
<p>{{ displayEther(balance) }} ETH</p>
<p>network: <span class="capitalize"> {{ chainId ? displayChainName(chainId) : '' }} </span></p>
<p>
network:
<span class="capitalize">
{{ chainId ? displayChainName(chainId) : '' }}
</span>
</p>
</div>

<div class="m-4">
<button
@click="isActivated ? disconnect() : open()"
class="btn"
:disabled="status === 'connecting'"
>{{ status === 'connected' ? "Disconnect" : status === 'connecting' ? "Connecting..." : "Connect" }}</button>
>
{{
status === 'connected'
? 'Disconnect'
: status === 'connecting'
? 'Connecting...'
: 'Connect'
}}
</button>
</div>
</div>
<vdapp-board />
Expand Down

0 comments on commit d22266e

Please sign in to comment.