Allow multiple $sprites declarations#20
Allow multiple $sprites declarations#20kriskhaira wants to merge 2 commits intoAdamBrodzinski:masterfrom
Conversation
|
I should include an amended README.md in the pull request as well, but let me know your thoughts first. Thanks, Adam. |
|
Awesome, thanks for the PR @kriskhaira ! I'll dig into this and try it out Fri or this weekend! 🍺 Have you tried putting the sprite declarations in separate sass partials/files? In Tagit's website i'm using multiple sprites files with a single declaration in each, albeit much less explicit. example below. I've also been thinking about changing the api to have one sprites folder and just have it look for a _header.scss /* ============================================================== *
* Header
* ============================================================== */
$sprites: sprite-map("sprites/hdr/*.png"); // import 1x sprites
$sprites2x: sprite-map("sprites-retina/hdr/*.png"); // import retina sprites
...
.hdr-logo {
float:left;
margin-top: 16px;
@include sprite(hdr-logo);
}
_buttons.scss * ============================================================== *
* Buttons Module - .btn namespace
* ============================================================== */
.btn { // Vector Buttons (default)
...
}
/* ==================== Raster Buttons ==================== */
$sprites: sprite-map("sprites/btn/*.png"); // import 1x sprites
$sprites2x: sprite-map("sprites-retina/btn/*.png"); // import retina sprites
.btn-playNow {
@include sprite(playNow, $hover: true);
}
.btn-getTheApp {
@include sprite(getTheApp);
}
.btn-signIn {
@include sprite(signIn);
}
.btn-go {
@include sprite(go, $hover: true);
}
.btn-registerNow {
@include sprite(registerNow, $hover: true);
}
.btn-twitter {
@include sprite(btn-twitter);
}
.btn-twitter-reg {
@include sprite(btn-twitter-reg);
}
|
|
Hey Adam, i've had the same problem and made multiple changes to your mixin over the time. I just uploaded these as a fork here: |
|
btw i like the idea of having file.png and file@2x.png in one folder, but how would the sprite-map() calls for this look like? |
|
@novascreen Oh wow, so much awesomeness!! We could definitely pull it into a feature something branch, remove the respondjs dependency (if it's a hard dep) and then update to 2.0 once everything once it's smoothed out. I also love how clean it is =)
To be honest i'm not sure offhand, i'd have to look over how the whole compass sprites works behind the scenes again... it's been almost a year 😄 . I was thinking of creating a mixin that would set both sprites as a side effect (like your retina-sprite-add), and perhaps take a param of just the path, e.g., |
|
Cool, thanks for looking at this so quickly, i'm glad you like it. RespondJS is not a hard dependency, i just had to support IE8 in many RWD projects and we used RespondJS to make that happen, so i wanted to have the option in there. But i have the option variable I can refine this a little further, put it in a branch and then make a pull request, ok? About But we could also just say it takes one path like |
Awesome! 🍻
Oh yea I see now, at first I thought it wouldn't output if it wasn't detected... cool let's keep it in!
Bummer, yea you're right. Maybe we can ping Chris and Nate to see if there's a quick fix for this deep in sass/compass. If all else fails we could do as you suggested by but maybe have a |
|
Guys, sorry for the late reply. @novascreen great work there. Would've used/forked your fork if I had seen it earlier. I definitely support using "@2x" and allowing the files to be in the same folder instead of having Retina images in a separate folder. One plus for having them in the same folder and using @2x is it's consistent with the way Slicy exports images. Slicy (http://macrabbit.com/slicy/) is an app which is used quite a lot to export images from PSD files based on the way you name the layers and groups. Right now I have to move all @2x files into a separate -retina folder and then run the following alias to remove the "@2x" from the filenames. |
Hi Adam. The current helper only allows one $sprites declaration.
I usually have multiple sections in my apps where I'd like separate sprites files. For example, I'd like to be able to do this:
I was wondering if you'd like to merge this.
It would be cool if it would just use "$sprites" if it wasn't set; as well as appending "2x" to the name of the $sprites value if the $sprites2x parameter isn't defined; but that's beyond me at the moment.