game-village-politics-frontend/app/components/ui/SubTabs.vue

28 lines
1.1 KiB
Vue
Raw Permalink Normal View History

<script setup lang="ts" generic="K extends string">
import type { UiIconName } from '~/components/icon/Ui.vue'
defineProps<{ tabs: { key: K; label: string; icon?: UiIconName; count?: number }[] }>()
/** The open tab. */
const current = defineModel<K>({ required: true })
</script>
<!-- A screen's own sections as a row of small boxes, like the tabs under a Die Stämme building header. -->
<template>
<nav class="flex flex-wrap gap-0.5 text-sm" role="tablist">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
role="tab"
:aria-selected="current === tab.key"
class="inline-flex items-center gap-1 border border-wood-800 px-2 py-0.5 font-semibold"
:class="current === tab.key ? 'bg-wood-800 text-gold-400' : 'bg-parchment-300 text-wood-950 hover:bg-parchment-200'"
@click="current = tab.key"
>
<IconUi v-if="tab.icon" :name="tab.icon" class="size-3.5" />
{{ tab.label }}
<span v-if="tab.count" class="font-bold text-blood-700 tabular-nums" :class="current === tab.key ? 'text-gold-400' : ''">({{ tab.count }})</span>
</button>
</nav>
</template>