| 1 |
<?php |
| 2 |
namespace Depicter\Document\Models\Common\Styles; |
| 3 |
|
| 4 |
use Depicter\Document\CSS\Breakpoints; |
| 5 |
|
| 6 |
class BackgroundBlur extends States |
| 7 |
{ |
| 8 |
/** |
| 9 |
* style name |
| 10 |
*/ |
| 11 |
const NAME = 'backdrop-filter'; |
| 12 |
|
| 13 |
/** |
| 14 |
* @var int |
| 15 |
*/ |
| 16 |
public $blur = 0; |
| 17 |
|
| 18 |
/** |
| 19 |
* @var int |
| 20 |
*/ |
| 21 |
public $opacity = 100; |
| 22 |
|
| 23 |
/** |
| 24 |
* @var int |
| 25 |
*/ |
| 26 |
public $brightness = 100; |
| 27 |
|
| 28 |
public function set( $css ) { |
| 29 |
$devices = Breakpoints::names(); |
| 30 |
foreach ( $devices as $device ) { |
| 31 |
if ( isset( $this->{$device}->enable ) ) { |
| 32 |
|
| 33 |
// If it is disabled in a breakpoint other than default, generate a reset style for breakpoint |
| 34 |
if( $device !== 'default' && ! empty( $this->default->enable ) && ! $this->{$device}->enable ) { |
| 35 |
$css[$device][ self::NAME ] = 'none'; |
| 36 |
|
| 37 |
} elseif( $this->{$device}->enable ) { |
| 38 |
$this->blur = $this->{$device}->blur ?? $this->blur; |
| 39 |
$this->brightness = $this->{$device}->brightness ?? $this->brightness; |
| 40 |
$this->opacity = $this->{$device}->opacity ?? $this->opacity; |
| 41 |
|
| 42 |
$css[$device][self::NAME] = "blur(" . $this->blur . "px) brightness(" . $this->brightness . "%) opacity(" . $this->opacity . "%)"; |
| 43 |
} |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
return $css; |
| 48 |
} |
| 49 |
} |
| 50 |
|