actuel-inactuel/site/snippets/tabs.php

80 lines
2.9 KiB
PHP
Raw Normal View History

2024-03-09 15:09:31 +01:00
<?php
2024-03-09 11:27:10 +01:00
$left['slug'] = Str::slug($left['label']);
2024-03-09 17:06:24 +01:00
$authorFilter = isset($authorFilter) ? $authorFilter : false;
$activeTab = isset($activeTab) ? Str::slug($activeTab) : '';
2024-03-09 11:27:10 +01:00
?>
2024-03-10 19:24:24 +01:00
<nav id="tabs" x-data="{
activeTab: '<?= $activeTab ?>'
2024-03-09 11:27:10 +01:00
}">
<div class="toggle-btns | flex space-between" style="
--content:space-between;
">
<button
class="toggle left"
:class="activeTab === '<?=$left['slug'] ?>' ? 'open' : 'close'"
@click="toggleTab($data, '<?=$left['slug'] ?>')"
><?= $left['label'] ?></button>
<button
class="toggle right"
2024-03-09 15:09:31 +01:00
:class="activeTab === 'texts' ? 'open' : 'close'"
2024-03-10 19:24:24 +01:00
title="Voir tous les textes"
2024-03-09 15:09:31 +01:00
@click="toggleTab($data, 'texts')"
>textes</button>
2024-03-09 11:27:10 +01:00
</div>
<div class="active-tab" x-show="activeTab.length > 0">
2024-03-09 11:27:10 +01:00
<section
2024-03-09 15:10:51 +01:00
x-show="activeTab === '<?=$left['slug'] ?>'">
2024-03-09 11:27:10 +01:00
<?= $left['content'] ?>
</section>
<ul
2024-03-09 15:10:51 +01:00
x-show="activeTab === 'texts'">
2024-03-09 11:27:10 +01:00
<?php foreach($kirby->collection('years') as $year): ?>
2024-03-10 19:24:24 +01:00
<div
x-data='{
isOpen: false
}'
:class="isOpen ? '' : 'short'"
class="
texts__year
| full-width
flex column
bottom"
style="
--content: center;
--bottom: 2;"
>
2024-03-09 11:27:10 +01:00
<h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $year->title() ?></h3>
2024-03-10 19:24:24 +01:00
<div class="year__edito">
<?= $year->edito() ?>
</div>
<button
:class="isOpen ? 'open' : 'close'"
class="see-more toggle left" @click="isOpen = !isOpen">Lire</button>
2024-03-09 11:27:10 +01:00
</div>
<?php foreach($year->children() as $article): ?>
2024-03-09 17:06:24 +01:00
<?php if (!$authorFilter || $authorFilter == $article->author()->toUser()->name()->value()) : ?>
2024-03-10 19:24:24 +01:00
<li class="texts | bottom" style="--bottom:3">
<a href="<?= $article->url() ?>" class="texts__title no-line">
2024-03-09 17:06:24 +01:00
<h3><?= $article->title() ?></h3>
</a>
2024-03-10 19:24:24 +01:00
<div class="texts__infos">
2024-03-09 17:06:24 +01:00
<p>
<?php if (!$authorFilter): ?>
<span class="opacity" style="--opacity:.5">par</span>
2024-03-10 19:24:24 +01:00
<a class="author" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a>,
2024-03-09 17:06:24 +01:00
<span class="opacity" style="--opacity:.5">le</span>
<?php endif ?>
<?= $article->published()->toDate('d/m/Y') ?>
</p>
</div>
2024-03-10 19:24:24 +01:00
<!-- <div class="texts__labels">
2024-03-09 17:06:24 +01:00
<button class="label label--category">[ <?= $article->category() ?> ]</button>
</div> -->
</li>
<?php endif ?>
2024-03-09 11:27:10 +01:00
<?php endforeach ?>
<?php endforeach ?>
</ul>
</div>
2024-03-10 19:24:24 +01:00
</nav>