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

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

250 lines 8.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Accordion;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Helper;
11 use ABlocks\Controls\Typography;
12 use ABlocks\Controls\TextShadow;
13 use ABlocks\Controls\TextStroke;
14 use ABlocks\Controls\Background;
15 use ABlocks\Controls\Border;
16 use ABlocks\Controls\Dimensions;
17 use ABlocks\Controls\Alignment;
18 use ABlocks\Controls\Range;
19
20 class Block extends BlockBaseAbstract {
21 protected $block_name = 'accordion';
22
23 public function build_css( $attributes ) {
24 $css_generator = new CssGenerator( $attributes );
25
26 $css_generator->add_class_styles(
27 '{{WRAPPER}} .ablocks-block--single-accordion',
28 $this->get_item_css( $attributes ),
29 $this->get_item_css( $attributes, 'Tablet' ),
30 $this->get_item_css( $attributes, 'Mobile' )
31 );
32 $css_generator->add_class_styles(
33 '{{WRAPPER}} .ablocks-block--single-accordion:hover',
34 $this->get_item_hover_css( $attributes ),
35 $this->get_item_hover_css( $attributes, 'Tablet' ),
36 $this->get_item_hover_css( $attributes, 'Mobile' )
37 );
38 $css_generator->add_class_styles(
39 '{{WRAPPER}} .ablocks-block--single-accordion__heading .ablocks-block-accordion-title',
40 $this->get_title_css( $attributes ),
41 $this->get_title_css( $attributes, 'Tablet' ),
42 $this->get_title_css( $attributes, 'Mobile' )
43 );
44 $css_generator->add_class_styles(
45 '{{WRAPPER}} .ablocks-block--single-accordion__heading:hover .ablocks-block-accordion-title',
46 $this->get_title_hover_css( $attributes ),
47 $this->get_title_hover_css( $attributes, 'Tablet' ),
48 $this->get_title_hover_css( $attributes, 'Mobile' )
49 );
50 $css_generator->add_class_styles(
51 '{{WRAPPER}} .ablocks-block--single-accordion-is-selected .ablocks-block-accordion-title',
52 $this->get_title_active_css( $attributes ),
53 $this->get_title_active_css( $attributes, 'Tablet' ),
54 $this->get_title_active_css( $attributes, 'Mobile' )
55 );
56 $css_generator->add_class_styles(
57 '{{WRAPPER}} .ablocks-block--single-accordion__heading',
58 $this->get_panel_css( $attributes ),
59 $this->get_panel_css( $attributes, 'Tablet' ),
60 $this->get_panel_css( $attributes, 'Mobile' )
61 );
62 $css_generator->add_class_styles(
63 '{{WRAPPER}} .ablocks-block--single-accordion__heading:hover',
64 $this->get_panel_hover_css( $attributes ),
65 $this->get_panel_hover_css( $attributes, 'Tablet' ),
66 $this->get_panel_hover_css( $attributes, 'Mobile' ),
67 );
68 $css_generator->add_class_styles(
69 '{{WRAPPER}} .ablocks-block--single-accordion-is-selected .ablocks-block--single-accordion__heading',
70 $this->get_panel_active_css( $attributes ),
71 $this->get_panel_active_css( $attributes, 'Tablet' ),
72 $this->get_panel_active_css( $attributes, 'Mobile' )
73 );
74 $css_generator->add_class_styles(
75 '{{WRAPPER}} .ablocks-block--single-accordion__heading svg.ablocks-svg-icon',
76 $this->get_icon_css( $attributes )
77 );
78 $css_generator->add_class_styles(
79 '{{WRAPPER}} .ablocks-block--single-accordion__heading:hover svg.ablocks-svg-icon',
80 $this->get_icon_hover_css( $attributes )
81 );
82 $css_generator->add_class_styles(
83 '{{WRAPPER}} .ablocks-block--single-accordion-is-selected svg.ablocks-svg-icon',
84 $this->get_icon_active_css( $attributes )
85 );
86 $css_generator->add_class_styles(
87 '{{WRAPPER}} .ablocks-block--single-accordion__body-content',
88 $this->get_content_css( $attributes ),
89 $this->get_content_css( $attributes, 'Tablet' ),
90 $this->get_content_css( $attributes, 'Mobile' )
91 );
92 $css_generator->add_class_styles(
93 '{{WRAPPER}} .ablocks-block--single-accordion__body-content:hover',
94 $this->get_content_hover_css( $attributes ),
95 $this->get_content_hover_css( $attributes, 'Tablet' ),
96 $this->get_content_hover_css( $attributes, 'Mobile' )
97 );
98 return $css_generator->generate_css();
99 }
100 public function get_item_css( $attributes, $device = '' ) {
101 $css = [];
102
103 return array_merge(
104 Range::get_css([
105 'attributeValue' => $attributes['itemSpace'],
106 'attribute_object_key' => 'value',
107 'isResponsive' => false,
108 'defaultValue' => 10,
109 'property' => 'margin-bottom',
110 'hasUnit' => false,
111 'unitDefaultValue' => 'px',
112 'device' => $device,
113
114 ]),
115 $css,
116 isset( $attributes['itemBorder'] ) ? Border::get_css( $attributes['itemBorder'], '', $device ) : []
117 );
118 }
119 public function get_item_hover_css( $attributes, $device = '' ) {
120 return array_merge(
121 isset( $attributes['itemBorder'] ) ? Border::get_hover_css( $attributes['itemBorder'], '', $device ) : []
122 );
123 }
124 public function get_title_css( $attributes, $device = '' ) {
125 $css = [];
126 if ( ! empty( $attributes['headerTextColor'] ) ) {
127 $css['color'] = $attributes['headerTextColor'];
128 }
129
130 return array_merge(
131 Range::get_css([
132 'attributeValue' => $attributes['iconSpace'],
133 'attribute_object_key' => 'value',
134 'isResponsive' => false,
135 'defaultValue' => 10,
136 'property' => 'margin-left',
137 'device' => $device,
138 ]),
139 $css,
140 Typography::get_css( $attributes['headerTypography'], '', $device ),
141 TextShadow::get_css( $attributes['headerTextShadow'], '', $device ),
142 TextStroke::get_css( $attributes['headerTextStroke'], '', $device )
143 );
144 }
145 public function get_title_hover_css( $attributes, $device = '' ) {
146 $css = [];
147 if ( ! empty( $attributes['headerTextColorH'] ) ) {
148 $css['color'] = $attributes['headerTextColorH'];
149 }
150 return array_merge(
151 $css,
152 );
153 }
154 public function get_title_active_css( $attributes, $device = '' ) {
155 $css = [];
156 if ( ! empty( $attributes['headerTextActiveColor'] ) ) {
157 $css['color'] = $attributes['headerTextActiveColor'];
158 }
159 return array_merge(
160 $css,
161 );
162 }
163 public function get_panel_css( $attributes, $device = '' ) {
164 $css = [];
165 if ( ! empty( $attributes['headerBackgroundColor'] ) ) {
166 $css['background'] = $attributes['headerBackgroundColor'];
167 }
168 return array_merge(
169 $css,
170 isset( $attributes['headerBorder'] ) ? Border::get_css( $attributes['headerBorder'], '', $device ) : [],
171 isset( $attributes['headerPadding'] ) ? Dimensions::get_css( $attributes['headerPadding'], 'padding', $device ) : []
172 );
173 }
174 public function get_panel_hover_css( $attributes, $device = '' ) {
175 $css = [];
176 if ( ! empty( $attributes['headerBackgroundColorH'] ) ) {
177 $css['background'] = $attributes['headerBackgroundColorH'];
178 }
179 return array_merge(
180 $css,
181 isset( $attributes['headerBorder'] ) ? Border::get_hover_css( $attributes['headerBorder'], '', $device ) : []
182 );
183 }
184 public function get_panel_active_css( $attributes, $device = '' ) {
185 $css = [];
186 if ( ! empty( $attributes['headerBackgroundActiveColor'] ) ) {
187 $css['background'] = $attributes['headerBackgroundActiveColor'];
188 }
189 return array_merge(
190 $css,
191 );
192 }
193 public function get_icon_css( $attributes, $device = '' ) {
194 $css = [];
195
196 if ( ! empty( $attributes['iconColor'] ) ) {
197 $css['fill'] = $attributes['iconColor'];
198 }
199 return array_merge(
200 $css,
201 Range::get_css([
202 'attributeValue' => $attributes['iconSize'],
203 'attribute_object_key' => 'value',
204 'isResponsive' => false,
205 'defaultValue' => 30,
206 'property' => 'font-size',
207 'device' => $device,
208 ]),
209 );
210 }
211 public function get_icon_hover_css( $attributes ) {
212 $css = [];
213 if ( ! empty( $attributes['iconColorH'] ) ) {
214 $css['fill'] = $attributes['iconColorH'];
215 }
216 return array_merge(
217 $css,
218 );
219 }
220 public function get_icon_active_css( $attributes ) {
221 $css = [];
222 if ( ! empty( $attributes['iconActiveColor'] ) ) {
223 $css['fill'] = $attributes['iconActiveColor'];
224 }
225 return array_merge(
226 $css,
227 );
228 }
229 public function get_content_css( $attributes, $device = '' ) {
230 $css = [];
231 if ( ! empty( $attributes['bodyBackground'] ) ) {
232 $css['background'] = $attributes['bodyBackground'];
233 }
234 return array_merge(
235 $css,
236 isset( $attributes['bodyPadding'] ) ? Dimensions::get_css( $attributes['bodyPadding'], 'padding', $device ) : []
237 );
238 }
239 public function get_content_hover_css( $attributes, $device = '' ) {
240 $css = [];
241 if ( ! empty( $attributes['bodyBackgroundH'] ) ) {
242 $css['background'] = $attributes['bodyBackgroundH'];
243 }
244 return array_merge(
245 $css,
246 );
247
248 }
249 }
250