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