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

Possibility to call spritesheet as param of "svg_spritesheet" #15

Closed
mauriciomateus opened this issue May 8, 2017 · 5 comments
Closed

Comments

@mauriciomateus
Copy link

Hi. I usually have different layouts and different icon collections in my projects. Different landing pages use different icon sets.

The way blade-svg package works does not allow the usage of multiple svg spritesheets, so you would need to render icons you are not actually going to use in every page (maybe I am wrong).

I think it would be very convenient if we could pass the location of any sprite sheet from any view, being able to switch icon collections as desired. Sometimes you need a collection of only three icons, for example. It would be nice if we could create and render a spritesheet for only those three icons instead of a big set of svg's.

Thanks in advance.

@meduzen
Copy link

meduzen commented May 10, 2017

svg_spritesheet() is a shortcut for <div syle="display:none;">@include('svg.your_spritesheet')</div>, and you don’t even need to include your spritesheet to be able to use @icon directive.

Indeed, having one or two (optionals) parameters for svg_spritesheet() would be a nice feature:

  • no parameter: you call the default spritesheet from config/blade-svg.php;
  • first parameter (string): you call another spritesheet;
  • second parameter (array of icon slugs): you filter the spritesheet to include only the icon set (so, an array) specified.

Example: svg_spritesheet('svg.socials', ['instagram', 'twitter', 'ello']);

For now, I work with multiple spritesheets in the front-end workflow side, with gulp-svg-sprite), which covers my current use case.

Maybe I’ll try to build something and PR for the version with one argument. I currently wait for @adamwathan ’s feedback of the one I made (as I’m noob to the Git contribution thing and not especially a PHP-guy).

@mauriciomateus
Copy link
Author

I agree, those parameters would be a good adition.

As to filtering the icons as you propose in the third parameter, I think it would be even better being able to pass an array of spritesheets. It would be convenient to split icons, for example, social_icons_spritesheet.svg, form_labels_spritesheet.svg, etc.

That way, we would not need to import a huge set of icons every time, but just render the ones we need, optimizing the amount of html rendered.

Other than that, the package is great. I like the fact that the spritesheet can be a blade view, allowing for html sintax highlighting in code editors, as well as auto completion. It does not force us to use the .svg extension.

@adamwathan
Copy link
Contributor

Would totally look at a PR for this 👍🏻 I'm personally only ever using maybe a dozen icons on a site so I'm fine with including the whole spritesheet, but even so I use the inline option 99% of the time anyways.

@adamwathan
Copy link
Contributor

Going to close this for now as I don't personally have any intention on adding it, although I would still look at a PR if someone were to submit one.

Part of me wants to remove spritesheet support entirely at some point, because I think directly inlining your SVGs is simpler with some benefits and not any real downsides. I probably won't but I will at least de-emphasize it in the docs.

Seems to be becoming the recommended approach in other circles:

https://css-tricks.com/pretty-good-svg-icon-system/

@meduzen
Copy link

meduzen commented Aug 14, 2017

That’s what I went for since a couple of weeks, too, after having discussed this specific point with a former colleague. Not sure a spritesheet couldn’t be a benefit for some projects, by the way (no examples come in mind right now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants