actuel-inactuel/site/snippets/tabs.php

81 lines
2.3 KiB
PHP
Raw Normal View History

2024-03-09 15:09:31 +01:00
<?php
2024-04-06 10:08:45 +02:00
$left = $left ?? false;
if ($left) {
$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-04-07 09:57:55 +02:00
<nav id="tabs"
x-data="{
activeTab: ''
}"
:class="activeTab.length > 0 ? 'open' : 'close'"
>
2024-03-09 11:27:10 +01:00
<div class="toggle-btns | flex space-between" style="
--content:space-between;
">
2024-04-06 10:08:45 +02:00
<?php if ($left): ?>
<button
class="toggle left"
:class="activeTab === '<?=$left['slug'] ?>' ? 'open' : 'close'"
@click="toggleTab($data, '<?=$left['slug'] ?>')"
><?= $left['label'] ?></button>
<?php endif ?>
2024-03-09 11:27:10 +01:00
<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')"
2024-04-07 11:09:43 +02:00
>catégories</button>
2024-03-09 11:27:10 +01:00
</div>
2024-03-12 17:38:53 +01:00
<div
class="active-tab"
>
2024-04-06 10:08:45 +02:00
<?php if ($left): ?>
<section
x-show="activeTab === '<?=$left['slug'] ?>'">
<?= $left['content'] ?>
</section>
<?php endif ?>
2024-03-09 11:27:10 +01:00
<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-04-06 10:08:45 +02:00
<?php if (!$authorFilter || $authorFilter == $article->author()->toUser()->name()->value()) : ?>
<?php snippet(
'text-item',
[
2024-04-07 11:09:43 +02:00
'article' => $article
]
2024-04-06 10:08:45 +02:00
) ?>
2024-03-09 17:06:24 +01:00
<?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>