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 / ecm-reaction / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.11.1, at includes/blocks/ecm-reaction/block.php

209 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ABlocks\Blocks\EcmReaction;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit;
7 }
8
9 use ABlocks\Classes\BlockBaseAbstract;
10 use ABlocks\Classes\CssGenerator;
11 use ABlocks\Helper;
12 use ABlocks\Controls\Typography;
13 use ABlocks\Controls\Background;
14 use ABlocks\Controls\Border;
15 use ABlocks\Controls\Dimensions;
16 use ABlocks\Controls\Range;
17 use ABlocks\Controls\BoxShadow;
18 use ABlocks\Controls\Color;
19 use ABlocks\Controls\Alignment;
20
21
22 class Block extends BlockBaseAbstract {
23 protected $block_name = 'ecm-reaction';
24
25 public function build_css( $attributes ) {
26 $css_generator = new CssGenerator( $attributes, $this->block_name );
27
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .ecm-shortcode--reaction',
30 $this->get_wrapper_alignment_css( $attributes ),
31 $this->get_wrapper_alignment_css( $attributes, 'Tablet' ),
32 $this->get_wrapper_alignment_css( $attributes, 'Mobile' ),
33
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} span.ecm-shortcode--reaction__label.ecm--hidden',
37 $this->get_show_title_css( $attributes ),
38
39 );
40 $css_generator->add_class_styles(
41 '{{WRAPPER}} div.ecm-shortcode--reaction__icon svg',
42 $this->get_icon_css( $attributes ),
43 $this->get_icon_css( $attributes, 'Tablet' ),
44 $this->get_icon_css( $attributes, 'Mobile' ),
45
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} div.ecm-shortcode--reaction__icon svg path',
49 $this->get_icon_color_css( $attributes ),
50 $this->get_icon_color_css( $attributes, 'Tablet' ),
51 $this->get_icon_color_css( $attributes, 'Mobile' ),
52
53 );
54 $css_generator->add_class_styles(
55 '{{WRAPPER}} .ecm-shortcode--reaction__button--active div.ecm-shortcode--reaction__icon svg path',
56 $this->get_icon_active_color_css( $attributes ),
57 $this->get_icon_active_color_css( $attributes, 'Tablet' ),
58 $this->get_icon_active_color_css( $attributes, 'Mobile' ),
59
60 );
61 $css_generator->add_class_styles(
62 '{{WRAPPER}} button.ecm-shortcode--reaction__button',
63 $this->get_title_style_css( $attributes ),
64 $this->get_title_style_css( $attributes, 'Tablet' ),
65 $this->get_title_style_css( $attributes, 'Mobile' ),
66
67 );
68 $css_generator->add_class_styles(
69 '{{WRAPPER}} button.ecm-shortcode--reaction__button:hover',
70 $this->get_title_hover_style_css( $attributes ),
71 $this->get_title_hover_style_css( $attributes, 'Tablet' ),
72 $this->get_title_hover_style_css( $attributes, 'Mobile' ),
73
74 );
75 $css_generator->add_class_styles(
76 '{{WRAPPER}} button.ecm-shortcode--reaction__button.ecm-shortcode--reaction__button--active',
77 $this->get_title_active_style_css( $attributes ),
78 $this->get_title_active_style_css( $attributes, 'Tablet' ),
79 $this->get_title_active_style_css( $attributes, 'Mobile' ),
80
81 );
82 $css_generator->add_class_styles(
83 '{{WRAPPER}} button.ecm-shortcode--reaction__button.ecm-shortcode--reaction__button--active:hover',
84 $this->get_title_active_hover_style_css( $attributes ),
85 $this->get_title_active_hover_style_css( $attributes, 'Tablet' ),
86 $this->get_title_active_hover_style_css( $attributes, 'Mobile' ),
87
88 );
89 return $css_generator->generate_css();
90 }
91
92 public function render_block_content( $attributes, $content, $block_instance ) {
93 $attr_array = [
94 'user_id' => Helper::get_attribute_value( $attributes, 'user_id' ),
95 'not_found_text' => Helper::get_attribute_value( $attributes, 'not_found_text' ),
96 ];
97
98 $shortcode = '[ecm_reaction ' . Helper::attr_shortcode( $attr_array ) . ']';
99 echo do_shortcode( $shortcode );
100
101 }
102
103 public function get_wrapper_alignment_css( $attributes, $device = '' ) {
104 $alignment = ! empty( $attributes['justificationAlign'] ) ? $attributes['justificationAlign'] : '';
105 return array_merge(
106 Range::get_css( [
107 'attributeValue' => $attributes['itemGap'],
108 'attribute_object_key' => 'value',
109 'isResponsive' => true,
110 'defaultValue' => 50,
111 'hasUnit' => true,
112 'unitDefaultValue' => 'px',
113 'property' => 'gap',
114 'device' => $device,
115 ] ),
116 Alignment::get_css( $alignment, 'justify-content', $device )
117 ); }
118 public function get_show_title_css( $attributes, $device = '' ) {
119 $css = [];
120 if(!empty($attributes['showTitle']) && $attributes['showTitle'] === true ){
121 $css['display'] = 'block';
122 }
123 return $css;
124 }
125 public function get_icon_css( $attributes, $device = '' ) {
126 return array_merge(
127 Range::get_css( [
128 'attributeValue' => $attributes['iconSize'],
129 'attribute_object_key' => 'value',
130 'isResponsive' => true,
131 'defaultValue' => 50,
132 'hasUnit' => true,
133 'unitDefaultValue' => 'px',
134 'property' => 'width',
135 'device' => $device,
136 ] ),
137 Range::get_css( [
138 'attributeValue' => $attributes['iconSize'],
139 'attribute_object_key' => 'value',
140 'isResponsive' => true,
141 'defaultValue' => 50,
142 'hasUnit' => true,
143 'unitDefaultValue' => 'px',
144 'property' => 'height',
145 'device' => $device,
146 ] ),
147 ); }
148 public function get_icon_color_css( $attributes, $device = '' ) {
149 return array_merge(
150 [ 'fill' => Color::get_css( isset( $attributes['fillColor'] ) ? $attributes['fillColor'] : '' ) . '!important' ],
151 [ 'stroke' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) . '!important' ],
152 ); }
153
154 public function get_icon_active_color_css( $attributes, $device = '' ) {
155 return array_merge(
156 [ 'fill' => Color::get_css( isset( $attributes['activeFillColor'] ) ? $attributes['activeFillColor'] : '' ) . '!important' ],
157 [ 'stroke' => Color::get_css( isset( $attributes['activeIconColor'] ) ? $attributes['activeIconColor'] : '' ) . '!important' ],
158 ); }
159
160 public function get_title_style_css( $attributes, $device = '' ) {
161 $typographyGlobal = ( isset( $attributes['titleTypographyGlobal'] ) ? $attributes['titleTypographyGlobal'] : '' );
162
163 return array_merge(
164 ! empty( $attributes['titleTypography'] ) ? Typography::get_css( $attributes['titleTypography'], '', $device, $typographyGlobal ) : array(),
165 Border::get_css( ! empty( $attributes['border'] ) ? $attributes['border'] : [], '', $device ),
166 [ 'background' => Color::get_css( isset( $attributes['bgColor'] ) ? $attributes['bgColor'] : '' ) . '!important' ],
167 [ 'color' => Color::get_css( isset( $attributes['titleColor'] ) ? $attributes['titleColor'] : '' ) . '!important' ],
168 ); }
169 public function get_title_hover_style_css( $attributes, $device = '' ) {
170
171 return array_merge(
172 Range::get_css( [
173 'attributeValue' => $attributes['transition'],
174 'defaultValue' => 10,
175 'unitDefaultValue' => 's',
176 'property' => 'transition-duration',
177 ] ),
178 Border::get_hover_css( ! empty( $attributes['border'] ) ? $attributes['border'] : [], '', $device ),
179
180 ); }
181
182 public function get_title_active_style_css( $attributes, $device = '' ) {
183 $typographyGlobal = ( isset( $attributes['activeTitleTypographyGlobal'] ) ? $attributes['activeTitleTypographyGlobal'] : '' );
184
185 return array_merge(
186 ! empty( $attributes['activeTitleTypography'] ) ? Typography::get_css( $attributes['activeTitleTypography'], '', $device, $typographyGlobal ) : array(),
187 Border::get_css( ! empty( $attributes['activeBorder'] ) ? $attributes['activeBorder'] : [], '', $device ),
188 [ 'background' => Color::get_css( isset( $attributes['activeBGColor'] ) ? $attributes['activeBGColor'] : '' ) . '!important' ],
189 [ 'color' => Color::get_css( isset( $attributes['activeTitleColor'] ) ? $attributes['activeTitleColor'] : '' ) . '!important' ],
190 ); }
191
192 public function get_title_active_hover_style_css( $attributes, $device = '' ) {
193 $css = [];
194 return array_merge(
195 Range::get_css([
196 'attributeValue' => $attributes['transition'],
197 'defaultValue' => 10,
198 'unitDefaultValue' => 's',
199 'property' => 'transition-duration',
200 'device' => $device,
201 ]),
202 $css,
203 Border::get_hover_css( $attributes['activeBorder'], '', $device ),
204 );
205 }
206
207
208 }
209