assembly/layouts/default.vue

193 lines
5.6 KiB
Vue
Raw Normal View History

2021-07-17 21:44:21 +00:00
<template>
2021-07-26 18:33:52 +00:00
<div
2021-08-09 19:11:32 +00:00
class="relative overflow-hidden font-sans antialiased text-primary-black"
2021-07-26 18:33:52 +00:00
>
2021-08-09 19:11:32 +00:00
<div class="min-h-screen flex flex-col">
<Navbar />
2021-08-14 12:30:55 +00:00
<div v-if="activeNetworkId" class="flex-1 overflow-x-hidden ">
2021-08-17 18:16:43 +00:00
<div class="px-4 md:px-0 max-w-6xl mx-auto py-12">
2021-08-09 19:11:32 +00:00
<Nuxt />
</div>
</div>
2021-08-14 12:30:55 +00:00
<div class="flex-1 flex items-center justify-center" v-else>
<svg
class="animate-spin h-12 w-12 text-[#1874FF]"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
></circle>
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>
</div>
2021-08-09 19:11:32 +00:00
<div class="text-center py-8">
<a
class="font-medium text-primary-blue-dark hover:text-primary-blue-hover hover:underline"
2021-08-11 19:46:17 +00:00
href="https://github.com/Instadapp/assembly"
2021-08-09 19:11:32 +00:00
target="_blank"
>
Contribute on GitHub
</a>
2021-07-17 21:44:21 +00:00
</div>
</div>
2021-07-26 18:33:52 +00:00
<Backdrop :show="isBackdropShown" @click="closeBackdrop" />
2021-08-01 17:13:24 +00:00
<SidebarContext />
2021-07-24 23:40:30 +00:00
2021-07-27 21:43:51 +00:00
<Modal />
2021-07-24 23:40:30 +00:00
<NotificationBar />
2021-08-01 18:29:41 +00:00
<div class="fixed bottom-0 right-0 mr-10 mb-16">
<button
2021-08-09 19:11:32 +00:00
@click="showSidebarBalances"
2021-08-01 18:29:41 +00:00
class="px-9 h-[56px] bg-primary-blue-dark hover:bg-primary-blue-hover text-white rounded-[28px] text-lg font-semibold shadow flex items-center"
>
<svg
class="mr-3"
width="14"
height="16"
viewBox="0 0 14 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
2021-08-08 11:34:44 +00:00
<g clip-path="url(#clip123)">
2021-08-01 18:29:41 +00:00
<path
d="M12.6109 4L2.1875 4C1.94578 4 1.75 3.77625 1.75 3.5C1.75 3.22375 1.94578 3 2.1875 3L12.6875 3C12.9292 3 13.125 2.77625 13.125 2.5C13.125 1.67156 12.5374 1 11.8125 1L1.75 1C0.783399 1 0 1.89531 0 3L0 13C0 14.1047 0.783399 15 1.75 15L12.6109 15C13.3771 15 14 14.3272 14 13.5L14 5.5C14 4.67281 13.3771 4 12.6109 4ZM11.375 10.5C10.8918 10.5 10.5 10.0522 10.5 9.5C10.5 8.94781 10.8918 8.5 11.375 8.5C11.8582 8.5 12.25 8.94781 12.25 9.5C12.25 10.0522 11.8582 10.5 11.375 10.5Z"
fill="white"
/>
</g>
<defs>
2021-08-08 11:34:44 +00:00
<clipPath id="clip123">
2021-08-01 18:29:41 +00:00
<rect width="14" height="16" fill="white" />
</clipPath>
</defs>
</svg>
Balance
</button>
</div>
2021-08-18 20:20:45 +00:00
<div v-if="canSimulate" class="fixed bottom-0 left-0 ml-10 mb-16">
<button
v-if="forkId"
@click="stopSimulation"
class="px-9 h-[56px] bg-primary-blue-dark hover:bg-primary-blue-hover text-white rounded-[28px] text-lg font-semibold shadow flex items-center"
>
Stop Simulation
</button>
<button
v-else
@click="startSimulation"
class="px-9 h-[56px] bg-primary-blue-dark hover:bg-primary-blue-hover text-white rounded-[28px] text-lg font-semibold shadow flex items-center"
>
Start Simulation
</button>
</div>
2021-07-17 21:44:21 +00:00
</div>
</template>
<script>
2021-08-18 20:20:45 +00:00
import { defineComponent, nextTick, onErrorCaptured, onMounted, useContext, useRoute, watch } from "@nuxtjs/composition-api";
2021-07-17 21:52:42 +00:00
import MakerDAOIcon from '~/assets/icons/makerdao.svg?inline'
import CompoundIcon from '~/assets/icons/compound.svg?inline'
import AaveIcon from '~/assets/icons/aave.svg?inline'
2021-07-19 19:35:31 +00:00
import { useWeb3 } from '~/composables/useWeb3'
2021-08-01 18:29:41 +00:00
import { init as initSidebars, useSidebar } from '~/composables/useSidebar'
2021-07-26 18:33:52 +00:00
import { useBackdrop } from '@/composables/useBackdrop'
2021-07-27 21:43:51 +00:00
import { useNetwork } from "~/composables/useNetwork";
2021-08-18 20:20:45 +00:00
import { useTenderly } from "~/composables/useTenderly";
2021-07-26 18:33:52 +00:00
2021-07-17 21:44:21 +00:00
export default defineComponent({
2021-07-17 21:52:42 +00:00
components: {
MakerDAOIcon,
CompoundIcon,
AaveIcon,
2021-07-19 19:35:31 +00:00
},
setup() {
2021-07-27 21:43:51 +00:00
const { active, activate, deactivate, chainId } = useWeb3();
2021-08-14 12:30:55 +00:00
const { activeNetworkId, activeNetwork, checkForNetworkMismatch } = useNetwork();
2021-07-26 18:33:52 +00:00
const { isShown: isBackdropShown, close: closeBackdrop } = useBackdrop()
2021-07-27 21:43:51 +00:00
const { redirect } = useContext()
2021-08-01 18:29:41 +00:00
const { showSidebarBalances } = useSidebar()
2021-08-18 20:20:45 +00:00
const { canSimulate, startSimulation, stopSimulation, forkId } = useTenderly()
2021-07-27 21:43:51 +00:00
const route = useRoute()
2021-07-26 18:33:52 +00:00
watch(isBackdropShown, () => {
if (isBackdropShown.value) {
document.body.classList.add('overflow-hidden')
} else {
document.body.classList.remove('overflow-hidden')
}
})
2021-07-19 19:35:31 +00:00
2021-07-24 23:40:30 +00:00
initSidebars();
2021-07-27 21:43:51 +00:00
// global routes guard
watch(
[activeNetwork, route],
async () => {
await nextTick()
if (route.path === '/') {
return;
}
2021-08-01 18:29:41 +00:00
if (route.value.path.includes(['mainnet', 'polygon']) && route.value.path.includes(activeNetwork.value.id)) {
2021-07-27 21:43:51 +00:00
redirect('/')
}
}, { immediate: true })
watch(chainId, (val) => {
if (val) {
checkForNetworkMismatch()
}
}, { immediate: true })
2021-08-10 16:11:15 +00:00
onErrorCaptured(() => {
return false
})
2021-08-05 17:47:14 +00:00
2021-07-19 19:35:31 +00:00
return {
active,
activate,
deactivate,
2021-07-26 18:33:52 +00:00
isBackdropShown,
closeBackdrop,
2021-08-01 18:29:41 +00:00
showSidebarBalances,
2021-08-14 12:30:55 +00:00
activeNetworkId,
2021-08-18 20:20:45 +00:00
startSimulation,
forkId,
stopSimulation,
canSimulate,
2021-07-19 19:35:31 +00:00
}
2021-07-17 21:52:42 +00:00
}
2021-07-17 21:44:21 +00:00
})
2021-07-24 23:40:30 +00:00
</script>
<style>
:root {
--min-width-app: 320px;
2021-07-26 22:19:20 +00:00
--width-sidebar-context: 385px;
2021-07-24 23:40:30 +00:00
--width-container-main: 1016px;
--height-navbar: 64px;
--height-top-banner: 32px;
@screen sm {
--height-navbar: 82px;
}
}
</style>