-
Notifications
You must be signed in to change notification settings - Fork 22
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
Deliver icons as backgrounds for high-traffic situations #65
Comments
This is probably a naive question, but why a png and not our svgs? Svg We still won't be able to style them since they're not in the DOM, but it would remove the need for another image format. I did some brief googling and happened upon mask-image. Basically, use an svg as a mask over the element, setting We could solve the pathing issues by embedding the svg itself into the less file. We can then ship this less file to be included into other projects as needed. It'll be a slightly larger hit at first request (loading every icon on the short list vs as needed), but the file will cache, so not an issue for future requests. Of course, I haven't tested any of this so... take it with a grain of salt. |
Yeah! Makes sense to skip PNGs entirely! Lemme dig into this. There's either masking or filtering. Let's explore both! |
This codepen currently uses https://codepen.io/aaronshekey/pen/abNNmBa Another interesting side effect is we'll have to add the dimensions into each icon. We generally hold to 18px by 18px, but occasionally an icon will need to be 20px wide. Additionally, we have our 14px by 14px variations. Very interesting sidenote: These look way better in legacy edge than the direct SVG. 🤔 |
I've beefed up the test cases in that Codepen to see what happens with |
So, coincidentally I needed this exact type of thing for a side project I was working on last night and I worked something up that I'm actually pretty happy with. The code is short, simple and very flexible. Check the very bottom of the page where I turn a "filled" icon into an "outlined" icon just by adding a Stacks Knowing how you feel about font icons, I hate to say that using these feels a lot like font icons (which, to me, is a good thing). We're getting a lot of the benefits with very few of the drawbacks. I think we might be on to something with this. |
Adding one thing in here - 2x PNGs would be handy for emails. I was thinking we could colour in the build script perhaps Would be much easier to maintain using the helper in the email templates. |
@abovedave Good call, I never even thought about supporting for emails. I wonder how css background image support is on that end |
I also have a hunch that if this alternate method is truly about performance both in rendering and page weight, pngs might be the way to go. There are a ton of scripts out there that can take a directory of SVG and turn them into sprite sheets. We can go that method for super-tuned Core experiences, and then we can go pre-baked |
Went for a long drive today and may have accidentally come up with a solution allowing for the same flexibility in our icon set that SVG allows, only for PNG.
Proposal
@2x
and#000
..css
file, export something like.png-icon.iconLink
withbackground-image: url(../path/to/Link.png)
.png-icon
that's based on CSS filters using this tool. eg..png-icon.iconLink.fc-orange-400
. These classes will also have their dark mode equivalents.@Png.Link.With("fc-orange-400")
Any thoughts before I hack together a proof of concept?
Things to solve / discover:
<div class="fc-orange-400"><div class="png-icon"></div></div>
, we'll probably want that icon to be orange.The text was updated successfully, but these errors were encountered: