-
-
Notifications
You must be signed in to change notification settings - Fork 353
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4863 from kodadot/feat/explorer-chain-selector
feat: network selector on explorer
- Loading branch information
Showing
4 changed files
with
86 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<template> | ||
<div> | ||
<NeoDropdown position="bottom-right" @active-change="isActive = $event"> | ||
<NeoButton | ||
:label="`Network: ${selected.text}`" | ||
:icon="isActive ? 'caret-up' : 'caret-down'" /> | ||
|
||
<template #items> | ||
<NeoDropdownItem | ||
v-for="chain in availableChains" | ||
:key="chain.value" | ||
:active="route.params.prefix === chain.value" | ||
@click.native="onSwitchChain(chain.value)"> | ||
{{ chain.text }} | ||
</NeoDropdownItem> | ||
</template> | ||
</NeoDropdown> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { NeoButton, NeoDropdown, NeoDropdownItem } from '@kodadot1/brick' | ||
const route = useRoute() | ||
const router = useRouter() | ||
const { $store } = useNuxtApp() | ||
const { availableChains } = useChain() | ||
const isActive = ref(false) | ||
const selected = computed(() => | ||
availableChains.value.find((chain) => chain.value === route.params.prefix) | ||
) | ||
function onSwitchChain(chain) { | ||
$store.dispatch('setUrlPrefix', chain) | ||
router.push({ | ||
params: { | ||
prefix: chain, | ||
}, | ||
query: { | ||
page: '1', | ||
sort: route.query.sort, | ||
}, | ||
}) | ||
} | ||
</script> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters