Summary
When running the sandbox (npm run dev) for https://gerrit.wikimedia.org/r/c/design/codex/+/993056 , CSS-only icons are broken:
The icons appear as pure black (#000), but they should be showing as off white (#f8f9fa) since that is the value of var( --color-base ) in this demo.
Potential solutions
This appears to happen because CSS variables don't work in data URI SVGs like this. We'll need to find a different way to do change the color:
- We can't just use currentColor for the SVG fill because there's no way for the URL to know what the currentColor is
- We could use mask-image and background-color, which is what we currently do for CSS icons within buttons. This would allow us to change the color outside of the SVG URL (via background-color). However, mask-image is not supported in Firefox v39-52, which are in our basic support tier. In those browsers, for icons within buttons, we just set the icon to either @color-base or white, whichever has more contrast. We'd need to do something similar for all icons to ensure a visible icon in old Firefox versions.
Acceptance criteria
- Change the CSS icon mixin so that tokens that are CSS variables work for setting the icon color
- Ensure this works when you pass in a raw CSS variable to the CSS icon mixin (instead of a Less token)
- Ensure this reaches an acceptable level of support in all of our supported browsers