-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Maps] Apply styles to icon SVGs in legend via descendent selectors #129255
Conversation
The wildcard descendent selector to applies fill and stroke to all elements in the SVG. This was not necessary before because Maki icons always had a single path element. But we don't have control over the number of elements with custom icons, so we must override any style settings on sibling and nested elements. The `non-scaling-stroke` property fixes the issue where the stroke was barely visible in the legend with large custom icons.
Pinging @elastic/kibana-gis (Team:Geo) |
style += `stroke-width:1;`; | ||
} | ||
if (style) svgXml.svg.$.style = style; | ||
svgXml.svg.$.id = symbolId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the id a uuid so there can be no conflict.
if (style) svgXml.svg.$.style = style; | ||
svgXml.svg.$.id = symbolId; | ||
svgXml.svg.style = ` | ||
#${symbolId} * { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment about why css selector is needed, maybe something like
// Elements nested under svg root may define style attribute
// Wildcard descendent selector provides more specificity to ensure root svg style attribute is applied instead of children style attributes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for fixing. Thanks for also moving custom icons to top of map settings and fixing issue where custom icon includes style attributes in children elements.
code review, tested in chrome
I incorrectly assumed the style element would override style attributes on descendants. This changes the specificity to the svg element and all descendents. It appears the scope of the style element is limited to the SVG and does not affect other SVGs. Additionally, the !important property force overrides any style attributes in descendant elements. It is still possible that an element may have a style attribute with !important that we can not override. Hopefully that is a rare case though.
…l/kibana into custom-icons-legend-fix
8cb8a11 should fix this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - Thanks for all the fixes.
code review, tested in chrome
@elasticmachine merge upstream |
💚 Build SucceededTest Failures
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…129255) (#129853) (cherry picked from commit 7b64a54) Co-authored-by: Nick Peihl <[email protected]>
Fixes #128846
The wildcard descendent selector to applies fill and stroke to all elements in the SVG. This was not necessary before because Maki icons always had a single path element. But we don't have control over the number of elements with custom icons, so we must apply and override any fill and stroke settings on sibling and nested elements.
The
vector-effect: non-scaling-stroke
property fixes the issue where the stroke was barely visible in the legend with large custom icons.Additionally, the !important property force overrides any style attributes in descendant elements. It is still possible that an element may have a style attribute with !important that we can not override. Hopefully that is a rare case though.
To test this:
[Flights] Origin Time Delayed
map from the Sample flight dataicon
and select the custom icon