first commit after refactor to vite

This commit is contained in:
Sockenklaus
2021-10-03 00:35:05 +02:00
commit 59d5d15702
18 changed files with 3193 additions and 0 deletions

View File

@@ -0,0 +1,84 @@
<template lang="pug">
h1(v-if="isValid(startDate)") {{format(startDate, "MMMM y", {locale: de})}}
table(class='table' v-for="(row, rIndex) in dates" :key="rIndex")
thead
tr
td(v-for="(day, index) in weekdays" :key="index") {{ day }}
tr
td(v-for="(date, dIndex) in row" :key="dIndex")
template(v-if="date !== null") {{ format(date, "dd.MM.")}}
tbody
tr
td(v-for="(date, dIndex) in row" :key="dIndex") &nbsp;
</template>
<script setup lang="ts">
import { toRef, computed } from 'vue'
import { addMonths, subDays, addDays, format, getISODay, isValid, eachDayOfInterval } from 'date-fns'
import { de } from 'date-fns/locale'
/*
* Props / Refs
*/
const props = defineProps<{
startDate: Date,
initialOffset: number
}>()
const startDate = toRef(props, 'startDate')
const endDate = computed(():Date => subDays(addMonths(startDate.value, 1), 1))
/*
* Local variables
*/
const weekdays : string[] = doubleWeekdays()
const employees : string[] = ['Pascal', 'Karin', 'Sandra']
const daysInMonth : Date[] = eachDayOfInterval({
start: startDate.value,
end: endDate.value
})
const offset : number = getISODay(startDate.value) - 1 + props.initialOffset
const dates = computed( () => {
let arr = []
let row = []
let start = startDate.value
let end = endDate.value
let i
for (i = 0; i < offset ; i++) {
row.push(null)
}
while (start <= end){
while (i < 14 && start <= end){
row.push(start)
start = addDays(start, 1)
i++
}
arr.push(row)
row = []
i = 0
}
return arr
})
function doubleWeekdays() : string[] {
let arr = ['Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.', 'So.']
return arr.concat(arr)
}
</script>
<style scoped>
table {
table-layout: fixed
}
</style>