natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
1.08k stars 60 forks source link

fix: show icon with gradients in Chrome #56

Closed dwightjack closed 1 year ago

dwightjack commented 2 years ago

I noticed that some icons (like logos:vitejs) are not showing in Chrome, but they work fine in Firefox.

After some investigation, it seems that using display: none on the spritesheet's SVG causes gradients to don't work in Chrome. Resources:

I also created a demo in CodePen to reproduce the issue (screenshot below):

image

This PR uses another technique to hide the spritesheet that should make everything work in Chrome.

For reference, here are my system's details:


  System:
    OS: macOS 12.5.1
  Binaries:
    Node: 16.17.0 
    Yarn: 1.22.4 
    npm: 8.15.0 
  Browsers:
    Chrome: 105.0.5195.125
    Firefox: 105.0.1
    Safari: 15.6.1
  npmPackages:
    astro-icon: 0.7.3 => 0.7.3
changeset-bot[bot] commented 2 years ago

🦋 Changeset detected

Latest commit: 4805671fd265554a8f3accb8d9bc2a2819ad8dae

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages | Name | Type | | ---------- | ----- | | astro-icon | Patch | | www | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 2 years ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
api-astroicon ✅ Ready (Inspect) Visit Preview Oct 4, 2022 at 7:50AM (UTC)
astroicon ✅ Ready (Inspect) Visit Preview Oct 4, 2022 at 7:50AM (UTC)
dwightjack commented 2 years ago

By the way, At the moment a quick fix could be adding the following CSS where the <Sprite.Provider /> component is used:

:global([astro-icon-spritesheet]) {
  display: block !important;
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}