docs/.vitepress/theme/components/tabs/PluginTabsTab.vue
36 lines · 895 bytes
1<script setup lang="ts">
2import { computed } from 'vue'
3import { useIsPrint } from './composables'
4import { useTabsRenderAll, useTabsSingleState } from './state'
5
6defineOptions({ name: 'PluginTabsTab' })
7
8const props = defineProps<{
9 anchor: string
10 label: string
11}>()
12
13const { selected, uid } = useTabsSingleState()
14const isPrint = useIsPrint()
15const renderAll = useTabsRenderAll()
16const isActive = computed(() =>
17 selected.value === props.label || Boolean(isPrint.value) || renderAll
18)
19const panelId = computed(() => `panel-${props.anchor}-${uid}`)
20const buttonId = computed(() => `tab-${props.anchor}-${uid}`)
21</script>
22
23<template>
24 <div
25 v-if="isActive"
26 :id="panelId"
27 class="plugin-tabs--content"
28 role="tabpanel"
29 tabindex="0"
30 :data-tab-anchor="anchor"
31 :aria-labelledby="buttonId"
32 :data-is-print="isPrint || undefined"
33 >
34 <slot />
35 </div>
36</template>