Last active
August 29, 2015 14:20
-
-
Save LukyVj/3a1c53a6e8886088e50b to your computer and use it in GitHub Desktop.
Google Web Font SASS Mixin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>Hello World</h1> | |
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Tenetur ipsa assumenda officia ipsam numquam maxime fugit, aliquam dolore aliquid soluta veritatis reiciendis doloremque consequuntur eum doloribus commodi! Minima, optio, earum.</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url("http://fonts.googleapis.com/css?family=Josefin+Slab:500, 600"); | |
@import url("http://fonts.googleapis.com/css?family=Open+Sans:500, 600"); | |
h1 { | |
font-family: "Josefin Slab"; | |
} | |
p { | |
font-family: "Open Sans"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import "compass/css3"; | |
/// Replace `$search` with `$replace` in `$string` | |
/// @author Hugo Giraudel | |
/// @param {String} $string - Initial string | |
/// @param {String} $search - Substring to replace | |
/// @param {String} $replace ('') - New value | |
/// @return {String} - Updated string | |
@function str-replace($string, $search, $replace: '') { | |
$index: str-index($string, $search); | |
@if $index { | |
@return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); | |
} | |
@return $string; | |
} | |
// Mixin | |
$font-array: 'Josefin Slab', 'Open Sans'; | |
@mixin gwf($fonts, $weight){ | |
@each $font in $fonts{ | |
$font: str-replace($font, ' ', '+'); | |
@import url('http://fonts.googleapis.com/css?family=#{$font}:#{$weight}'); | |
} | |
} | |
@include gwf($font-array, '500, 600'); | |
h1{ | |
font-family: "Josefin Slab"; | |
} | |
p{ | |
font-family: "Open Sans"; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment