mirror of
https://github.com/iconify/iconify.git
synced 2024-12-12 13:47:49 +00:00
chore: option to not compress color in utils
This commit is contained in:
parent
08669af71f
commit
d9ffc20a20
@ -3,7 +3,7 @@
|
||||
"type": "module",
|
||||
"description": "Common functions for working with Iconify icon sets used by various packages.",
|
||||
"author": "Vjacheslav Trushkin",
|
||||
"version": "2.1.14",
|
||||
"version": "2.1.15",
|
||||
"license": "MIT",
|
||||
"bugs": "https://github.com/iconify/iconify/issues",
|
||||
"homepage": "https://iconify.design/docs/libraries/utils/",
|
||||
|
@ -374,7 +374,10 @@ export function compareColors(color1: Color, color2: Color): boolean {
|
||||
/**
|
||||
* Color to hex
|
||||
*/
|
||||
function colorToHex(color: RGBColor): string | null {
|
||||
export function colorToHexString(
|
||||
color: RGBColor,
|
||||
canCompact = true
|
||||
): string | null {
|
||||
if (color.alpha !== 1) {
|
||||
return null;
|
||||
}
|
||||
@ -394,6 +397,7 @@ function colorToHex(color: RGBColor): string | null {
|
||||
|
||||
// Compact color
|
||||
if (
|
||||
canCompact &&
|
||||
result[0] === result[1] &&
|
||||
result[2] === result[3] &&
|
||||
result[4] === result[5]
|
||||
@ -421,7 +425,7 @@ export function colorToString(color: Color): string {
|
||||
return 'currentColor';
|
||||
|
||||
case 'rgb': {
|
||||
const hex = colorToHex(color);
|
||||
const hex = colorToHexString(color);
|
||||
if (hex !== null) {
|
||||
return hex;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user