4.0.0 • Published 4 years ago

yiq v4.0.0

Weekly downloads
1,011
License
MIT
Repository
github
Last release
4 years ago

YIQ

Returns light when a color is dark and dark when a color is light. 🎨

CI NPM Uses TypeScript

Installing

yarn add yiq

# If you're using NPM:
# npm install yiq --save

Basic Usage

Just call the yiq function after importing it:

import { yiq } from 'yiq';

console.log(yiq('#fff')); // #000
console.log(yiq('#000')); // #fff

API

yiq

yiq — Returns a light color when a color is dark and a dark color when a color is light.

Description

function yiq(
  colorHex: string,
  options?: {
    colors?: {
      light: string;
      dark: string;
    };
    threshold?: number;
  }
): string;

The second argument (options) can be used to define the colors that the function will return:

yiq('#fff', {
  colors: {
    light: '#f0f0f0',
    dark: '#333'
  }
}); // #333

It can also be used to define the threshold YIQ value at which the function switches between light and dark:

yiq('#36d386', { threshold: 156 }); // #fff

The default options are:

  • options.colors.light: #fff;
  • options.colors.dark: #000;
  • options.threshold: 128.

Authors and License

lffg and contributors.

MIT License, see the included MIT file.

4.0.0

4 years ago

4.0.0-1

4 years ago

4.0.0-0

4 years ago

3.0.1

5 years ago

3.0.0

5 years ago

3.0.0-0

5 years ago

2.1.0

5 years ago

2.0.4

5 years ago

2.0.3

5 years ago

2.0.2

5 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago