@types/contrast-color
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

Installation

npm install --save @types/contrast-color

Summary

This package contains type definitions for contrast-color (https://github.com/busterc/contrast-color#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/contrast-color.

index.d.ts

/**
 * A hex color code
 * @example "#ff0000"
 * @example "#f00"
 */
type HexColor = string;

/**
 * A named color
 * @example "red"
 */
type NamedColor = string;

type Color = HexColor | NamedColor;

interface ContrastColorConfig {
    /**
     * The background color to determine a foreground color for
     * @default "#FFFFFF"
     */
    bgColor?: Color;
    /**
     * The color to be returned if `bgColor` is determined to be _light_
     * @default "#000000"
     */
    fgDarkColor?: Color;
    /**
     * The color to be returned if `bgColor` is determined to be _dark_
     * @default "#FFFFFF"
     */
    fgLightColor?: Color;
    /**
     * The color to be returned if `bgColor` is determined to be _invalid_
     * @default "#000000"
     */
    defaultColor?: Color;
    /**
     * Number (0-255) used to adjust variance
     * @default 128
     */
    threshold?: number;
    /**
     * Object to override or add named colours
     * @example { blue: "#0074D9" }
     * @default {}
     */
    customNamedColors?: {
        [colorName: string]: Color;
    };
}

declare class ContrastColor {
    constructor(defaults?: ContrastColorConfig);

    contrastColor(config?: ContrastColorConfig): Color;
}

declare namespace ContrastColor {
    function contrastColor(config?: ContrastColorConfig): Color;
}

export = ContrastColor;

Additional Details

  • Last updated: Mon, 06 Nov 2023 22:41:05 GMT
  • Dependencies: none

Credits

These definitions were written by Adam Jones.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/contrast-color

Weekly Downloads

1,974

Version

1.0.3

License

MIT

Unpacked Size

5.27 kB

Total Files

5

Last publish

Collaborators

  • types