From e463223e15ff95ba58726ddf7b652a1a9cd41059 Mon Sep 17 00:00:00 2001 From: sptaule Date: Mon, 31 Jan 2022 18:43:17 +0100 Subject: [PATCH] Fix doc submenus states, doc links hover, split page & global ToC --- src/input.css | 2 +- static/js/site.js | 7 +--- templates/documentation.html | 5 +-- templates/partials/doc/global_toc.html | 12 ++++--- templates/partials/doc/global_toc_script.html | 35 +++++++++++++++++++ .../{toc_script.html => page_toc_script.html} | 25 ------------- templates/partials/shared/nav.html | 9 +++-- templates/partials/shared/search.html | 13 +++++-- 8 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 templates/partials/doc/global_toc_script.html rename templates/partials/doc/{toc_script.html => page_toc_script.html} (63%) diff --git a/src/input.css b/src/input.css index 1f4e978..f842bc1 100755 --- a/src/input.css +++ b/src/input.css @@ -91,7 +91,7 @@ p > code, p > strong > code, li > code, li > strong > code { } .page-content a { - @apply font-semibold text-garage-orange border-b hover:border-garage-gray border-garage-orange bg-transparent hover:bg-garage-orange hover:text-white hover:rounded-sm hover:no-underline duration-150 transition; + @apply font-semibold text-garage-orange border-b border-garage-orange hover:text-red-500 hover:border-red-500 transition-all duration-500; } .page-content img { diff --git a/static/js/site.js b/static/js/site.js index d8e0d69..77913c3 100755 --- a/static/js/site.js +++ b/static/js/site.js @@ -195,12 +195,7 @@ function documentReadyCallback() { } document.addEventListener('click', function(ev) { - if (ev.target.matches('#nav-search-btn') || ev.target.matches('#nav-search-btn-icon')) { - openSearchModal(); - } - else if (ev.target.matches('#close-modal-btn') - || ev.target.matches('#close-modal-btn-icon') - || !ev.target.closest('#search-modal')) { + if (!ev.target.closest('#search-modal')) { closeSearchModal(); } }); diff --git a/templates/documentation.html b/templates/documentation.html index d22d9e6..3f48e55 100644 --- a/templates/documentation.html +++ b/templates/documentation.html @@ -13,7 +13,7 @@ {% include "partials/doc/global_toc.html" %}
-
+

{{ page.title }} @@ -53,6 +53,7 @@ {% set page = section %} {% endif %} {% if page.toc %} - {% include "partials/doc/toc_script.html" %} + {% include "partials/doc/page_toc_script.html" %} {% endif %} + {% include "partials/doc/global_toc_script.html" %} {% endblock %} diff --git a/templates/partials/doc/global_toc.html b/templates/partials/doc/global_toc.html index 277739c..eea7d26 100644 --- a/templates/partials/doc/global_toc.html +++ b/templates/partials/doc/global_toc.html @@ -7,7 +7,7 @@ {% for page in section.pages %} {{ page.title }} @@ -19,13 +19,15 @@
  • + class="bg-white border border-garage-orange block p-1 rounded-r rounded-tl font-semibold {% if current_path == h1.path %}activePage text-garage-orange font-semibold border-opacity-100 border-garage-orange{% else %}text-gray-800{% endif %}"> {{ h1.title }} {% if h1.pages %} - + diff --git a/templates/partials/doc/global_toc_script.html b/templates/partials/doc/global_toc_script.html new file mode 100644 index 0000000..42abcda --- /dev/null +++ b/templates/partials/doc/global_toc_script.html @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/templates/partials/doc/toc_script.html b/templates/partials/doc/page_toc_script.html similarity index 63% rename from templates/partials/doc/toc_script.html rename to templates/partials/doc/page_toc_script.html index 7d10ee6..efe4bac 100644 --- a/templates/partials/doc/toc_script.html +++ b/templates/partials/doc/page_toc_script.html @@ -5,22 +5,6 @@ const mainTocMenuWidth = document.getElementById('main-toc-menu').clientWidth; const tocItems = document.querySelectorAll(".toc"); const navSections = new Array(tocItems.length); - // Global ToC -/* - Fixed ToC when user scrolls. -*/ - -window.addEventListener('scroll', function() { - if (window.screen.width >= 1280) { - if (window.scrollY >= menuBarHeight) { - document.getElementById('main-toc-menu').classList.add('fixed', 'top-0', 'left-0'); - document.getElementById('main-toc-menu').style.width = mainTocMenuWidth + 'px'; - } else { - document.getElementById('main-toc-menu').classList.remove('fixed', 'top-0', 'left-0'); - } - } -}); - // Page content /* Focus effect on current section anchor when user scrolls. @@ -70,13 +54,4 @@ window.addEventListener('scroll', () => { } }, false); -document.addEventListener("DOMContentLoaded", function() { - var menusTriggers = document.getElementsByClassName("deploySubMenu"); - var activeDocPage = document.getElementsByClassName("activePage")[0]; - for (var i = 0; i < menusTriggers.length; i++) { - menusTriggers[i].checked = true; - } - activeDocPage.parentElement.parentElement.previousElementSibling.previousElementSibling.checked = false; -}); - diff --git a/templates/partials/shared/nav.html b/templates/partials/shared/nav.html index a4a4b99..adb1a70 100644 --- a/templates/partials/shared/nav.html +++ b/templates/partials/shared/nav.html @@ -22,13 +22,16 @@ {% endfor %} {% endif %} {% endfor %} - + + + + diff --git a/templates/partials/shared/search.html b/templates/partials/shared/search.html index cb0ae2e..c41feca 100644 --- a/templates/partials/shared/search.html +++ b/templates/partials/shared/search.html @@ -17,9 +17,16 @@
  • - +
    \ No newline at end of file