1.1.2 • Published 1 year ago

@chriscodesthings/compress-css-hex-color v1.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

compress-css-hex-color · Test workflow status NPM Version License: MIT

Convert a CSS hex color code to short form

Description

Compresses a CSS hex color code.

If the string passed is already a short form color code or it is a long form color code that cannot be shortened, the color is returned unmodified.

If a long form color code is passed and can be shortened, the short form of the color is returned.

If the alpha value is F or FF then it is removed.

Example hex color codes:

#000      // black short form
#000000   // black long form
#663399   // rebeccapurple
#66449988 // ... with 53% transparency
#6498     // ... in short form

See...


Install

npm install --save @chriscodesthings/compress-css-hex-color

Use

import compressCSSHexColor from '@chriscodesthings/compress-css-hex-color';

console.log(compressCSSHexColor("#ff0000dd"));
// => #f00d

Types

This package uses types from:

Syntax

compressCSSHexColor(color);

Parameters

  • color: a CSS hex color string

Return Value

Returns the short form of the CSS color code, or the original string if it can't be compressed.

See Also...

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago