Offshoot from #3064880: Create new default front-end theme
Summary
There is a need to be able to change the default colors of the Olivero theme. Traditionally, this could be done through the Color Module, however, there is an issue to remove this module from core. See #2808151: [policy] Move the Color module to a contributed project when Bartik is deprecated.
If we did not have to support IE11, we could just change the color values in the custom CSS properties that we will have defined. However, these variables get processed down to old-style CSS via PostCSS to remain compatible with IE11.
Options
So, we have a couple options:
1) Support the Color module. I honestly do not know what's involved. I'm assuming we'll have to know every.single.css.selector that uses a color?
2) Remove the PostCSS transpilation and use https://www.npmjs.com/package/css-vars-ponyfill to handle IE11 compatibility. According to @laurii in https://www.drupal.org/project/ideas/issues/3064880#comment-13284844, this can be hosted on Drupal.org. I'm personally concerned about a flash of unstyled content, though.
3) ??
Dark theme
It would be nice to have two options. One for a normal theme, and one for dark that would be activated by media-query!
Timeline
This will not be a requirement for MVP, but I'm also not opposed to adding this functionality (and would like to do so).
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | Screen Shot 2022-01-03 at 10.01.55 AM.png | 1.94 MB | karing |
| #41 | Screen Shot 2022-01-03 at 9.55.52 AM.png | 3.54 MB | karing |
| #41 | Screen Shot 2022-01-03 at 9.53.55 AM.png | 2.06 MB | karing |
| #39 | 3086514-38.patch | 16.59 KB | andy-blum |
Comments
Comment #2
mherchelComment #3
chrisfromredfinThe one thing I can say about the color module is that it basically does a find and replace of #abc123 with the new color you've chosen, in a CSS file, then it writes that CSS file into public files folder, and adds it at the end of the cascade.
So, to support color module, a "base" CSS file needs to exist that defines all the 'colorable' portions of the theme that serves as overrides to what the default CSS is.
Comment #4
naheemsays commentedCSS Variables need to be investigated as a better way of implementing this.
It should also allow all themeable colours to be included in a single themeable stylesheet.
Comment #5
mherchelComment #6
anruetherWe now have a working color successor candidate based on css variables, see #3090894: Replace color module with a CSS-Variables based module to provide configurable theme parameters.
> I'm personally concerned about a flash of unstyled content, though.
We integrated the mentioned ponyfill library and indeed in ie11 on my machine I see the flash. This could be worked around by #3090875: Add a server side css variables replacer (for JS-less IE11).
Also cssvars is domain config compatible.
Comment #7
anruether> I'm personally concerned about a flash of unstyled content, though.
An addition to this: The flicker did improve/disappear once I changed the JS that triggers the ponyfill to this:
(Effectively removing the curly brackets from within the cssVars function, compare https://git.drupalcode.org/project/cssvars/blob/8.x-1.x/polyfill/run-css... This is possible as long as no ponyfill options are needed)
Comment #8
geek-merlin@anruether: Thanks a lot for your investigations in this! Let's discuss this more in the project queue and upstream.
Comment #9
shaalFew ideas, that I was discussing with @mherchel during Florida Drupalcamp:
Allow modern browsers use regular CSS (with vars), but then add special files (ie. ie11-color.css, ie11-fixes.css, etc) to deal with IE11 specific issues while allowing take advantage of latest and greatest features in modern browsers.
Inspired by the ideas shown here (and seems like a simple implementation):
https://dev.to/ananyaneogi/create-a-dark-light-mode-switch-with-css-vari...
Add additional special vars
That will make it easy to add a toggle button and/or use prefers-color-scheme.
Additional interesting ideas we can use can be found here:
https://web.dev/prefers-color-scheme
Comment #10
pingwin4egReviewing the #2808151: [policy] Move the Color module to a contributed project when Bartik is deprecated I can say that the decision on removing the Color module from core heavily depends on whether the new FE theme is going to use it or not. So I guess if the Olivero actually needs the Color, it will stay in core.
Comment #11
andrewmacpherson commentedOK, so let's look at some other questions:
I think support for the
prefers-color-schememedia feature is a separate concern, which color module isn't really suited for (in it's current form). Instead, I think there could be a theme setting: dark, light, or respect the user's preference. I'm thinking of the way macOS treats light/dark and accent colour as separate settings. So the site builder could say "red accent scheme, on light background" or "green accent scheme, and respect the visitor's user preference for light/dark mode". If color module is disabled, blue is the only accent colour, but the light/dark functionality is still there.Comment #12
mherchelComment #13
mherchelAnother CSS polyfill that might work better: https://github.com/nuxodin/ie11CustomProperties
Comment #14
jasonawantAdding related issue #2808151: [policy] Move the Color module to a contributed project when Bartik is deprecated.
Comment #15
trebormcI add another related issue. We have to have all the colors as variables if we want to be able to change them easily.
https://www.drupal.org/project/olivero/issues/3151405
Comment #16
kostyashupenkoComment #17
kostyashupenko1. As @jhodgdon said we have at least ~2 years to go with color module
2. I was thinking about how we can deal with it, to easily switch the colours, so i have implemented actually the same thing we use already ~1 year in my Skilld company, let me explain:
I see no reason to go with postcss-custom-properties plugin anymore, instead we have to use css-vars-ponyfill
Globally idea here is to have css variables in the compiled css. I know it doesn't work in IE, that's why
css-vars-ponyfillwill help here.3. I added colours implementation to Olivero, check

color/folder in the root. With proper configuration on this page/admin/appearance/settings/oliverowe will have this one:The list of all colours used within the theme. Note that these colours are not really good to me in terms of its names, it should be changed, but it is not really important for this task. This task is an idea what we can do with colours
4. The next thing is a preview with the ability to change colours on the fly. I have added some elements from header and some little js to change colours if you going to edit it, look how it looks if i'll change some:

By default these colours were blue, but when i have changed it on this page - it was immediately have changed with the little js script, which is defined here
color/preview.js. Also you can see that "Olivero" word becomes blue, it's because i have changed white color by#00e. Sooo.. we can easily put all needed elements to this preview to see visually the difference if colours will be changed (can be form elements, buttons, footer, text, etc).5. One more thing - all colours were moved from
css/src/base/variables.csstocolor/colors.css- this is necessary for color module to move it into standalone file.6. All
@import "../base/variables.css";from all components were removed, coz we don't need to import variables anymore, see the 2nd point (we have now all variables in generated css).Everything works fine, even in IE11, look at left corner, i have change blue color by violet:

You can change any color from this page
/admin/appearance/settings/oliveroand it will be applied automatically everywhere, where this color was used in css. (Thanks again tocss-vars-ponyfill)7. I didnt find how i can put
css-vars-ponyfillinto the theme, so i have copied its sources tojs/css-vars-ponyfill.js. Note that this is temporary fix, just for you guys to test / to understand how it feelsIdea of this patch is to forget about IE11 problems about not supported css variables in generated files - it's working fine with
css-vars-ponyfill. I'm insist we can update core with that idea and all core themes.Css variables everywhere :)

Comment #18
mherchelThis is good work. I created a tugboat preview at https://3086514-change-colors-isvama9kcodb9xfnhynthqpmqnntdche.tugboat.qa/.
Note that within IE11, there is a flash of unstyled content. Video at https://www.youtube.com/watch?v=l48kNWriuhc
Comment #19
geek-merlin> Note that within IE11, there is a flash of unstyled content.
Maybe the on efrom #13 performs better wrt this.
Comment #20
mherchelUnfortunately, that polyfill is worse. See #3150283: Investigate use of new IE11 polyfill in place of PostCSS custom properties
Comment #21
kostyashupenkoYes @mherchel, i saw these 2 issues, what i can say is the following:
1. For wrong calc cases i would say we can just adapt those variables, look at here how it is done right now, just an ex:
So what i'm trying to say is that there are nested calc functions inside of another calc. It is normal behavior looks like for IE11 when he can't recognize it properly. That means we need to fix nested calcs.
2. About short moment before ponyfill gets working - yep, looks not really good, but this is how it's working. Maybe we can hide whole content by default for IE? And to show it right after ponyfill has finished his job. Or actually is it really an issue for us?
Comment #22
karingTuning in! We colour Olivero into an organization's primary colour - always. It's do-able with a lot of css overrides (packaged into a subtheme). It would be great to have a configuration option for it. Happy to help test any solutions.
Comment #23
mherchelPostponing for now. My initial thought is that if we didn't have to support IE11, this would be trivial. This isn't a stable blocker, so it's low priority for now.
Comment #24
bwoods commentedI was eager to try out the patch in #17, but it doesn't seem to apply to 9.1.4. Any tips on which version of core I should use?
Comment #25
mherchelThe patch in #17 was made against the contrib version of Olivero (before it was added to core). There hasn't been much if any work on this since.
Our first goal is to get to stable and make Olivero the default. After that, this will be one of the very top priorities.
Comment #26
bwoods commentedThanks for the update, Mike. Looking forward to seeing and testing the stable version.
Comment #27
dqd@mherchel would you mind to link to a roadmap or issue or META where this progress is documented, if it is somewhere? It would be helpful.
Comment #28
mherchelThe issue to make Olivero stable is at #3177296: [META] Make Olivero stable.
As far as issues for changing color, this issue is it :)
Comment #29
dqdOh no it's fine here :-) (for color)
That's what I was referring to. Thanks! +1 (Didn't found it)
Reference: I'll wanted to put the META as related Parent in here to make the reasons for postponed clearer, but I saw #3064880: Create new default front-end theme has been chosen as Parent to this one. So I just left it as it is to not confuse things. EDIT: Wait, the other one is closed (fixed). Ok then, so let's do it? Feel free to change it if it doesn't fit.
Comment #30
dqdComment #31
andypostIt looks actionable now
Comment #32
kattekrab commentedWow - Olivero is amazing. I love it! A huge thank you and karma to everyone involved. It's so impressive!
I've just enabled it in an experimental project and was trying to figure out how to change colours like we could do with good 'ol bartik, and ended up here. So a +1 from me this is an important feature for a default theme, so that site builders can easily tweak colours, without having to become themers or developers.
Comment #33
mherchelThanks for the positive feedback! 😊
Yes, this will likely be the very top priority for Drupal 10 after becoming the stable and default.
Comment #34
longwave+1 to this feature as well.
https://github.com/nuxodin/ie11CustomProperties/issues/54 suggests the CPU issue may be fixed in the polyfill in the latest release, has this been tested? If this is acceptable I think this can be worked on in D9 - if this is still no use then this issue will have to be postponed until Drupal 10 as unfortunately we need to support IE11 until then.
Comment #35
ressaThis would be an awesome feature, complementing #3214072: Provide an Olivero sub-theme creation tool perfectly, to easily create a unique looking theme with minimal effort.
Comment #36
dqd@ressa: +1
Comment #38
mherchelAfter talking with @lauriii, I'd like to get some clarification from the core Product Managers on if we
1) Need to refactor and use the Color module for this functionality
2) Can build this functionality using theme settings
I'm hoping the answer is that we can build this into the theme settings. If we have to rebuild the color module, the work will be stalled as we wait for backend devs to work on this (we don't have the available backend chops within the Olivero team). However, if we can go the route of doing it in a theme setting, we can likely get this in by 10.0.0, which would be super cool.
Comment #39
andy-blumAttached is a patch that makes use of the most recent patch in #3217924: Olivero: Convert all colors (blues and grays) to HSL and normalize hues and saturations. . A new number input has been added to the theme setting to allow users to select the base hue value from which Olivero will derive all theme colors. I originally planned to use a color input for this, but decided against it to prevent confusion when as we'd only be utilizing the hue value. This prevents users from selecting different saturation/lightness values of the same color but ultimately getting the same result in the Olivero theme.
Instead, there's now a number input with a step of 0.1 to allow fine-grained control and tweaking of the hue value. To make it easier for users to see the color they're selecting, the number input also has a #suffix that places a span tag that we're styling with a new library in olivero. On load, the span tag picks up the default value, and as the hue selector input changes, the span updates to always show the background color as the most-saturated, and half-lightness version of that hue
hsl([value], 100%, 50%)Comment #40
gábor hojtsyRe @mherchel in #38: rather than answering whether Color module should be used or not it would be good what's the vision/idea in terms of what kind of color customization would you want to allow practically? The feature gap between #39 and #17 is huge and #39 is actually more appealing in terms of colors working together but appears having a sub-par UX in terms of needing to specify what may appear random numbers for an audience that does not have color theory experience. Either way both are in my understanding proof of concepts, but it would be better IMHO to agree on a direction of what is to be customizable. THEN we can talk about how IMHO :D
Comment #41
karingNot sure if this is helpful here, but below are two examples of the kind of color customization that we're currently doing for clients to bring in their primary + secondary colours into Olivero -> menu items, links, buttons, etc.
Comment #42
karingPS -> also for mobile menu -> that's the primary colour (not olivero/drupal blue):
Comment #43
mherchelfrom @Gábor Hojtsy
Thanks for the feedback. Agree on all points.
My preference is to use an approach similar to @andy-blum in #39, however with a standard color picker (and use JS to extract the hue and then save to config)
So, in a perfect world, Olivero:
This is my goal and I doubt that this can work in the confines of a (new) color module. Let me know if this makes sense.
Comment #44
gábor hojtsyIf we are to only pick one color and use browser-native widgets for it (don't build a parallel color module), then in my humbe opinion doing it custom to Olivero is fine.
Comment #45
mherchelI had an additional conversation w @Gábor Hojtsy at https://drupal.slack.com/archives/CJT807H7T/p1641307912149300
Transcript:
mherchel 9:51 AM
Gábor Hojtsy (he/him) 2 days ago
Comment #46
mherchelOpened up followup #3257274: Implement color changing theme settings for Olivero
Comment #47
mherchelAssigning credit and marking as fixed.
All subsequent work on this will be done in #3257274: Implement color changing theme settings for Olivero