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
← All changes | includes/blocks/image-hotspot-child/block.php +76 -0 2.7.7 → 2.14.0 View file →
@@ -1,0 +1,76 @@
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 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_active_content_css( $attributes, $device ); } )
29 + );
30 +
31 + $css_generator->add_class_styles(
32 + '{{WRAPPER}} .ablocks-image-hotspot__tooltip--active:hover',
33 + $this->get_active_content_hover_css( $attributes ),
34 + $this->get_active_content_hover_css( $attributes, 'Tablet' ),
35 + $this->get_active_content_hover_css( $attributes, 'Mobile' ),
36 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_active_content_hover_css( $attributes, $device ); } )
37 + );
38 +
39 + return $css_generator->generate_css();
40 + }
41 +
42 + public function get_active_content_css( $attributes, $device = '' ) {
43 + // Add border and padding styles
44 + $border_css = isset( $attributes['contentBorder'] ) ? Border::get_css( $attributes['contentBorder'], '', $device ) : [];
45 + $padding_css = isset( $attributes['contentPadding'] ) ? Dimensions::get_css( $attributes['contentPadding'], 'padding', $device ) : [];
46 +
47 + // Merge border and padding styles with the main CSS
48 + $css = array_merge($border_css, $padding_css,
49 + [ 'background' => Color::get_css( isset( $attributes['backgroundColor'] ) ? $attributes['backgroundColor'] : '' ) ],
50 + Range::get_css(
51 + [
52 + 'attributeValue' => $attributes['contentWidth'],
53 + 'attribute_object_key' => 'value',
54 + 'isResponsive' => true,
55 + 'defaultValue' => '',
56 + 'hasUnit' => true,
57 + 'unitDefaultValue' => 'px',
58 + 'property' => 'width',
59 + 'device' => $device,
60 + ]
61 + )
62 + );
63 +
64 + return $css;
65 + }
66 +
67 + public function get_active_content_hover_css( $attributes, $device = '' ) {
68 + $css = [];
69 +
70 + $border_hover_css = isset( $attributes['contentBorder'] ) ? Border::get_hover_css( $attributes['contentBorder'], $device ) : [];
71 +
72 + $css = array_merge( $css, $border_hover_css );
73 +
74 + return $css;
75 + }
76 +}