-
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
Render nav icons in IE in white like the other supported browsers #7731
Conversation
opts.svgHeight = $elem.height(); | ||
opts.svgSource = $elem.attr('src'); | ||
|
||
opts.svgContent = `<svg xmlns="http://www.w3.org/2000/svg" class="${$elem[0].className}" viewBox="0 0 ${opts.svgWidth} ${opts.svgHeight}" width="${opts.svgWidth}" height="${opts.svgHeight}">` |
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.
Since this is fairly large, how about pulling it out into a template file?
Rather than applying the invert filter in two different places ( |
$(opts.rootElm).addClass(opts.rootFlag); | ||
} | ||
|
||
if (!isFilterSupported()) { |
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.
There should also be a check for whether the element is actually an SVG or not.
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.
it works with all kind of images
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.
Then we should do a check to confirm it's being applied to an img
tag
makes sense |
> svg { | ||
height: 18px; | ||
margin-top: 10px; | ||
} |
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.
The directive should work without needing additional styles applied in an external stylesheet.
If this workaround came from a blog or library somewhere, I'd recommend linking to the source either in the code or in your commit message so other devs can read the details in the future if need be. |
|
||
if (!isFilterSupported()) { | ||
$elem.css('visibility', 'hidden'); | ||
$elem.on('load', () => { invert($elem); }); |
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.
Does this really need to wait for onload?
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.
i need image width& height
|
||
function invert($elem) { | ||
$scope.opts = { | ||
idHash: (Math.random().toString(36) + '00000000000000000').slice(2, 7), |
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.
do we have a method to generate random string ?
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.
Not that I know of, but does this really need to be random? As far as I can tell, IDs defined inside the SVGs defs
element are scoped to the individual SVG, so this can probably just be hard coded?
svgWidth: $elem.width(), | ||
svgHeight: $elem.height(), | ||
svgSource: $elem.attr('src'), | ||
className: $elem[0].className |
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.
$elem.attr('class')
doesn't work?
Looks like this branch needs to be rebased on master as well |
i've tried to make it work with different values but it gives different result than css filter property. i don't really understand how css filter property works ... what should invert(50%) do ? invert(100%) would do 255-c for each color channel .... |
This needs to be rebased or have master merged. |
@ppisljar it seems like the unsupported browser test isn't done yet, is that right? Just making sure this isn't blocked on me at the moment. |
Please re-assign me when this is ready for another review |
for browsers that dont support css3 filter property image is inverted with SVG filters
Sorry for the delay on getting back to this. LGTM! 🎉 🎉 🎉 🎉 🎉 |
LGTM, Perhaps I'm issing something crucial, but I would consider one thing though. This is a LOT of code for a minor cosmetic annoyance. I know it's nice to isolate styling in CSS, but we're adding a whole new compile step for something IMHO is quite minor. Why not (?)
Both approaches would just be a spot change, iso. creating a whole new programmatic component just to redress this single coloring issue. But again, maybe I'm missing something obvious. |
I think @thomasneirynck is 100% correct here... the problem is the assets are black, but we want them rendered white. So why not just make the assets white? :) |
i couldn't agree more @thomasneirynck ... if everyone is ok with it i am gonna throw this away and create a new PR where i'll just change the assets to white. It doesnt seem that we use them black at all. i was wondering if dark theme has any effect on how this is rendered, but it doesnt. @Bargs what do you think ? |
Sounds fine, we don't use the filter property for this purpose anywhere else anyway. |
closing in favour of #8221 |
fixes #7528
internet explorer doesnt support css3 filter property (which is used to invert images)
i created a directive which uses SVG filters to invert the image in case css3 filter property is not supported.