nouveau-theatre-de-besancon/site/snippets/calendar-strip.php

76 lines
2.2 KiB
PHP
Raw Normal View History

2024-07-24 09:43:31 +02:00
<div
class="calendar-strip"
2024-07-26 10:33:31 +02:00
@mouseleave="open = false"
2024-07-24 09:43:31 +02:00
x-data="{
monthNumb: dayjs().month(),
2024-07-24 15:56:28 +02:00
token: '<?= $site->mapadoToken() ?>',
contractId: '<?= $site->mapadoContractId() ?>',
dates: [],
2024-07-26 10:33:31 +02:00
targetSessions: [],
open: false,
2024-07-24 09:43:31 +02:00
get monthName() {
return dayjs().month(this.monthNumb).format('MMMM');
},
async updateDates() {
2024-07-26 10:33:31 +02:00
document.body.classList.toggle('progress')
this.dates = getDatesInMonth(this.monthNumb);
const mapadoDates = await getMapadoDates(this.monthNumb)
2024-07-29 08:57:35 +02:00
2024-07-26 08:51:05 +02:00
mapadoDates.forEach(mapadoDate => {
const day = parseInt(mapadoDate.day)
2024-07-26 10:33:31 +02:00
this.dates[day].push(mapadoDate)
2024-07-26 08:51:05 +02:00
})
2024-07-29 08:57:35 +02:00
const kirbyDates = await getKirbyDates(this.monthNumb, this.dates)
console.log('kirby dates', kirbyDates)
2024-07-26 08:51:05 +02:00
console.log('dates', this.dates)
2024-07-26 10:33:31 +02:00
document.body.classList.toggle('progress')
},
handleDayHover() {
this.targetSessions = this.date;
if (this.date.length > 0) {this.open = true} else {this.open = false}
2024-07-24 09:43:31 +02:00
}
}"
2024-07-24 15:56:28 +02:00
x-init="updateDates()"
2024-07-24 09:43:31 +02:00
>
<div class="calendar-strip__selector">
2024-07-29 08:57:35 +02:00
<button class="prev-month" @click="monthNumb--; updateDates()"></button>
2024-07-24 09:43:31 +02:00
<span x-text="monthName"></span>
<button class="next-month" @click="monthNumb++; updateDates()"></button>
2024-07-24 09:43:31 +02:00
</div>
<ul class="calendar-strip__days">
<template x-for="(date, index) in dates">
2024-07-24 18:19:25 +02:00
<li class="calendar-strip__day">
2024-07-26 10:33:31 +02:00
<button
x-text="index"
:disabled="date.length === 0 ? true : false"
:title="date.length === 0 ? 'Pas de représentation.' : 'Voir les représentations.'"
@mouseenter="handleDayHover()"
></button>
2024-07-24 18:19:25 +02:00
</li>
2024-07-24 09:43:31 +02:00
</template>
</ul>
<button class="calendar-strip__calendar-btn">calendrier</button>
2024-07-26 10:33:31 +02:00
<div class="calendar-strip__date" :class="open ? 'open' : ''">
<ul class="calendar-strip__sessions">
<template x-for="session in targetSessions">
<li class="calendar-strip__session">
<div x-html="`${session.day} ${monthName}<br><br>${session.startTime}`"></div>
<div x-html="`<strong>${session.title}</strong>`"></div>
<div></div>
<div></div>
<div xhtml=""></div>
</li>
</template>
</ul>
</div>
2024-07-24 09:43:31 +02:00
</div>
2024-07-24 18:19:25 +02:00