diff options
author | Paul Duncan <pabs@pablotron.org> | 2021-10-17 19:52:10 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2021-10-17 19:52:10 -0400 |
commit | ba930dfe0ec42e181000a4e2c460805fceeb2d9a (patch) | |
tree | 59456802f7534cc0dac0fe2584eaed1638ca7243 /themes/hugo-pt2021/assets | |
parent | a3e0e3d86e0d2257c4ac5eff458a5605191ec533 (diff) | |
download | pablotron.org-ba930dfe0ec42e181000a4e2c460805fceeb2d9a.tar.bz2 pablotron.org-ba930dfe0ec42e181000a4e2c460805fceeb2d9a.zip |
add menu script, fix menu rendering on mobile
Diffstat (limited to 'themes/hugo-pt2021/assets')
-rw-r--r-- | themes/hugo-pt2021/assets/script.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/themes/hugo-pt2021/assets/script.js b/themes/hugo-pt2021/assets/script.js new file mode 100644 index 0000000..bc95b27 --- /dev/null +++ b/themes/hugo-pt2021/assets/script.js @@ -0,0 +1,15 @@ +// enable burger menu support +// src: https://bulma.io/documentation/components/navbar/ +document.addEventListener('DOMContentLoaded', () => { + "use strict"; + // iterate through burgers + Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0).forEach(e => { + e.addEventListener('click', () => { + // get target from data-target attribute + const t = document.getElementById(e.dataset.target); + + // toggle is-active on both burger and menu + [e, t].forEach(e => e.classList.toggle('is-active')); + }); + }); +}); |