@csstools/css-color-parser
Parse CSS color values
Last updated 2 years ago by alaguna .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ gnpm install @csstools/css-color-parser 
SYNC missed versions from official npm registry.

CSS Color Parser

npm version Build Status Discord

Usage

Add CSS Color Parser to your project:

npm install @csstools/css-color-parser @csstools/css-parser-algorithms @csstools/css-tokenizer --save-dev
import { color } from '@csstools/css-color-parser';
import { isFunctionNode, parseComponentValue } from '@csstools/css-parser-algorithms';
import { serializeRGB } from '@csstools/css-color-parser';
import { tokenize } from '@csstools/css-tokenizer';

// color() expects a parsed component value.
const hwbComponentValue = parseComponentValue(tokenize({ css: 'hwb(10deg 10% 20%)' }));
const colorData = color(hwbComponentValue);
if (colorData) {
	console.log(colorData);

	// serializeRGB() returns a component value.
	const rgbComponentValue = serializeRGB(colorData);
	console.log(rgbComponentValue.toString());
}

Current Tags

  • 1.0.0                                ...           latest (2 years ago)

1 Versions

  • 1.0.0                                ...           2 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (2)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |