this post was submitted on 03 Mar 2025
6 points (87.5% liked)

Programming

18484 readers
34 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

(https://just-the-docs.com/docs/customization/#define-a-custom-scheme for reference)

I am using just the docs (jekyll theme) + github pages to create a webpage and trying to have two separate colour schemes: a normal and high contrast option.

I am using a custom style with "_sass/custom/custom.scss" to set all the colours, layout configurations, etc. because there are some options that are not available using "_sass/color_schemes/foo.scss" such as more control over the colours of different elements.

However, I cannot find in the docs how to make it possible to easily switch with a custom.scss. One option is to create two github pages sites, one with high contrast and the other with normal colours, but that's really janky. just-the-docs seems to only allow you to create switchable colour schemes if you use "color_schemes/foo.scss" rather than "custom/custom.scss".

Am I forced to create a second github pages site for high contrast, or is there a way to switch between two different custom.scss?

top 2 comments
sorted by: hot top controversial new old
[โ€“] [email protected] 1 points 23 hours ago* (last edited 23 hours ago) (1 children)

Tokenise your styles with variable layers. Eg: put a class on your body tag for each theme, eg: dark-mode, high-contrast

Then define your components by abstract style variables, eg: button-color, heading-weight,

Then define the style variables for each theme:

body { --button-color: green; }

body.dark-mode { --button-color: blue; }

button { backgroud: var(--button-color); }

Then all you need to do is a simple JS function to set the appropriate theme class on your document body!

This way your components are compliant to your style guide, without needing to know the implementation details of your themeing Very SRP, much Demeter, such OCP

Apologies for psudocode, LMK if you have any furthers :)

[โ€“] [email protected] 1 points 23 hours ago

would that work with the jekyll theme?