nouveau-theatre-de-besancon/site/snippets/calendar-strip.php
2024-08-28 19:11:58 +02:00

93 lines
3.2 KiB
PHP

<section
class="calendar-strip"
@mouseleave="open = false"
x-data="{
monthNumb: dayjs().month(),
token: '<?= $site->mapadoToken() ?>',
contractId: '<?= $site->mapadoContractId() ?>',
dates: [],
targetSessions: [],
open: false,
today: dayjs().format('DD-MM-YYYY'),
get monthName() {
return dayjs().month(this.monthNumb).format('MMMM');
},
async updateDates() {
document.body.classList.toggle('progress')
this.dates = getDatesInMonth(this.monthNumb);
this.dates = await getMergedDates(this.monthNumb, this.dates)
console.log('Merged dates', this.dates)
document.body.classList.toggle('progress')
},
handleDayHover() {
if (this.date.sessions.length > 0) {
this.targetSessions = this.date.sessions;
this.open = true
} else {
setTimeout(() => {
this.targetSessions = this.date.sessions;
}, 100)
this.open = false
}
}
}"
x-init="updateDates()"
>
<div class="calendar-strip__selector">
<button class="prev-month" @click="monthNumb--; updateDates()"></button>
<span x-text="monthName"></span>
<button class="next-month" @click="monthNumb++; updateDates()"></button>
</div>
<ul class="calendar-strip__days">
<template x-for="(date, index) in dates">
<li class="calendar-strip__day" :class="targetSessions.length > 0 && open && index == targetSessions[0].day ? 'active' : ''">
<button
:class="date.full === today ? 'today' : ''"
:disabled="date.sessions.length === 0 ? true : false"
:title="date.sessions.length === 0 ? 'Pas de représentation.' : 'Voir les représentations.'"
@mouseenter="handleDayHover()"
>
<span x-text="date.initial"></span>
<span x-text="index"></span>
</button>
</li>
</template>
</ul>
<button class="calendar-strip__calendar-btn">calendrier</button>
<div class="calendar-strip__date" :class="open ? 'open' : ''">
<ul class="calendar-strip__sessions">
<template x-for="session in targetSessions">
<li class="calendar-strip__session" :style="'--color: ' + session.color">
<a :href="session.eventUrl" title="En savoir plus">
<div x-html="`${session.day} ${monthName}<br><br>${session.time}`"></div>
<div>
<p><strong x-html="`<strong>${session.title}</strong>`"></strong></p>
<p x-html="session.authors"></p>
</div>
<div x-text="`${session.duration}`"></div>
<div x-text="`${session.place}`"></div>
<template x-if="session.ticketingUrl">
<div>
<a class="ticket-link" :href="session.ticketingUrl" target="_blank" title="Aller à la billetterie"><?php snippet('ticket') ?> Billetterie</a>
</div>
</template>
<template x-if="!session.ticketingUrl">
<div>
<a class="ticket-link" target="_blank" title="Entrée libre" disabled><?php snippet('ticket') ?> Entrée libre</a>
</div>
</template>
</a>
</li>
</template>
</ul>
</div>
</section>