actuel-inactuel/site/snippets/tabs.php
2024-03-10 12:03:31 +01:00

60 lines
No EOL
2.4 KiB
PHP

<?php
$left['slug'] = Str::slug($left['label']);
$authorFilter = isset($authorFilter) ? $authorFilter : false;
$activeTab = isset($activeTab) ? Str::slug($activeTab) : '';
?>
<div id="tabs" x-data="{
activeTab: '<?= $activeTab ?>'
}">
<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"
:class="activeTab === 'texts' ? 'open' : 'close'"
@click="toggleTab($data, 'texts')"
>textes</button>
</div>
<div class="active-tab" x-show="activeTab.length > 0">
<section
x-show="activeTab === '<?=$left['slug'] ?>'">
<?= $left['content'] ?>
</section>
<ul
x-show="activeTab === 'texts'">
<?php foreach($kirby->collection('years') as $year): ?>
<div class="article__year | full-width flex bottom" style="--content: center;--bottom:2">
<h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $year->title() ?></h3>
</div>
<?php foreach($year->children() as $article): ?>
<?php if (!$authorFilter || $authorFilter == $article->author()->toUser()->name()->value()) : ?>
<li class="article | bottom" style="--bottom:3">
<a href="<?= $article->url() ?>" class="article__title no-line">
<h3><?= $article->title() ?></h3>
</a>
<div class="article__infos">
<p>
<?php if (!$authorFilter): ?>
<span class="opacity" style="--opacity:.5">par</span>
<a class="author no-line" href="/auteurs/<?= Str::slug($article->author()->toUser()->name()) ?>"><?= $article->author()->toUser()->name() ?></a>,
<span class="opacity" style="--opacity:.5">le</span>
<?php endif ?>
<?= $article->published()->toDate('d/m/Y') ?>
</p>
</div>
<!-- <div class="article__labels">
<button class="label label--category">[ <?= $article->category() ?> ]</button>
</div> -->
</li>
<?php endif ?>
<?php endforeach ?>
<?php endforeach ?>
</ul>
</div>
</div>