Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strip alpha from colors for improved SVG export compatibility #3865

Merged
merged 1 commit into from Aug 24, 2023

Conversation

cmdcolin
Copy link
Collaborator

@cmdcolin cmdcolin commented Aug 23, 2023

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)

@github-actions github-actions bot added the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label Aug 23, 2023
@cmdcolin cmdcolin changed the title Strip alpha Strip alpha from colors for improved SVG export compatibility Aug 23, 2023
@cmdcolin cmdcolin removed the needs label triage Needs a label to show in changelog (breaking, enhancement, bug, documentation, or internal) label Aug 23, 2023
@cmdcolin
Copy link
Collaborator Author

fixes #3864

@cmdcolin cmdcolin added the bug Something isn't working label Aug 23, 2023
@codecov
Copy link

codecov bot commented Aug 23, 2023

Codecov Report

Merging #3865 (f302478) into main (f6a4244) will decrease coverage by 0.01%.
Report is 1 commits behind head on main.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #3865      +/-   ##
==========================================
- Coverage   64.46%   64.45%   -0.01%     
==========================================
  Files        1003     1003              
  Lines       29782    29785       +3     
  Branches     7146     7146              
==========================================
- Hits        19198    19197       -1     
- Misses      10421    10425       +4     
  Partials      163      163              
Files Changed Coverage Δ
packages/core/util/index.ts 80.65% <100.00%> (-0.09%) ⬇️
...ns/svg/src/SvgFeatureRenderer/components/Arrow.tsx 100.00% <100.00%> (ø)
...src/SvgFeatureRenderer/components/FeatureLabel.tsx 80.95% <100.00%> (ø)
...svg/src/SvgFeatureRenderer/components/Segments.tsx 93.75% <100.00%> (ø)

... and 1 file with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@cmdcolin cmdcolin merged commit f8f0a77 into main Aug 24, 2023
11 checks passed
@cmdcolin cmdcolin deleted the strip_alpha branch August 24, 2023 03:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant