-
Notifications
You must be signed in to change notification settings - Fork 357
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
Dark mode #214
Dark mode #214
Conversation
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.
Thanks for your contribution! Here are some comments.
I have some more about the way you switch classes but have no time to explore ways now.
It needs some edits to be easily readable and perf efficient.
PS: I love your commit name
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.
Left some comments, thanks for contributing! 🎉
Great work so far, just needs some polishing 💅
src/js/index.js
Outdated
for (var i =0; i<refs.length; i++) { | ||
refs[i].classList.toggle("dark_refs"); | ||
} | ||
}); |
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.
Could you run npm run lint
and fix any issues? Thanks!
One more thing in general - I don't like the small moon icon being a trigger, I think we should have something more substantial, with a label that tells you what's happening |
Thank you, I knew I was a long way from perfect, just needed some feedback to know I am on the right track. I will work on it soon. Also, I am sorry if I am not 100% technically correct with my commits, this is one of my first times contributing to a big project. :) |
Hope you like this version better. Cheers and merry christmas :) |
Waiting for some feedback. If something needs to change please tell me. |
@@ -7,14 +7,15 @@ meta(http-equiv="X-UA-Compatible" content="IE=edge") | |||
|
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.
These changes should be reverted.
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.
Just added a bunch of comments, do not hesitate to ask any question you need!
I keep getting an error when running lint but I have not been able to see what's wrong whatsoever :/ |
As I said in the comment, start by running |
I keep getting this error. Any idea why? |
Please rebase on master, I should have fixed your problem with #244 |
|
Should I stash the changes from #244 or include them too? |
@aslafy-z I'll review after you approve 🙂 |
Just merge your branch with upstream/master and fix conflicts |
I'm really sorry I messed up with your branch.. GitHub doesn't let me reopen the PR till there is content in there so i'll after you pushed. I've could have fixed it myself if GitHub haven't close the PR letting me without repo access. Sorry for that :/ |
I can only push to my upstream repo, with this PR being closed :/ . How should I go with this? |
Since you're trying to merge from sseficha:master, you should force push your changes there As a personal note, it's usually a good idea to create a branch rather than work directly off of master - here's a great guide from GitHub as to how a general workflow can be like: https://guides.github.com/introduction/flow/ |
I am force pushing my changes to sseficha:master, but they aren't being synced here like the previous times. I was using different branches, but I was pushing my changes to master so that they will be reflected to the PR. |
src/styl/imports/dark-theme.styl
Outdated
& h1, p, span | ||
color white !important | ||
& a | ||
color #d11717 !important |
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.
This file misses a ending new line, you need to run lint !
=> Lint should be ran automatically on commit with husky and lint-staged modules
Why is it not working for you ?
I think you should do a clean merge or rebase from upstream because it looks that you misses files.
You may want to do a npm install again also.
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.
I ran lint but it didn't show any errors! Guess it may be missing something. I will run npm again.
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.
Does it works for you now?
@@ -104,3 +105,26 @@ window.addEventListener('load', () => { | |||
|
|||
cascade.call(window, true); | |||
}); | |||
|
|||
function setTheme(preference) { |
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.
There is lot of repetitions in this function and the following one, maybe we can do something to get some more generic theme switching engine ? staying simple
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.
Ok got it.
if (preference === 'dark') { | ||
document.body.classList.add('dark'); | ||
colorSwitch.innerHTML = 'Light mode'; | ||
} else if (preference === 'light' || preference === null) { |
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.
} else if (preference === 'light' || preference === null) { | |
} else if (preference === 'light' || !preference) { |
function setTheme(preference) { | ||
if (preference === 'dark') { | ||
document.body.classList.add('dark'); | ||
colorSwitch.innerHTML = 'Light mode'; |
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.
I think it would be better to set colorSwitch.textContent
here since the value used is plaintext and doesn't contain any HTML (this also applies to line 115).
@sseficha Here's an example of ~ what I was thinking for dark mode: https://overreacted.io/ |
Added a dark mode switch! Awaiting feedback :)
Fixes #106