Initially, I was happy with one light and one dark color scheme defined within my single theme. But there is CSS I’d like to alter specifically when the dark color scheme is in use.
Is there a way to set up a dark theme as a kind of child theme, so it can inherit all the styles of its parent (light) theme, but it has its own color scheme and its consists solely of overrides to the parent?
Can you share what CSS you would specifically like to alter only for the dark color scheme? In theory, if it’s only colors, you can do this using color definitions. If it’s more than that, you will need separate themes (and you would need to also give up on automatic dark mode switching).
I referred to @pmusaraj’s post here, and after some experimentation, did the following:
In common/color_definitions.scss, define variables to represent the background-color and font color of .nav-pills. My dark mode doesn’t specify a font color, and my light mode doesn’t specify a background color, but I have to specify something for dark-light-choose() to work, so I put the Discourse core variables ($primary and $quaternary-low, respectively :
// All-purpose scss for both dark and light modes:
.nav-pills>li>a:hover {
background-color: var(--custom-nav-pills-bg);
&:not(.active) {
color: var(--custom-nav-pills);
}
}
Oh, ok, I had skimmed through this post too quickly, and assumed that it was best practice to always include a fallback. I realize it’s only for backwards compatibility, which I don’t need. Thanks for that clarification. I edited the code in my post above to reflect it.