1.2.0 • Published 6 months ago

hue-check v1.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

:art: Hue Check · NPM version npm-typescript GitHub License NPM Downloads

Hue check is a lightweight library for checking color contrast and generating accessible color palettes.

Features

:arrow_right: isRatioOk

  • Determines if the contrast ratio between two colors meets the specified WCAG accessibility level.
  • Returns:
    • true if the contrast ratio meets the specified WCAG level.
    • false if it doesn’t meet the level.
    • undefined if the input colors are invalid.

:arrow_right: contrastColors

  • Generates an array of CSS named colors that meet the specified contrast ratio requirements with a given color.
  • Returns:
    • An array of CSS named colors.

:arrow_right: contrastRatio

  • Calculates the contrast ratio between two colors.
  • Returns:
    • The contrast ratio between the two colors.
    • undefined if the input colors are invalid.

:arrow_right: hexToNamedColor

  • Converts a hex color code to its corresponding CSS named color.
  • Returns:
    • The CSS named color if found, otherwise undefined.

:arrow_right: cssNamedColors

  • An object containing all css named colors as keys and the corresponding hex codes as values.

Example

import { contrastColors, contrastRatio, isRatioOk } from 'hue-check';

const sufficentRatio = isRatioOk('papayawhip', '#000'); // true
const contrastColor = contrastColors('papayawhip')?.[0] ?? ''; // "black"
const ratio = contrastRatio('white', '#000000'); // 21
const colorName = hexToNamedColor('#fff'); // "white"

Contributing

Create a branch on your fork, add commits to your fork, and open a pull request from your fork to this repository.

Changelog

To check full changelog click here

License

MIT

1.2.0

6 months ago

1.1.0

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago

0.1.1

7 months ago

0.1.0

7 months ago