Skip to content

Commit fda3868

Browse files
committed
refactor(modal): update test modal app and modal component
1 parent a67e685 commit fda3868

File tree

3 files changed

+42
-34
lines changed

3 files changed

+42
-34
lines changed

packages/modal/src/App.vue packages/modal/src/TestModalApp.vue

+20-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
2-
import { ref } from 'vue'
32
import { BrowserWalletConnector, useVueDapp } from '@vue-dapp/core'
3+
import { onMounted, ref } from 'vue'
44
import VueDappModal from './VueDappModal.vue'
55
66
const isModalOpen = ref(false)
@@ -13,6 +13,25 @@ function onClickConnectButton() {
1313
if (!isConnected.value) isModalOpen.value = true
1414
else disconnect()
1515
}
16+
17+
// emit fake erc-6963 provider
18+
onMounted(() => {
19+
for (let i = 0; i < 3; i++) {
20+
window.dispatchEvent(
21+
new CustomEvent('eip6963:announceProvider', {
22+
detail: {
23+
info: {
24+
uuid: 'test-wallet-' + Math.random(),
25+
name: 'Test Wallet',
26+
icon: 'https://placehold.co/150',
27+
rdns: 'com.test.wallet',
28+
},
29+
provider: window.ethereum,
30+
},
31+
}),
32+
)
33+
}
34+
})
1635
</script>
1736

1837
<template>

packages/modal/src/VueDappModal.vue

+20-31
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import { Ref, computed, ref, watch } from 'vue'
2+
import { ConnectOptions, ConnectorName, isMobileBrowser, useAutoConnect, useVueDapp } from '@vue-dapp/core'
3+
import { Ref, computed, watch } from 'vue'
34
import Modal from './components/Modal.vue'
45
import WalletConnectIcon from './components/logos/WalletConnectIcon.vue'
5-
import { useVueDapp, useAutoConnect, ConnectorName, ConnectOptions, isMobileBrowser } from '@vue-dapp/core'
66
import { useVueDappModal } from './store'
77
88
const props = withDefaults(
@@ -115,36 +115,24 @@ const vClickOutside = {
115115
},
116116
}
117117
118-
const columnAmount = computed(() => {
119-
let total = providerDetails.value.length
120-
if (hasConnector('WalletConnect')) total++
121-
if (hasConnector('CoinbaseWallet')) total++
122-
if (total < 2) return 1
123-
return 2
124-
})
118+
// const columnAmount = computed(() => {
119+
// let total = providerDetails.value.length
120+
// if (hasConnector('WalletConnect')) total++
121+
// if (hasConnector('CoinbaseWallet')) total++
122+
// if (total < 2) return 1
123+
// return 2
124+
// })
125125
126-
const isOneColumn = computed(() => columnAmount.value === 1)
126+
// const isOneColumn = computed(() => columnAmount.value === 1)
127127
const isNoWalletFound = computed(
128128
() => providerDetails.value.length === 0 && !hasConnector('WalletConnect') && !hasConnector('CoinbaseWallet'),
129129
)
130-
131-
const vdModalPadding = computed(() => {
132-
if (isOneColumn.value) return '10px 10px'
133-
return '15px 15px'
134-
})
135130
</script>
136131

137132
<template>
138133
<div>
139134
<Modal :modalOpen="modalOpen" @close="closeModal" :dark="dark">
140-
<div
141-
id="vd-modal"
142-
class="vd-modal-column"
143-
:style="{
144-
padding: vdModalPadding,
145-
}"
146-
v-click-outside="closeModal"
147-
>
135+
<div id="vd-modal" class="vd-modal-column" v-click-outside="closeModal">
148136
<div
149137
v-for="detail in providerDetails"
150138
:key="detail.info.uuid"
@@ -193,7 +181,7 @@ const vdModalPadding = computed(() => {
193181
</div>
194182

195183
<slot v-if="isNoWalletFound && $slots['no-wallet-found']" name="no-wallet-found"></slot>
196-
<div id="vd-no-wallet-found" v-else-if="isNoWalletFound">No wallet provider found 😔</div>
184+
<div id="vd-no-wallet-found" v-else-if="isNoWalletFound">No wallet provider found.</div>
197185
</div>
198186
</Modal>
199187

@@ -218,20 +206,21 @@ const vdModalPadding = computed(() => {
218206

219207
<style scoped>
220208
#vd-modal {
221-
display: grid;
222-
gap: 5px;
209+
display: flex;
210+
flex-direction: column;
211+
gap: 0px;
223212
height: auto;
213+
min-height: 150px;
214+
padding: 20px 15px;
224215
}
225216
226217
#vd-modal.vd-modal-column {
227-
grid-template-columns: repeat(2, minmax(0, 1fr));
228-
width: 450px;
218+
width: 320px;
229219
}
230220
231-
@media (max-width: 550px) {
221+
@media (max-width: 320px) {
232222
#vd-modal.vd-modal-column {
233-
grid-template-columns: repeat(1, minmax(0, 1fr));
234-
width: 100%;
223+
width: 80vw;
235224
}
236225
}
237226

packages/modal/src/main.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { createApp } from 'vue'
2-
import App from './App.vue'
2+
import TestModalApp from './TestModalApp.vue'
33
import { createPinia } from 'pinia'
44

5-
const app = createApp(App)
5+
const app = createApp(TestModalApp)
66
app.use(createPinia())
77

88
app.mount('#app')

0 commit comments

Comments
 (0)