Created
April 1, 2017 09:24
-
-
Save GarySwift/195480e59fa00addc7bd1d55156e61f4 to your computer and use it in GitHub Desktop.
Sass Nested Color Palette: An example of how to how to use nested color palettes in sass.
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
// Color Palettes | |
$kilflam-colors: ( | |
'primary': #E10001, | |
'secondary': #FE9800 | |
); | |
$guardian-colors: ( | |
'primary': #004A9D, | |
'secondary': #0099F2 | |
); | |
$fumeguard-colors: ( | |
'primary': #048D33, | |
'secondary': #59BB24 | |
); | |
$pvc-colors: ( | |
'primary': #FA7D00, | |
'secondary': #FFB000 | |
); | |
// Nested Color Palette | |
$product-colors: ( | |
'kilflam': $kilflam-colors, | |
'guardian': $guardian-colors, | |
'fumeguard': $fumeguard-colors, | |
'pvc': $pvc-colors | |
); | |
// Function to get nested colors | |
@function product-colors($family, $key) { | |
@return map-get(map-get($product-colors, $family), $key); | |
} |
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
@mixin topbar-style ($family) { | |
background-color: product-colors($family, 'primary'); | |
ul.menu li { | |
background-color: product-colors($family, 'primary'); | |
} | |
a:hover:not(.button) { | |
background-color: product-colors($family, 'secondary'); | |
} | |
ul.menu li.current-menu-item.is-submenu-item { | |
border: 2px solid product-colors($family, 'secondary'); | |
} | |
} | |
@mixin topbar-active-style ($family) { | |
border-right: 3px solid product-colors($family, 'secondary'); | |
} | |
@mixin topbar-hover-style ($family) { | |
border-right: 3px solid product-colors($family, 'primary'); | |
} |
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
.top-bar .menu li.kilflam { | |
@include topbar-style ('kilflam'); | |
} | |
.top-bar .menu li.kilflam.current-menu-item.is-submenu-item { | |
@include topbar-active-style ('kilflam'); | |
} | |
.top-bar .menu li.kilflam.current-menu-item.is-submenu-item:hover { | |
@include topbar-hover-style ('kilflam'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment