gancio/components/Calendar.vue

92 lines
2.2 KiB
Vue
Raw Normal View History

2020-12-03 01:05:26 +01:00
<template lang="pug">
2022-11-24 01:00:30 +01:00
client-only
vc-date-picker(
ref='cal'
v-model='selectedDate'
title-position='left'
:is-dark="settings['theme.is_dark']"
:columns="!$vuetify.breakpoint.smAndDown ? 2 : 1"
@input='click'
@update:from-page='updatePage'
:locale='$i18n.locale'
2022-11-24 17:27:30 +01:00
:popover="{ visibility: 'click' }"
2022-11-24 01:00:30 +01:00
:attributes='attributes'
transition='fade'
aria-label='Calendar'
is-expanded
is-inline)
2023-01-09 16:56:01 +01:00
//- template(v-slot="{ inputValue, inputEvents }")
2022-11-24 01:00:30 +01:00
v-btn#calendarButton(v-on='inputEvents' text tile :color='selectedDate ? "primary" : "" ') {{inputValue || $t('common.calendar')}}
2022-11-24 17:27:30 +01:00
v-icon(v-if='selectedDate' v-text='mdiClose' right small icon @click.prevent.stop='selectedDate = null')
2022-11-24 01:00:30 +01:00
v-icon(v-else v-text='mdiChevronDown' right small icon)
2023-01-09 16:56:01 +01:00
.calh.d-flex.justify-center.align-center(slot='placeholder')
v-progress-circular(indeterminate)
//- v-btn#calendarButton(text tile) {{$t('common.calendar')}}
//- v-icon(v-text='mdiChevronDown' right small icon)
2022-11-24 01:00:30 +01:00
</template>
2020-12-03 01:05:26 +01:00
</template>
<script>
import { mapState } from 'vuex'
2020-12-03 01:05:26 +01:00
import dayjs from 'dayjs'
2022-11-24 01:00:30 +01:00
import { mdiChevronDown, mdiClose } from '@mdi/js'
2021-03-10 16:09:35 +01:00
import { attributesFromEvents } from '../assets/helper'
2020-12-03 01:05:26 +01:00
export default {
name: 'Calendar',
data () {
const month = dayjs.tz().month() + 1
const year = dayjs.tz().year()
2020-12-03 01:05:26 +01:00
return {
2022-11-24 01:00:30 +01:00
mdiChevronDown, mdiClose,
2022-02-26 21:28:08 +01:00
selectedDate: null,
2022-11-24 01:00:30 +01:00
page: { month, year },
2020-12-03 01:05:26 +01:00
}
},
2021-03-08 14:38:47 +01:00
computed: {
2022-11-24 01:00:30 +01:00
...mapState(['settings', 'events']),
2021-03-08 14:38:47 +01:00
attributes () {
return attributesFromEvents(this.events)
2021-03-08 14:38:47 +01:00
}
},
methods: {
2020-12-03 01:05:26 +01:00
updatePage (page) {
if (page.month !== this.page.month || page.year !== this.page.year) {
2022-11-24 17:27:30 +01:00
this.$root.$emit('monthchange', page)
this.page.month = page.month
this.page.year = page.year
}
2020-12-03 01:05:26 +01:00
},
click (day) {
2022-11-24 17:27:30 +01:00
this.$root.$emit('dayclick', day)
2020-12-03 01:05:26 +01:00
}
}
}
</script>
<style>
2023-01-10 17:58:19 +01:00
.vc-container.vc-is-dark {
--gray-900: #111;
--gray-700: #333;
}
.vc-container {
--gray-400: #999 !important;
--rounded-lg: 4px !important;
}
2020-12-03 01:05:26 +01:00
.vc-opacity-0 {
opacity: 0.3 !important;
}
.past-event {
opacity: 0.3;
}
2022-11-24 01:00:30 +01:00
#calendarButton {
margin-top: -6px;
margin-left: -10px;
}
2020-12-03 01:05:26 +01:00
</style>