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

Create a getting started / best practice guide #22

Closed
FWeinb opened this issue May 21, 2014 · 13 comments
Closed

Create a getting started / best practice guide #22

FWeinb opened this issue May 21, 2014 · 13 comments

Comments

@FWeinb
Copy link
Owner

FWeinb commented May 21, 2014

The workflow improvements discussed in #16 have an impact on the usage of grunt-svgstore so I would like to update/create a getting started and best practice guide.

If implementing the proposed idea from #1 the user will have to use css like:

.svg-sprite{
  width:0;
  height:0;
  visibility:hidden;
}

instead of the current display:none; to hide the svg sprite to keep linearGradient working.

@FWeinb
Copy link
Owner Author

FWeinb commented May 22, 2014

Things to do:

  • link to @chriscoyier svg-sprites article (maybe ask him update it to reflect the changes made here)
  • record a usage video
  • write down best practices

@chriscoyier
Copy link

I'm down to fix up all my article and stuff. Just waiting for all this to shake out. The big things I need to understand fully and then update:

  • Account for "how to use SVG's with different viewBox's"
  • Account for update to <symbol> stuff
  • Account for not hiding with display none

Anything else?

@FWeinb
Copy link
Owner Author

FWeinb commented May 26, 2014

Great @chriscoyier thanks for taking the time to update your articles.

Just to clear things up. The <symbol> element is used instead of a (<g> element) because it allows us to put the viewBox attribute of the original svg on it so there is no need to fiddle with the viewBox attribute in the <use> block anymore. You can also merge svgs with multiple different viewBoxs without any problem.

To support gradient elements like linearGradient we can no longer use display:none; in the svg sprite because that would result in a unrendert gradient (demo pen) I don't know if this an implementation bug of Webkit or intended by the spec, whatsoever we have to life with it now.
To make it work we need to hide the SVG sprite but don't remove it from the render tree using visibility:hidden; and setting the width and height to 0. I don't know how big the performance hit is but can't imagine it to but that big (I asked paul but he is obviously quite busy these days)

I hope I could cover everything you need to know.

@judewang
Copy link

Hello, I just read the article of using SVG use with External Source. But I found that because of symbol element is used, the SVG use can not be using with external source, I have to include all the svg codes into the html.
Do you know how to fix this problem? Thanks.

@FWeinb
Copy link
Owner Author

FWeinb commented May 29, 2014

Thanks @judewang for reporting this. <symbol> is working as an external source (see this plunk) keep in mind that you have to host the ressource on the same origin (port, domain and protocol must match)

The only things that aren't working using external referencing are gradients and the viewBox attribute, which must be added again.

@chriscoyier
Copy link

I wrote this up so there is a good reference to why the <symbol> stuff is better: http://css-tricks.com/svg-symbol-good-choice-icons/

@FWeinb
Copy link
Owner Author

FWeinb commented Jun 3, 2014

Great @chriscoyier. But there is one mistake. The title and desc attribute you are using are wrong. These informations have to be added as separated elements like this:

<symbol id="icon1"  
         viewBox="original-file's-viewBox" >
  <title>"original-file's-title"</title> 
  <desc>"original-file's-desc"</desc>

  [paths]

</symbol>

spec

The comment of TxHawks is wrong on this

@chriscoyier
Copy link

Got it, thx

@maxisix
Copy link

maxisix commented Aug 1, 2014

Nice one i really like ! What do you think about creating the gulpJS plugin ;)

@FWeinb
Copy link
Owner Author

FWeinb commented Aug 1, 2014

@maxisix
Copy link

maxisix commented Aug 1, 2014

@FWeinb Fuck yeah ! You rock dude ! ;)

@w0rm
Copy link

w0rm commented Aug 3, 2014

@FWeinb Thanks for mentioning my plugin here, I added link back to yours in the readme.
@maxisix If you encounter any bugs or need a feature, feel free to open an issue.

@maxisix
Copy link

maxisix commented Aug 3, 2014

Sure ill try this today !

@FWeinb FWeinb closed this as completed Nov 3, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants