IntelliClass_FE/components/nav/Tertiary.vue
Timothy Yin 49b9e97ee8
Some checks failed
CI / test (push) Failing after 1m12s
CI / lint (push) Failing after 14m36s
feat: 完成教学设计模块(除了课程图谱),添加了炫酷的思考中动画
2025-04-27 18:51:40 +08:00

53 lines
1.2 KiB
Vue

<script lang="ts">
export interface NavTertiaryItem {
label: string
to?: string
component?: string | Component
props?: Record<string, unknown>
disabled?: boolean
}
</script>
<script lang="ts" setup>
const props = withDefaults(
defineProps<{
navs: NavTertiaryItem[]
modelValue?: number
}>(),
{
modelValue: 0,
},
)
const emit = defineEmits<{
(e: 'update:modelValue', idx: number): void
}>()
const isActiveItem = (idx: number) => {
return props.modelValue === idx
}
const onClickItem = (idx: number) => {
if (props.navs[idx].disabled) return
emit('update:modelValue', idx)
}
</script>
<template>
<div class="flex flex-col gap-2">
<div
v-for="(nav, i) in navs"
:key="i"
class="flex justify-center items-center gap-2 p-2.5 rounded-sm cursor-pointer select-none transition-colors duration-75"
:class="`${isActiveItem(i) ? 'bg-primary text-primary-foreground' : 'bg-accent text-foreground'} ${nav.disabled ? 'cursor-not-allowed text-foreground/40' : ''}`"
@click="onClickItem(i)"
>
<span class="text-sm font-medium">
{{ nav.label }}
</span>
</div>
</div>
</template>
<style scoped></style>