| 1 |
<?php |
| 2 |
namespace ABlocks\Blocks\MenuChildMega; |
| 3 |
|
| 4 |
if ( ! defined( 'ABSPATH' ) ) { |
| 5 |
exit; |
| 6 |
} |
| 7 |
|
| 8 |
use ABlocks\Classes\BlockBaseAbstract; |
| 9 |
use ABlocks\Classes\CssGenerator; |
| 10 |
use ABlocks\Controls\Range; |
| 11 |
|
| 12 |
class Block extends BlockBaseAbstract { |
| 13 |
protected $parent_block_name = 'menu'; |
| 14 |
protected $block_name = 'menu-child-mega'; |
| 15 |
|
| 16 |
public function build_css( $attributes ) { |
| 17 |
|
| 18 |
$css_generator = new CssGenerator( $attributes, $this->block_name ); |
| 19 |
// Wrapper CSS |
| 20 |
$css_generator->add_class_styles( |
| 21 |
'{{WRAPPER}}', |
| 22 |
$this->get_wrapper_css( $attributes, '' ), |
| 23 |
$this->get_wrapper_css( $attributes, 'Tablet' ), |
| 24 |
$this->get_wrapper_css( $attributes, 'Mobile' ) |
| 25 |
); |
| 26 |
return $css_generator->generate_css(); |
| 27 |
} |
| 28 |
private function get_wrapper_css( $attributes, $device = '' ) { |
| 29 |
$css = []; |
| 30 |
$padding = isset( $attributes['padding'] ) ? $attributes['padding'] : ''; |
| 31 |
if ( isset( $attributes['height'] ) && $attributes['height'] > 0 ) { |
| 32 |
$css['overflow-y'] = 'auto'; |
| 33 |
$css['overflow-x'] = 'hidden'; |
| 34 |
} |
| 35 |
return array_merge( |
| 36 |
Range::get_css([ |
| 37 |
'attributeValue' => $attributes['width'], |
| 38 |
'attribute_object_key' => 'value', |
| 39 |
'isResponsive' => true, |
| 40 |
'defaultValue' => 100, |
| 41 |
'hasUnit' => true, |
| 42 |
'unitDefaultValue' => '%', |
| 43 |
'property' => 'width', |
| 44 |
'device' => $device, |
| 45 |
]), |
| 46 |
Range::get_css([ |
| 47 |
'attributeValue' => $attributes['height'], |
| 48 |
'attribute_object_key' => 'value', |
| 49 |
'isResponsive' => true, |
| 50 |
'hasUnit' => true, |
| 51 |
'unitDefaultValue' => 'px', |
| 52 |
'property' => 'height', |
| 53 |
'device' => $device, |
| 54 |
]), |
| 55 |
Range::get_css([ |
| 56 |
'attributeValue' => $attributes['positionX'], |
| 57 |
'attribute_object_key' => 'value', |
| 58 |
'isResponsive' => true, |
| 59 |
'defaultValue' => 0, |
| 60 |
'property' => 'left', |
| 61 |
'unitDefaultValue' => '%', |
| 62 |
'hasUnit' => true, |
| 63 |
'device' => $device, |
| 64 |
]), |
| 65 |
$css |
| 66 |
); |
| 67 |
} |
| 68 |
} |
| 69 |
|