new nav buttons

This commit is contained in:
isUnknown 2024-04-07 11:09:43 +02:00
parent 7e21e1ffb7
commit 92625d2fb9
11 changed files with 552 additions and 39 deletions

View file

@ -47,7 +47,7 @@
margin-top: calc(var(--unit--vertical-relative) * 19); margin-top: calc(var(--unit--vertical-relative) * 19);
} }
#home .page-cover { [data-template="home"] .page-cover {
padding-top: calc(var(--unit--vertical-relative) * 6); padding-top: calc(var(--unit--vertical-relative) * 6);
} }

41
assets/css/src/nav.css Normal file
View file

@ -0,0 +1,41 @@
#entries {
position: sticky;
top: calc(var(--unit--vertical) * 8);
display: flex;
justify-content: space-between;
}
.entry-btn {
transition: all 0.5s var(--curve-sine);
}
[data-template="linear"] #entries {
transform: translateY(calc(0rem - var(--unit--vertical-relative) * 4));
}
.entry-btn--left::after,
.entry-btn--right::before {
transition: all 0.5s var(--curve-sine);
content: "+";
}
.entry-btn--left::after {
margin-left: var(--unit--horizontal);
}
.entry-btn--right::before {
margin-right: var(--unit--horizontal);
}
#entries.minimized {
color: var(--color-secondary);
}
#entries.minimized .entry-btn::before,
#entries.minimized .entry-btn::after {
font-weight: bold;
}
#entries.minimized .entry-btn--left {
margin-left: calc(-4px - var(--width));
}
#entries.minimized .entry-btn--right {
margin-right: calc(-4px - var(--width));
}

View file

@ -89,7 +89,7 @@ button.toggle.right.open::before {
} }
@media screen and (min-width: 640px) { @media screen and (min-width: 640px) {
#home #tabs { [data-template="home"] #tabs {
margin-top: calc(0px - (10 * var(--unit--vertical))); margin-top: calc(0px - (10 * var(--unit--vertical)));
} }
button.toggle.left::after { button.toggle.left::after {

View file

@ -5,6 +5,7 @@
@import url("src/texts.css"); @import url("src/texts.css");
@import url("src/header.css"); @import url("src/header.css");
@import url("src/tabs.css"); @import url("src/tabs.css");
@import url("src/nav.css");
@import url("src/home.css"); @import url("src/home.css");
@import url("src/linear.css"); @import url("src/linear.css");
@import url("src/footer.css"); @import url("src/footer.css");

475
assets/dist/style.css vendored

File diff suppressed because one or more lines are too long

View file

@ -73,25 +73,24 @@ function roundToNearestHalf(num) {
return Math.max(round, 0); return Math.max(round, 0);
} }
function enableToggleTabsVisibility() { function enableToggleEntriesVisibility() {
const tabs = document.querySelector("#tabs"); const entries = document.querySelector("#entries");
const toggleLeftBtn = tabs.querySelector("button.toggle.left");
const toggleRightBtn = tabs.querySelector("button.toggle.right");
const toggleLeftBtnWidth = toggleLeftBtn.offsetWidth;
const toggleRightBtnWidth = toggleRightBtn.offsetWidth;
toggleLeftBtn.style = `--width: ${toggleLeftBtnWidth}px`; const leftBtn = entries.querySelector(".entry-btn--left");
toggleRightBtn.style = `--width: ${toggleRightBtnWidth}px`; const rightBtn = entries.querySelector(".entry-btn--right");
const leftBtnWidth = leftBtn.offsetWidth;
const rightBtnWidth = rightBtn.offsetWidth;
const toggleVisibility = (entries) => { leftBtn.style = `--width: ${leftBtnWidth}px`;
entries.forEach((entry) => { rightBtn.style = `--width: ${rightBtnWidth}px`;
const isIntersecting = entry.isIntersecting;
const toggleVisibility = (items) => {
items.forEach((item) => {
const isIntersecting = item.isIntersecting;
if (isIntersecting) { if (isIntersecting) {
console.log("is intersecting"); entries.classList.remove("minimized");
tabs.classList.remove("minimized");
} else { } else {
console.log("is not intersecting"); entries.classList.add("minimized");
tabs.classList.add("minimized");
} }
}); });
}; };
@ -104,7 +103,7 @@ function enableToggleTabsVisibility() {
threshold: 0, threshold: 0,
}); });
observer.observe(tabs); observer.observe(entries);
} }
function toggleLogoState() { function toggleLogoState() {
@ -132,6 +131,6 @@ document.addEventListener("DOMContentLoaded", () => {
// Wait for fonts applied // Wait for fonts applied
setTimeout(() => { setTimeout(() => {
enableToggleTabsVisibility(); enableToggleEntriesVisibility();
}, 100); }, 100);
}); });

View file

@ -9,12 +9,12 @@
<script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script> <script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script>
<meta name="robots" content="noindex, nofollow, noarchive"> <meta name="robots" content="noindex, nofollow, noarchive">
</head> </head>
<body class="grid"> <body class="grid" data-template="<?= $page->template() ?>">
<header id="main-header"> <header id="main-header">
<div id="logo" > <div id="logo" >
<a href="/" class="no-line"> <a href="/" class="no-line">
<h1 id="actuel">actuel</h1> <h1 id="actuel">actuel</h1>
<h1 id="inactuel">inactuel</h1> <h1 id="inactuel">inactuel</h1>
</a> </a>
</div> </div>
</header> </header>

4
site/snippets/nav.php Normal file
View file

@ -0,0 +1,4 @@
<nav id="entries">
<button class="entry-btn entry-btn--left">années</button>
<button class="entry-btn entry-btn--right">categories</button>
</nav>

View file

@ -29,7 +29,7 @@ $activeTab = isset($activeTab) ? Str::slug($activeTab) : '';
:class="activeTab === 'texts' ? 'open' : 'close'" :class="activeTab === 'texts' ? 'open' : 'close'"
title="Voir tous les textes" title="Voir tous les textes"
@click="toggleTab($data, 'texts')" @click="toggleTab($data, 'texts')"
>textes</button> >catégories</button>
</div> </div>
<div <div
class="active-tab" class="active-tab"
@ -70,8 +70,8 @@ $activeTab = isset($activeTab) ? Str::slug($activeTab) : '';
<?php snippet( <?php snippet(
'text-item', 'text-item',
[ [
'article' => $article 'article' => $article
] ]
) ?> ) ?>
<?php endif ?> <?php endif ?>
<?php endforeach ?> <?php endforeach ?>

View file

@ -1,6 +1,6 @@
<?php snippet('header') ?> <?php snippet('header') ?>
<main id="<?= $page->template() ?>"> <main>
<?php snippet('cover', slots: true) ?> <?php snippet('cover', slots: true) ?>
<?php slot('title') ?> <?php slot('title') ?>
<h2 class="title-center"> <h2 class="title-center">

View file

@ -18,12 +18,7 @@
</p> </p>
<?php endslot() ?> <?php endslot() ?>
<?php endsnippet() ?> <?php endsnippet() ?>
<?php snippet('tabs', [ <?php snippet('nav') ?>
'left' => [
'label' => 'édito ' . $page->parent()->title(),
'content' => $page->parent()->edito()
],
]) ?>
<?= $page->body() ?> <?= $page->body() ?>
</article> </article>
</main> </main>