Last active
October 26, 2017 21:15
-
-
Save tiagoporto/3231e356c2435a775c69c2655f8c7a1d to your computer and use it in GitHub Desktop.
Preprocessors helpers
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
// ************* VARIABLE **************** // | |
$color: #FFF | |
// ******* ESCAPE CONCAT VAR ************ // | |
.test | |
background: url(#{$path + 'file.jpg'}) | |
// ********** COLOR FUNCTIONS *********** // | |
rgba(#ffcc00, .7) // Return RGBA from the r,g,b,a channels | |
tint(#fd0cc7, 10%) // Mix the given color with white. | |
shade(#fd0cc7, 10%) // Mix the given color with black. | |
saturate(#00c, 20%) // Saturate the given color by amount. | |
darken(#D62828, 50%) // Darken the given color by amount. | |
lighten(#2c2c2c, 10%) // Lighten the given color by amount. | |
desaturate(#f00, 20%) // Desaturate the given color by amount. | |
// ********** This is a mixin *********** // | |
=inline | |
display: inline | |
float: left | |
// ************ Using mixin ************* // | |
.using-mixin-1 | |
+inline | |
.using-mixin-2 | |
+inline | |
// CSS Output | |
.using-mixin-1 { | |
display: inline; | |
float: left; | |
} | |
.using-mixin-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output | |
// ******** This is a placeholder ******** // | |
%inline | |
+inline //Include a mixin | |
// ********* Using placeholder ********** // | |
.extend-placeholder-1 | |
@extend %inline | |
.extend-placeholder-2 | |
@extend %inline | |
// CSS Output | |
.extend-placeholder-1, | |
.extend-placeholder-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output |
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
// ************* VARIABLE **************** // | |
$color: #FFF; | |
// ******* ESCAPE CONCAT VAR ************ // | |
.test{ | |
background: url(#{$path + 'file.jpg'}); | |
} | |
// ********** COLOR FUNCTIONS *********** // | |
rgba(#ffcc00, .7) // Return RGBA from the r,g,b,a channels | |
tint(#fd0cc7, 10%) // Mix the given color with white. | |
shade(#fd0cc7, 10%) // Mix the given color with black. | |
saturate(#00c, 20%) // Saturate the given color by amount. | |
darken(#D62828, 50%) // Darken the given color by amount. | |
lighten(#2c2c2c, 10%) // Lighten the given color by amount. | |
desaturate(#f00, 20%) // Desaturate the given color by amount. | |
// ********** This is a mixin *********** // | |
@mixin inline(){ | |
display: inline; | |
float: left; | |
} | |
// ************ Using mixin ************* // | |
.using-mixin-1{ | |
@include inline(); | |
} | |
.using-mixin-2{ | |
@include inline(); | |
} | |
// CSS Output | |
.using-mixin-1 { | |
display: inline; | |
float: left; | |
} | |
.using-mixin-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output | |
// ******** This is a placeholder ******** // | |
%inline{ | |
@include inline(); | |
} | |
// ********* Using placeholder ********** // | |
.extend-placeholder-1{ | |
@extend %inline; | |
} | |
.extend-placeholder-2{ | |
@extend %inline; | |
} | |
// CSS Output | |
.extend-placeholder-1, | |
.extend-placeholder-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output |
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
// *********** GOOD PRATICES ************** // | |
https://gist.github.com/declandewet/7220997 | |
// User $ to prepended variables | |
$color = #FFF | |
// User - to prepended function | |
-function() | |
// ******* ESCAPE VAR ************ // | |
{$myVar} | |
// ******* CONCAT VAR ************ // | |
$var + var | |
.test | |
background: url($path + 'file.jpg') | |
// ********** COLOR FUNCTIONS *********** // | |
rgba(#ffcc00, .7) // Return RGBA from the r,g,b,a channels | |
tint(#fd0cc7, 10%) // Mix the given color with white. | |
shade(#fd0cc7, 10%) // Mix the given color with black. | |
saturate(#00c, 20%) // Saturate the given color by amount. | |
darken(#D62828, 50%) // Darken the given color by amount. | |
lighten(#2c2c2c, 10%) // Lighten the given color by amount. | |
desaturate(#f00, 20%) // Desaturate the given color by amount. | |
// **** Getting image width & height **** // | |
image-size("../images/header-bg.jpg")[0] //width | |
image-size("../images/header-bg.jpg")[1] //height | |
// ********** This is a mixin *********** // | |
inline() | |
display: inline | |
float: left | |
// ******* This is a placeholder ******** // | |
$inline | |
display: inline | |
float: left | |
// ************ Using mixin ************* // | |
.using-mixin-1 | |
inline() | |
.using-mixin-2 | |
inline() | |
// CSS Output | |
.using-mixin-1 { | |
display: inline; | |
float: left; | |
} | |
.using-mixin-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output | |
// ********* Using placeholder ********** // | |
.extend-placeholder-1 | |
@extend $inline | |
.extend-placeholder-2 | |
@extend $inline | |
// CSS Output | |
.extend-placeholder-1, | |
.extend-placeholder-2 { | |
display: inline; | |
float: left; | |
} | |
// End CSS Output |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment