diff --git a/resources/css/components/index-panel.css b/resources/css/components/index-panel.css index b6359c9..a02a48b 100644 --- a/resources/css/components/index-panel.css +++ b/resources/css/components/index-panel.css @@ -14,6 +14,13 @@ @apply w-7 h-7 block; } } + button#mobile-open-toggle { + @apply lg:hidden ml-auto !opacity-100; + .icon { + transition: transform 0.3s ease-in-out; + @apply h-10 w-10; + } + } button[aria-selected='true'] { @apply text-primary opacity-100; .icon { @@ -75,3 +82,31 @@ } } } + +@media (max-width: 1024px) { + .index-panel__content { + transition: height 0.3s ease-in-out; + } + + .index-panel[data-mobile-open='false'] .index-panel__content { + @apply h-0 py-2; + ul.sommaire-index, + ul.footnotes-index { + @apply hidden; + } + } + + .index-panel[data-mobile-open='true'] .index-panel__header { + @apply h-fit py-4; + button#mobile-open-toggle { + img { + transition: transform 0.3s ease-in-out; + @apply rotate-180; + } + } + ul.sommaire-index, + ul.footnotes-index { + @apply block; + } + } +} diff --git a/resources/css/pages/singles.css b/resources/css/pages/singles.css index 6a73104..14ff388 100644 --- a/resources/css/pages/singles.css +++ b/resources/css/pages/singles.css @@ -154,10 +154,11 @@ /* ON MOBILE, STICK ON THE BOTTOM OF THE ARTICLE */ /* We need to reverse the content order */ @media (max-width: 1024px) { - @apply sticky bottom-0; + @apply sticky bottom-0 z-50; order: 2; @apply sticky bottom-0; align-self: flex-end; + } } } diff --git a/resources/img/icons/open-close-arrow-button.svg b/resources/img/icons/open-close-arrow-button.svg new file mode 100644 index 0000000..574fe8d --- /dev/null +++ b/resources/img/icons/open-close-arrow-button.svg @@ -0,0 +1,4 @@ + diff --git a/resources/js/singles/index-panel.ts b/resources/js/singles/index-panel.ts index 94384a5..10c0b33 100644 --- a/resources/js/singles/index-panel.ts +++ b/resources/js/singles/index-panel.ts @@ -8,6 +8,24 @@ export default function handleIndexPanel(): void { observeTabsButtons(); observeFootnotesLinks(); observeSommaireLinks(); + handleMobileOpenToggle(); +} + +function handleMobileOpenToggle(): void { + const mobileOpenToggle = document.querySelector('#mobile-open-toggle'); + const indexPanel = document.querySelector('.index-panel'); + if (!mobileOpenToggle) return; + if (!indexPanel) return; + + mobileOpenToggle.addEventListener('click', () => { + const isMobileOpen = indexPanel.getAttribute('data-mobile-open'); + console.log(isMobileOpen); + if (isMobileOpen === 'true') { + indexPanel.setAttribute('data-mobile-open', 'false'); + } else { + indexPanel.setAttribute('data-mobile-open', 'true'); + } + }); } // HANDLE TABS diff --git a/template-parts/articles/index-panel.php b/template-parts/articles/index-panel.php index c252ccf..d4e7a06 100644 --- a/template-parts/articles/index-panel.php +++ b/template-parts/articles/index-panel.php @@ -1,5 +1,5 @@ -