Package Exports
- @libgranite/contrast-color
- @libgranite/contrast-color/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@libgranite/contrast-color) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
SCSS Contrast Color
This package provides a contrast color calculator for scss and js. The library will calculate if the color has a higher contrast against white or black.
Using the library
The package provides a js module and a scss mixing for the calculation of the contrast color.
The library functions will return either 'black' or 'white', based upon the input color.
JavaScript
The js module provides two functions. The first, get_contrast_color_rgb takes an
RGB color while get_contrast_color_hex takes a hex color string.
import {get_contrast_color_rgb, get_contrast_color_hex} form '@grante/contrast-color'
var best_color = get_contrast_color_rgb({red: 100, green: 100, blue: 100});
// or
var best_color_2 = get_contrast_color_hex('#123456');
SCSS
The scss project provides one mixin. It can be used with any css color (Hex, RGB, or RBGa);
@import '@grante/contrast-color/_mixin';
div.example {
background-color: #123456;
color: @import(#123456);
}