css-color-l4
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

css-color-l4

npm version test coverage GitHub Workflow Status

CSS Color Module Level 4-compliant color string parser

(forked from adroitwhiz/css-color and translated to TypeScript)

css-color-l4 is a CSS Color Module Level 4-compliant CSS color value parser. It parses any color values defined in the CSS Color Module Level 4, and refuses to parse any other values. This is to ensure complete consistency with, for instance, web browsers. In comparison, most other JS color parsers both fail to parse color values that browsers will accept.

Key points:

  • this library is well tested around edge cases
  • this library doesn't include any color conversion functionality

Limitations

  • The color() function syntax is currently not supported.
  • currentcolor is currently not supported.
  • System colors (i.e. like VisitedText) are currently not supported. (Named colors like red are supported)

Usage

The parser function is the default export:

const parseColor = require('css-color')

Installation

npm install css-color-l4 --save
# yarn add css-color-l4

Alternatively, there are also client web builds available:

<!-- Dependencies -->

<!-- window.CSSColor -->
<script src="https://unpkg.com/css-color-l4/dist/css-color-l4.umd.js"></script>

Documentation

License

MIT

Dependents (2)

Package Sidebar

Install

npm i css-color-l4

Weekly Downloads

23

Version

1.1.0

License

MIT

Unpacked Size

245 kB

Total Files

13

Last publish

Collaborators

  • tbjgolden