-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add dark mode feature #26
Add dark mode feature #26
Conversation
✅ Deploy Preview for makedeb ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
Thanks a ton for this! I've been wanting this done for a while, I just never got around to doing it. I'm gonna be busy for a bit today, but I'll get this checked out by the end of the day with some review comments. There's a few things I'd like changed, I agree with the comments @Heus-Sueh made, but I can give some when I get a chance to look at everything more later today. |
@Heus-Sueh I agree with you. I'll be working on the button and the background of the code 🤓 |
I think I'm asking a lot but can you make the change that this issue proposes? |
@Heus-Sueh Yeah, I'll look into it. |
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.
Most of my comments are visual, though one placement thing is under a separate comment below;
- Is there any CDN to get the two icons you used from? Currently Jam icons is used for most things, but the icons you got look quite good with the text next to it in the header bar (the lines being close to the same width as the text next to it makes it work really good imo). Just because the Jam icons are loaded directly from the website though, I'd also like to load these two icons in the same manner.
- The clipboard icon on the homepage (visible if you hover over the codeblock under
Install makedeb
) isn't changing colors with the rest of the codeblock. - The border color under the post boxes on the News page looks a bit too light under the dark mode.
#464646
looked pretty good in my local testing. - With the border color change above, I also think the date text on post boxes could be a bit lighter on dark mode, I think
#bfbfbf
works pretty good. - The
<hr>
line elements on individual news post pages looks a bit too bright for me,#6a6a6a
was a nice color when I tried changing it. - I think the theme changer icon could have no border on it, and then just have a background that blends in with the rest of the header. The line color for it could just change like the links in the header bar too, thus making it all look unified.
And then I also had some other issues, but I'm not quite sure how they should be solved yet:
- The icon doesn't look quite in place on the mobile view - it feels like it should be separated from the links, but putting it on it's own line feels a bit off too.
- The Authelia and Prism Launcher logos under
Ready for Production
don't stand out enough on the dark theme. I'll probably have to reach out to the two teams to see if I could get some dark-theme friendly icons.
I'll probably have to think about at least that first one, if you got any thoughts feel free to throw them out too.
With all of that though, thanks again for getting support for this going! It's definitely long overdue, and I'm really looking forward to getting it merged in :)
|
||
<script> | ||
initialThemeLoad() | ||
|
||
const toggleThemeBtn = document.getElementById("toggle-theme-button") | ||
toggleThemeBtn?.addEventListener("click",function(){ | ||
const body = document.body | ||
if (body.className=="dark") | ||
{ | ||
setBodyClass("") | ||
toggleThemeBtn?.classList.remove("active") | ||
changeBtnIcon("moon") | ||
localStorage.removeItem("theme") | ||
} | ||
else { | ||
toggleThemeBtn?.classList.add("active") | ||
changeBtnIcon("sun") | ||
localStorage.setItem("theme", "dark") | ||
setBodyClass("dark") | ||
} | ||
}) | ||
|
||
/** | ||
* Makes nessesary changes for initial theme load | ||
*/ | ||
function initialThemeLoad(){ | ||
const toggleThemeBtn = document.getElementById("toggle-theme-button") | ||
const theme = localStorage.getItem("theme") | ||
if (theme == "dark") { | ||
setBodyClass("dark") | ||
changeBtnIcon("sun") | ||
toggleThemeBtn?.classList.add("active") | ||
} else changeBtnIcon("moon") | ||
} | ||
|
||
/** | ||
* Changes the body class | ||
* @param {string} className - class name to be set | ||
*/ | ||
function setBodyClass(className){ | ||
const body = document.body | ||
body.className = className | ||
} | ||
|
||
/** | ||
* Changes theme toggle button's icon | ||
* @param {"sun" | "moon"} iconType - icon type to be displayed | ||
*/ | ||
function changeBtnIcon(iconType){ | ||
const sunIcon = document.getElementById("sun-icon") | ||
const moonIcon = document.getElementById("moon-icon") | ||
if (iconType == "sun"){ | ||
moonIcon?.classList.remove("active-icon") | ||
sunIcon?.classList.add("active-icon") | ||
} | ||
if (iconType == "moon"){ | ||
sunIcon?.classList.remove("active-icon") | ||
moonIcon?.classList.add("active-icon") | ||
} | ||
} | ||
</script> |
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.
Can we put this in a separate file just so the code doesn't get too messy? Just somewhere like static/js/color-theme.js
would work.
Pinging @hiddeninthesand too since you were the one originally wanting it. Do you any comments about how you'd like all this implemented? |
@Heus-Sueh: That probably needs to be done as a separate PR under the |
yeah... because maybe that requires more drastic changes in the structure 👍 |
Yeah it'll probably take more work on the MPR side just because there's more pages to set up, nothing much should have to change for this PR though - every project has it's own code for the CSS, I just kind of copy-paste through the projects as I've needed |
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.
Hey, I just got one tiny change. I didn't quite like how the JavaScript file was added (there was some indentation stuff that looked a bit foreign to me), so I went ahead an added Prettier for code formatting as well so everything's looking clean.
themes/makedeb/static/js/theme.js
Outdated
function setBodyClass(className) { | ||
const body = document.body; | ||
body.className = className; | ||
} |
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.
Can't this just be written in one line as document.body.className = blahBlah
and then put directly in the toggleThemeBtn?.addEventListener
callback above? Since that's how things like toggleThemeBtn?.classList.remove
are being used I think that'd make the code more consistent.
Some other things too:
|
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.
Alright, this is looking really good! I just need to get the two logos from Authelia/Prism Launcher, get one last issue fixed, and this should be good to merge :)
.dark .themeHeaderColor { | ||
background-color: #1e1e1e; | ||
} | ||
.dark .themeTextColor { | ||
color: #fff; | ||
} | ||
.dark .themeHeaderHrColor { | ||
color: #111111; | ||
background-color: #111111; | ||
} | ||
.dark .themeBackgroundColor { | ||
color: #fff; | ||
background-color: #2d2d2d; | ||
border-color: #464646; | ||
} | ||
.dark .themeFactsColor { | ||
color: #fff; | ||
background-color: #272727; | ||
} | ||
.dark .themeCodeColor { | ||
color: #fff; | ||
background-color: #202020; | ||
} | ||
.dark .themeClipboardCheckedColor { | ||
color: #40a85c; | ||
background-color: #202020; | ||
} | ||
.dark .themePostContentDateColor { | ||
color: #bfbfbf; | ||
} | ||
.dark .themePostHrColor { | ||
background-color: #6a6a6a; | ||
} | ||
.dark .themeCardsColor { | ||
background-color: #262626; | ||
color: #fff; | ||
} |
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 just realized this, but could .light .theme*
variants also be created? The places where these are used already have a background-color
defined manually (such as in scss/post.scss:5
), and if they were defined in a .light .theme*
block in here (and the the background-color
/color
/etc. calls removed in the other places) it would make the code more consistent.
themes/makedeb/static/js/theme.js
Outdated
initialThemeLoad(); | ||
|
||
const toggleThemeBtn = document.getElementById("toggle-theme-button"); | ||
toggleThemeBtn?.addEventListener("click", function () { |
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 actually didn't know about this ?
stuff until now, apparently it's called optional chaining? If so, we should probably remove it so that errors are raised when elements don't exist (since they always should), right?
It all looks good to me! I can't see anything questionable. |
@hwittenborn Hey! I just wanted to inquire about the status of my pull request. Can you please let me know if any further changes or updates are needed before it can be merged? I am looking forward to seeing it incorporated into the project. |
Sorry about that @sumanbiswas7, I got a bit sidetracked with some stuff and forget to get this looked at. Once I'm home (in about 4 hours) I'll get this reviewed. Everything was pretty much fine the last time I checked though, I'm pretty sure I just need to get a dark theme friendly icon from Authelia and we're set. |
themes/makedeb/assets/scss/post.scss
Outdated
hr { | ||
@extend .themePostHrColor; | ||
} | ||
hr { | ||
@extend .themePostHrColor; | ||
} |
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 duplication isn't needed, right? Also I think we could just remove it entirely and apply this styling to all <hr>
in main.scss
, as places like /donate
have the <hr>
element a bit too bright on the dark theme.
border-color: darken($silver, 10%); | ||
border-width: 0.15em; | ||
@extend .themeCardsColor; |
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.
The border-color
here is a bit too light on the dark theme (see the cards on /news
) - could this be one of the theme-toggleable colors, with the dark theme having it set to something like #4d4d4d
?
Those should be the last two things, other than that it should be ready to go once I get the Authelia icon. |
@hwittenborn The Authelia website link which is attached to homepage is using a different logo. Seems like they have updated their logo. If that's the case can we use the below logos that I extracted? |
I'm pretty sure that's just the font style from the documentation theme they use :p. |
Just need to get those two icons figured out and this'll be good to merge :) |
Hey, just sending a message so you know what's going on @sumanbiswas7: I'm messaging the Authelia people in that issue above, and everything's in the process for getting a dark logo going. Once that's done I'll get the two logos added, get the needed JS code going, and then I'll just have you look over the changes to make sure you're fine with them. After that everything should be good to go, and I'll get this merged in :). |
@hwittenborn Hello 👋. |
Hey @sumanbiswas7, I just added in the new dark-friendly logos, and I made a few other changes while I was at it. Let me know if there's anything I did that you'd like changed, and then this can get merged right in! |
I'm terribly sorry on the wait too, it's definitely not the way I wanted everything to go. I've been juggling about 5 projects right now, and some end up falling behind like this when I'm zoning in on a specific one. I'm still trying to figure out how to balance everything in a good way with all my daily activities, but I just wanted to send a message about all that's been going on. |
@hwittenborn no worries. hoping to see this getting merged soo. :) |
Alright, sounds great! Thanks a ton for all the work you put in for thing, I'm really happy to finally see some stuff for a dark mode! I'll go ahead and get this merged in :) |
Feature working on pages
/
,/news
,news/[post]
,/donate
localStorage
Fixes #1