-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed error caused by getDarkMode in edit page #156
Fixed error caused by getDarkMode in edit page #156
Conversation
Thank you @bryan-brancotte for this Removal. I was also doubtful whether to have a single button for the whole website or let it be on all pages. |
That bottom-border colour was needed to be changed, cause we changed class="page-header" to id="page-header" for the front page in #143, so those styling which this edit page was using get changed so added it separately. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You indeed found an issue, but the PRis partially fixing it. I recommend you start a first PR with the css fix which is sound (I'll merge it right away). And a second in which you will investigate why there is a js issue.
Indentation change was required because of addition of if-else statement, so reformatting was needed. Please check @bryan-brancotte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi,
You indeed spotted the issue well, the solution is working, but is refactoring a too much.
Indentation
There was an incorrect indentation here and it is still present : when opening a new curly bracket indetation should go on level more.
Smaller test
Also, and even if your solution works, you could have done it with less refactoring :
- Here you get the button
- Here you add a listener
- You could have simply tested right before if btn was null and then returning :
if (null == btn || undefinfed == btn)
return;
@bryan-brancotte have a look. |
If button isn't present then still we need to check for the current theme for application on edit page. We can't simply return no @bryan-brancotte |
and after fixing the indentation, and removing a tab function getDarkMode() {
const btn = document.querySelector(".btn-toggle");
const currentTheme = localStorage.getItem("theme");
if (currentTheme == "dark") {
document.body.classList.add("dark-mode");
}
if (null == btn || undefined == btn)
return;
btn.addEventListener("click", function () {
document.body.classList.toggle("dark-mode");
let theme = "light";
if (document.body.classList.contains("dark-mode")) {
theme = "dark";
}
localStorage.setItem("theme", theme);
});
} |
sorry for complicating things 😓 now good to merge |
not complicating things, learning things |
Checklist
Issue
fix #154
Details
this went unnoticed when I proposed those changes.