@function color-claim($color, $claim: "bg", $percentage: 50%) {
    //  Check if color exists.
    @if map-has-key($color-claim, $color) {
        $color: map-get($color-claim, $color);     

        // Return bg value (1st item in list).
        @if ($claim == "bg") {
            @return nth($color, 1);
        }

        //  Return text value (2nd item in list).
        @else if ($claim == "text") {
            @return nth($color, 2);
        }

        @else if ($claim == "mix"){
            @return mix(nth($color, 1), nth($color, 2), $percentage);
        }

    }

    @warn "This color or selector does not exist";
    @return null;
}

@mixin color-claim($color, $claim: null){
    //  Check for inverse first
    @if ($claim == "inv"){
        background-color: color-claim($color, "text") !important;
        color: color-claim($color, "bg") !important;
    }
    @else {
        //  Set bg if "text" isn't passed
        @if ($claim != "text") {
            background-color: color-claim($color, "bg") !important;
        }

        //  Set text if "bg" isn't passed
        @if ($claim != "bg") {
            color: color-claim($color, "text") !important;
        }
    }
}

$_type: if($_silent, unquote("%"), unquote("."));
@if($_type == true){
    /*
    **  You can use the following classes if you really need to use it as a class (f.e. in HTML, jQuery, ...).
    **  In any other cases - like the ones addressed above - just use the mixin or the function. 
    **  With #color a number from 1-50:
    **      use .color-claim-#color to set both the background-color and color attributes,
    **      .color-claim-bg-#color to only set the background-color attribute,
    **      .color-claim-text-#color to only set the color attribute.
    **      .color-claim-inv-#color to set the background-color attribute to the color value (and vice versa).
    **
    **  You can also set these classes as silent, so they won't compile to your css.
    **  Before importing color-claim-sass in your project, set $_silent to true.
    */
}
@each $color in $color-claim {
    //  Get the key.
    $color: nth($color, 1);
    
    //  Set both bg and text colors.
    #{$_type}color-claim-#{$color}{
        @include color-claim($color);
    }

    //  Only set bg color.
    #{$_type}color-claim-bg-#{$color}{
        @include color-claim($color, "bg");
    }

    //  Only set text color.
    #{$_type}color-claim-text-#{$color}{
        @include color-claim($color, "text");
    }

    //  Set inverse color.
    #{$_type}color-claim-inv-#{$color}{
        @include color-claim($color, "inv");
    }
}