contrast-color
contrast-color copied to clipboard
TypeScript: Could not find a declaration file for module 'contrast-color', it implicitly has an 'any' type.
Typings would be a great addition
Anyone coming from the Angular realm, you can import this library at the top of your file using:
declare var require: any;
const ContrastColor = require('contrast-color');
Call it from your template using,
getContrastColor(bgColor: string) {
return ContrastColor.contrastColor({ bgColor });
}
<div class="label" [style.backgroundColor]="label.color" [style.color]="getContrastColor(label.color)" *ngFor="let label of task.labels">
{{ label.title }}
</div>
Looks like typings were added at some point :)
https://www.npmjs.com/package/@types/contrast-color
import ContrastColor from 'contrast-color';
return ContrastColor.contrastColor({ bgColor });