Skip to content
New issue

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

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

Already on GitHub? # to your account

Use svg icons as "mask" so their colors could be changed using CSS background-color #426

Merged
merged 10 commits into from
Jun 12, 2019

Conversation

yvonnetangsu
Copy link
Member

@yvonnetangsu yvonnetangsu commented Jun 10, 2019

READY FOR REVIEW

Summary

  • Investigate best way to use SVG icons
    Investigate the best way to include custom icons into our system #423
  • Use SVG icons as mask seems to do the trick (except IE). After discussion with Kerri and JB, we think it's ok to just hide the icon in IE.
  • This is just a test so I've only done work on .su-link--external. If this way of including SVG icon is approved, we'll refactor the other components where SVG icons are used in another PR.

Needed By (Date)

  • Sooner the better since Kerri/JB is working on the new link components this week.

Urgency

  • Earlier the better :)

Steps to Test

  1. Pull this branch and compile styleguide
  2. Go to Components - links, and check that the external link variant icon works fine in all browsers except IE, and that the icon is hidden in IE.

Affected Projects or Products

  • Decanter

Associated Issues and/or People

@yvonnetangsu yvonnetangsu requested review from sherakama and JBCSU June 10, 2019 19:05
}

// IE only - hides icon.
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a mixin? This seems like something we would want to standardize and have available.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a great idea :)

height: 0.65em;
width: 0.65em;
content: '';
mask: url("#{$image-path}/#{$external-link}.svg") no-repeat 0 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Browser support for this looks limited: https://caniuse.com/#feat=css-masks
Did you check that this spec meets our compatibility requirements? https://github.com/SU-SWS/decanter/wiki/Compatibility

width: 0.65em;
content: '';
mask: url("#{$image-path}/#{$external-link}.svg") no-repeat 0 0;
mask-size: cover;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@sherakama sherakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you verify that the browser support requirements for Decanter are met?

@yvonnetangsu
Copy link
Member Author

Can you verify that the browser support requirements for Decanter are met?

Yeah, I've tested on desktop Firefox, Safari, Chrome, Edge - those are all ok. I'll test it on Android and iOS.

@yvonnetangsu
Copy link
Member Author

Can you verify that the browser support requirements for Decanter are met?

Yeah, I've tested on desktop Firefox, Safari, Chrome, Edge - those are all ok. I'll test it on Android and iOS.

@sherakama , I checked a few devices on Browserstack picking not the newest phones on purpose - Galaxy S8 v.7 Chrome, iOS 11 iPhone SE Safari, iOS 10 iPhone 7 Chrome, Pixel 2 Android 8 Firefox and all ok.

Copy link
Member

@sherakama sherakama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for testing. This is GTG then.

@yvonnetangsu
Copy link
Member Author

Thank you for testing. This is GTG then.

Cool - I'm writing that IE-only mixin. Should be fairly quick.

@JBCSU
Copy link
Collaborator

JBCSU commented Jun 11, 2019

Our compatibility guidelines say we will support the latest version of Edge and 1 back. But the mask only seems to work on the latest version of Edge, i.e. 18. It doesn't render on Edge 17 or 16. I'm totally fine with that - just sayin'. Otherwise, (almost) all the device / browser combinations I tested behave as expected. I had trouble with the default (Samsung) browser on a Galaxy S8, but it was not related to this change.

Copy link
Collaborator

@JBCSU JBCSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great step forward for us. Thanks!

@yvonnetangsu
Copy link
Member Author

Our compatibility guidelines say we will support the latest version of Edge and 1 back. But the mask only seems to work on the latest version of Edge, i.e. 18. It doesn't render on Edge 17 or 16. I'm totally fine with that - just sayin'. Otherwise, (almost) all the device / browser combinations I tested behave as expected. I had trouble with the default (Samsung) browser on a Galaxy S8, but it was not related to this change.

Yeah, I found out about that last night. Though https://caniuse.com/#search=mask says it can be enabled in Edge 17 behind the flag? Any idea what that means? Is that a setting in the browser?

I'm still hoping that this is ok, since Edge is going Chromium soon and I like the ease of being able to change the colors easily. What do you think? 🤔

@yvonnetangsu
Copy link
Member Author

Our compatibility guidelines say we will support the latest version of Edge and 1 back. But the mask only seems to work on the latest version of Edge, i.e. 18. It doesn't render on Edge 17 or 16. I'm totally fine with that - just sayin'. Otherwise, (almost) all the device / browser combinations I tested behave as expected. I had trouble with the default (Samsung) browser on a Galaxy S8, but it was not related to this change.

Perhaps we do this in phases. We use this approach for the more decorative icons (e.g., external link), and for components like Main Nav (which it's more important to have the icons visible), we switch to this approach after a newer version of Edge gets pushed out and IE population drops even lower ?

@JBCSU JBCSU closed this Jun 11, 2019
@JBCSU
Copy link
Collaborator

JBCSU commented Jun 11, 2019

[...] https://caniuse.com/#search=mask says it can be enabled in Edge 17 behind the flag? Any idea what that means? Is that a setting in the browser?

MS Edge 17 doc says:

EdgeHTML 17 includes experimental support for CSS Masking. The partial implementation introduces the CSS mask-image and mask-size properties. Check the "Enable CSS Masking" flag in about:flags to being experimenting!

No Edge 17 users will do this, so it's effectively unsupported.

I'm still hoping that this is ok, since Edge is going Chromium soon and I like the ease of being able to change the colors easily. What do you think? 🤔

I'm fine with it being only the latest version of Edge. @sherakama, how about you?

@yvonnetangsu
Copy link
Member Author

Hey @JBCSU did you close this PR? 👀

@JBCSU JBCSU reopened this Jun 11, 2019
* master:
  424 default link style (#427)
  Update package.json (#438)
  Set up color maps for Decanter and refactor main nav colors to refer to color maps (#420)
@@ -37,10 +37,10 @@ $core-colors: (
text--high-contrast: #000,
text--reverse: $color-white,

link: $color-bright-blue,
link--hover: $color-black,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to replace link and link--hover with link-inline and link-inline--hover to be more explicit about the application. I don't want to have both, so let's decide. I prefer the -inline variants, in which case please use those. But if you feel strongly that link and link--hover are better, then please delete the ones I added and change all references to the -inline map entries to match

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like having a clean default link color without any modifiers since we have clean bg, text colors. Also, the -inline makes me wonder if it only applies to display:inline links. For example, the links in the vertical link list will probably take on this default link color, but it might be a bit strange if I apply the color link-inline even though the link might be a block element.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then please delete the -inline options and update all references to them to refer to the shorter names.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Added a link--alt and link--alt-hover for cases like the secondary button link style. I feel like the bright red link will appear on some sites in some other ways so I make that the link--alt color.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. I introduced an error in the doc for @function color(), so I fixed that.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!!

Copy link
Collaborator

@JBCSU JBCSU left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is GTG.

@yvonnetangsu
Copy link
Member Author

I think this is GTG.

Yay, merging before you changed your mind 😂

@yvonnetangsu yvonnetangsu merged commit e6d2f8a into master Jun 12, 2019
@yvonnetangsu yvonnetangsu deleted the 423-svg-icon-test branch June 12, 2019 01:53
yvonnetangsu added a commit that referenced this pull request Jun 12, 2019
* master:
  Use svg icons as "mask" so their colors could be changed using CSS background-color (#426)
  424 default link style (#427)
  Update package.json (#438)
JBCSU added a commit that referenced this pull request Jun 12, 2019
* master:
  Use svg icons as "mask" so their colors could be changed using CSS background-color (#426)
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants