11@import ' variables' ;
2- @import " svg-sprite-map" ;
2+ @import ' svg-sprite-map' ;
33
44// @author Mike Street
55// modified by Devbridge
99// @include svg-sprite('file-name', 'size in px or em');
1010
1111$base-font-size : 16px !default ;
12- $ieSprite : ' .ie8' !default ;
12+ $ie-sprite : ' .ie8' !default ;
1313
1414$sprite : map-get ($icons , sprite ) !default ;
1515
1616// Retrieve an attributes value for a specific icon in the sprite map
1717@function sprite-attr ($icon , $attr ) {
18- $newIcon : map-get ($icons , $icon );
19- @if $newIcon == null {
20- @warn " Can't find an icon with the name #{$icon } " ;
21- }
22- @return map-get ($newIcon , $attr );
18+ $new-icon : map-get ($icons , $icon );
19+ @if $new-icon == null {
20+ @warn " Can't find an icon with the name #{$icon } " ;
21+ }
22+ @return map-get ($new-icon , $attr );
2323}
2424
2525// Create a map with the specified icon of attributes
2626@function icon-attr ($icon ) {
27- $attr : (
28- width : sprite-attr ($icon , width ),
29- height : sprite-attr ($icon , height ),
30- x : sprite-attr ($icon , backgroundX ),
31- y : sprite-attr ($icon , backgroundY )
32- );
33-
34- @return $attr ;
27+ $attr : (
28+ width : sprite-attr ($icon , width ),
29+ height : sprite-attr ($icon , height ),
30+ x : sprite-attr ($icon , backgroundX ),
31+ y : sprite-attr ($icon , backgroundY )
32+ );
33+
34+ @return $attr ;
3535}
3636
3737@function parse-int ($n ) {
38- @return $n / ($n * 0 + 1 );
38+ @return $n / ($n * 0 + 1 );
3939}
4040
4141@function px-to-em ($px , $base : $base-font-size ) {
42- @if not unitless ($px ) {
43- $px : parse-int ($px );
44- }
45- @if not unitless ($base ) {
46- $base : parse-int ($base );
47- }
48- @return ($px / $base ) * 1em ;
42+ @if not unitless ($px ) {
43+ $px : parse-int ($px );
44+ }
45+ @if not unitless ($base ) {
46+ $base : parse-int ($base );
47+ }
48+ @return ($px / $base ) * 1em ;
4949}
5050
51- @function get-ratio ($width , $height ){
52- @return parse-int ($width / $height );
51+ @function get-ratio ($width , $height ) {
52+ @return parse-int ($width / $height );
5353}
5454
55- @function get-scale ($width , $new-width ){
56- @return parse-int ($new-width / $width );
55+ @function get-scale ($width , $new-width ) {
56+ @return parse-int ($new-width / $width );
5757}
5858
5959%sprite {
60- display : inline-block ;
61- background-image : url ( map-get ( $sprite , svgPath )) ;
62- background-size : map-get ($sprite , width ) map-get ($sprite , height );
63- background-repeat : no-repeat ;
60+ background-image : url ( map-get ( $sprite , svgPath )) ;
61+ background-repeat : no-repeat ;
62+ background-size : map-get ($sprite , width ) map-get ($sprite , height );
63+ display : inline-block ;
6464}
6565
6666%ie-sprite {
67- background-image : url (map-get ($sprite , pngPath ));
67+ background-image : url (map-get ($sprite , pngPath ));
6868}
6969
7070@mixin svg-sprite ($icon , $size : null) {
7171
72- $sprite-width : map-get ($sprite , width );
73- $sprite-height : map-get ($sprite , height );
72+ $sprite-width : map-get ($sprite , width );
73+ $sprite-height : map-get ($sprite , height );
7474
75- $iconMap : icon-attr ($icon );
76- $icon-width : map-get ($iconMap , width );
77- $icon-height : map-get ($iconMap , height );
78- $icon-pos-x : map-get ($iconMap , x );
79- $icon-pos-y : map-get ($iconMap , y );
75+ $icon-map : icon-attr ($icon );
76+ $icon-width : map-get ($icon-map , width );
77+ $icon-height : map-get ($icon-map , height );
78+ $icon-pos-x : map-get ($icon-map , x );
79+ $icon-pos-y : map-get ($icon-map , y );
8080
81- @if ($size ){
81+ @if ($size ){
8282
83- $unit : unit ($size );
84- $ratio : get-ratio ($icon-width , $icon-height );
83+ $unit : unit ($size );
84+ $ratio : get-ratio ($icon-width , $icon-height );
8585
86- @if ($unit == ' px' ){
86+ @if ($unit == ' px' ){
8787
88- $scale : get-scale ($icon-width , $size );
88+ $scale : get-scale ($icon-width , $size );
8989
90- $icon-height : ($size / $ratio );
91- $icon-width : $size ;
90+ $icon-height : ($size / $ratio );
91+ $icon-width : $size ;
9292
93- $icon-pos-x : ($icon-pos-x * $scale );
94- $icon-pos-y : ($icon-pos-y * $scale );
93+ $icon-pos-x : ($icon-pos-x * $scale );
94+ $icon-pos-y : ($icon-pos-y * $scale );
9595
96- background-size : ($sprite-width * $scale ) ($sprite-height * $scale );
97- }
96+ background-size : ($sprite-width * $scale ) ($sprite-height * $scale );
97+ }
9898
99- @if ($unit == ' em' ){
99+ @if ($unit == ' em' ){
100100
101- $icon-width : parse-int (px-to-em ($icon-width )) * parse-int ($size ) + em;
102- $icon-height : parse-int (px-to-em ($icon-height )) * parse-int ($size ) + em;
101+ $icon-width : parse-int (px-to-em ($icon-width )) * parse-int ($size ) + em;
102+ $icon-height : parse-int (px-to-em ($icon-height )) * parse-int ($size ) + em;
103103
104- $sprite-width : parse-int (px-to-em ($sprite-width )) * parse-int ($size ) + em;
105- $sprite-height : parse-int (px-to-em ($sprite-height )) * parse-int ($size ) + em;
104+ $sprite-width : parse-int (px-to-em ($sprite-width )) * parse-int ($size ) + em;
105+ $sprite-height : parse-int (px-to-em ($sprite-height )) * parse-int ($size ) + em;
106106
107- $icon-pos-x : parse-int (px-to-em ($icon-pos-x )) * parse-int ($size ) + em;
108- $icon-pos-y : parse-int (px-to-em ($icon-pos-y )) * parse-int ($size ) + em;
107+ $icon-pos-x : parse-int (px-to-em ($icon-pos-x )) * parse-int ($size ) + em;
108+ $icon-pos-y : parse-int (px-to-em ($icon-pos-y )) * parse-int ($size ) + em;
109109
110- background-size : $sprite-width $sprite-height ;
110+ background-size : $sprite-width $sprite-height ;
111111
112- }
112+ }
113113
114- @if ($unit == ' %' ){
115- @warn " SVG Icons - values in percentages are not supported" ;
116- }
114+ @if ($unit == ' %' ){
115+ @warn ' SVG Icons - values in percentages are not supported' ;
116+ }
117117
118- }
118+ }
119119
120- @extend %sprite ;
121- width : $icon-width ;
122- height : $icon-height ;
123- background-position : $icon-pos-x $icon-pos-y ;
120+ @extend %sprite ;
121+ width : $icon-width ;
122+ height : $icon-height ;
123+ background-position : $icon-pos-x $icon-pos-y ;
124124
125- // Add IE fallback
126- // Works with icons with default size ONLY
127- @if $ieSprite {
128- #{$ieSprite } & {
129- @extend %ie-sprite ;
130- }
131- }
132- }
125+ // Add IE fallback
126+ // Works with icons with default size ONLY
127+ @if $ie-sprite {
128+ #{$ie-sprite } & {
129+ @extend %ie-sprite ;
130+ }
131+ }
132+ }
0 commit comments