Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composable refactor #175

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
</head>
<body>
<div id="app"></div>
<script>
let global = globalThis
</script>
<script type="module" src="/src/main.ts"></script>
</body>
</html>
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
}
}
29 changes: 17 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@
"format": "prettier -w -u ."
},
"engines": {
"node": "16.13.0"
"node": "16.13.0"
},
"dependencies": {
"@ethersproject/providers": "^5.4.5",
"@ethersproject/units": "^5.4.0",
"@metamask/detect-provider": "^1.2.0",
"@portis/web3": "^4.0.6",
"@snapshot-labs/lock": "github:snapshot-labs/lock#master",
"@snapshot-labs/snapshot.js": "^0.2.14",
"@walletconnect/web3-provider": "1.4.1",
"@snapshot-labs/snapshot.js": "^0.3.23",
"@uma/contracts-frontend": "^0.1.16",
"@vueuse/core": "^7.3.0",
"@walletconnect/ethereum-provider": "^1.7.0",
"@walletconnect/web3-provider": "1.7.0",
"autoprefixer": "^10.3.5",
"chart.js": "^3.5.1",
"ethers": "^5.5.0",
Expand All @@ -33,8 +37,8 @@
"sass": "^1.42.1",
"synths-sdk": "^1.1.5",
"tailwind-config-viewer": "^1.6.2",
"tailwindcss": "^2.2.15",
"unplugin-vue-components": "^0.15.6",
"tailwindcss": "^3.0.7",
"unplugin-vue-components": "^0.17.9",
"vue": "^3.2.13",
"vue-i18n": "^9.1.9",
"vue-js-modal": "^2.0.1",
Expand All @@ -43,21 +47,22 @@
"vue3-clipboard": "^1.0.0"
},
"devDependencies": {
"@types/node": "^16.10.5",
"@types/node": "^17.0.0",
"@types/pathjs": "^0.8.36",
"@typescript-eslint/eslint-plugin": "^5.1.0",
"@typescript-eslint/parser": "^5.1.0",
"@vitejs/plugin-vue": "^1.9.0",
"@vitejs/plugin-vue": "^2.0.1",
"@vue/compiler-sfc": "^3.0.5",
"@vue/eslint-config-prettier": "^6.0.0",
"@vue/eslint-config-typescript": "^7.0.0",
"eslint": "^7.27.0",
"@vue/eslint-config-typescript": "^9.1.0",
"@vuedx/typescript-plugin-vue": "^0.7.4",
"eslint": "^8.4.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-vue": "^7.19.1",
"eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-vue": "^8.2.0",
"prettier": "^2.4.1",
"typescript": "^4.4.3",
"vite": "^2.5.10",
"vue-tsc": "^0.3.0"
"vue-tsc": "^0.29.8"
}
}
89 changes: 12 additions & 77 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,88 +1,23 @@
<template>
<template v-if="!loadingStatus">
<suspense>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was removed a while ago for causing load issues, any specific reason for adding it again?

<router-view />
</template>
<template v-else-if="loadingStatus">
<p class="absolute left-1/2 top-1/2">Loading...</p>
</template>
<template #fallback>
<p class="absolute left-1/2 top-1/2">Loading...</p>
</template>
</suspense>
</template>

<script lang="ts">
import { defineComponent, provide, reactive, ref, onUnmounted, onMounted } from "vue"
<script setup lang="ts">
import { onMounted } from "vue"
import { globalStore } from "@/composables/global"
import { useApp } from "@/composables/useApp"

export default defineComponent({
setup() {
//Setup Simple Data
const state = reactive({
name: "John Doe",
email: "[email protected]",
})
const { init } = useApp()
const { loadBlockNumber } = globalStore()

const updateUsername = (name: string) => {
state.name = name
}

const updateEmail = (email: string) => {
state.email = email
}

const { loadBlockNumber } = globalStore()

loadBlockNumber()

//Setup window resize watcher
const screenWidth = ref<number | null>(null)

const resizeHandler = () => {
screenWidth.value = window.innerWidth
}

window.addEventListener("resize", resizeHandler)

// const { addNewNotifications } = globalStore();

onUnmounted(() => {
window.removeEventListener("resize", resizeHandler)
})

provide("screen", screenWidth)

const { init } = useApp()
onMounted(async () => {
init()
})
return { state, screenWidth }
},
data() {
return {
loadingStatus: true,
}
},
watch: {
$route(to, from) {
if (from.fullPath !== "/" || (from.fullPath == "/" && from.name)) {
this.loadingHandler()
}
},
},
mounted() {
this.loadingHandler()
},
methods: {
loadingHandler() {
let obj = this
document.onreadystatechange = function () {
let state = document.readyState
if (state == "interactive") {
obj.loadingStatus = true
} else if (state == "complete") {
obj.loadingStatus = false
}
}
},
},
loadBlockNumber()
onMounted(async () => {
await init()
})
</script>

Expand Down
16 changes: 0 additions & 16 deletions src/components/ConnectWallet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,22 +250,6 @@
</div>
</div>
</template>

<script>
export default {
name: "ConnectWallet",

methods: {
close() {
this.$emit("close")
},
saveWalletType() {
this.$emit("saveWalletType")
},
},
}
</script>

<style>
.modal-backdrop {
background-color: rgba(0, 0, 0, 0.3);
Expand Down
1 change: 0 additions & 1 deletion src/components/SynthsInsideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ export default {
"s-button": SynthsRoundedButton,
"s-crypto-input": SynthsCryptoInput,
},
inject: ["screen"],
data: () => ({
tokens: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ let tabs = [
{
id: 2,
title: "Markets",
to: "synths",
to: "markets",
},
{
id: 3,
Expand Down
Loading