-
-
Save willbowling/3131791 to your computer and use it in GitHub Desktop.
Using lists like a hash in Sass
This file contains hidden or 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
| @mixin category-colors($after: false) | |
| @each $category in $categories | |
| @if $after == true | |
| .cat-#{nth($category, 1)}:after | |
| background-color: nth($category, 2) | |
| @else | |
| .cat-#{nth($category, 1)} | |
| background-color: nth($category, 2) |
This file contains hidden or 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
| // Categories & Category Colors | |
| $categories: site teal, youth orange, poetry plum, fiction salmon, creativewriting steelblue | |
| // The semi-semantic class we'll be @extending | |
| .category-colors | |
| +category-colors | |
| .category-banners | |
| li | |
| // @extend the color classes into the list items | |
| @extend .category-colors |
This file contains hidden or 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
| .category-colors .cat-site, .category-banners li .cat-site { | |
| background-color: teal; | |
| } | |
| .category-colors .cat-youth, .category-banners li .cat-youth { | |
| background-color: orange; | |
| } | |
| .category-colors .cat-poetry, .category-banners li .cat-poetry { | |
| background-color: plum; | |
| } | |
| .category-colors .cat-fiction, .category-banners li .cat-fiction { | |
| background-color: salmon; | |
| } | |
| .category-colors .cat-creativewriting, .category-banners li .cat-creativewriting { | |
| background-color: steelblue; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment