Skip to content

Commit

Permalink
fix toggle in design system docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcilurzo committed Aug 21, 2024
1 parent a3edca4 commit e12926f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
4 changes: 3 additions & 1 deletion .eleventy.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ module.exports = async function(eleventyConfig) {
],
});*/
}
else { console.log(`SSR plugin not active`);}
else {
//console.log(`SSR plugin not active`);
}


eleventyConfig.setLibrary('md', markdownLib)
Expand Down
4 changes: 4 additions & 0 deletions src/assets/css/_content.scss
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,8 @@ h3 {

p.subtext {
color: var(--sbb-color-metal);
}

.switcher {
margin-bottom: 16px;
}
35 changes: 18 additions & 17 deletions src/assets/js/mode-toggle.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
const oneswitch = document.querySelectorAll(".switch");
const switcher = document.querySelectorAll(".switcher");
const images = document.querySelectorAll('.boxed-image');
oneswitch.forEach(function (element) {
element.addEventListener("click", modeSwitch);
switcher.forEach(function (element) {
element.addEventListener("change", modeSwitch);
});
number = 0;
function modeSwitch() {
if (this.value != this.parentElement.value) {
oneswitch.forEach(function (tog) {
if(number % 2 == 0) {
if (tog.parentElement.value == "dark") {
tog.parentElement.setAttribute("value", "light")
} else {
tog.parentElement.setAttribute("value", "dark")
}
}
number++;
if (this.value == "light") {
switcher.forEach(function (element) {
element.firstElementChild.click();
images.forEach(function (element) {
element.classList.add("light");
element.classList.remove("dark");
});
images.forEach(function (img) {
img.classList.toggle("light");
img.classList.toggle("dark");
});
} else {
switcher.forEach(function (element) {
element.lastElementChild.click();
images.forEach(function (element) {
element.classList.add("dark");
element.classList.remove("light");
});
}
});
}
}

0 comments on commit e12926f

Please sign in to comment.