1
0
Fork 1
mirror of https://github.com/elk-zone/elk.git synced 2024-11-02 23:19:57 +00:00
elk/components/common/CommonRouteTabs.vue

46 lines
1.2 KiB
Vue
Raw Normal View History

2022-12-11 10:52:36 +00:00
<script setup lang="ts">
import type { RouteLocationRaw } from 'vue-router'
2022-12-13 21:01:25 +00:00
const { options, command, replace, preventScrollTop = false } = $defineProps<{
2022-12-11 10:52:36 +00:00
options: {
to: RouteLocationRaw
display: string
name?: string
icon?: string
}[]
command?: boolean
replace?: boolean
2022-12-13 21:01:25 +00:00
preventScrollTop?: boolean
2022-12-11 10:52:36 +00: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>
<NuxtLink
2022-12-11 10:52:36 +00:00
v-for="(option, index) in options"
:key="option?.name || index"
:to="option.to"
:replace="replace"
relative flex flex-auto cursor-pointer sm:px6 px2 rounded transition-all
tabindex="1"
hover:bg-active transition-100
exact-active-class="children:(font-bold !border-primary !op100)"
@click="!preventScrollTop && $scrollToTop()"
2022-12-11 10:52:36 +00:00
>
<span ws-nowrap mxa sm:px2 sm:py3 py2 text-center border-b-3 op50 hover:op70 border-transparent>{{ option.display }}</span>
</NuxtLink>
2022-12-11 10:52:36 +00:00
</div>
</template>