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.
@asamuzakjp/css-color
Advanced tools
Resolve and convert CSS colors.
npm i @asamuzakjp/css-color
import { convert, resolve } from '@asamuzakjp/css-color';
const resolvedValue =
resolve('color-mix(in oklab, rgb(255 0 0), color(srgb 0 0.5 0 / 0.5))');
// 'oklab(0.5914 0.103273 0.119688 / 0.75)'
const convertedValue = covert.colorToHex('lab(46.2775% -47.5621 48.5837)');
// '#008000'
resolves CSS color
Returns (string? | Array) returns one of rgba?()
, color(space r g b / a)
, color(space x y z / a)
, lab(l a b / A)
, lch(l c h / a)
, oklab(l a b / A)
, oklch(l c h / a)
, \#rrggbb(aa)?
, null
, and, if key
is specified, [key, rgba?()]
etc.
spec
, values are numbers, however rgb() values are integersrgb
, values are rounded to integers, and returns rgba(0, 0, 0, 0)
for unknown colorshex
, transparent
value is resolved as null
, also returns null
if any of r
, g
, b
, a
is not a numberhexAlpha
, transparent
resolves as #00000000
, and returns null
if any of r
, g
, b
, a
is not a numberContains various conversion functions as properties.
convert number to hex string
value
number color valueReturns string hex string: 00..ff
convert color to hex
value
string color valueopt
object? options (optional, default {}
)
opt.alpha
boolean? return in #rrggbbaa notationReturns string #rrggbb|#rrggbbaa
convert color to hsl
value
string color valueReturns Array<number> [h, s, l, a]
convert color to hwb
value
string color valueReturns Array<number> [h, w, b, a]
convert color to lab
value
string color valueReturns Array<number> [l, a, b, aa]
convert color to lch
value
string color valueReturns Array<number> [l, c, h, aa]
convert color to oklab
value
string color valueReturns Array<number> [l, a, b, aa]
convert color to oklch
value
string color valueReturns Array<number> [l, c, h, aa]
convert color to rgb
value
string color valueReturns Array<number> [r, g, b, a]
convert color to xyz
value
string color valueopt
object? options (optional, default {}
)
opt.d50
boolean? xyz in d50 white pointReturns Array<number> [x, y, z, a]
convert color to xyz-d50
value
string color valueReturns Array<number> [x, y, z, a]
Copyright (c) 2024 asamuzaK (Kazz)
FAQs
CSS color - Resolve and convert CSS colors.
The npm package @asamuzakjp/css-color receives a total of 272,864 weekly downloads. As such, @asamuzakjp/css-color popularity was classified as popular.
We found that @asamuzakjp/css-color demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.