Skip to content

Instantly share code, notes, and snippets.

@AlbinoDrought
Created September 26, 2016 18:58
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 AlbinoDrought/30d34d025169cb1a65a5efc85432d966 to your computer and use it in GitHub Desktop.
Save AlbinoDrought/30d34d025169cb1a65a5efc85432d966 to your computer and use it in GitHub Desktop.
Auto-generate contrasted color pairs with LESS
@contrast-level: 85%;
.auto-colorize(@text-color) {
color: @text-color;
// pick the color with the most contrast to our text color
// _should_ at least be readable with light colors
background-color: contrast(
@text-color,
shade(@text-color, @contrast-level),
tint(@text-color, @contrast-level)
);
}
/* Examples */
.mc-monza {
.auto-colorize(#CF000F);
}
.mc-chestrose {
.auto-colorize(#D24D57);
}
.mc-marino {
.auto-colorize(#446CB3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment