Socket
Socket
Sign inDemoInstall

get-best-contrast-color

Package Overview
Dependencies
4
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    get-best-contrast-color

Calculate the color in an array of colors that gives the highest contrast to another color.


Version published
Weekly downloads
532
increased by12.24%
Maintainers
1
Install size
62.9 kB
Created
Weekly downloads
 

Readme

Source

Get best contrast color

Greenkeeper badge

get-best-contrast-color calculates which color in an array of colors gives the highest contrast to another color.

Doesn't handle transparency as of yet.

Installation

$ npm install get-best-contrast-color

Usage

import bestContrast from 'get-best-contrast-color';
// If you're not using EMS but CommonJS:
// const bestContrast = require('get-best-contrast-color').default;

const background1 = 'palevioletred';
const background2 = 'saddlebrown';

const colors = [
  '#222',
  'blue',
  'rgb(255, 255, ,255)',
];

bestContrast(background1, colors); // '#222'
bestContrast(background2, colors); // 'rgb(255, 255, 255)'

Signature

(background: string, colors: array) => string

Contributing

I appreciate your issues and PRs on Github!

Testing

yarn build && yarn test

Releasing

This project uses np.

  1. Make sure your changes are in master
  2. Run yarn release
  3. Follow the interactive release guide

Keywords

FAQs

Last updated on 16 Jul 2019

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc