Strip alpha from colors for improved SVG export compatibility #3865
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.
This PR adds a @jbrowse/coreu/util called stripAlpha primarily used for exporting svg colors. The core SVG spec doesn't like the fill to be an rgba, and instead likes fill being rgb and a separate prop for "opacity". Our usage of the theme variables from MUI includes an alpha by default, so this strips it (and does not supply the separate opacity prop). We could make it supply the separate opacity prop automatically e.g. for user defined colors but it's probably better at least for the default theme variables to strip it off. There is an interesting built-in way this could be done with MUI with 'css variables' but it is an experimental API (see channel tokens here https://mui.com/material-ui/experimental-api/css-theme-variables/customization/#channel-tokens)