2022-12-11 19:52:36 +09:00
|
|
|
<script setup lang="ts">
|
|
|
|
import type { RouteLocationRaw } from 'vue-router'
|
|
|
|
|
2023-01-25 03:52:48 +09:00
|
|
|
export interface CommonRouteTabOption {
|
|
|
|
to: RouteLocationRaw
|
|
|
|
display: string
|
|
|
|
disabled?: boolean
|
|
|
|
name?: string
|
|
|
|
icon?: string
|
|
|
|
}
|
2022-12-14 06:01:25 +09:00
|
|
|
const { options, command, replace, preventScrollTop = false } = $defineProps<{
|
2023-01-25 03:52:48 +09:00
|
|
|
options: CommonRouteTabOption[]
|
2022-12-11 19:52:36 +09:00
|
|
|
command?: boolean
|
|
|
|
replace?: boolean
|
2022-12-14 06:01:25 +09:00
|
|
|
preventScrollTop?: boolean
|
2022-12-11 19:52:36 +09:00
|
|
|
}>()
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
useCommands(() => command
|
|
|
|
? options.map(tab => ({
|
|
|
|
scope: 'Tabs',
|
|
|
|
|
|
|
|
name: tab.display,
|
|
|
|
icon: tab.icon ?? 'i-ri:file-list-2-line',
|
|
|
|
onActivate: () => router.replace(tab.to),
|
|
|
|
}))
|
|
|
|
: [])
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div flex w-full items-center lg:text-lg of-x-auto scrollbar-hide>
|
2022-12-26 14:39:18 +09:00
|
|
|
<template
|
2022-12-11 19:52:36 +09:00
|
|
|
v-for="(option, index) in options"
|
|
|
|
:key="option?.name || index"
|
|
|
|
>
|
2022-12-26 14:39:18 +09:00
|
|
|
<NuxtLink
|
|
|
|
v-if="!option.disabled"
|
|
|
|
:to="option.to"
|
|
|
|
:replace="replace"
|
|
|
|
relative flex flex-auto cursor-pointer sm:px6 px2 rounded transition-all
|
|
|
|
tabindex="1"
|
|
|
|
hover:bg-active transition-100
|
2023-01-03 20:53:40 +09:00
|
|
|
exact-active-class="children:(text-secondary !border-primary !op100 !text-base)"
|
2022-12-26 14:39:18 +09:00
|
|
|
@click="!preventScrollTop && $scrollToTop()"
|
|
|
|
>
|
2023-01-11 23:50:47 +09:00
|
|
|
<span ws-nowrap mxa sm:px2 sm:py3 xl:pb4 xl:pt5 py2 text-center border-b-3 text-secondary-light hover:text-secondary border-transparent>{{ option.display || ' ' }}</span>
|
2022-12-26 14:39:18 +09:00
|
|
|
</NuxtLink>
|
2023-01-06 19:52:58 +09:00
|
|
|
<div v-else flex flex-auto sm:px6 px2 xl:pb4 xl:pt5>
|
2022-12-26 14:39:18 +09:00
|
|
|
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center text-secondary-light op50>{{ option.display }}</span>
|
|
|
|
</div>
|
|
|
|
</template>
|
2022-12-11 19:52:36 +09:00
|
|
|
</div>
|
|
|
|
</template>
|