Skip to content

Instantly share code, notes, and snippets.

@jackarmley
Last active August 29, 2015 14:22
Show Gist options
  • Select an option

  • Save jackarmley/425642414e07b16e8e71 to your computer and use it in GitHub Desktop.

Select an option

Save jackarmley/425642414e07b16e8e71 to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
// ----
// Sass (v3.4.13)
// Compass (v1.0.3)
// ----
$producticons:(
spritesrc: (
'../images/processicons.svg',
'../images/processicons.png'
),
iconpadding: 2,
icons:(
posturalzonedsupport,
reducedpressurepoints,
healthysleepenvironment,
increasedbloodflow,
fullsleepsurface,
aquacool,
greaterflexibility,
reducedpartnerdisturbance,
10yr-warranty,
over10yr-warranty
)
);
$processicons:(
spritesrc: (
'../images/processicons.svg',
'../images/processicons.png'
),
iconpadding: 0,
icons:(
store,
cart,
van,
delivery,
ute,
phone,
nextdaycollection,
couple-plus,
couple,
card
)
);
/// Icon sprite
/// @author Jack Armley
/// @group Bedshed Dreamsense
/// @param {Bool|String} $icon Icon name. Take from 'icons' key in selected map
/// @param {Number} $size [80px] Icon size
/// @param {Variable} $spritemap Spritemap to use. Specific map keys need to be
/// used to work with this mixin. See example
/// @param {Bool} $styles [true]
/// @example
/// // Example map structure
/// $icons:(
/// spritesrc: (
/// 'sprite.svg', // svg of the icons
/// 'sprite.png' // fallback image for the icons
/// ),
/// iconpadding: 0, // if each icon has space underneath
/// icons:( // list of icons, listed vertically from the top of the image
/// icon1,
/// icon2
/// )
/// );
@mixin iconsprite($icon, $spritemap, $size: 80px, $styles: true ){
// Set default size
@if $size == false{
$size: 80px;
}
// Set icon properties
$iconlist: map-get($spritemap,'icons');
$iconimage: map-get($spritemap,'spritesrc');
$iconpadding: map-get($spritemap,'iconpadding');
$iconw: $size;
$iconh: ($size + $iconpadding);
$iconlen: length($iconlist);
@if $icon{
// Set icon position
$iconindex: index($iconlist,$icon);
$iconpos: -($iconh * ($iconindex - 1));
background-position: 0 #{$iconpos};
}
// Add additional styles
@if $styles{
display: inline-block;
width: $iconw;
height: $iconw;
background-image: url('#{nth($iconimage,1)}');
background-size: $iconw ($iconh * $iconlen);
.no-svg &{
background-image: url('#{nth($iconimage,2)}');
}
}
}
p{
@include iconsprite(false,$processicons)
}
p {
display: inline-block;
width: 80px;
height: 80px;
background-image: url("../images/processicons.svg");
background-size: 80px 800px;
}
.no-svg p {
background-image: url("../images/processicons.png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment