start event card content and add schedule method

This commit is contained in:
isUnknown 2024-07-31 07:19:10 +02:00
parent c1a94e832f
commit be549bba16
12 changed files with 102 additions and 11 deletions

View file

@ -0,0 +1,12 @@
title: Image
fields:
alt:
label: Texte alternatif
type: text
maxlength: 120
help: |
**Décrivez l'image avec précision et concision.**
- affiché à la place de l'image lorsqu'elle ne peut pas être chargée
- lu par les lecteurs d'écran des personnes malvoyantes
- lu par les robots des moteurs de recherche
[Plus d'infos](https://duckduckgo.com/?q=balise+alt&t=ffab&ia=web)

View file

@ -38,5 +38,9 @@ return [
],
'hooks' => [
'page.update:after' => require_once(__DIR__ . '/hooks/update-mapado-event.php')
]
],
'date' => [
'handler' => 'intl'
],
'locale' => 'fr_FR.UTF-8'
];

25
site/models/event.php Normal file
View file

@ -0,0 +1,25 @@
<?php
class EventPage extends Page {
public function schedule() {
$sessions = $this->isMapadoEvent() != 'true' ? $this->sessions()->toStructure() : $this->remoteSessions()->toStructure();
try {
$firstSession = $sessions->first()->date();
$lastSession = $sessions->last()->date();
} catch (\Throwable $th) {
throw new Exception('Can\'t define sessions for event "' . $this->title()->value() . '".', 1);
}
$startDay = intval($firstSession->toDate('d'));
$startMonth = $firstSession->toDate('MMMM');
$endDay = intval($lastSession->toDate('d'));
$endMonth = $lastSession->toDate('MMMM');
if ($firstSession->toDate('y-M') === $lastSession->toDate('y-M')) {
return $startDay . ' - ' . $endDay . ' ' . $endMonth;
} else {
return $startDay . ' ' . $startMonth . ' - ' . $endDay . ' ' . $endMonth;
}
}
}

View file

@ -1,3 +1,13 @@
<div class="event-card">
<?php snippet('picture', ["file" => $event->files()->first()]) ?>
<div class="event-card grid__item" style="--span: <?= $span ?>">
<?php snippet('picture', ["file" => $event->gallery()->toFiles()->first()]) ?>
<div class="event-card__infos">
<div>
<h5><?= $event->title() ?></h5>
<?= svg('assets/images/icons/ticket.svg') ?>
</div>
<div>
<p class="event-card__authors"><?= $event->authors() ?></p>
<p><?= $event->schedule() ?></p>
</div>
</div>
</div>

View file

@ -1,5 +1,8 @@
<div class="events-grid grid" style="--span: <?= $events->count() ?>;">
<?php foreach($events as $event): ?>
<?php snippet('event-card', ["event" => $event]) ?>
<?php endforeach ?>
</div>
<section class="events-grid">
<h4>À venir</h4>
<div class="grid">
<?php foreach($events as $event): ?>
<?php snippet('event-card', ["event" => $event, "span" => 12 / $events->count()]) ?>
<?php endforeach ?>
</div>
</section>

View file

@ -1,7 +1,7 @@
<?php
$sizes = '(min-width: 1200px) 25vw, (min-width: 900px) 33vw, (min-width: 600px) 50vw, 100vw';
$alt = method_exists($file, 'alt') ? $file->alt() : 'Fragment de carte de la France';
$alt = $file->alt();
$crop = $crop ?? false;
$webPSrcset = $crop === 'banner' ? $file->crop(1600, 800)->srcset('webp') : $file->srcset('webp');