PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.11.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.11.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.11.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 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8
9 use ABlocks\Controls\Border;
10 use ABlocks\Controls\Dimensions;
11 use ABlocks\Controls\Range;
12 use ABlocks\Classes\BlockBaseAbstract;
13 use ABlocks\Classes\CssGenerator;
14 use ABlocks\Controls\Color;
15
16 class Block extends BlockBaseAbstract {
17 protected $parent_block_name = 'image-hotspot';
18 protected $block_name = 'image-hotspot-child';
19
20 public function build_css( $attributes ) {
21 $css_generator = new CssGenerator( $attributes );
22
23 $css_generator->add_class_styles(
24 '{{WRAPPER}} .ablocks-image-hotspot__tooltip--active',
25 $this->get_active_content_css( $attributes ),
26 $this->get_active_content_css( $attributes, 'Tablet' ),
27 $this->get_active_content_css( $attributes, 'Mobile' )
28 );
29
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .ablocks-image-hotspot__tooltip--active:hover',
32 $this->get_active_content_hover_css( $attributes ),
33 $this->get_active_content_hover_css( $attributes, 'Tablet' ),
34 $this->get_active_content_hover_css( $attributes, 'Mobile' )
35 );
36
37 return $css_generator->generate_css();
38 }
39
40 public function get_active_content_css( $attributes, $device = '' ) {
41 // Add border and padding styles
42 $border_css = isset( $attributes['contentBorder'] ) ? Border::get_css( $attributes['contentBorder'], '', $device ) : [];
43 $padding_css = isset( $attributes['contentPadding'] ) ? Dimensions::get_css( $attributes['contentPadding'], 'padding', $device ) : [];
44
45 // Merge border and padding styles with the main CSS
46 $css = array_merge($border_css, $padding_css,
47 [ 'background' => Color::get_css( isset( $attributes['backgroundColor'] ) ? $attributes['backgroundColor'] : '' ) ],
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