docs.nestjs.com icon indicating copy to clipboard operation
docs.nestjs.com copied to clipboard

WIP: feat(theme): Add dark mode

Open BrunnerLivio opened this issue 5 years ago • 27 comments

Poll

Use a reaction :+1: or :-1: on this PR to vote, whether Dark Mode shall be implemented for docs.nestjs.com and you would happily use it!

Kamil:

if there are more people interested in having the dark theme, I'm completely fine with it.

PR Checklist

Please check if your PR fulfills the following requirements:

  • [x] The commit message follows our guidelines: https://github.com/nestjs/docs.nestjs.com/blob/master/CONTRIBUTING.md

PR Type

What kind of change does this PR introduce?

[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] Other... Please describe:

What is the current behavior?

Sunglasses

What is the new behavior?

No Sunglasses

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

Dark Mode

I know from #613 @kamilmysliwiec is opposed to dark mode. Though since more and more platforms are migrating and I have been working the last year on a design system, I felt a huge urge to follow it as well ;)

Notes:

  • This PR uses CSS variables. This means IE11 support will be dropped. Maybe double-check the analytics, whether this is something we still should support? FYI: Stackoverflow dropped the IE11 support as well, when they introduced dark mode with CSS variables.

  • The NestJS primary color #ed2945 does not have a good contrast ratio with the background. I changed it to a lighter color (randomly picked). If you have a better strategy, feel free to let me know.

  • Valor

  • Companies do not look very good in dark mode Companies

Next steps:

  • Consider refactoring graphs to MermaidJS. Then we can easily convert those graphics to dark mode + images can be maintained in code.

BrunnerLivio avatar Apr 05 '20 18:04 BrunnerLivio

Thanks for your contribution! Honestly, I'm not entirely convinced of this feature. I have a dark mode turned on in my OS (and I love it!), but I think dark themes in documentations make them less readable. I checked documentations of other popular projects like Angular, React or Vue, and I haven't noticed anything like this either. So what I'm thinking - if there are more people interested in having the dark theme, I'm completely fine with it. Nonetheless, it has to be disabled by default (for the sake of consistency between platforms) and available on-demand (so if you want to have it, you have to explicitly turn it on, otherwise, we should use the light theme by default).

kamilmysliwiec avatar Apr 06 '20 08:04 kamilmysliwiec

@kamilmysliwiec

dark themes in documentations make them less readable

Before this feature would get merged, I would check it with Lighthouse to check the contrast colors (making it readable). Maybe automate it via #971

So what I'm thinking - if there are more people interested in having the dark theme, I'm completely fine with it.

Makes sense, fine for me :)

Nonetheless, it has to be disabled by default (for the sake of consistency between platforms) and available on-demand (so if you want to have it, you have to explicitly turn it on, otherwise, we should use the light theme by default).

Also if you have selected "prefer Dark Mode" as OS/Browser setting?

BrunnerLivio avatar Apr 06 '20 09:04 BrunnerLivio

Also if you have selected "prefer Dark Mode" as OS/Browser setting?

Yes, following other documentations and StackOverflow. We can also provide a third option, "Light, Dark, System" (inspired by StackOverflow).

kamilmysliwiec avatar Apr 06 '20 09:04 kamilmysliwiec

I checked documentations of other popular projects like Angular, React or Vue, and I haven't noticed anything like this either.

Docker docs have the "toggable" dark mode feature: https://docs.docker.com/ The doc's "light" color theme is still that light-ish blue, so logos that are white are still readable in both dark and light. Some icons change color depending on the theme, but generally the docs have limited colors and images.

As someone that uses dark theme on basically everything, either via native or via some extension/styling mod. There are a bunch of cases where going dark theme can screw stuff up, like images become unreadable. I'd say the docs are totally in the realm of possibility of having a dark theme, and Angular makes toggle themes pretty easy. (or at least I think so hehe)

bradtaniguchi avatar Apr 08 '20 23:04 bradtaniguchi

@BrunnerLivio @kamilmysliwiec about a year later, and it seems there is some want from the community around dark mode. What would we need to do to scope this out and merge it?

jmcdo29 avatar Apr 18 '21 01:04 jmcdo29

Just wanted to add that Redux and Redux toolkit docs have a toggle for dark mode. People who work at night would definitely appreciate this feature.

MSandeep96 avatar Apr 18 '21 04:04 MSandeep96

@jmcdo29 @kamilmysliwiec I’d love to follow-up on this one! Just let me know when I can proceed rebasing!

BrunnerLivio avatar Apr 18 '21 13:04 BrunnerLivio

I personally use the DarkReader extension, which works almost perfectly with any website (including the docs of NestJS). Available on Chrome and Firefox.

Haltarys avatar Apr 29 '21 07:04 Haltarys

Rebased & dark mode toggle added 🦜

BrunnerLivio avatar May 18 '21 14:05 BrunnerLivio

Bump?

MSandeep96 avatar Jun 29 '21 00:06 MSandeep96

Thanks for your contribution! Honestly, I'm not entirely convinced of this feature. I have a dark mode turned on in my OS (and I love it!), but I think dark themes in documentations make them less readable. I checked documentations of other popular projects like Angular, React or Vue, and I haven't noticed anything like this either. So what I'm thinking - if there are more people interested in having the dark theme, I'm completely fine with it. Nonetheless, it has to be disabled by default (for the sake of consistency between platforms) and available on-demand (so if you want to have it, you have to explicitly turn it on, otherwise, we should use the light theme by default).

I agree that a lot of people will have an easier time reading the documentation in light-theme, however; I personally find it hard to read websites with a light background because of my visual impairment (I have moderately severe astigmatism), and dark themes are a lot less straining on my eyes (this also applies to some people outside the context of eye conditions). I wouldn't mind light theme being the default, and having the option to turn on dark theme would greatly improve my experience on the NestJS documentation website

chris9740 avatar Jun 29 '21 23:06 chris9740

Any plans to merge this?

clicktodev avatar Nov 19 '21 18:11 clicktodev

Docs work fine with darkreader extension without any noticeable issue image

armujahid avatar Oct 04 '22 10:10 armujahid

Hi everyone šŸ‘‹šŸ» ,

I made some updates to this PR, fixed tons of conflicts, made some updates and changes you colors. To avoid creating another PR since there has been a long discussion here I have improved this PR, hoping it will be merged.

I attach a screenshot of what it looks like now:

screen-dark-mode

Here is the link for a preview: https://deploy-preview-1138--docs-nestjs.netlify.app/ šŸ”„šŸš€

so you can view it.

If you are interesting and want this PR to be merged approve it! šŸ™šŸ»

I hope I have been helpful.

@BrunnerLivio mission accomplished! āœ…

Dark mode for NestJS documentation šŸ‘€ šŸ”„, the story continues..... šŸ”„ šŸš€

