Skip to content

Instantly share code, notes, and snippets.

@jordanbrauer
Created December 5, 2017 01:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jordanbrauer/5dd8b7c97c41e210d3321575502ba03f to your computer and use it in GitHub Desktop.
Save jordanbrauer/5dd8b7c97c41e210d3321575502ba03f to your computer and use it in GitHub Desktop.
// Hexadecimal Alpha Colour function
@function hda($hexdec: null, $alpha: 1)
{
@if $hexdec == null {
// throw error if no value supplied for $hexdec
@error "$hexdex cannot be null: was, NULL";
} @else {
// evaluate input
@if $alpha >= 1 {
// return plain hexadecimal value if $alpha is greater than or equal to 1.
@return $hexdec;
} @else {
// otherwise return an rgba value with an alpha value.
@return rgba($hexdec, $alpha);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment