2022-11-21 00:38:52 +03:00
|
|
|
<script setup lang="ts">
|
|
|
|
defineProps<{
|
|
|
|
options: string[]
|
|
|
|
}>()
|
2022-11-23 11:08:49 +03:00
|
|
|
|
|
|
|
const { modelValue } = defineModel<{
|
|
|
|
modelValue: string
|
|
|
|
}>()
|
2022-11-21 00:38:52 +03:00
|
|
|
|
|
|
|
function toValidName(otpion: string) {
|
|
|
|
return otpion.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-')
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-11-26 20:36:23 +03:00
|
|
|
<div flex w-full items-center lg:text-lg>
|
2022-11-21 00:38:52 +03:00
|
|
|
<template v-for="option in options" :key="option">
|
|
|
|
<input
|
2022-11-23 11:08:49 +03:00
|
|
|
:id="`tab-${toValidName(option)}`"
|
|
|
|
:checked="modelValue === option"
|
|
|
|
:value="option"
|
|
|
|
type="radio"
|
|
|
|
name="tabs"
|
|
|
|
display="none"
|
|
|
|
@change="modelValue = option"
|
|
|
|
><label
|
2022-11-26 20:36:23 +03:00
|
|
|
flex flex-auto cursor-pointer p3 m1 rounded transition-all
|
2022-11-23 11:08:49 +03:00
|
|
|
:for="`tab-${toValidName(option)}`"
|
|
|
|
tabindex="1"
|
2022-11-23 17:39:48 +03:00
|
|
|
hover:bg-active transition-100
|
2022-11-23 11:08:49 +03:00
|
|
|
@keypress.enter="modelValue = option"
|
|
|
|
><span
|
2022-11-26 20:36:23 +03:00
|
|
|
mxa px2 text-center
|
2022-11-23 11:08:49 +03:00
|
|
|
:class="modelValue === option ? 'font-bold border-b-3 border-primary' : 'op50 hover:op50'"
|
|
|
|
>{{ option }}</span>
|
|
|
|
</label>
|
2022-11-21 00:38:52 +03:00
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</template>
|