Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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' {
$hex: str-slice(ie-hex-str($string), 4);
$string:unquote("#{$hex}");
}
$string: '%23' + $string;
@return $string;
}
@jacobdubail

This comment has been minimized.

Copy link

commented Apr 21, 2017

just saved me so much work. fixed an issue in firefox where the svg wouldn't appear as a background.

@seuck

This comment has been minimized.

Copy link

commented Dec 29, 2017

I had the same problem as jacobdubail. Thanks!

@keeperofkeys

This comment has been minimized.

Copy link

commented Feb 28, 2018

This wasn't working properly for me. I have forked it and added a couple of fixes.

@radube

This comment has been minimized.

Copy link

commented Jun 14, 2018

Exactly what I was looking for, thanks!

@weberjacob

This comment has been minimized.

Copy link

commented Jun 13, 2019

Awesome. Thank you.

@cor

This comment has been minimized.

Copy link

commented Jul 8, 2019

Thanks so much! I also had the same problem as jacobdubail.

@iamnimnul

This comment has been minimized.

Copy link

commented Jul 24, 2019

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.