28 lines
1.1 KiB
Vue
28 lines
1.1 KiB
Vue
<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 building screen's own sections, like the tabs under a Die Stämme building header. -->
|
|
<template>
|
|
<nav class="flex flex-wrap gap-1 border-b-2 border-wood-700" role="tablist">
|
|
<button
|
|
v-for="tab in tabs"
|
|
:key="tab.key"
|
|
type="button"
|
|
role="tab"
|
|
:aria-selected="current === tab.key"
|
|
class="-mb-0.5 inline-flex items-center gap-1.5 rounded-t-sm border-2 border-b-0 px-3 py-1.5 text-sm font-semibold"
|
|
:class="current === tab.key ? 'border-wood-700 bg-parchment-50 text-blood-700' : 'border-transparent text-wood-800 hover:text-blood-700'"
|
|
@click="current = tab.key"
|
|
>
|
|
<IconUi v-if="tab.icon" :name="tab.icon" class="size-4" />
|
|
{{ tab.label }}
|
|
<span v-if="tab.count" class="rounded-sm bg-blood-700 px-1.5 text-xs text-parchment-50 tabular-nums">{{ tab.count }}</span>
|
|
</button>
|
|
</nav>
|
|
</template>
|