-
Notifications
You must be signed in to change notification settings - Fork 94
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
ID's being changed #50
Comments
An Id must be unique in the document so svg-store prefixes each I'd by the file hash. You should not use IDs for styling anyway. So use a class to style the svg. |
I've just tried this by changing the id's on the two circles inside my SVG to classes and then targeted the classes from my CSS but it doesn't work. I thought elements inside SVG's could only be styled from CSS via id's? |
It's working for me see: http://codepen.io/FWeinb/pen/1b9e5c5db92f95f19090dbd0f7bbdbcf |
I'll have another go. Must have missed something. Thanks |
I'm having the same problem when I |
@joeldbirch |
This example SVG file uses a #menu-pill symbol for the lines of the hamburger icon: <svg width="44px" height="39px" viewBox="0 0 44 39">
<symbol viewBox="0 0 44 6" id="menu-pill"><title>menu-pill</title> <rect fill="currentColor" x="0" y="0" width="44px" height="5px" rx="3px" ry="3px"/></symbol>
<text transform="matrix(1 0 0 1 0.1514 38)" fill="currentColor" font-family="'Neue Helvetica eText W01', sans-serif" font-size="15.5">menu</text>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 21)" overflow="visible"/>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 12)" overflow="visible"/>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 3)" overflow="visible"/>
</svg> Putting that through Svgstore results in something like this: <svg>
<symbol viewBox="0 0 44 39" id="menu-icon"><title>menu-pill</title>
<symbol viewBox="0 0 44 6" id="svgstore7948d8654bb5e4abd186ea603b4da4c4menu-pill"> <rect fill="currentColor" x="0" y="0" width="44px" height="5px" rx="3px" ry="3px"/></symbol>
<text transform="matrix(1 0 0 1 0.1514 38)" fill="currentColor" font-family="'Neue Helvetica eText W01', sans-serif" font-size="15.5">menu</text>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 21)" overflow="visible"/>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 12)" overflow="visible"/>
<use xlink:href="#menu-pill" width="44" height="6" x="-22" y="-3" transform="matrix(1 0 0 -1 22 3)" overflow="visible"/>
</symbol>
</svg> Maybe symbol elements are not allowed inside other symbol elements? I'm currently working around this by including #menu-pill as a seperate file and using it within a #menu-icon file, but it seems weird that it isn't contained in one file, which is then not editable via Illustrator. |
The spec suggests that |
@joeldbirch Thanks! This is fixed in |
Brilliant! Love your work, it has massively improved my workflow and I wouldn't want to be without it. Thanks. |
Isn't it better to change the ID to a class instead of giving it a random hash? |
These id's need to be preserved because they are used to cross reference patterns or gradients. And the hash is needed to be sure they are unique across the whole document.
|
I'm experiencing a similar issue. I'm maintaining a library of icons via 100 artboards in Illustrator. The artboard names are output as the filenames, and these are later used as the symbol ID by grunt-svgstore. However, you can also name individual paths in Illustrator, the wheels on a car for instance, and these names are output as an ID on each path/shape. (As a sidenote, I'm running the SVGs through grunt-svgmin prior to svgstore, but I've made sure grunt-svgmin is leaving the IDs alone). grunt-svstore is modifying the IDs by prepending a long string like so: <symbol id="car" ...>
<title>...</title>
<path id="svgstore2a644b6624aacdae6a6a951fcb9edd84front-wheel" d="..." />
<path id="svgstore2a644b6624aacdae6a6a951fcb9edd84back-wheel" d="..." />
<path id="svgstore2a644b6624aacdae6a6a951fcb9edd84body" d="..." />
</symbol> I'm assuming this is for identification purposes so svgstore can 'smoosh' the correct paths into each symbol - is it possible to remove them afterwards though? |
svgstore is prefixing each ID with the md5 hash of the original file because an ID must be unique across the whole document. I can create a option to disable this but if there are two IDs named
|
I see, that makes sense, thanks. If filenames/IDs are being used for the symbols themselves and are already unique (I guess they'd have to be otherwise the two files couldn't both exist), would it be possible to use these as a prefix instead of the hash? Something like this:
|
@IanOliver That sounds like a really clever solution. I will look into it. |
I implemented it the way @IanOliver described it. It will be in |
Great stuff, thanks @FWeinb. Looking forward to 0.4.0. |
Love it, you rock. |
I just released |
I have an SVG of the Flickr logo to which I added an ID to each circle so I could fill them via CSS later.
When using SVGStore it seems to change the ID's
My id that was set on one circle was
left
and svgstore has changed it tosvgstore4774e1d17249478ca0e984fea77cc9f4left
Why has it done this and how can I keep my original id's?
I do not have the cleanup option enabled.
Thanks
The text was updated successfully, but these errors were encountered: