game-village-politics-frontend/app/components/game/TabBar.vue

27 lines
1.1 KiB
Vue

<script setup lang="ts">
const props = defineProps<{ villageId: number }>()
const route = useRoute()
const base = computed(() => `/village/${props.villageId}`)
const isActive = (path: string) => route.path === `${base.value}${path}`
</script>
<!-- On phones the village's screens sit in a bar at the bottom, in thumb reach. -->
<template>
<nav
class="fixed inset-x-0 bottom-0 z-40 grid grid-cols-5 border-t-2 border-wood-950 bg-wood-900 pb-[env(safe-area-inset-bottom)] md:hidden"
:aria-label="$t('village.screens.label')"
>
<NuxtLink
v-for="s in VILLAGE_SCREENS"
:key="s.name"
:to="`${base}${s.path}`"
class="flex flex-col items-center gap-0.5 px-1 py-1 text-[11px] leading-tight font-semibold"
:class="isActive(s.path) ? 'bg-wood-800 text-gold-400' : 'text-parchment-200'"
:aria-current="isActive(s.path) ? 'page' : undefined"
>
<IconBuilding :type="s.icon" class="size-5" />
<span class="w-full truncate text-center">{{ $t(`village.screens.short.${s.name}`) }}</span>
</NuxtLink>
</nav>
</template>