Fix rgba cast when 0 (black color)

This commit is contained in:
Jérémy Munsch 2022-06-29 16:31:20 +02:00
parent 99c33bbaf2
commit 8c0b1fbacb
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -24,10 +24,9 @@ class RgbaColor extends HtmlColor
public function get($model, $key, $value, $attributes)
{
// phpcs:enable
$intValues = collect(\str_split(\dechex(\intval($value)), 2))
->map(function ($hex) {
return \hexdec($hex);
});
$intValues = collect(\str_split($this->zeropad(\dechex(\intval($value)), 8), 2))->map(function ($hex) {
return intval(\hexdec($hex));
});
// * Set Transparency as float
$hexString = $intValues->push(\round($intValues->pop() / 100, 2))->implode(',');
return "rgba($hexString)";