Created
September 26, 2016 18:58
-
-
Save AlbinoDrought/30d34d025169cb1a65a5efc85432d966 to your computer and use it in GitHub Desktop.
Auto-generate contrasted color pairs with LESS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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