多维表格
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.7 KiB

<script lang="ts" setup>
10 months ago
import { useCalendarViewStoreOrThrow } from '#imports'
10 months ago
const { changeCalendarView, activeCalendarView } = useCalendarViewStoreOrThrow()
10 months ago
const highlightStyle = ref({ left: '0px' })
const setActiveCalendarMode = (mode: 'day' | 'week' | 'month' | 'year', event: MouseEvent) => {
10 months ago
changeCalendarView(mode)
const tabElement = event.target as HTMLElement
highlightStyle.value.left = `${tabElement.offsetLeft}px`
}
onMounted(() => {
const activeTab = document.querySelector('.nc-calendar-mode-tab .tab.active') as HTMLElement
if (activeTab) {
highlightStyle.value.left = `${activeTab.offsetLeft}px`
}
})
</script>
<template>
<div class="flex flex-row relative p-1 mx-3 mt-3 mb-3 bg-gray-100 rounded-lg gap-x-0.5 nc-calendar-mode-tab">
<div :style="highlightStyle" class="highlight"></div>
10 months ago
<div
v-for="mode in ['day', 'week', 'month', 'year']"
:key="mode"
:class="{ active: activeCalendarView === mode }"
class="tab"
@click="setActiveCalendarMode(mode, $event)"
>
10 months ago
<div class="tab-title nc-tab">{{ $t(`objects.${mode}`) }}</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.highlight {
@apply absolute h-7.5 w-20 shadow bg-white rounded-lg transition-all duration-300;
z-index: 0;
}
.tab {
@apply flex items-center h-7.5 w-20 z-10 justify-center px-2 py-1 rounded-lg gap-x-1.5 text-gray-500 hover:text-black cursor-pointer transition-all duration-300 select-none;
}
.tab .tab-title {
@apply min-w-0 pointer-events-none;
word-break: 'keep-all';
white-space: 'nowrap';
display: 'inline';
line-height: 0.95;
}
.active {
@apply text-black bg-transparent;
}
.nc-calendar-mode-tab {
@apply -ml-120 relative;
}
10 months ago
</style>