Add Loader

This commit is contained in:
Georges KABBOUCHI 2021-08-14 15:30:55 +03:00
parent c1c7f0c533
commit 953c9bf11f
2 changed files with 27 additions and 4 deletions

View File

@ -17,7 +17,7 @@ export const networks = [
{ id: "polygon", chainId: 136, name: "Polygon", icon: PolygonSVG } { id: "polygon", chainId: 136, name: "Polygon", icon: PolygonSVG }
]; ];
export const activeNetworkId = ref<Network>(Network.Polygon); export const activeNetworkId = ref<Network>();
export const activeNetwork = computed( export const activeNetwork = computed(
() => networks.find(n => n.id === activeNetworkId.value) || networks[0] () => networks.find(n => n.id === activeNetworkId.value) || networks[0]
); );
@ -113,7 +113,7 @@ export function useNetwork() {
onMounted( () => { onMounted( () => {
//@ts-ignore //@ts-ignore
activeNetworkId.value = localStorage.getItem('network') || "polygon"; activeNetworkId.value = localStorage.getItem('network') || "mainnet";
refreshWeb3() refreshWeb3()
}) })

View File

@ -4,11 +4,33 @@
> >
<div class="min-h-screen flex flex-col"> <div class="min-h-screen flex flex-col">
<Navbar /> <Navbar />
<div class="flex-1 overflow-x-hidden "> <div v-if="activeNetworkId" class="flex-1 overflow-x-hidden ">
<div class="max-w-6xl mx-auto py-12"> <div class="max-w-6xl mx-auto py-12">
<Nuxt /> <Nuxt />
</div> </div>
</div> </div>
<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>
<div class="text-center py-8"> <div class="text-center py-8">
<a <a
class="font-medium text-primary-blue-dark hover:text-primary-blue-hover hover:underline" class="font-medium text-primary-blue-dark hover:text-primary-blue-hover hover:underline"
@ -78,7 +100,7 @@ export default defineComponent({
}, },
setup() { setup() {
const { active, activate, deactivate, chainId } = useWeb3(); const { active, activate, deactivate, chainId } = useWeb3();
const { activeNetwork, checkForNetworkMismatch } = useNetwork(); const { activeNetworkId, activeNetwork, checkForNetworkMismatch } = useNetwork();
const { isShown: isBackdropShown, close: closeBackdrop } = useBackdrop() const { isShown: isBackdropShown, close: closeBackdrop } = useBackdrop()
const { redirect } = useContext() const { redirect } = useContext()
const { showSidebarBalances } = useSidebar() const { showSidebarBalances } = useSidebar()
@ -126,6 +148,7 @@ export default defineComponent({
isBackdropShown, isBackdropShown,
closeBackdrop, closeBackdrop,
showSidebarBalances, showSidebarBalances,
activeNetworkId,
} }
} }