Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
css-color-function
Advanced tools
A parser and converter for Tab Atkins's proposed color function in CSS.
The css-color-function npm package allows you to perform color manipulations using CSS-like syntax. It is useful for dynamically adjusting colors in your stylesheets, such as lightening, darkening, saturating, or desaturating colors.
Lighten a color
This feature allows you to lighten a given color by a specified percentage. In this example, the color red is lightened by 10%.
const colorFunction = require('css-color-function');
const color = 'color(red lightness(+ 10%))';
const result = colorFunction.convert(color);
console.log(result); // Outputs: #ff3333
Darken a color
This feature allows you to darken a given color by a specified percentage. In this example, the color blue is darkened by 20%.
const colorFunction = require('css-color-function');
const color = 'color(blue lightness(- 20%))';
const result = colorFunction.convert(color);
console.log(result); // Outputs: #0000cc
Saturate a color
This feature allows you to increase the saturation of a given color by a specified percentage. In this example, the color green is saturated by 30%.
const colorFunction = require('css-color-function');
const color = 'color(green saturation(+ 30%))';
const result = colorFunction.convert(color);
console.log(result); // Outputs: #00ff00
Desaturate a color
This feature allows you to decrease the saturation of a given color by a specified percentage. In this example, the color purple is desaturated by 40%.
const colorFunction = require('css-color-function');
const color = 'color(purple saturation(- 40%))';
const result = colorFunction.convert(color);
console.log(result); // Outputs: #993399
The 'color' npm package provides a comprehensive API for color manipulation and conversion. It supports a wide range of color models and offers methods for adjusting lightness, saturation, and other properties. Compared to css-color-function, 'color' offers a more extensive set of features and greater flexibility.
The 'tinycolor2' npm package is a fast and lightweight color manipulation library. It supports various color formats and provides methods for adjusting colors, such as lightening, darkening, and mixing. While it offers similar functionalities to css-color-function, 'tinycolor2' is known for its performance and ease of use.
The 'chroma-js' npm package is a powerful library for color conversions and color scales. It supports a wide range of color spaces and provides advanced color manipulation methods. Compared to css-color-function, 'chroma-js' offers more advanced features and is suitable for complex color manipulations and visualizations.
A parser and converter for Tab Atkins's proposed color function in CSS.
$ npm install css-color-function
var color = require('css-color-function');
color.convert('color(red tint(50%))');
// "rgb(255, 128, 128)"
color.parse('color(red blue(+ 30))');
// {
// type: 'function',
// name: 'color',
// arguments: [
// {
// type: 'color',
// value: 'red'
// },
// {
// type: 'function',
// name: 'blue',
// arguments: [
// {
// type: 'modifier',
// value: '+'
// },
// {
// type: 'number',
// value: '30'
// }
// ]
// }
// ]
// }
Convert a color function CSS string
into an RGB color string.
Parse a color function CSS string
and return an AST.
The MIT License (MIT)
Copyright (c) 2013 Ian Storm Taylor <ian@segment.io>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
A parser and converter for Tab Atkins's proposed color function in CSS.
The npm package css-color-function receives a total of 271,963 weekly downloads. As such, css-color-function popularity was classified as popular.
We found that css-color-function demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.