Files
leim-tools/components/calendar/Calendar.vue
2024-05-13 14:41:28 +02:00

47 lines
1.2 KiB
Vue

<script lang="ts" setup>
import { useCalendar } from '@/stores/CalendarStore'
import { computed, type Component, type ComputedRef } from 'vue'
import CalendarMenu from './CalendarMenu.vue'
import MonthlyLayout from './state/monthly/Layout.vue'
import CenturyLayout from './state/centennially/Layout.vue'
import DecadeLayout from './state/decennially/Layout.vue'
import YearLayout from './state/yearly/Layout.vue'
const { currentConfig } = useCalendar()
const { eventsLoaded, eventsAreLoading } = storeToRefs(useCalendarEvents())
const currentViewComponent: ComputedRef<Component> = computed<Component>(() => {
switch (currentConfig.viewType) {
case 'month':
return MonthlyLayout
case 'year':
return YearLayout
case 'decade':
return DecadeLayout
case 'century':
default:
return CenturyLayout
}
})
</script>
<template>
<div class="h-full grid grid-rows-[auto,1fr]">
<CalendarMenu />
<template v-if="eventsAreLoading">
<div>
Loading
</div>
</template>
<template v-else-if="eventsLoaded">
<component :is="currentViewComponent" v-if="eventsLoaded" />
</template>
</div>
</template>