Last active
July 29, 2016 21:37
-
-
Save davidsekar/585ec5459165277b4cb136bc3fe1fedb to your computer and use it in GitHub Desktop.
Scss force get hex value for the provided colour
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
// ---- | |
// Sass (v3.4.21) | |
// Compass (v1.0.3) | |
// ---- | |
@function returnHexValue($color){ | |
@debug $color; | |
@if $color == "white" { | |
@return "#fff"; | |
} | |
@if $color == "black" { | |
@return "#000"; | |
} | |
@return $color; | |
} | |
@function force-hex($color) { | |
@if type-of($color) == 'color' { | |
$hex: str-slice(ie-hex-str($color), 4); | |
@return unquote("\##{$hex}"); | |
} | |
@return $color; | |
} | |
body{ | |
color: force-hex(teal); | |
} |
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
body { | |
color: #008080; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment