PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.13.1
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.13.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 / icon / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.13.1, at includes/blocks/icon/block.php

137 lines 4.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Icon;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Dimensions;
11 use ABlocks\Controls\Icon;
12 use ABlocks\Classes\CssGeneratorV2;
13
14 class Block extends BlockBaseAbstract {
15 protected $block_name = 'icon';
16
17 public function build_css_v1( $attributes ) {
18 $css_generator = new CssGenerator( $attributes, $this->block_name );
19
20 // Generate wrapper CSS start
21 $css_generator->add_class_styles(
22 '{{WRAPPER}} .ablocks-block-container',
23 $this->get_wrapper_css( $attributes ),
24 $this->get_wrapper_css( $attributes, 'Tablet' ),
25 $this->get_wrapper_css( $attributes, 'Mobile' )
26 );
27
28 // Icon Style
29 $css_generator->add_class_styles(
30 '{{WRAPPER}} .ablocks-icon-wrap',
31 Icon::get_wrapper_css( $attributes ),
32 Icon::get_wrapper_css( $attributes, 'Tablet' ),
33 Icon::get_wrapper_css( $attributes, 'Mobile' )
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ablocks-icon-wrap:hover',
37 Icon::get_wrapper_hover_css( $attributes ),
38 Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
39 Icon::get_wrapper_hover_css( $attributes, 'Mobile' )
40 );
41 $css_generator->add_class_styles(
42 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
43 Icon::get_element_image_css( $attributes ),
44 Icon::get_element_image_css( $attributes, 'Tablet' ),
45 Icon::get_element_image_css( $attributes, 'Mobile' )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover',
49 Icon::get_element_image_hover_css( $attributes ),
50 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
51 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
52 );
53 $css_generator->add_class_styles(
54 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
55 Icon::get_element_css( $attributes ),
56 Icon::get_element_css( $attributes, 'Tablet' ),
57 Icon::get_element_css( $attributes, 'Mobile' ),
58 );
59 $css_generator->add_class_styles(
60 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
61 Icon::get_element_image_hover_css( $attributes ),
62 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
63 Icon::get_element_image_hover_css( $attributes, 'Mobile' )
64 );
65
66 return $css_generator->generate_css();
67 }
68 public function build_css_v2( $attributes ) {
69 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
70
71 // Generate wrapper CSS start
72 $css_generator->add_class_styles(
73 '{{WRAPPER}}',
74 $this->get_wrapper_css( $attributes ),
75 $this->get_wrapper_css( $attributes, 'Tablet' ),
76 $this->get_wrapper_css( $attributes, 'Mobile' )
77 );
78
79 // Icon Style
80 $css_generator->add_class_styles(
81 '{{WRAPPER}} .ablocks-icon-wrap',
82 Icon::get_wrapper_css( $attributes ),
83 Icon::get_wrapper_css( $attributes, 'Tablet' ),
84 Icon::get_wrapper_css( $attributes, 'Mobile' )
85 );
86 $css_generator->add_class_styles(
87 '{{WRAPPER}} .ablocks-icon-wrap:hover',
88 Icon::get_wrapper_hover_css( $attributes ),
89 Icon::get_wrapper_hover_css( $attributes, 'Tablet' ),
90 Icon::get_wrapper_hover_css( $attributes, 'Mobile' )
91 );
92 $css_generator->add_class_styles(
93 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
94 Icon::get_element_image_css( $attributes ),
95 Icon::get_element_image_css( $attributes, 'Tablet' ),
96 Icon::get_element_image_css( $attributes, 'Mobile' )
97 );
98 $css_generator->add_class_styles(
99 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon:hover',
100 Icon::get_element_image_hover_css( $attributes ),
101 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
102 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
103 );
104 $css_generator->add_class_styles(
105 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
106 Icon::get_element_css( $attributes ),
107 Icon::get_element_css( $attributes, 'Tablet' ),
108 Icon::get_element_css( $attributes, 'Mobile' ),
109 );
110 $css_generator->add_class_styles(
111 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
112 Icon::get_element_image_hover_css( $attributes ),
113 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
114 Icon::get_element_image_hover_css( $attributes, 'Mobile' )
115 );
116
117 return $css_generator->generate_css();
118 }
119
120 public function build_css( $attributes ) {
121 if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
122 return $this->build_css_v2( $attributes );
123 }
124 return $this->build_css_v1( $attributes );
125 }
126
127 public function get_wrapper_css( $attributes = [], $device = '' ) {
128 $css = [];
129 $css['display'] = 'flex';
130 $css['align-items'] = 'flex-start';
131 if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) ) {
132 $css['justify-content'] = $attributes['alignment'][ 'value' . $device ];
133 }
134 return $css;
135 }
136 }
137