Skip to content

Instantly share code, notes, and snippets.

@sapegin
Created February 15, 2012 12:52
Show Gist options
  • Save sapegin/1835465 to your computer and use it in GitHub Desktop.
Save sapegin/1835465 to your computer and use it in GitHub Desktop.
Color to hex in SASS
@function _decToHex($dec) {
$h2: $dec % 16;
$h1: ($dec - $h2) / 16;
@if $h1 > 9 {
$h1: nth((a b c d e f), $h1 - 9);
}
@if $h2 > 9 {
$h2: nth((a b c d e f), $h2 - 9);
}
@return "#{$h1}#{$h2}";
}
@function _colorToHex($color) {
@return "#{_decToHex(red($color))}#{_decToHex(green($color))}#{_decToHex(blue($color))}";
}
.pony {
$color: _colorToHex($element--color);
font-family:$color;
content:$color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment