Skip to content
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

added: a dark mode in css for us night dwellers #515

Merged
merged 5 commits into from
Mar 19, 2024

Conversation

ChrisMcKenzie
Copy link
Contributor

@ChrisMcKenzie ChrisMcKenzie commented Mar 14, 2024

This site has been a part of my reference site list for a long time but for me a dark theme user it gets a bit fatiguing so it would be nice to have a simple dark mode. hope it isn't offensive just thought it would be a nice addition.

the colors are based on tokyo_night

image

@mmcgrana
Copy link
Owner

In the past I've resisted adding dark mode support because I wasn't a fan of any complexity, but I'm coming around to it, if we do it only in CSS as in this PR.

I think we should iterate on the exact styling:

  • The white text on a dark background seems a little to thick to me, especially in the footer where we previously used grey-on-white.
  • I'd want to look for a theme that was more black and less purple-oriented. Of the styles here, github-dark and one-dark are the closest to me. I also think I had to tweak various values from the base theme when I did the light styling, but honestly it was so long ago I'm not sure.

If you're up to iterate on the styling per above please give it a shot. I also welcome any other observers to jump in with their own style suggestions.

I can't finalize the style myself right away but I can plan to get to it before too long, in the next week or so.

The CSS file also needs some minor style and consistency tweaks but I'm happy to do that at the end.

Old issues for reference:

@eliben
Copy link
Collaborator

eliben commented Mar 14, 2024

Just a quick note that we use the Go package https://github.com/alecthomas/chroma for syntax highlighting now.

It seems to have a style gallery here: https://xyproto.github.io/splash/docs/longer/all.html with at least the github-dark style that @mmcgrana mentioned present

Of course we can customize it at will, I just wanted to make sure we don't get confused by pygments names in case things have deviated

@ChrisMcKenzie
Copy link
Contributor Author

great feedback I can work on this change tonight.

@ChrisMcKenzie
Copy link
Contributor Author

ChrisMcKenzie commented Mar 15, 2024

ok here is a screen of what I just added, sans purple and tweaks to the
text and github-dark syntax theme.

image

Refactoring:
* Refactor CSS to make clear what varies with light/dark mode and what doesn't.
* Consistently use 2 spaces for indenting in CSS file.
* Remove unused Chroma CSS classes to make styling easier to understand.
* Add some comments about how Chroma CSS classes map to Go code.
* Organize Chroma CSS classes so that like-styled classes are contiguous.
* Display "operators" like regular code - doesn't make sense to style ":="
  specially but not "=" e.g.

Style tweaks:
* Adjust dark mode styling to be less blue, more subdued.
@mmcgrana
Copy link
Owner

mmcgrana commented Mar 17, 2024

Thank you @ChrisMcKenzie!

I've built on your PR by further refactoring the code to make it easier for us to reason about light vs dark mode here and in the future. I've also done some further style experiments (see below).

I'd like to let this bake in PR for a bit to see if others have comments on the styling or anything else. I may also want to try more styling variations but this is all I can do today. IMO it's looking promising though!

Screenshot 2024-03-17 at 13 12 55

@mon-jai
Copy link

mon-jai commented Mar 18, 2024

@ChrisMcKenzie's second version looks better to me.

@mmcgrana
Copy link
Owner

After thinking about it some more, I'm going to go ahead merge the iterated design I had with a few more tweaks.

We probably just all have our slightly different preferences, but fwiw what I'm trying to go for here a) a straight-greyscale background (vs blue or purple tinted) and subdued foreground colors (vs. too bright or neon), as we have in the light style. (Note that the screenshot may look unusually weird to you on GitHub if you have that on dark mode, because of the blue/purple tint on GitHub.)

Anyways part of this change makes it a lot easier for us to change syntax highlighting styles in the future, which I'll be open to doing (for both light and dark mode). Hopefully folks with dark mode enabled on their systems at least find this better than bright white 😎

@mmcgrana mmcgrana merged commit 4a0a0c0 into mmcgrana:master Mar 19, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants