chore: move datepicker popup to real popup component

This commit is contained in:
kolaente 2021-12-29 20:54:01 +01:00
parent 932f1774ec
commit 950fdce111
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -1,28 +1,35 @@
<template>
<a @click="showPopup = !showPopup">
<div class="datepicker-with-range-container">
<popup>
<template #trigger="{toggle}">
<a @click.prevent.stop="toggle()">
{{ $t('task.show.select') }}
</a>
<div class="datepicker-with-range-container">
<transition name="fade">
<div class="datepicker-with-range" v-if="showPopup">
</template>
<template #content="{isOpen}">
<div class="datepicker-with-range" :class="{'is-open': isOpen}">
<div class="selections">
<button @click="setDateRange(datesToday)" :class="{'is-active': dateRange === datesToday}">
{{ $t('task.show.today') }}
</button>
<button @click="setDateRange(datesThisWeek)" :class="{'is-active': dateRange === datesThisWeek}">
<button @click="setDateRange(datesThisWeek)"
:class="{'is-active': dateRange === datesThisWeek}">
{{ $t('task.show.thisWeek') }}
</button>
<button @click="setDateRange(datesNextWeek)" :class="{'is-active': dateRange === datesNextWeek}">
<button @click="setDateRange(datesNextWeek)"
:class="{'is-active': dateRange === datesNextWeek}">
{{ $t('task.show.nextWeek') }}
</button>
<button @click="setDateRange(datesNext7Days)" :class="{'is-active': dateRange === datesNext7Days}">
<button @click="setDateRange(datesNext7Days)"
:class="{'is-active': dateRange === datesNext7Days}">
{{ $t('task.show.next7Days') }}
</button>
<button @click="setDateRange(datesThisMonth)" :class="{'is-active': dateRange === datesThisMonth}">
<button @click="setDateRange(datesThisMonth)"
:class="{'is-active': dateRange === datesThisMonth}">
{{ $t('task.show.thisMonth') }}
</button>
<button @click="setDateRange(datesNextMonth)" :class="{'is-active': dateRange === datesNextMonth}">
<button @click="setDateRange(datesNextMonth)"
:class="{'is-active': dateRange === datesNextMonth}">
{{ $t('task.show.nextMonth') }}
</button>
<button @click="setDateRange(datesNext30Days)"
@ -40,7 +47,8 @@
/>
</div>
</div>
</transition>
</template>
</popup>
</div>
</template>
@ -51,6 +59,7 @@ import {computed, ref, watch} from 'vue'
import {useI18n} from 'vue-i18n'
import {store} from '@/store'
import {format} from 'date-fns'
import Popup from '@/components/misc/popup'
const {t} = useI18n()
@ -202,15 +211,25 @@ const customRangeActive = computed<Boolean>(() => {
.datepicker-with-range-container {
position: relative;
z-index: 10;
}
.datepicker-with-range {
:deep(.popup) {
margin-top: 1rem;
border-radius: $radius;
border: 1px solid var(--grey-200);
background-color: var(--white);
box-shadow: $shadow;
display: flex;
&.is-open {
width: 500px;
height: 320px;
}
}
}
.datepicker-with-range {
display: flex;
width: 100%;
height: 100%;
position: absolute;
:deep(.flatpickr-calendar) {