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);
}
#home .page-cover {
[data-template="home"] .page-cover {
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) {
#home #tabs {
[data-template="home"] #tabs {
margin-top: calc(0px - (10 * var(--unit--vertical)));
}
button.toggle.left::after {

View file

@ -5,6 +5,7 @@
@import url("src/texts.css");
@import url("src/header.css");
@import url("src/tabs.css");
@import url("src/nav.css");
@import url("src/home.css");
@import url("src/linear.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);
}
function enableToggleTabsVisibility() {
const tabs = document.querySelector("#tabs");
const toggleLeftBtn = tabs.querySelector("button.toggle.left");
const toggleRightBtn = tabs.querySelector("button.toggle.right");
const toggleLeftBtnWidth = toggleLeftBtn.offsetWidth;
const toggleRightBtnWidth = toggleRightBtn.offsetWidth;
function enableToggleEntriesVisibility() {
const entries = document.querySelector("#entries");
toggleLeftBtn.style = `--width: ${toggleLeftBtnWidth}px`;
toggleRightBtn.style = `--width: ${toggleRightBtnWidth}px`;
const leftBtn = entries.querySelector(".entry-btn--left");
const rightBtn = entries.querySelector(".entry-btn--right");
const leftBtnWidth = leftBtn.offsetWidth;
const rightBtnWidth = rightBtn.offsetWidth;
const toggleVisibility = (entries) => {
entries.forEach((entry) => {
const isIntersecting = entry.isIntersecting;
leftBtn.style = `--width: ${leftBtnWidth}px`;
rightBtn.style = `--width: ${rightBtnWidth}px`;
const toggleVisibility = (items) => {
items.forEach((item) => {
const isIntersecting = item.isIntersecting;
if (isIntersecting) {
console.log("is intersecting");
tabs.classList.remove("minimized");
entries.classList.remove("minimized");
} else {
console.log("is not intersecting");
tabs.classList.add("minimized");
entries.classList.add("minimized");
}
});
};
@ -104,7 +103,7 @@ function enableToggleTabsVisibility() {
threshold: 0,
});
observer.observe(tabs);
observer.observe(entries);
}
function toggleLogoState() {
@ -132,6 +131,6 @@ document.addEventListener("DOMContentLoaded", () => {
// Wait for fonts applied
setTimeout(() => {
enableToggleTabsVisibility();
enableToggleEntriesVisibility();
}, 100);
});

View file

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

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'"
title="Voir tous les textes"
@click="toggleTab($data, 'texts')"
>textes</button>
>catégories</button>
</div>
<div
class="active-tab"

View file

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

View file

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