Added calendar config base

This commit is contained in:
Alexis
2024-03-31 12:43:12 +02:00
parent 82ff5010b5
commit d903b371b2
3 changed files with 67 additions and 13 deletions

60
src/stores/calendar.ts Normal file
View File

@@ -0,0 +1,60 @@
import { computed, ref, type Ref } from 'vue'
import { defineStore } from 'pinia'
type CalendarPeriod = 'ante' | 'nante'
type CalendarStaticConfig = {
months: string[]
monthsPerYear: number
daysPerYear: number
daysPerMonth: number
daysPerWeek: number
}
type CalendarCurrentConfig = {
currentPeriod: Ref<CalendarPeriod>
currentYear: Ref<number>
currentMonth: Ref<number>
currentDay: Ref<number>
}
export const useCalendar = defineStore('calendar', () => {
const months = [
'Jalen',
'Malsen',
'Verlys',
'Nalys',
'Verdore',
'Sidore',
'Lyllion',
'Rion',
'Farene',
'Dalvene'
]
const monthsPerYear = computed(() => months.length)
const daysPerYear = 320
const daysPerMonth = computed(() => daysPerYear / monthsPerYear.value)
const daysPerWeek = 6
const staticConfig: CalendarStaticConfig = {
months,
monthsPerYear: monthsPerYear.value,
daysPerYear,
daysPerMonth: daysPerMonth.value,
daysPerWeek
}
const currentPeriod: Ref<'nante' | 'ante'> = ref('nante')
const currentYear = ref(3209)
const currentMonth = ref(8)
const currentDay = ref(12)
const config: CalendarCurrentConfig = {
currentPeriod,
currentYear,
currentMonth,
currentDay
}
return { staticConfig, config }
})

View File

@@ -1,12 +0,0 @@
import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
export const useCounterStore = defineStore('counter', () => {
const count = ref(0)
const doubleCount = computed(() => count.value * 2)
function increment() {
count.value++
}
return { count, doubleCount, increment }
})

View File

@@ -1,5 +1,11 @@
<script lang="ts" setup>
import { useCalendar } from '@/stores/calendar'
const c = useCalendar()
</script>
<template>
<main class="container">
<h1 class="text-3xl font-bold">Hello world!</h1>
<h1 class="text-3xl font-bold">{{ c }}</h1>
</main>
</template>