assembly/layouts/default.vue

109 lines
2.4 KiB
Vue
Raw Normal View History

2021-07-17 21:44:21 +00:00
<template>
2021-07-26 18:33:52 +00:00
<div
class="min-h-screen overflow-hidden font-sans antialiased text-primary-black"
>
2021-07-17 21:44:21 +00:00
<Navbar />
2021-07-24 23:40:30 +00:00
<div class="max-w-6xl mx-auto py-12 overflow-x-hidden ">
2021-07-21 20:53:46 +00:00
<div>
2021-07-17 21:44:21 +00:00
<Nuxt />
</div>
</div>
2021-07-26 18:33:52 +00:00
<Backdrop :show="isBackdropShown" @click="closeBackdrop" />
2021-07-24 23:40:30 +00:00
<SidebarContext class="grid-sidebar-context" />
2021-07-27 21:43:51 +00:00
<Modal />
2021-07-24 23:40:30 +00:00
<NotificationBar />
2021-07-17 21:44:21 +00:00
</div>
</template>
<script>
2021-07-27 21:43:51 +00:00
import { defineComponent, nextTick, 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-07-24 23:40:30 +00:00
import { init as initSidebars } 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-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();
const { 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()
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;
}
if (!route.value.path.includes(activeNetwork.value.id)) {
redirect('/')
}
}, { immediate: true })
watch(chainId, (val) => {
if (val) {
checkForNetworkMismatch()
}
}, { immediate: true })
2021-07-19 19:35:31 +00:00
return {
active,
activate,
deactivate,
2021-07-26 18:33:52 +00:00
isBackdropShown,
closeBackdrop,
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;
}
}
.grid-sidebar-context {
grid-row-start: navbar;
grid-row-end: main;
@screen xl {
grid-area: sidebar-context;
}
}
</style>