fill categories panel

This commit is contained in:
isUnknown 2024-04-09 10:44:12 +02:00
parent a2722a0264
commit 93a628ec57
5 changed files with 108 additions and 47 deletions

View file

@ -1,7 +1,7 @@
/* ================= ENTRIES BTNS ================= */ /* ================= ENTRIES BTNS ================= */
#entry-btns { #entry-btns {
position: sticky; position: sticky;
top: calc(var(--unit--vertical) * 8); top: calc(var(--unit--vertical) * 10);
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
z-index: 2; z-index: 2;
@ -11,6 +11,9 @@
transition: all 0.5s var(--curve-sine); transition: all 0.5s var(--curve-sine);
} }
[data-template="home"] #entry-btns {
transform: translateY(calc(0rem - var(--unit--vertical-relative) * 8));
}
[data-template="linear"] #entry-btns { [data-template="linear"] #entry-btns {
transform: translateY(calc(0rem - var(--unit--vertical-relative) * 4)); transform: translateY(calc(0rem - var(--unit--vertical-relative) * 4));
} }
@ -74,49 +77,44 @@
.panel-close { .panel-close {
position: fixed; position: fixed;
top: 0; justify-content: center;
border: none; width: calc(100% - 2 * var(--unit--horizontal));
bottom: 0;
outline: none; outline: none;
height: 100svh; border-top: 1px solid #fff;
width: calc(var(--unit--horizontal) * 2); font-size: var(--font-size-m);
font-size: 0.8rem; background-color: #000;
display: flex; padding: calc(var(--unit--vertical) / 2) 0;
margin-bottom: env(safe-area-inset-bottom);
} }
.panel--left .panel-close { /* ================= LISTS ================= */
right: 0;
justify-content: flex-end;
}
.panel-close::after { .panel__toggle-btn {
content: "◀";
}
/* ================= YEARS ================= */
.year__toggle {
width: 100%; width: 100%;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
margin-bottom: var(--unit--vertical); margin-bottom: var(--unit--vertical);
} }
.year__toggle-icon { .panel__toggle-icon {
color: var(--color-secondary); color: var(--color-secondary);
font-size: var(--font-size-xl); font-size: var(--font-size-xl);
} }
.year__edito { /* ================= YEARS ================= */
.panel-item-content__edito {
margin-bottom: calc(var(--unit--vertical) / 2); margin-bottom: calc(var(--unit--vertical) / 2);
} }
.year__edito.short { .panel-item-content__edito.short {
display: -webkit-box; display: -webkit-box;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
-webkit-line-clamp: 5; -webkit-line-clamp: 5;
overflow: hidden; overflow: hidden;
} }
.year__texts { .panel-item-content__texts {
margin-top: var(--unit--vertical); margin-top: var(--unit--vertical);
} }

View file

