Skip to content
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

Update svg-sprites.svg syntax #28

Open
calvinjuarez opened this issue Mar 14, 2015 · 4 comments
Open

Update svg-sprites.svg syntax #28

calvinjuarez opened this issue Mar 14, 2015 · 4 comments

Comments

@calvinjuarez
Copy link

I feel like the svg-sprites.svg file could do with a syntax update. Chris Coyier wrote a really good article about the syntax called SVG symbol a Good Choice for Icons. In it he describes this pattern for the svg sprite file:

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <symbol id="fa-glass" viewBox="0 0 1792 1792"><path d="..."></symbol>
  ...
  <symbol id="fa-medium" viewBox="0 0 1792 1792"><path d="..."></symbol>
</svg>

Reasons:

As Chris points out, there are some very good reasons for going with this markup style.

  • It could open the doors for some really great accessibility (with the <title> and <desc> tags)
  • The viewBox attribute should make consistent sizing very easy.
  • "This is probably what <symbol> was invented for anyway."

I get that this will increase the file size (because of repetition over 519 icons), but GZIP eats this kind of character repetition for breakfast, so the performance hit shouldn't be all that severe.

Alternatively, all the <paths> could be wrapped inside a <defs> tag, which should hide things properly, and the <svg> itself could just be set to display: none;. Like so:

<svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
  <defs>
    <path id="fa-glass" d="...">
    ...
    <path id="fa-medium" d="...">
  </defs>
</svg>
nikgavalas added a commit to nikgavalas/Font-Awesome-SVG-PNG that referenced this issue May 5, 2015
Great suggestion and works really well.
@nikgavalas
Copy link

So I've implemented this in by forked branch if you want it. Great suggestion. The icons show up more consistently centered and sized

https://github.com/nikgavalas/Font-Awesome-SVG-PNG

@calvinjuarez
Copy link
Author

@nikgavalas Nice work! Would it affect #29 at all?

@Rush
Copy link
Owner

Rush commented Feb 25, 2016

@nikgavalas Could you do a PR?

@calvinjuarez
Copy link
Author

@nikgavalas @Rush Did this ever move?

midnightveil pushed a commit to midnightveil/Font-Awesome-SVG-PNG that referenced this issue Nov 21, 2024
Great suggestion and works really well.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants