css-color-l4
v1.1.0
Published
CSS Color Module Level 4-compliant color string parser
Downloads
188
Readme
css-color-l4
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 likered
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