Background
The Olivero theme utilizes CSS variables in a very basic fashion. We declare colors like --color--primary-30, --color--primary-40, --color--primary-50, --color--primary-60,
--color--gray-5, --color--gray-10, --color--gray-20, --color--gray-45, --color--gray-60, etc.
We then utilize these variables directly within the component styles like
.breadcrumb__link {
color: var(--color--primary-40);
}Task
This task is to create an abstraction layer between the color custom properties and the component's CSS rules.
So, in the case above, we'd define a new variable scoped to :root something like --color-text-primary-medium and set that to var(--color--primary-40)
Then within the component stylesheet, we'd set the rule to use the new --color-text-primary-medium property.
.breadcrumb__link {
color: var(--color-text-primary-medium);
}Benefits
Once we have this abstraction layer in place, and another similar layer with background colors, we'll be in a great position to better control accessibility, as well as implement dark modes, etc.
Notes
We're not updating the link hover states here. The link hover-state color does not meet the 4.5:1 WCAG 2.0 AA standard, and needs to be updated. This will occur in a followup issue.
Resources
A list of CSS color properties, selectors, and values is at https://docs.google.com/spreadsheets/d/19zkRfD4CogL8ZUbIirpHpAH2Xh9ma6Va...
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 3284912-8-primary_medium.png | 445.71 KB | javi-er |
| #8 | 3284912-8-neutral_soft.png | 511.17 KB | javi-er |
| #8 | 3284912-8-neutral_medium.png | 777.25 KB | javi-er |
| #8 | 3284912-8-neutral_loud.png | 378.33 KB | javi-er |
Issue fork drupal-3284912
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
- 3284912-abstract-and-refactor
changes, plain diff MR !2367
Comments
Comment #2
mherchelComment #3
mherchelAssigning this to myself.
Comment #4
mherchelComment #5
mherchelComment #7
mherchelComment #8
javi-er commentedThis looks good to me, I reviewed the color replacements and they are fine, visually everything is looking good as well, I'm attaching some screenshots of my local.
Comment #9
javi-er commentedComment #10
mherchelComment #11
lauriiiThis one is ready to be committed once the situation with HEAD has been sorted out.
Comment #14
lauriiiCommitted 5b89b53 and pushed to 10.1.x. Also cherry-picked to 10.0.x. Thanks!