gancio-upstream/components/Calendar.vue

62 lines
1.2 KiB
Vue
Raw Normal View History

2020-12-03 01:05:26 +01:00
<template lang="pug">
#calendar
2022-02-26 21:28:08 +01:00
vc-date-picker(
v-model='selectedDate'
2020-12-03 01:05:26 +01:00
title-position='left'
:is-dark="settings['theme.is_dark']"
2021-02-09 12:10:00 +01:00
:columns="$screens({ sm: 2 }, 1)"
2022-02-26 21:28:08 +01:00
@input='click'
2020-12-03 01:05:26 +01:00
@update:from-page='updatePage'
:locale='$i18n.locale'
:attributes='attributes'
transition='fade'
2021-07-15 23:40:58 +02:00
aria-label='Calendar'
2020-12-03 01:05:26 +01:00
is-expanded
2022-02-26 21:28:08 +01:00
is-inline)
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'
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',
props: {
2021-01-11 00:17:56 +01:00
events: { type: Array, default: () => [] }
2020-12-03 01:05:26 +01:00
},
data () {
const month = dayjs.tz().month() + 1
const year = dayjs.tz().year()
2020-12-03 01:05:26 +01:00
return {
2022-02-26 21:28:08 +01:00
selectedDate: null,
2021-03-08 14:38:47 +01:00
page: { month, year }
2020-12-03 01:05:26 +01:00
}
},
2021-03-08 14:38:47 +01:00
computed: {
...mapState(['settings']),
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) {
2021-01-22 23:07:19 +01:00
this.$emit('monthchange', page)
2020-12-03 01:05:26 +01:00
},
click (day) {
this.$emit('dayclick', day)
}
}
}
</script>
<style>
.vc-opacity-0 {
opacity: 0.3 !important;
}
.past-event {
opacity: 0.3;
}
</style>