@ -91,7 +91,7 @@ function enableToggleEntriesVisibility() {
}); });
}; };
const top = verticalUnit * 6; const top = verticalUnit * 8;
const observer = new IntersectionObserver(toggleVisibility, { const observer = new IntersectionObserver(toggleVisibility, {
root: null, root: null,
@ -114,7 +114,17 @@ function toggleLogoState() {
function togglePanel(side) { function togglePanel(side) {
document.querySelector(`.panel--${side}`).classList.toggle("open"); document.querySelector(`.panel--${side}`).classList.toggle("open");
document.querySelector("#main-header").classList.remove("minimized"); const isOpen = document
.querySelector(`.panel--${side}`)
.classList.contains("open");
const scrollY = window.scrollY || window.pageYOffset;
if (isOpen) {
document.querySelector("#main-header").classList.remove("minimized");
} else if (scrollY > 10) {
document.querySelector("#main-header").classList.add("minimized");
}
} }
document.addEventListener("DOMContentLoaded", () => { document.addEventListener("DOMContentLoaded", () => {

View file

@ -0,0 +1,27 @@
<?php
return function ($site) {
$textsPage = $site->find('texts');
$years = $textsPage->children();
$texts = $years->children()->index();
$categories = array();
foreach ($textsPage->categories()->split() as $category) {
$categories[$category] = array(
'title' => $category,
'texts' => array()
);
}
foreach ($texts as $text) {
try {
$categories[$text->category()->value()]['texts'][] = $text;
} catch (\Throwable $th) {
throw new Exception(json_encode($th->getFile() . ' : ' . $th->getMessage()));
}
}
return $categories;
};

View file

@ -11,32 +11,30 @@
</div> </div>
<nav class="panel panel--left"> <nav class="panel panel--left">
<ul <ul>
class="years"
>
<?php foreach($kirby->collection('years') as $year): ?> <?php foreach($kirby->collection('years') as $year): ?>
<li <li
class="year" class="panel__item "
x-data='{ year: false }' x-data='{ year: false }'
> >
<button <button
class="year__toggle" class="panel__toggle-btn"
:class="year ? '' : 'short'" :class="year ? '' : 'short'"
@click="year = !year" @click="year = !year"
> >
<h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $year->title() ?></h3> <h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $year->title() ?></h3>
<div <div
class="year__toggle-icon" class="panel__toggle-icon"
x-text="year ? '-' : '+'" x-text="year ? '-' : '+'"
></div> ></div>
</button> </button>
<div <div
class="year__content" class="panel-item-content"
x-show="year" x-show="year"
x-data="{edito: false}" x-data="{edito: false}"
> >
<div <div
class="year__edito" class="panel-item-content__edito"
:class="edito ? '' : 'short'" :class="edito ? '' : 'short'"
> >
<?= $year->edito() ?> <?= $year->edito() ?>
@ -45,7 +43,7 @@
:class="edito ? 'open' : 'close'" :class="edito ? 'open' : 'close'"
class="see-more toggle left" @click="edito = !edito" class="see-more toggle left" @click="edito = !edito"
>Lire</button> >Lire</button>
<ul class="year__texts"> <ul class="panel-item-content__texts">
<?php foreach($year->children() as $article): ?> <?php foreach($year->children() as $article): ?>
<?php snippet( <?php snippet(
'text-item', 'text-item',
@ -60,11 +58,47 @@
<button <button
onclick="togglePanel('left')" onclick="togglePanel('left')"
class="panel-close"> class="panel-close"
</button> >fermer</button>
</nav> </nav>
<nav class="panel panel--right">
<nav <ul>
onclick="togglePanel('right')" <?php foreach($kirby->collection('categories') as $category): ?>
class="panel panel--right"></nav> <li
class="panel__item"
x-data='{ category: false }'
>
<button
class="panel__toggle-btn"
:class="category ? '' : 'short'"
@click="category = !category"
>
<h3 class="fs-xl color" style="--color:var(--color-secondary)"><?= $category['title'] ?></h3>
<div
class="panel__toggle-icon"
x-text="category ? '-' : '+'"
></div>
</button>
<div
class="panel-item-content"
x-show="category"
>
<ul class="panel-item-content__texts">
<?php foreach($category['texts'] as $article): ?>
<?php snippet(
'text-item',
array('article' => $article)
) ?>
<?php endforeach ?>
</ul>
</div>
</li>
<?php endforeach ?>
</ul>
<button
onclick="togglePanel('right')"
class="panel-close"
>fermer</button>
</nav>

View file

@ -8,15 +8,7 @@
et des techniques<br> et des techniques<br>
</h2> </h2>
<?php endslot() ?> <?php endslot() ?>
<?php slot('tabs') ?>
<?php snippet('tabs', [
'left' => [
'label' => 'édito',
'content' => $site->edito()
]
]) ?>
<?php endslot() ?>
<?php endsnippet() ?> <?php endsnippet() ?>
<?php snippet('nav') ?>
</main> </main>
<?php snippet('footer') ?> <?php snippet('footer') ?>