Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
font-color-contrast
Advanced tools
JavaScript module to use black or white font according to the given background color
NodeJS module to select black or white to a font according to the background.
$ npm i font-color-contrast
You can use the module 3 ways:
If any other format is sent, the function will respond with white by default.
var fontColorContrast = require('font-color-contrast');
var lightGreenBackground: "#b6e9be";
var paleYellowBackground = ["255", "246", "199"];
var darkBlueRedBackground = 20;
var darkBlueGreenBackground = 85;
var darkBlueBlueBackground = 91;
var fontColor1 = fontColorContrast(lightGreenBackground);
// fontColor will be a string for black hexadecimal color: "#000000"
var fontColor2 = fontColorContrast(paleYellowBackground);
// fontColor will be a string for black hexadecimal color: "#000000"
var fontColor3 = fontColorContrast(
darkBlueRedBackground,
darkBlueGreenBackground,
darkBlueBlueBackground
);
// fontColor will be a string for white hexadecimal color: "#ffffff"
Tests made using Jest to check color format possibilities and contrast, including all CSS colors and WebSafe (90's stuff) colors as shown in the image below
JavaScript version, accepting strings for RGB
TypeScript version.
Only numbers are now accepted as params when using array or RGB, because it was impossible to know if the string was decimal or hexadecimal. Accepting only numbers we can be sure the correct values are being used to calculate the contrast.
FAQs
JavaScript module to use black or white font according to the given background color
The npm package font-color-contrast receives a total of 17,080 weekly downloads. As such, font-color-contrast popularity was classified as popular.
We found that font-color-contrast demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.