PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.1
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 1.1.2 All 80 releases
ablocks / includes / blocks / image-hotspot-child / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.1, at includes/blocks/image-hotspot-child/block.php

75 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\ImageHotspotChild;
3
4 use ABlocks\Controls\Border;
5 use ABlocks\Controls\Dimensions;
6 use ABlocks\Controls\Range;
7 use ABlocks\Classes\BlockBaseAbstract;
8 use ABlocks\Classes\CssGenerator;
9
10 class Block extends BlockBaseAbstract {
11 protected $parent_block_name = 'image-hotspot';
12 protected $block_name = 'image-hotspot-child';
13
14 public function build_css( $attributes ) {
15 $css_generator = new CssGenerator( $attributes );
16
17 $css_generator->add_class_styles(
18 '{{WRAPPER}} .ablocks-image-hotspot__tooltip--active',
19 $this->get_active_content_css( $attributes ),
20 $this->get_active_content_css( $attributes, 'Tablet' ),
21 $this->get_active_content_css( $attributes, 'Mobile' )
22 );
23
24 $css_generator->add_class_styles(
25 '{{WRAPPER}} .ablocks-image-hotspot__tooltip--active:hover',
26 $this->get_active_content_hover_css( $attributes ),
27 $this->get_active_content_hover_css( $attributes, 'Tablet' ),
28 $this->get_active_content_hover_css( $attributes, 'Mobile' )
29 );
30
31 return $css_generator->generate_css();
32 }
33
34 public function get_active_content_css( $attributes, $device = '' ) {
35 $css = array();
36
37 // Set background color
38 if ( ! empty( $attributes['backgroundColor'] ) ) {
39 $css['background-color'] = $attributes['backgroundColor'];
40 }
41
42 // Add border and padding styles
43 $border_css = isset( $attributes['contentBorder'] ) ? Border::get_css( $attributes['contentBorder'], '', $device ) : [];
44 $padding_css = isset( $attributes['contentPadding'] ) ? Dimensions::get_css( $attributes['contentPadding'], 'padding', $device ) : [];
45
46 // Merge border and padding styles with the main CSS
47 $css = array_merge( $css, $border_css, $padding_css,
48 Range::get_css(
49 [
50 'attributeValue' => $attributes['contentWidth'],
51 'attribute_object_key' => 'value',
52 'isResponsive' => true,
53 'defaultValue' => '',
54 'hasUnit' => true,
55 'unitDefaultValue' => 'px',
56 'property' => 'width',
57 'device' => $device,
58 ]
59 )
60 );
61
62 return $css;
63 }
64
65 public function get_active_content_hover_css( $attributes, $device = '' ) {
66 $css = [];
67
68 $border_hover_css = isset( $attributes['contentBorder'] ) ? Border::get_hover_css( $attributes['contentBorder'], $device ) : [];
69
70 $css = array_merge( $css, $border_hover_css );
71
72 return $css;
73 }
74 }
75