ready for PR
This commit is contained in:
17
www/js/styles/nav-burger.js
Normal file
17
www/js/styles/nav-burger.js
Normal file
@@ -0,0 +1,17 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
// Get all "navbar-burger" elements
|
||||
const $navbarBurgers = Array.prototype.slice.call(document.querySelectorAll('.navbar-burger'), 0);
|
||||
|
||||
// Add a click event on each of them
|
||||
$navbarBurgers.forEach(el => {
|
||||
el.addEventListener('click', () => {
|
||||
// Get the target from the "data-target" attribute
|
||||
const target = el.dataset.target;
|
||||
const $target = document.getElementById(target);
|
||||
|
||||
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
||||
el.classList.toggle('is-active');
|
||||
$target.classList.toggle('is-active');
|
||||
});
|
||||
});
|
||||
});
|
||||
11
www/js/styles/nav-state.js
Normal file
11
www/js/styles/nav-state.js
Normal file
@@ -0,0 +1,11 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
// Check for click events on the navbar burger icon
|
||||
$(".navbar-burger").click(function() {
|
||||
|
||||
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
|
||||
$(".navbar-burger").toggleClass("is-active");
|
||||
$(".navbar-menu").toggleClass("is-active");
|
||||
|
||||
});
|
||||
});
|
||||
27
www/js/styles/toggle-theme.js
Normal file
27
www/js/styles/toggle-theme.js
Normal file
@@ -0,0 +1,27 @@
|
||||
// toggle-theme.js
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const themeToggleButton = document.querySelector('.js-theme-toggle');
|
||||
const htmlElement = document.documentElement;
|
||||
const icon = themeToggleButton.querySelector('.icon i');
|
||||
|
||||
// Toggle theme on button click
|
||||
themeToggleButton.addEventListener('click', function () {
|
||||
if (htmlElement.classList.contains('theme-dark')) {
|
||||
htmlElement.classList.remove('theme-dark');
|
||||
htmlElement.classList.add('theme-light');
|
||||
localStorage.setItem('theme', 'theme-light');
|
||||
|
||||
// Change icon to moon (light mode)
|
||||
icon.classList.remove('fa-sun');
|
||||
icon.classList.add('fa-moon');
|
||||
} else {
|
||||
htmlElement.classList.remove('theme-light');
|
||||
htmlElement.classList.add('theme-dark');
|
||||
localStorage.setItem('theme', 'theme-dark');
|
||||
|
||||
// Change icon to sun (dark mode)
|
||||
icon.classList.remove('fa-moon');
|
||||
icon.classList.add('fa-sun');
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user