From fa45dfcfff2708aa455ca61c1bcdd3c7b8215f84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anur=20Ba=C5=A1i=C4=87?= <48890281+bashovski@users.noreply.github.com> Date: Thu, 24 Oct 2019 19:31:34 +0200 Subject: Added dynamic icon container shifting depending on width of child-containers of navbar. --- layouts/partials/nav.html | 11 ++++++----- static/css/style.css | 8 +++----- static/js/navicon-shift.js | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 static/js/navicon-shift.js diff --git a/layouts/partials/nav.html b/layouts/partials/nav.html index 96993e4..69f6f8d 100644 --- a/layouts/partials/nav.html +++ b/layouts/partials/nav.html @@ -1,13 +1,13 @@
-
\ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index 21971c8..4688229 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -5267,11 +5267,9 @@ a.nav-item.is-tab.is-active { z-index: 2; } -@media (max-width:767px) { - .nav { - display: grid; - grid-template-columns: auto; - } +.nav-shifted { + display: grid !important; + grid-template-columns: auto !important; } .panel-heading, diff --git a/static/js/navicon-shift.js b/static/js/navicon-shift.js new file mode 100644 index 0000000..b87ec9f --- /dev/null +++ b/static/js/navicon-shift.js @@ -0,0 +1,24 @@ +const + nameElement = document.getElementById('nav-name'), + parentElement = document.getElementById('nav-main'); + +let incremented = 0; +function shiftNavIcons() { + + let headingElement = document.getElementById('nav-heading'); + if(nameElement.offsetWidth < (headingElement.offsetWidth+10)) { + parentElement.classList.add('nav-shifted'); + } else { + incremented++; + if(incremented > 5 && parentElement.offsetWidth > 445) { + parentElement.className = parentElement.className.replace(/\bnav-shifted\b/g, ''); + incremented = 0; + } + + } + +}; +window.addEventListener('resize', (event) => { + shiftNavIcons(); +}); +shiftNavIcons(); \ No newline at end of file -- cgit v1.2.3