1.0.7 • Published 1 year ago

colorcsstohex v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

colorcsstohex

colorcsstohex is a JavaScript library that provides functions for converting colors between different formats.

Installation

colorcsstohex can be installed via npm:

npm i colorcsstohex

Usage

convertColor(color)

Converts a color from one format to another. The color parameter can be in any of the following formats:

  • Hexadecimal string (e.g. "#ff0000")
  • RGB string (e.g. "rgb(255, 0, 0)")
  • HSL string (e.g. "hsl(0, 100%, 50%)")
  • Named color string (e.g. "red")
  • The function returns a hexadecimal string representing the converted color.

Example:

const { convertColor } = require('colorcsstohex');

const hexColor = convertColor('rgb(255, 0, 0)'); // returns "#ff0000"

isValidHex(hex)

Checks if a string is a valid hexadecimal color code. Returns true if the input is valid, false otherwise.

Example:

const { isValidHex } = require('colorcsstohex');

const isValid = isValidHex('#ff0000'); // returns true

namedToHex(name)

Converts a named color to its corresponding hexadecimal code. Returns a hexadecimal string.

Example:

const { namedToHex } = require('colorcsstohex');

const hexColor = namedToHex('red'); // returns "#ff0000"
1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago