👌 Improve cross-theme compatibility of need collapse button #1181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, the need collapse toggle icons are added to the page like:
Wrapping the SVG icons in an
<img src=...>
is not great, because it does not allow it to be properly styled.Indeed for our own docs, we have to use the horrible hack of
filter: brightness(0) invert(1)
, to get these icons to have the correct color for light/dark mode 😬This PR instead places the entire SVG onto the page, and adds some core CSS to set it at the correct relative size (and float right)
the SVG then matches the local text color, without any need for additional CSS:
Also, the initial visibility of the icons is now set correctly, before any JS is run,
so that you don't get a bad render experience, whereby both icons are initial visible (until the JS is triggered)
Note, it might be ideal to de-duplicate these SVGs on the page (see e.g. this stackoverflow), but given these icons are small I don't think this is worth the added complexity for now
part of addressing #1172