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

@igor.dvlpr/common-color

v1.3.0

Published

🎨 Provides common Color-related TypeScript types. 🌈

Downloads

8

Readme

📃 Table of contents


🕵🏼 Usage

Install it by executing:

npm i -D "@igor.dvlpr/common-color"

🤹🏼 API

This package only exposes the types below:

🤖 Constants


SpecialColor

Technically, keywords - not colors per se, they provide ways of using special colors: currentcolor, transparent, initial, inherit and unset.

Each of them has a special meaning for the browser:

  • currentcolor: the current color of the element
  • transparent: a fully transparent color
  • initial: the default value defined by the browser
  • inherit: inherits the color from the parent element
  • unset: resets the property to its natural value, either inherited or initial

SystemColor

This type represents a set of system-defined color keywords that correspond to system UI elements, which can adapt based on the user's operating system and theme settings.

Includes keywords like: AccentColor, AccentColorText, ActiveText, ButtonBorder, ButtonFace, etc.

[!TIP] Learn more about SystemColor External link on MDN.


NamedStandardColor

Common and standardized color identifiers. Includes values like: black, silver, gray, white, maroon, red, etc.


NamedExtendedColor

Includes all of the colors defined by NamedStandardColor and 131 colors more, values like: aliceblue, antiquewhite, aqua, aquamarine, azure, beige, bisque, etc.


📜 Template literals

[!CAUTION] The following types are derived from a template literal type, the types do NOT validate the actual color.


HexColor

A template literal type that adheres to the format #${string}, effectively representing a Hex color.


RgbColor

A template literal type that adheres to the format rgb(${string}), effectively representing an RGB color.


RgbaColor

A template literal type that adheres to the format rgba(${string}), effectively representing an RGBA color.


HslColor

A template literal type that adheres to the format hsl(${string}), effectively representing an HSL color.


HwbColor

A template literal type that adheres to the format hwb(${string}), effectively representing an HWB color.


LabColor

A template literal type that adheres to the format lab(${string}), effectively representing a LAB color.


LchColor

A template literal type that adheres to the format lch(${string}), effectively representing a LCH color.


OklabColor

A template literal type that adheres to the format oklab(${string}), effectively representing an Oklab color.


OklchColor

A template literal type that adheres to the format oklch(${string}), effectively representing an Oklch color.


LightDarkColor

A template literal type that adheres to the format light-dark(${string}), effectively representing a light-dark color.


ColorMix

A template literal type that adheres to the format color-mix(${string}), effectively representing a color-mix.


DeviceCmyk

A template literal type that adheres to the format device-cmyk(${string}), effectively representing a device-cmyk color.


ColorContrast

A template literal type that adheres to the format color-contrast(${string}), effectively representing a color-contrast color.


Gradients

[!TIP] Gradients are supported from v1.1.0.


LinearGradient

A template literal type that adheres to the format linear-gradient(${string}), effectively representing a linear gradient.


RadialGradient

A template literal type that adheres to the format radial-gradient(${string}), effectively representing a radial gradient.


ConicGradient

A template literal type that adheres to the format conic-gradient(${string}), effectively representing a conic gradient.


RepeatingLinearGradient

A template literal type that adheres to the format repeating-linear-gradient(${string}), effectively representing a repeating linear gradient.


RepeatingRadialGradient

A template literal type that adheres to the format repeating-radial-gradient(${string}), effectively representing a repeating radial gradient.


RepeatingConicGradient

A template literal type that adheres to the format repeating-conic-gradient(${string}), effectively representing a repeating conic gradient.


🦄 Special


Color

A broad color type that includes all of the previously mentioned color types:


ColorWithKeywords

An even broader color type that includes the Color type (and all of the previously mentioned color types) with the addition of colors from the SpecialColor type.


ColorExtended

The most broad color type that includes the ColorWithKeywords type (and all of the previously mentioned color types) with the addition of colors from the SystemColor type.


CSS levels

In addition to using any color type, since v1.2.0 it is possible to narrow the color types to a certain CSS color module level An external link.


CssLevel3Color

Includes the following CSS color module level 3 types:


CssLevel4Color

Includes previously mentioned CSS color module level 3 types and the following CSS color module level 4 types:


CssLevel5Color

Includes previously mentioned CSS color module level 4 types and the following CSS color module level 5 types:


CssLevel6Color

Includes previously mentioned CSS color module level 5 types and the following CSS color module level 6 types:


✨ Examples

ui.ts

import type { Color } from '@igor.dvlpr/common-color'

const uiColor: Color = '#0099ff' // ok, now do something with the Hex color
const uiScrollbar: Color = 'rfb(0, 128, 255)' // will trigger an ERROR
                  // (typo, rFb instead of rGb)

📝 Changelog

📑 Changelog is available here: CHANGELOG.md.


🪪 License

Licensed under the MIT license which is available here, MIT license.


🧬 Related

@igor.dvlpr/unc-path

🥽 Provides ways of parsing UNC paths and checking whether they are valid. 🎱

@igor.dvlpr/keppo

🎡 Parse, manage, compare and output SemVer-compatible version numbers. 🛡

@igor.dvlpr/jmap

🕶️ Reads a JSON file into a Map. 🌻

@igor.dvlpr/zing

🐌 Zing is a C# style String formatter for JavaScript that empowers Strings with positional arguments - composite formatting. 🚀

@igor.dvlpr/duoscribi

✒ DúöScríbî allows you to convert letters with diacritics to regular letters. 🤓


👨🏻‍💻 Author

Created by Igor Dimitrijević (@igorskyflyer).