Last active
April 23, 2017 00:33
-
-
Save MFFunmaker/c5747f63e463349377f86f9b11145205 to your computer and use it in GitHub Desktop.
A collection of things you can do with Sass that are pretty cool
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
/* | |
* Dynamically grab a partial based on a class name | |
*/ | |
@function get-class-partial() { | |
$className: str-slice(#{&}, 2); | |
@return "../partials/_#{$className}.scss"; | |
} | |
.signup { | |
content: "#{get-class-partial()}"; | |
} | |
/* | |
* Output: | |
* | |
* .signup { | |
* @import "../partials/_signup.scss"; | |
* } | |
* | |
*/ | |
//////////////////// | |
// CSS Extensions // | |
//////////////////// | |
/* | |
* Create nested properties using shorthand syntax | |
*/ | |
.funky { | |
font: { | |
family: fantasy; | |
size: 30em; | |
weight: bold; | |
} | |
} | |
/* | |
* Output: | |
* | |
* .funky { | |
* font-family: fantasy; | |
* font-size: 30em; | |
* font-weight: bold; | |
* } | |
* | |
*/ | |
/* | |
* Placeholder Selectors | |
*/ | |
%button-reset { | |
appearance: none; | |
outline: none; | |
border: none; | |
} | |
.button { | |
@extend %button-reset; | |
} | |
/* | |
* Output: | |
* | |
* .button { | |
* appearance: none; | |
* outline: none; | |
* border: none; | |
* } | |
* | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sass Lists
Not really a use case for the particular styles below but I was messing around with multi-dimensional lists and theres a lot of cool tricks you can do. With variables or mixins themselves being passed into a css list, it could be a very useful tool.