Skip to content

Instantly share code, notes, and snippets.

@nicolasalarconrapela
Created June 21, 2018 18:04
Show Gist options
  • Select an option

  • Save nicolasalarconrapela/54d7b47c7bbf6957540e22f3808a771e to your computer and use it in GitHub Desktop.

Select an option

Save nicolasalarconrapela/54d7b47c7bbf6957540e22f3808a771e to your computer and use it in GitHub Desktop.

I want to create a function which will change color based on background-colorlightness(), but get an error

Argument $color of lightness($color) must be a color

When I setup color: set-color(#000000); everything is okay, but I need to setup varibable ($background-color). Is there is a way to achieve it?

    @function set-color($color) {
        @if (lightness($color) >= 50) {
            @return #000;
        }
        @else {
            @return #FFF;
        }
    }

    $background-color: attr(data-color);
    background-color: $background-color;
    color: set-color($background-color);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment