JsonApiDotNetCore icon indicating copy to clipboard operation
JsonApiDotNetCore copied to clipboard

Add dark mode to documentation landing page

Open bkoelman opened this issue 2 years ago • 2 comments

The docfx site features dark mode, but our landing page (based on this template) at www.jsonapi.net does not. Ideally, it would reuse the setting that docfx stores in the browser settings.

bkoelman avatar Jul 20 '23 20:07 bkoelman

Here's one way to do it:

The Chrome addin Night Eye renders the page pretty nice when switched to dark mode. It has a free trial for one month.

image

What I think needs to be done:

  1. Update the existing HTML page at https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/master/docs/home based on the latest template, because it uses Bootstrap v5.3.2, which includes support for dark mode.
  2. Somehow extract the changed colors, after turning on dark mode in Night Eye, and apply them to the .css file. I can see the new colors using Inspect Element in Chrome Dev Tools, but I don't understand where they come from.
  3. Write JavaScript that sets data-bs-theme on the root <HTML> element, based on the theme (dark/light/auto) property that docfx stores in local storage (see docfx theme.ts).
  4. Add a drop-down button (similar to what docfx provides) to toggle the mode.

Unfortunately, I'm pretty clumsy and inexperienced when it comes to styling. Any help would be immensely appreciated! If you know of a different landing page template with built-in dark-mode support, that could be an even better solution!

bkoelman avatar Sep 21 '23 00:09 bkoelman

Another browser add-in that produces a nice dark mode is Dark Reader.

bkoelman avatar Sep 26 '23 00:09 bkoelman

In https://github.com/dotnet/docfx/pull/8482 a "modern" template was introduced. From that screenshot it seems to implement dark mode

image

verdie-g avatar Feb 23 '24 21:02 verdie-g

This issue is not about docfx.

bkoelman avatar Feb 24 '24 01:02 bkoelman

A different (simpler) approach is described at https://radu-matei.com/blog/dark-mode/.

bkoelman avatar Mar 27 '24 07:03 bkoelman