Separated navigation and selectedDate
This commit is contained in:
@@ -4,13 +4,23 @@ import CalendarMenuToday from './CalendarMenuToday.vue'
|
||||
import CalendarMenuNav from './CalendarMenuNav.vue'
|
||||
import CalendarSwitch from './CalendarSwitch.vue'
|
||||
import CalendarSearch from './search/CalendarSearch.vue'
|
||||
import { substractToDate } from '@/models/Date'
|
||||
import { computed } from 'vue'
|
||||
import { storeToRefs } from 'pinia'
|
||||
import { PhMapPin } from '@phosphor-icons/vue'
|
||||
|
||||
const { currentDate } = useCalendar()
|
||||
const { defaultDate, getFormattedDateTitle, currentDate } = useCalendar()
|
||||
const { currentLeimDate, selectedDate } = storeToRefs(useCalendar())
|
||||
|
||||
const mainDateTitle = computed(() => getFormattedDateTitle(selectedDate.value, true))
|
||||
|
||||
const dateDifference = computed(() => substractToDate(defaultDate, currentLeimDate.value))
|
||||
const formattedDateDifference = computed(() => getFormattedDateTitle(dateDifference.value, true))
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<header class="py-4 border-slate-700 border-b-[1px]">
|
||||
<div class="container">
|
||||
<header class="border-slate-700 border-b-[1px]">
|
||||
<div class="pt-4 container">
|
||||
<div class="grid md:grid-cols-12 items-center">
|
||||
<div class="md:col-span-9">
|
||||
<div class="flex items-center gap-6">
|
||||
@@ -25,9 +35,12 @@ const { currentDate } = useCalendar()
|
||||
<CalendarMenuNav />
|
||||
</li>
|
||||
</menu>
|
||||
<h1 class="text-2xl font-bold">
|
||||
{{ currentDate.currentDateTitle }}
|
||||
</h1>
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold flex items-center gap-1">
|
||||
<PhMapPin size="26" weight="bold" /> {{ mainDateTitle }}
|
||||
</h1>
|
||||
<h2 class="text-lg italic opacity-75">Placeholder</h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="md:col-span-3 flex justify-end">
|
||||
@@ -35,5 +48,12 @@ const { currentDate } = useCalendar()
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="flex">
|
||||
<div class="px-4 py-2 border-slate-700 border-x-[1px] border-t-[1px] rounded-sm">
|
||||
<span class="text-sm font-bold">{{ currentDate.currentDateTitle }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
</template>
|
||||
|
||||
@@ -11,7 +11,8 @@ const props = defineProps<{
|
||||
faded?: boolean
|
||||
}>()
|
||||
|
||||
const { defaultDate } = useCalendar()
|
||||
const { defaultDate, selectDate } = useCalendar()
|
||||
const { selectedDate } = storeToRefs(useCalendar())
|
||||
const { currentEvents } = storeToRefs(useCalendarEvents())
|
||||
|
||||
const eventsForTheDay = computed(() => {
|
||||
@@ -23,6 +24,10 @@ const eventsForTheDay = computed(() => {
|
||||
const isDefaultDate = computed(() => {
|
||||
return areDatesIdentical(props.date, defaultDate)
|
||||
})
|
||||
|
||||
const isSelectedDate = computed(() => {
|
||||
return areDatesIdentical(props.date, selectedDate.value)
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -35,22 +40,29 @@ const isDefaultDate = computed(() => {
|
||||
>
|
||||
<div class="text-center">
|
||||
<span
|
||||
class="inline-flex w-8 h-8 aspect-square items-center justify-center rounded-full font-bold"
|
||||
:class="{ 'bg-slate-800': isDefaultDate }"
|
||||
>{{ date.day }}</span
|
||||
class="inline-flex w-8 h-8 aspect-square items-center justify-center rounded-full font-bold transition-colors"
|
||||
:class="{
|
||||
'bg-slate-800': isDefaultDate && !isSelectedDate,
|
||||
'text-white bg-blue-500': isSelectedDate
|
||||
}"
|
||||
>
|
||||
{{ date.day }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ul
|
||||
v-if="eventsForTheDay.length > 0"
|
||||
class="absolute top-12 bottom-2 inset-x-2 grid auto-rows-min gap-1"
|
||||
class="absolute top-12 bottom-2 inset-x-2 grid auto-rows-min gap-1 z-10 pointer-events-none transition-opacity"
|
||||
:class="{
|
||||
'opacity-40': props.faded
|
||||
'opacity-40': props.faded && !isSelectedDate
|
||||
}"
|
||||
>
|
||||
<li v-for="event in eventsForTheDay" :key="event.title" class="grid">
|
||||
<li v-for="event in eventsForTheDay" :key="event.title" class="grid pointer-events-auto">
|
||||
<CalendarEvent :event />
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<button class="absolute inset-0 w-full h-full cursor-default z-0" @click="selectDate(date)" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user