mirror of
https://github.com/fawney19/Aether.git
synced 2026-01-08 02:32:27 +08:00
Initial commit
This commit is contained in:
35
frontend/src/components/ui/tabs.vue
Normal file
35
frontend/src/components/ui/tabs.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<template>
|
||||
<div class="tabs-root">
|
||||
<slot />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { provide, ref, watch } from 'vue'
|
||||
|
||||
interface Props {
|
||||
defaultValue?: string
|
||||
modelValue?: string
|
||||
}
|
||||
|
||||
const props = defineProps<Props>()
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [value: string]
|
||||
}>()
|
||||
|
||||
const activeTab = ref(props.modelValue || props.defaultValue || '')
|
||||
|
||||
watch(() => props.modelValue, (newValue) => {
|
||||
if (newValue !== undefined) {
|
||||
activeTab.value = newValue
|
||||
}
|
||||
})
|
||||
|
||||
const setActiveTab = (value: string) => {
|
||||
activeTab.value = value
|
||||
emit('update:modelValue', value)
|
||||
}
|
||||
|
||||
provide('activeTab', activeTab)
|
||||
provide('setActiveTab', setActiveTab)
|
||||
</script>
|
||||
Reference in New Issue
Block a user