@interaktiv.de/colors
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

Interaktiv Colors

code style: ts-standard Version: 1.2.2

Color converter for JavaScript/TypeScript.

Installation

# using yarn
$ yarn add @interaktiv.de/colors

# using npm
$ npm i -S @interaktiv.de/colors

Usage

import Color from '@interaktiv/colors'

// Create new instance of Colors with hex code #ff6f61
const color = new Color('#ff6f61');

// set text color of all elements with class "coral" to hsl-string of color
[...document.querySelectorAll('.coral')]
  .forEach(element => element.style.color = color.hsl)

// function that checks whether the input color is light
const isColorLight = (color: Color|string): boolean => {
  if (color instanceof Color) return color.luminance > 0.5
  
  return (new Color(color).lumincance) > 0.5
}

Package Sidebar

Install

npm i @interaktiv.de/colors

Weekly Downloads

1

Version

1.2.2

License

BSD-3-Clause

Unpacked Size

59.5 kB

Total Files

9

Last publish

Collaborators

  • veyxos