Skip to content

Instantly share code, notes, and snippets.

@keeperofkeys
Forked from certainlyakey/library.scss
Last active November 7, 2018 10:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save keeperofkeys/45b14189f49017171a3d48f12c6ccf69 to your computer and use it in GitHub Desktop.
Save keeperofkeys/45b14189f49017171a3d48f12c6ccf69 to your computer and use it in GitHub Desktop.
URL-encode color SASS function / convert color to hex SASS function
//does not work with colors containing alpha
@function encodecolor($string) {
@if type-of($string) == 'color' {
@if $string != transparent {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
$string: '%23' + $string;
}
}
@return $string;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment