Palettes #5230
Replies: 1 comment
-
ImplementationContextThere are only two possible color modes:
The mode can be set at two levels:
This leads to four possible combinations:
Both the base and fallback implementations are built around these four combinations. Base SolutionIn the base solution, we use the CSS
Then, the color of the components inside the container is set using the Fallback Solution
Some browsers do not support Instead of setting the
In the case:
This property is then used to determine the colors of components inside the container, based on this technique.
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Context
What is the issue that we're seeing that is motivating this decision or change?
Decision
Semantic layer order matters for setting up cascade
POC: https://codepen.io/alizedebray/pen/QwWVXzm?editors=1100
Static colour scheme layer vs. dynamic colour scheme layer
Palette background colours are static based on the root colour scheme. Having palette colours on the static scheme layer enables us to set
color-schemedirectly on the palette because the background of the palette is not set withlight-dark().Difference: Static colour scheme components are setting
color-schemethemselves, every other component that's not doing this,Preferred and forced colour schemes
Body background
Decided to define body background in a dedicated component since it might not be the palette-default in a specific theme.
Fallback
Only needed in the scheme layer where we use
light-dark, https://dev.to/janeori/css-lightdark-mode-implementation-without-duplicating-vars-22c9 can maybe help reducing the need for two fallback space toggles to one space toggle.light-darkis resolved at component level, even if thelight-darkCSS function is only used at the:root. For the fallback, we can't usecolor-schemeto switch color-scheme, so we can't just define the fallback variables at the:rootonly. We need to redeclare them wherever a colour scheme can be changed. Otherwise, it will just take the:rootdefinition into account. The affected selectors are:root, [data-color-scheme], .palette, .banner, .card, ....The fallback works, because we're patching the mode variables at the static-scheme semantic layer:
Benefits:
Drawbacks:
Open todos
[data-color-scheme]inside palettes and vice versaAccent Colors
The design is not clear here and we need a discussion with Designers.
Example:
On Cargo Palette-Brand there is an accent color (lightblue) used on the heading, but also an accent color (lightgray) used inside of the card.
No mather which solution is prefered, the implementation of these accent colors is not complete on the current integration-test branch.
Consequences
What becomes easier or more difficult to do because of this change?
Example (optional)
If applicable, show a code example to support the decision.
Beta Was this translation helpful? Give feedback.
All reactions