PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.0 2.13.0 2.13.1 2.12.0 2.11.1 2.11.0 2.10.0 2.9.0 2.7.4 2.7.5 2.7.6 2.7.7 2.8.0 2.8.1 2.9.1 trunk 1.0 1.0-beta1 1.0-beta2 1.0-beta3 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 All 81 releases
ablocks / includes / blocks / menu-child-mega / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.14.0, at includes/blocks/menu-child-mega/block.php

70 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_wrapper_css( $attributes, $device ); } )
26 );
27 return $css_generator->generate_css();
28 }
29 private function get_wrapper_css( $attributes, $device = '' ) {
30 $css = [];
31 $padding = isset( $attributes['padding'] ) ? $attributes['padding'] : '';
32 if ( isset( $attributes['height'] ) && $attributes['height'] > 0 ) {
33 $css['overflow-y'] = 'auto';
34 $css['overflow-x'] = 'hidden';
35 }
36 return array_merge(
37 Range::get_css([
38 'attributeValue' => $attributes['width'],
39 'attribute_object_key' => 'value',
40 'isResponsive' => true,
41 'defaultValue' => 100,
42 'hasUnit' => true,
43 'unitDefaultValue' => '%',
44 'property' => 'width',
45 'device' => $device,
46 ]),
47 Range::get_css([
48 'attributeValue' => $attributes['height'],
49 'attribute_object_key' => 'value',
50 'isResponsive' => true,
51 'hasUnit' => true,
52 'unitDefaultValue' => 'px',
53 'property' => 'height',
54 'device' => $device,
55 ]),
56 Range::get_css([
57 'attributeValue' => $attributes['positionX'],
58 'attribute_object_key' => 'value',
59 'isResponsive' => true,
60 'defaultValue' => 0,
61 'property' => 'left',
62 'unitDefaultValue' => '%',
63 'hasUnit' => true,
64 'device' => $device,
65 ]),
66 $css
67 );
68 }
69 }
70