108 lines
3.4 KiB
Vue
108 lines
3.4 KiB
Vue
<script setup lang="ts">
|
|
import {
|
|
iconCalendar,
|
|
iconChart,
|
|
iconCircleInformation,
|
|
iconFlash,
|
|
iconHome,
|
|
} from '@sit-onyx/icons'
|
|
|
|
const route = useRoute()
|
|
const config = useRuntimeConfig()
|
|
const usingMock = computed(() => {
|
|
const value = config.public.useMock
|
|
return value === true || value === '1' || value === 'true'
|
|
})
|
|
|
|
const isNewShell = computed(
|
|
() =>
|
|
route.path === '/' ||
|
|
route.path.startsWith('/sensors') ||
|
|
route.path.startsWith('/playground') ||
|
|
route.path.startsWith('/use-cases'),
|
|
)
|
|
const isCool = computed(() => route.path.startsWith('/cool'))
|
|
const isDarkPresentation = computed(
|
|
() => route.path === '/stage' || route.path === '/live' || route.path === '/cool/stage',
|
|
)
|
|
const isStandalone = computed(() => isCool.value || isDarkPresentation.value)
|
|
const bodyClass = computed(() =>
|
|
isDarkPresentation.value ? 'pc-presentation' : isCool.value ? 'pc-cool-presentation' : '',
|
|
)
|
|
|
|
const navigation = [
|
|
{ to: '/', label: 'Now', icon: iconHome },
|
|
{ to: '/forecast', label: 'Forecast', icon: iconChart },
|
|
{ to: '/plan', label: 'Plan', icon: iconCalendar },
|
|
{ to: '/simulate', label: 'Simulate', icon: iconFlash },
|
|
{ to: '/about', label: 'About', icon: iconCircleInformation },
|
|
]
|
|
|
|
const hiddenPageLabels: Record<string, string> = { '/control': 'Control' }
|
|
const activeLabel = computed(
|
|
() => navigation.find((item) => item.to === route.path)?.label ?? hiddenPageLabels[route.path] ?? 'PulseCast',
|
|
)
|
|
|
|
useHead(() => ({
|
|
bodyAttrs: { class: bodyClass.value },
|
|
}))
|
|
|
|
// Onyx renders its overflow navigation as a `menubar` whose direct child is a
|
|
// div, which fails the required-children rule. The list is site navigation,
|
|
// not an application menu, so remove the menu role rather than fake menuitems.
|
|
let navRoleObserver: MutationObserver | undefined
|
|
function fixNavAria() {
|
|
for (const list of document.querySelectorAll('.onyx-more-list[role="menubar"]')) {
|
|
list.setAttribute('role', 'none')
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
fixNavAria()
|
|
navRoleObserver = new MutationObserver(fixNavAria)
|
|
navRoleObserver.observe(document.body, { childList: true, subtree: true })
|
|
})
|
|
onBeforeUnmount(() => navRoleObserver?.disconnect())
|
|
</script>
|
|
|
|
<template>
|
|
<NuxtLayout v-if="isNewShell">
|
|
<NuxtPage />
|
|
</NuxtLayout>
|
|
|
|
<NuxtPage v-else-if="isStandalone" />
|
|
|
|
<OnyxAppLayout v-else>
|
|
<template #navBar>
|
|
<OnyxNavBar app-name="PulseCast" logo-url="/logo.svg" mobile="sm">
|
|
<OnyxUnstableNavButton
|
|
v-for="item in navigation"
|
|
:key="item.to"
|
|
:link="item.to"
|
|
:label="item.label"
|
|
:icon="item.icon"
|
|
/>
|
|
<template #contextArea>
|
|
<NuxtLink class="pc-present" to="/stage">Stage</NuxtLink>
|
|
<NuxtLink class="pc-present" to="/live">Live</NuxtLink>
|
|
</template>
|
|
<template #mobileActivePage>{{ activeLabel }}</template>
|
|
</OnyxNavBar>
|
|
</template>
|
|
|
|
<OnyxPageLayout>
|
|
<NuxtPage />
|
|
<template #footer>
|
|
<footer class="app-footer">
|
|
<span><strong>PulseCast</strong> — staff the pulse, not the noise.</span>
|
|
<span class="pc-small">
|
|
Decision support, not an optimizer.
|
|
<NuxtLink to="/about">Method & limits</NuxtLink> ·
|
|
<NuxtLink to="/cool">Cool City public module</NuxtLink>
|
|
<template v-if="usingMock"> · demo data</template>
|
|
</span>
|
|
</footer>
|
|
</template>
|
|
</OnyxPageLayout>
|
|
</OnyxAppLayout>
|
|
</template>
|