Skip to content

Instantly share code, notes, and snippets.

@seven-phases-max
Created March 23, 2019 17:51
Show Gist options
  • Save seven-phases-max/a12a361d0076a637e8051b577015bf66 to your computer and use it in GitHub Desktop.
Save seven-phases-max/a12a361d0076a637e8051b577015bf66 to your computer and use it in GitHub Desktop.
// data:
@on-primary: #ffffff;
@icon-variants: active, inactive, disabled;
@icon-opacity-on-primary: 70, 50, 38;
// test:
div {
r: .get-icon-color(inactive)[];
}
// functions:
.get-icon-color(@variant) {
@index: .index-of(@icon-variants, @variant)[];
@opacity: extract(@icon-opacity-on-primary, @index);
return: fade(@on-primary, @opacity * 1%);
}
.index-of(@list, @value-to-find) {
each(@list, {
& when (@value = @value-to-find) {
return: @index;
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment