🎨 Make date selector modular

This commit is contained in:
2023-06-18 18:18:26 +02:00
parent 3a8ce74f53
commit 211d1d2b2f
2 changed files with 28 additions and 8 deletions

View File

@@ -1,5 +1,6 @@
<script setup>
import { selectedDate, selectedDay, changeDay, changeDate } from "@/store";
defineProps(["selectedDate", "selectedDay"]);
defineEmits(["changeDay", "changeDate"]);
import { ArrowLeftIcon, ArrowRightIcon } from "lucide-vue-next";
import dayjs from "dayjs";
import { getDateSkippingWeekend } from "@/util";
@@ -17,15 +18,19 @@ const dayNames = [
<template>
<div class="selector">
<ArrowLeftIcon @click="changeDay--" />
<ArrowLeftIcon @click="$emit('changeDay', -1)" />
<span
class="day"
@click="changeDate = getDateSkippingWeekend(dayjs().toDate(), true)"
@click="
$emit('changeDate', getDateSkippingWeekend(dayjs().toDate(), true))
"
>
{{ $t(dayNames[selectedDay + 1]) }},
{{ dayjs(selectedDate).format("DD.MM.YYYY") }}
{{ $t(dayNames[selectedDay + 1])
}}{{
selectedDate ? ", " + dayjs(selectedDate).format("DD.MM.YYYY") : ""
}}
</span>
<ArrowRightIcon @click="changeDay++" />
<ArrowRightIcon @click="$emit('changeDay', +1)" />
</div>
</template>