refactoring avec claude + ajout scroll-margin-top et désaffichage du panel au click sur les liens du toc
This commit is contained in:
parent
d51fc592ed
commit
01c5b098e4
14 changed files with 149 additions and 121 deletions
|
|
@ -8,9 +8,9 @@ $isOpen ??= false;
|
|||
<?= $slots->title() ?>
|
||||
</a>
|
||||
</div>
|
||||
<?php if ($page->parent() && $page->parent()->parent()->is('textes')){
|
||||
snippet('toc', ["content" => $page->bodyBlocks()->toBlocks()]);
|
||||
} ?>
|
||||
<?php if ($page->hasToc()): ?>
|
||||
<?php snippet('toc') ?>
|
||||
<?php endif ?>
|
||||
<?php if ($slots->text()): ?>
|
||||
<div class="text-wrapper">
|
||||
<?= $slots->text() ?>
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
<?php if (!$page->is(page('lettre')) && !$page->is(page('a-propos'))): ?>
|
||||
<footer id="main-footer">
|
||||
<ul id="links">
|
||||
<li class="open-nav-wrapper open-nav-wrapper_text hidden">
|
||||
<button class="plus open-nav open-nav_text" title="chercher parmi les textes">textes</button>
|
||||
<li class="open-nav-wrapper hidden">
|
||||
<button class="plus open-nav" data-open-panel="text" title="chercher parmi les textes">textes</button>
|
||||
</li>
|
||||
<?php if ($page->parent() && $page->parent()->parent()->is('textes')): ?>
|
||||
<li class="open-nav-wrapper open-nav-wrapper_toc hidden if_toc">
|
||||
<button class="plus open-nav open-nav_toc" title="ouvrir le sommaire">sommaire</button>
|
||||
<?php if ($page->hasToc()): ?>
|
||||
<li class="open-nav-wrapper hidden">
|
||||
<button class="plus open-nav" data-open-panel="toc" title="ouvrir le sommaire">sommaire</button>
|
||||
</li>
|
||||
<?php endif ?>
|
||||
<li>
|
||||
|
|
|
|||
|
|
@ -84,13 +84,7 @@ $entryTopPos ??= 20;
|
|||
|
||||
<body
|
||||
class="background-grid <?= e($page->fullWidth() == 'true', 'full-width') ?>"
|
||||
data-is_toc="<?php
|
||||
if ($page->bodyBlocks() && $page->bodyBlocks()->isNotEmpty() && preg_match('/<h3>(.*?)<\/h3>/', $page->bodyBlocks())){
|
||||
echo "true";
|
||||
}else{
|
||||
echo "false";
|
||||
}
|
||||
?>"
|
||||
data-has-toc="<?= $page->hasToc() ? 'true' : 'false' ?>"
|
||||
data-template="<?= $page->template() ?>">
|
||||
<button class="theme-toggler" data-theme-toggler>
|
||||
<span class="theme-toggler-icon"></span>
|
||||
|
|
@ -107,8 +101,7 @@ $entryTopPos ??= 20;
|
|||
</a>
|
||||
</header>
|
||||
<?php snippet('nav') ?>
|
||||
<?php if ($page->parent() && $page->parent()->parent()->is('textes')){
|
||||
snippet('panel-toc');
|
||||
}
|
||||
?>
|
||||
<?php if ($page->hasToc()): ?>
|
||||
<?php snippet('panel-toc') ?>
|
||||
<?php endif ?>
|
||||
<div id="nav-overlay"></div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
<nav class="panel panel-text" x-data="{search: ''}">
|
||||
<nav class="panel panel-text" data-panel="text" x-data="{search: ''}">
|
||||
<header>
|
||||
<p class="sort-btns">
|
||||
<button class="sort-btn sort-btn--years active">années</span></button>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,4 @@
|
|||
<div class="panel panel-toc" x-data="{search: ''}">
|
||||
<?php
|
||||
snippet('toc', ["content" => $page->bodyBlocks()->toBlocks()]);
|
||||
?>
|
||||
<div class="panel panel-toc" data-panel="toc">
|
||||
<?php snippet('toc') ?>
|
||||
<button class="less panel-close">sommaire</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,8 @@
|
|||
<nav class="toc">
|
||||
<div class="light toc_label if_toc">Sommaire</div>
|
||||
<div class="light toc_label">Sommaire</div>
|
||||
<ul>
|
||||
<?php
|
||||
preg_match_all('/<h3>(.*?)<\/h3>/', $content, $titres);
|
||||
foreach ($titres[1] as $index => $titre) {
|
||||
$slug = Str::slug($titre);
|
||||
echo '<li><a href="#' . $slug . '">' . $titre . '</a></li>';
|
||||
}
|
||||
?>
|
||||
<?php foreach ($page->tocItems() as $item): ?>
|
||||
<li><a href="#<?= $item['slug'] ?>"><?= $item['title'] ?></a></li>
|
||||
<?php endforeach ?>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue