event : ajouter isLive() et revoir le style du badge 'en ce moment' en bandeau diagonal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
isUnknown 2026-05-27 18:18:33 +02:00
parent 768eb15493
commit bdd5fcfb69
3 changed files with 53 additions and 33 deletions

View file

@ -10,8 +10,6 @@
background-color: #fff;
.event-card {
position: relative;
h2 {
box-sizing: border-box;
width: 100%;
@ -26,32 +24,33 @@
height: 8rem;
}
.playing-now {
position: absolute;
top: 2rem;
transform: rotate(-45deg);
width: 5rem;
height: 5rem;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-green);
border-radius: 100%;
p {
width: max-content;
padding: 0.2rem 0.5rem;
}
}
picture {
display: block;
.cover-wrapper {
position: relative;
overflow: hidden;
margin-top: 1rem;
}
.playing-now {
position: absolute;
top: 2rem;
left: -2rem;
transform: rotate(-45deg);
width: 10rem;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
background-color: var(--color-beige);
img {
border-radius: 1rem;
p {
width: max-content;
padding: 0.2rem 0.5rem;
}
}
picture {
display: block;
img {
border-radius: 1rem;
}
}
}
}
}

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

@ -0,0 +1,17 @@
<?php
class EventPage extends Page
{
public function isLive(): bool
{
$today = date('Y-m-d');
foreach ($this->dates()->toStructure() as $range) {
if ($today >= $range->from()->value() && $today <= $range->to()->value()) {
return true;
}
}
return false;
}
}

View file

@ -6,13 +6,17 @@
<li class="event-card">
<h2><?= $event->title() ?></h2>
<a href="<?= $event->url() ?>"></a>
<div class="playing-now"><p>En ce moment</p></div>
<?php snippet('picture', [
'file' => $event->cover()->toFile(),
'srcsetName' => 'event-card',
'sizes' => '(min-width: 800px) 30vw, 100vw',
'alt' => $event->title()->value(),
]) ?>
<div class="cover-wrapper">
<?php if ($event->isLive()): ?>
<div class="playing-now"><p>En ce moment</p></div>
<?php endif ?>
<?php snippet('picture', [
'file' => $event->cover()->toFile(),
'srcsetName' => 'event-card',
'sizes' => '(min-width: 800px) 30vw, 100vw',
'alt' => $event->title()->value(),
]) ?>
</div>
</li>
<?php endforeach ?>
</ul>