npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

css-color-converter-class

v1.0.4

Published

``` typescript import { CssColor, fromString, fromHsla, fromRgba } from 'css-color-converter-class' ``` ## fromString(value)

Downloads

2

Readme

css-color-converter-class

import { CssColor, fromString, fromHsla, fromRgba } from 'css-color-converter-class'

fromString(value)

Returns instance of CssColor if valid, null if invalid.

fromHsla(hue, saturation, lightness, alpha)

Returns instance of CssColor

fromRgba(red, green, blue, alpha)

Returns instance of CssColor

CssColor

Properties

static

non static

Accessors (Javascript, Typescript)

non static

| accessibility | name | type | get | set | description | | :-------------------- |:-------------| :----- | :----- | :----- | :----- | | public | hexString | string | :heavy_check_mark: | :x: | returns "hex" property and applies a "#" if it has non does the same as the method toHexString | | public | saturationString | string | :heavy_check_mark: | :x: | returns "saturation" property as string with "%" at the end | | public | lightnessString | string | :heavy_check_mark: | :x: | returns "lightness" property as string with "%" at the end | | public | rgbString | string | :heavy_check_mark: | :x: | returns a rgb string 'rgb(100,100,100)' does the same as the method toRgbString | | public | rgbaString | string | :heavy_check_mark: | :x: | returns a rgba string 'rgba(100,100,100, 1)' does the same as the method toRgbaString | | public | hslString | string | :heavy_check_mark: | :x: | returns a hsl string 'hsl(0,50%,100%)' does the same as the method toHslString | | public | hslaString | string | :heavy_check_mark: | :x: | returns a hsla string 'hsla(0,50%,100%, 1)' does the same as the method toHslaString |

Methods

static

| accessibility | name | parameter | returns | description | | :-------------------- |:-------------| :----- | :----- | :----- | | public | getInstanceFromString | value: string | instance of CssColor if valid else null | does the same as fromString Supports named colors (only client side), hex, rgb/rgba, hsl/hsla |

non static

| accessibility | name | parameter | returns | description | | :-------------------- |:-------------| :---------------- | :----- | :----- | | public | constructor | rgb?: Partial<RGB> | nullhsl?: Partial<HSL> | nullalpha = 1hex = ''htmlColorName = '' | instance of CssColor | / | | public | setHtmlColorName | value: string | void | sets htmlColorName to the new value and re-calculates "hsl-values", "rgb-values" and "alpha" (if valid string) | | public | fromHtmlColorName | / | void | re-calculates "hsl-values", "rgb-values" and "alpha" based on htmlColorName | | public | setHex | value: string | void | sets hex to the new value (if it matches hexRegExp) and re-calculates "hsl-values", "rgb-values" and "alpha" | | public | fromHex | / | void | re-calculates "hsl-values", "rgb-values" and "alpha" based on hex | | public | setRed | value: number | void | sets red to the new value and re-calculates "hsl-values" and "hex" | | public | setGreen | value: number | void | sets green to the new value and re-calculates "hsl-values" and "hex" | | public | setBlue | value: number | void | sets blue to the new value and re-calculates "hsl-values" and "hex" | | public | setRgb | rgb: Partial<RGB> | void | sets the new RGB values and re-calculates "hsl-values" and "hex" | | public | setRgba | rgba: Partial<RGBA> | void | sets the new RGBA values and re-calculates "hsl-values" and "hex" | | public | fromRgb | / | void | re-calculates "hsl-values" and "hex" based on "rgb-values" and "alpha" | | public | fromRgba | / | void | re-calculates "hsl-values" and "hex" based on "rgb-values" and "alpha" | | public | setHue | value: number | void | sets hue to the new value and re-calculates "rgb-values" and "hex" | | public | setSaturation | value: number | void | sets saturation to the new value and re-calculates "rgb-values" and "hex" | | public | setLightness | value: number | void | sets lightness to the new value and re-calculates "rgb-values" and "hex" | | public | setHsl | hsl: Partial<HSL> | void | sets the new HSL values and re-calculates "rgb-values" and "hex" | | public | setHsla | hsla: Partial<HSLA> | void | sets the new RGBA values and re-calculates "hsl-values" and "hex" | | public | fromHsl | / | void | re-calculates "rgb-values" and "hex" based on "hsl-values" and "alpha" | | public | fromHsla | / | void | re-calculates "rgb-values" and "hex" based on "hsl-values" and "alpha" | | public | setAlpha | value: number | void | sets alpha to the new value an re-calculates "hex" | | public | getRgb | / | Required<RGB> | / | | public | getRgba | / | Required<RGBA> | / | | public | getHsl | / | Required<HSL> | / | | public | getHsla | / | Required<HSLA> | / | | public | toRgbString | / | string | does the same as accessor rbgString | | public | toRgbaString | / | string | does the same as accessor rbgaString | | public | toHslString | / | string | does the same as accessor hslString | | public | toHslaString | / | string | does the same as accessor hslaString | | public | getStrings | / | Array<string> | [ this.rgbString, this.rgbaString, this.hslString, this.hslaString, this.hexString, this.htmlColorName ] |

Helper Classes

class RGB {
  red = 0
  green = 0
  blue = 0
}

class RGBA extends RGB {
  alpha = 1
}

class HSL {
  hue = 0
  saturation = 50
  lightness = 100
}

class HSLA extends HSL {
  alpha = 1
}