11<script setup lang="ts">
2- import type { BcHeaderMegaMenu } from ' #build/components'
3- import { useLatestStateStore } from ' ~/stores/useLatestStateStore'
2+ import type { BcNavigationMenu } from ' #build/components'
43import {
54 mobileHeaderThreshold , smallHeaderThreshold ,
65} from ' ~/types/header'
76
8- defineProps <{
9- isHomePage: boolean ,
10- minimalist: boolean ,
11- }>()
12- const latestStateStore = useLatestStateStore ()
13- const { latestState } = storeToRefs (latestStateStore )
147const {
158 getEpochFromSlot,
169 networkInfo,
10+ secondsPerSlot,
1711} = useNetwork ()
12+
13+ const { counter } = useInterval (secondsPerSlot )
14+
15+ // Todo: decide if this is an antipattern or we should rather use watcher with callOnce
16+ useApi (' /api/latest-state' , {
17+ watch: [ counter ],
18+ })
19+
1820const {
1921 doLogout,
2022 isLoggedIn,
@@ -32,12 +34,13 @@ const { promoCode } = usePromoCode()
3234const isSmallScreen = computed (() => width .value < smallHeaderThreshold )
3335const isMobileScreen = computed (() => width .value < mobileHeaderThreshold )
3436
35- const showInDevelopment = Boolean (useRuntimeConfig ().public .showInDevelopment )
37+ const config = useRuntimeConfig ()
38+ const showInDevelopment = Boolean (config .public .showInDevelopment )
3639const hideInDevelopmentClass = showInDevelopment
3740 ? ' '
3841 : ' hide-because-it-is-unfinished' // TODO: once the searchbar is enabled in production, delete this line
3942
40- const megaMenu = ref <null | typeof BcHeaderMegaMenu >(null )
43+ const megaMenu = ref <null | typeof BcNavigationMenu >(null )
4144
4245const hasExchangeRates = computed (() => exchangeRates .value .length > 1 )
4346
@@ -55,11 +58,8 @@ const currentRate = computed(() => {
5558 })
5659})
5760
58- const currentEpoch = computed (() =>
59- latestState .value ?.current_slot !== undefined
60- ? getEpochFromSlot (latestState .value .current_slot )
61- : undefined ,
62- )
61+ const currentSlot = useCurrentSlot ()
62+ const currentEpoch = computed (() => getEpochFromSlot (currentSlot .value ))
6363
6464const toggleMegaMenu = (evt : Event ) => {
6565 megaMenu .value ?.toggleMegaMenu (evt )
@@ -70,7 +70,7 @@ const isMobileMegaMenuOpen = computed(() => megaMenu.value?.isMobileMenuOpen)
7070type UserMenuItem = { command: () => Promise <void >, label: string }
7171const userMenu: UserMenuItem [] = [
7272 {
73- command : async () => { await navigateTo (' /user/settings' ) },
73+ command : async () => { await navigateTo (` ${ v1Domain } /user/settings` , { external: true } ) },
7474 label: $t (' header.settings' ),
7575 },
7676 {
@@ -81,41 +81,31 @@ const userMenu: UserMenuItem[] = [
8181const handleUserMenuSelect = async (value : UserMenuItem ) => {
8282 await value .command ?.()
8383}
84+ const v1Domain = useV1Domain ()
8485 </script >
8586
8687<template >
8788 <div
88- v-if =" minimalist"
89- class =" minimalist"
90- >
91- <div class =" top-background" />
92- <div class =" rows" >
93- <BcHeaderLogo layout-adaptability =" low" />
94- </div >
95- </div >
96-
97- <div
98- v-else
9989 class =" complete"
10090 :class =" hideInDevelopmentClass"
10191 >
10292 <div class =" top-background" />
10393 <div class =" rows" >
10494 <div class =" grid-cell blockchain-info" >
105- <span v-if =" latestState?.current_slot " ><span >{{ $t("header.slot") }}</span >:
95+ <span v-if =" currentSlot " ><span >{{ $t("header.slot") }}</span >:
10696 <BcLink
107- :to =" `/slot/${latestState.current_slot }`"
97+ :to =" `${v1Domain} /slot/${currentSlot }`"
10898 :disabled =" !showInDevelopment || null"
10999 >
110100 <BcFormatNumber
111101 class =" bold"
112- :value =" latestState.current_slot "
102+ :value =" currentSlot "
113103 />
114104 </BcLink >
115105 </span >
116- <span v-if =" currentEpoch !== undefined " ><span >{{ $t("header.epoch") }}</span >:
106+ <span v-if =" currentEpoch" ><span >{{ $t("header.epoch") }}</span >:
117107 <BcLink
118- :to =" `/epoch/${currentEpoch}`"
108+ :to =" `${v1Domain} /epoch/${currentEpoch}`"
119109 :disabled =" !showInDevelopment || null"
120110 >
121111 <BcFormatNumber
@@ -191,7 +181,7 @@ const handleUserMenuSelect = async (value: UserMenuItem) => {
191181 </div >
192182
193183 <div class =" grid-cell explorer-info" >
194- <BcHeaderLogo layout-adaptability =" high" />
184+ <BcNavigationLogo layout-adaptability =" high" />
195185 <span class =" variant" >
196186 v2 beta |
197187 <span class =" mobile" >{{ networkInfo.shortName }}</span >
@@ -200,7 +190,7 @@ const handleUserMenuSelect = async (value: UserMenuItem) => {
200190 </div >
201191
202192 <div class =" grid-cell mega-menu" >
203- <BcHeaderMegaMenu ref =" megaMenu" />
193+ <BcNavigationMenu ref =" megaMenu" />
204194 <div
205195 v-if =" isMobileMegaMenuOpen"
206196 class =" decoration"
@@ -217,7 +207,11 @@ const handleUserMenuSelect = async (value: UserMenuItem) => {
217207$mobileHeaderThreshold : 600px ;
218208$smallHeaderThreshold : 1024px ;
219209
220- @mixin common {
210+ .complete {
211+ top : -1px ; // needed for some reason to perfectly match Figma
212+ border-bottom : 1px solid var (--container-border-color );
213+ background-color : var (--container-background );
214+
221215 position : relative ;
222216 display : flex ;
223217 width : 100% ;
@@ -231,23 +225,7 @@ $smallHeaderThreshold: 1024px;
231225 .rows {
232226 width : var (--content-width );
233227 }
234- }
235-
236- .minimalist {
237- color : var (--header-top-font-color );
238- @include common ();
239- @media (max-width : $mobileHeaderThreshold ) {
240- .top-background {
241- height : 36px ;
242- }
243- }
244- }
245228
246- .complete {
247- top : -1px ; // needed for some reason to perfectly match Figma
248- border-bottom : 1px solid var (--container-border-color );
249- background-color : var (--container-background );
250- @include common ();
251229 & .hide-because-it-is-unfinished {
252230 // TODO: once the searchbar is enabled in production, delete this block (because border-bottom is always needed, due to the fact that the lower header is always visible (it contains the search bar when the screeen is narrow, otherwise the logo and mega menu))
253231 @media (max-width : $smallHeaderThreshold ) {
0 commit comments