Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript: Could not find a declaration file for module 'contrast-color', it implicitly has an 'any' type. #2

Open
mykhailo-space44 opened this issue Jun 23, 2021 · 3 comments

Comments

@mykhailo-space44
Copy link

No description provided.

@Tyler-V
Copy link

Tyler-V commented Sep 9, 2021

Typings would be a great addition

@Tyler-V
Copy link

Tyler-V commented Sep 9, 2021

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>

@Tyler-V
Copy link

Tyler-V commented Jan 2, 2024

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 });

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants