peteboere / css-crush

CSS preprocessor.
http://the-echoplex.net/csscrush
MIT License
537 stars 51 forks source link

Color conversion from rgb to hex #84

Closed scornaky closed 6 years ago

scornaky commented 6 years ago
Color.php line 283

public static function rgbToHex(array $rgba) { // Drop alpha component. array_pop($rgba);

    $hex_out = '#';
    foreach ($rgba as $val) {
        $hex_out .= str_pad(dechex($val), 2, '0', STR_PAD_LEFT);
    }

    return $hex_out;
}

try this out :

.some_class{ font-size: 12px; color: rgb(93, 96, 99); background-color: rgb(240, 255, 255);

}

with : $options['plugins'] = ['property-sorter'];

    $options['minify'] = ['colors'];

    $string = csscrush_string($string, $options);

Hello Look how rgb color is converted because of "array_pop($rgba); "

Expected: .class{ color:#5d6063;background-color:#f0ffff;font-size:12px }

Ouput:

.class{ color:#5d60;background-color:#f0ff;font-size:12px }

peteboere commented 6 years ago

Thanks for reporting. Fix now in master branch