P.s. the CI fails but not because of these changes ( for info see here: https://github.com/nestjs/docs.nestjs.com/actions/runs/5524617442/jobs/10077158987?pr=1138)

Tony133 avatar Jul 11 '23 21:07 Tony133

@Tony133 great job!

I believe we could also apply CSS filters to template illustrations we have, for example, the one we have on the Modules page:

image

to:

image

CSS:

filter: invert(1) contrast(0.85);
box-shadow: 0 0 50px #fff;

kamilmysliwiec avatar Jul 12 '23 11:07 kamilmysliwiec

I have a great suggestion, why not move to Docusaurus or Vitepress. These are tools built specifically for this type of website and they are used by a lot of tech companies and startups.

clicktodev avatar Jul 12 '23 12:07 clicktodev

Because migrating something that has proved to work well for several years makes zero sense

kamilmysliwiec avatar Jul 12 '23 12:07 kamilmysliwiec

Ok, I added the css rule for illustrative images šŸ”„, these are the following links to check them:

  • https://deploy-preview-1138--docs-nestjs.netlify.app/controllers
  • https://deploy-preview-1138--docs-nestjs.netlify.app/providers
  • https://deploy-preview-1138--docs-nestjs.netlify.app/modules
  • https://deploy-preview-1138--docs-nestjs.netlify.app/middleware
  • https://deploy-preview-1138--docs-nestjs.netlify.app/exception-filters
  • https://deploy-preview-1138--docs-nestjs.netlify.app/pipes
  • https://deploy-preview-1138--docs-nestjs.netlify.app/guards
  • https://deploy-preview-1138--docs-nestjs.netlify.app/interceptors
  • https://deploy-preview-1138--docs-nestjs.netlify.app/microservices/basics
  • https://deploy-preview-1138--docs-nestjs.netlify.app/microservices/redis
  • https://deploy-preview-1138--docs-nestjs.netlify.app/websockets/gateways
  • https://deploy-preview-1138--docs-nestjs.netlify.app/fundamentals/lifecycle-events

There are these two pages:

  • https://deploy-preview-1138--docs-nestjs.netlify.app/openapi/types-and-parameters
  • https://deploy-preview-1138--docs-nestjs.netlify.app/recipes/documentation

which have images with always white background, but the css rule is not very suitable in this case šŸ˜…. (See the example screenshot) and at the moment I left them as they are without using the css rule. šŸ˜…

screen-dark screen-dark-2

Let me know what you think and if you have any ideas for those two pages. šŸ˜„

Tony133 avatar Jul 12 '23 16:07 Tony133

Button colors don't match

image

image

kamilmysliwiec avatar Jul 13 '23 12:07 kamilmysliwiec

Button colors don't match

image

image

The colors of the buttons have been changed to increase the contrast. In the documentation currently the contrast is low as a percentage(see screenshot)

screen

If you use chrome's development tools you can control the contrast percentage on colors.

This only if you want to have colors with correct contrast and that are clearly visible during the light / dark mode change šŸ™‚

Tony133 avatar Jul 13 '23 13:07 Tony133

It doesn't match the logo color now though

kamilmysliwiec avatar Jul 13 '23 13:07 kamilmysliwiec

It doesn't match the logo color now though

Okay, I would say it should now be similar/equal to the color of the logo šŸ˜… Screenshot 2023-07-13 alle 18 15 15

link preview: https://deploy-preview-1138--docs-nestjs.netlify.app/ šŸ”„

Tony133 avatar Jul 13 '23 16:07 Tony133

valor-logo-light-selected We should use this SVG to remove the problematic white artifacts https://valor-software.com/assets/img/valor-img/valor-logo.svg.

I made a change to the logo so that I removed those white parts in the lettering, now in dark mode it displays like this: screenshot-logo

Link preview: https://deploy-preview-1138--docs-nestjs.netlify.app šŸ”„

then if we want to update the logo let me know šŸ™‚

Tony133 avatar Jul 24 '23 13:07 Tony133

After signing up for the newsletter, the checkbox is still quite light: image

Exac avatar Jul 26 '23 02:07 Exac

After signing up for the newsletter, the checkbox is still quite light: image

Fixed!Ā āœ… see commit here: https://github.com/nestjs/docs.nestjs.com/pull/1138/commits/319555e735a307e78dc23c61db6873a64b7429d7

Thanks for the reporting!

Link preview: https://deploy-preview-1138--docs-nestjs.netlify.app/ Ā šŸ”„

Tony133 avatar Jul 26 '23 07:07 Tony133

Please, merge it ASAP. My eyes are bleeding when reading these docs in the evening. Implementation of this feature is taking 3 years now

aharbavets avatar Dec 13 '23 17:12 aharbavets

@kamilmysliwiec please consider merging this feature. There are many people who are photophobic. This is a disorder and is very frustrating. For many people this is not about style or being cool, it's just about health.

j-tag avatar Feb 15 '24 11:02 j-tag