Skip to content

Instantly share code, notes, and snippets.

@jonnykates
Created April 22, 2018 16:30
Show Gist options
  • Save jonnykates/c2961ec71d493ede56ac9dcd55f10254 to your computer and use it in GitHub Desktop.
Save jonnykates/c2961ec71d493ede56ac9dcd55f10254 to your computer and use it in GitHub Desktop.
@mixin text-contrast($n) {
$color-brightness: round((red($n)*299)+(green($n)*587)+(blue($n)*114)/1000);
$light-color: round((red(#ffffff)*299)+(green(#ffffff)*587)+(blue(#ffffff)*114)/1000);
@if abs($color-brightness) < ($light-color/2){
color: white;
} @else {
color: black;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment