Skip to content
Snippets Groups Projects
Commit 585c83e2 authored by Lucas Hedding's avatar Lucas Hedding Committed by Nick Dickinson-Wilde
Browse files

Issue #2946795 by kala4ek, justin2pin, heddn: Default Value for Opacity is not being honoured

parent b447acf6
No related branches found
No related tags found
No related merge requests found
......@@ -175,7 +175,7 @@ class ColorHSL extends ColorBase {
$g = round(($g + $m) * 255);
$b = round(($b + $m) * 255);
return new ColorRGB(intval($r), intval($g), intval($b), $this->getOpacity());
return new ColorRGB((int) $r, (int) $g, (int) $b, $this->getOpacity());
}
/**
......
......@@ -27,7 +27,7 @@ class ColorHex extends ColorBase {
* @throws \Exception
* If the color doesn't appear to be a valid hex value.
*/
public function __construct(string $color, string $opacity) {
public function __construct(string $color, ?string $opacity) {
$color = trim(strtolower($color));
if (str_starts_with($color, '#')) {
......@@ -43,7 +43,8 @@ class ColorHex extends ColorBase {
}
$this->color = hexdec($color);
$this->setOpacity(floatval($opacity));
$opacity = $opacity ?? '1';
$this->setOpacity((float) $opacity);
return $this;
}
......
......@@ -309,7 +309,7 @@ class ColorFieldFormatterCss extends FormatterBase implements ContainerFactoryPl
$opacity = $this->getFieldSetting('opacity');
$settings = $this->getSettings();
$color_hex = new ColorHex($item->color, $item->opacity ?? 'FF');
$color_hex = new ColorHex($item->color, $item->opacity);
return $opacity && $settings['opacity']
? $color_hex->toRgb()->toString(TRUE)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment