calendar-strip mobile organisé en semaine presque terminé. Attente reponse à question
This commit is contained in:
parent
f2f28d9012
commit
47b8fe07e1
3 changed files with 85 additions and 26 deletions
|
|
@ -15,12 +15,18 @@
|
||||||
width: 10rem;
|
width: 10rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.calendar-strip__days {
|
.calendar-strip__days,
|
||||||
|
.calendar-strip__days .week > ul {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-evenly;
|
justify-content: space-evenly;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.calendar-strip__days .week,
|
||||||
|
.calendar-strip__days .week > ul {
|
||||||
|
display: contents;
|
||||||
|
}
|
||||||
|
|
||||||
.calendar-strip__day {
|
.calendar-strip__day {
|
||||||
font-size: var(--font-size-s);
|
font-size: var(--font-size-s);
|
||||||
transition: opacity 0.2s ease-in-out;
|
transition: opacity 0.2s ease-in-out;
|
||||||
|
|
@ -97,4 +103,17 @@
|
||||||
.calendar-strip .next-month {
|
.calendar-strip .next-month {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.calendar-strip__days .week,
|
||||||
|
.calendar-strip__days .week > ul {
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
.calendar-strip__days .week:not(.current) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.calendar-strip__days .week,
|
||||||
|
.calendar-strip__days .week > ul {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,8 @@ function createEmptyCalendar() {
|
||||||
sessions: [],
|
sessions: [],
|
||||||
full: currentDay.format("DD-MM-YYYY"),
|
full: currentDay.format("DD-MM-YYYY"),
|
||||||
initial: dayInitial,
|
initial: dayInitial,
|
||||||
|
index: parseInt(currentDay.format("DD")),
|
||||||
|
indexInWeek: currentDay.day() === 0 ? 7 : currentDay.day(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,18 @@
|
||||||
@mouseleave="open = false"
|
@mouseleave="open = false"
|
||||||
x-data="{
|
x-data="{
|
||||||
calendar: createEmptyCalendar(),
|
calendar: createEmptyCalendar(),
|
||||||
monthNumb: dayjs().month() + 1,
|
currentMonthIndex: dayjs().month() + 1,
|
||||||
|
currentWeekIndex: (() => {
|
||||||
|
dayjs.extend(window.dayjs_plugin_weekOfYear);
|
||||||
|
|
||||||
|
const today = dayjs();
|
||||||
|
const firstDayOfMonth = today.startOf('month');
|
||||||
|
const currentWeek = today.week();
|
||||||
|
const firstWeekOfMonth = firstDayOfMonth.week();
|
||||||
|
const currentWeekIndex = currentWeek - firstWeekOfMonth;
|
||||||
|
|
||||||
|
return currentWeekIndex;
|
||||||
|
})(),
|
||||||
token: '<?= $site->mapadoToken() ?>',
|
token: '<?= $site->mapadoToken() ?>',
|
||||||
contractId: '<?= $site->mapadoContractId() ?>',
|
contractId: '<?= $site->mapadoContractId() ?>',
|
||||||
targetSessions: [],
|
targetSessions: [],
|
||||||
|
|
@ -11,11 +22,29 @@
|
||||||
today: dayjs().format('DD-MM-YYYY'),
|
today: dayjs().format('DD-MM-YYYY'),
|
||||||
|
|
||||||
get monthName() {
|
get monthName() {
|
||||||
return dayjs().month(this.monthNumb - 1).format('MMMM');
|
return dayjs().month(this.currentMonthIndex - 1).format('MMMM');
|
||||||
},
|
},
|
||||||
|
|
||||||
get currentMonth() {
|
get currentMonth() {
|
||||||
return this.calendar[this.monthNumb]
|
return this.calendar[this.currentMonthIndex]
|
||||||
|
},
|
||||||
|
|
||||||
|
get currentWeeks() {
|
||||||
|
const weeks = [[]];
|
||||||
|
let index = 0;
|
||||||
|
for (let key in this.currentMonth) {
|
||||||
|
const date = this.currentMonth[key]
|
||||||
|
weeks[index].push(date)
|
||||||
|
if (date.indexInWeek === 7) {
|
||||||
|
weeks.push([])
|
||||||
|
index++
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return weeks
|
||||||
|
},
|
||||||
|
|
||||||
|
get currentWeek() {
|
||||||
|
this.currentWeeks[this.currentWeekIndex];
|
||||||
},
|
},
|
||||||
|
|
||||||
async updateDates() {
|
async updateDates() {
|
||||||
|
|
@ -29,7 +58,7 @@
|
||||||
.catch(error => console.log('No saved calendar.'))
|
.catch(error => console.log('No saved calendar.'))
|
||||||
|
|
||||||
const daysNode = document.querySelector('.calendar-strip__days');
|
const daysNode = document.querySelector('.calendar-strip__days');
|
||||||
daysNode.classList.toggle('progress');
|
daysNode.classList.toggle('progress');
|
||||||
|
|
||||||
this.calendar = await getCurrentSeasonCalendar();
|
this.calendar = await getCurrentSeasonCalendar();
|
||||||
|
|
||||||
|
|
@ -51,17 +80,17 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
nextMonth() {
|
nextMonth() {
|
||||||
if (this.monthNumb == 12) {
|
if (this.currentMonthIndex == 12) {
|
||||||
this.monthNumb = 1
|
this.currentMonthIndex = 1
|
||||||
} else {
|
} else {
|
||||||
this.monthNumb++
|
this.currentMonthIndex++
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
prevMonth() {
|
prevMonth() {
|
||||||
if (this.monthNumb == 1) {
|
if (this.currentMonthIndex == 1) {
|
||||||
this.monthNumb = 12
|
this.currentMonthIndex = 12
|
||||||
} else {
|
} else {
|
||||||
this.monthNumb--
|
this.currentMonthIndex--
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
|
|
@ -70,28 +99,37 @@
|
||||||
x-init="updateDates()"
|
x-init="updateDates()"
|
||||||
>
|
>
|
||||||
<div class="calendar-strip__selector">
|
<div class="calendar-strip__selector">
|
||||||
<button class="prev-month" @click="prevMonth()" :disabled="monthNumb === 9">←</button>
|
<button class="prev-month" @click="prevMonth()" :disabled="currentMonthIndex === 9">←</button>
|
||||||
<span x-text="monthName"></span>
|
<span x-text="monthName"></span>
|
||||||
<button class="next-month" @click="nextMonth()" :disabled="monthNumb === 8">→</button>
|
<button class="next-month" @click="nextMonth()" :disabled="currentMonthIndex === 8">→</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ul class="calendar-strip__days">
|
<ul class="calendar-strip__days">
|
||||||
<template x-for="(date, index) in currentMonth">
|
<template x-for="(week, weekIndex) in currentWeeks">
|
||||||
<li class="calendar-strip__day" :class="targetSessions.length > 0 && open && index == targetSessions[0].day ? 'active' : ''" :style="'animation-delay: ' + index * 0.03 + 's'">
|
<li class="week" :class="weekIndex == currentWeekIndex ? 'current' : ''">
|
||||||
<button
|
<ul>
|
||||||
:class="!date || date.full !== today ? '' : 'today'"
|
<template x-for="date in week">
|
||||||
:disabled="!date || date.sessions.length === 0 ? true : false"
|
<li class="calendar-strip__day" :class="targetSessions.length > 0 && open && date.index == targetSessions[0].day ? 'active' : ''" :style="'animation-delay: ' + date.index * 0.03 + 's'">
|
||||||
:title="!date || date.sessions.length === 0 ? 'Pas de représentation.' : 'Voir les représentations.'"
|
<button
|
||||||
@mouseenter="handleDayHover()"
|
:class="!date || date.full !== today ? '' : 'today'"
|
||||||
>
|
:disabled="!date || date.sessions.length === 0 ? true : false"
|
||||||
<template x-if="date">
|
:title="!date || date.sessions.length === 0 ? 'Pas de représentation.' : 'Voir les représentations.'"
|
||||||
<span x-text="date.initial"></span>
|
@mouseenter="handleDayHover()"
|
||||||
</template>
|
>
|
||||||
<span x-text="index"></span>
|
<template x-if="date">
|
||||||
</button>
|
<span x-text="date.initial"></span>
|
||||||
|
</template>
|
||||||
|
<span x-text="date.index"></span>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</template>
|
</template>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<a href="<?= page('programme')->url() ?>" class="calendar-strip__calendar-btn">calendrier</a>
|
<a href="<?= page('programme')->url() ?>" class="calendar-strip__calendar-btn">calendrier</a>
|
||||||
|
|
||||||
<div class="calendar-strip__date" :class="open ? 'open' : ''">
|
<div class="calendar-strip__date" :class="open ? 'open' : ''">
|
||||||
<ul class="sessions">
|
<ul class="sessions">
|
||||||
<template x-for="session in targetSessions">
|
<template x-for="session in targetSessions">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue