PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / trunk
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder vtrunk
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 1.2.0 1.2.1 All 78 releases
ablocks / includes / blocks / menu / block.php

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

480 lines 21.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Menu;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Controls\Typography;
9 use ABlocks\Controls\Dimensions;
10 use ABlocks\Controls\Border;
11 use ABlocks\Classes\BlockBaseAbstract;
12 use ABlocks\Classes\CssGenerator;
13 use ABlocks\Controls\Range;
14 use ABlocks\Controls\BoxShadow;
15 use ABlocks\Classes\CssGeneratorV2;
16 use ABlocks\Controls\Color;
17
18 class Block extends BlockBaseAbstract {
19 protected $block_name = 'menu';
20
21 public function build_css_v1( $attributes ) {
22 $css_generator = new CssGenerator( $attributes, $this->block_name );
23 $css_generator->add_class_styles(
24 '{{WRAPPER}} .ablocks-menu',
25 $this->get_menu_css( $attributes, '' ),
26 $this->get_menu_css( $attributes, 'Tablet' ),
27 $this->get_menu_css( $attributes, 'Mobile' )
28 );
29 $css_generator->add_class_styles(
30 '{{WRAPPER}}.ablocks-menu',
31 $this->get_menu_css( $attributes, '' ),
32 $this->get_menu_css( $attributes, 'Tablet' ),
33 $this->get_menu_css( $attributes, 'Mobile' )
34 );
35 $css_generator->add_class_styles(
36 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item',
37 $this->get_menu_item_css( $attributes ),
38 $this->get_menu_item_css( $attributes, 'Tablet' ),
39 $this->get_menu_item_css( $attributes, 'Mobile' )
40 );
41 $css_generator->add_class_styles(
42 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item .ablocks-menu-item__link',
43 $this->get_menu_item_css( $attributes ),
44 $this->get_menu_item_css( $attributes, 'Tablet' ),
45 $this->get_menu_item_css( $attributes, 'Mobile' )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover',
49 $this->get_menu_item_hover_css( $attributes, '' ),
50 $this->get_menu_item_hover_css( $attributes, 'Tablet' ),
51 $this->get_menu_item_hover_css( $attributes, 'Mobile' )
52 );
53 $css_generator->add_class_styles(
54 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item > .ablocks-menu-item__link:hover',
55 $this->get_menu_item_hover_css( $attributes, '' ),
56 $this->get_menu_item_hover_css( $attributes, 'Tablet' ),
57 $this->get_menu_item_hover_css( $attributes, 'Mobile' )
58 );
59 $css_generator->add_class_styles(
60 '{{WRAPPER}} .ablocks-block--menu-child-sub',
61 $this->get_sub_menu_css( $attributes, '' ),
62 $this->get_sub_menu_css( $attributes, 'Tablet' ),
63 $this->get_sub_menu_css( $attributes, 'Mobile' ),
64 );
65 $css_generator->add_class_styles(
66 '{{WRAPPER}} .ablocks-block--menu-child-sub:hover',
67 $this->get_sub_menu_hover_css( $attributes, '' ),
68 $this->get_sub_menu_hover_css( $attributes, 'Tablet' ),
69 $this->get_sub_menu_hover_css( $attributes, 'Mobile' ),
70 );
71 $css_generator->add_class_styles(
72 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item',
73 $this->get_subMenu_responsive_css( $attributes, '' ),
74 $this->get_subMenu_responsive_css( $attributes, 'Tablet' ),
75 $this->get_subMenu_responsive_css( $attributes, 'Mobile' ),
76 );
77 $css_generator->add_class_styles(
78 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item:hover',
79 $this->get_subMenu_responsive_hover_css( $attributes, '' ),
80 );
81 $css_generator->add_class_styles(
82 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item .ablocks-menu-item__link',
83 $this->get_subMenu_responsive_text_css( $attributes, '' ),
84 $this->get_subMenu_responsive_text_css( $attributes, 'Tablet' ),
85 $this->get_subMenu_responsive_text_css( $attributes, 'Mobile' ),
86 );
87 $css_generator->add_class_styles(
88 '{{WRAPPER}} .ablocks-menu-child-mega',
89 $this->getMegaMenuCSS( $attributes ),
90 $this->getMegaMenuCSS( $attributes, 'Tablet' ),
91 $this->getMegaMenuCSS( $attributes, 'Mobile' )
92 );
93 $css_generator->add_class_styles(
94 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item > .ablocks-menu-item__link',
95 $this->get_menu_item_link_css( $attributes, '' ),
96 $this->get_menu_item_link_css( $attributes, 'Tablet' ),
97 $this->get_menu_item_link_css( $attributes, 'Mobile' )
98 );
99 $css_generator->add_class_styles(
100 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover > .ablocks-menu-item__link ',
101 $this->get_menu_item_link_hover_css( $attributes, '' ),
102 );
103 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item > .ablocks-menu-item__dropdown-icon svg',
104 $this->get_menu_item_dropdown_icon_css( $attributes ),
105 $this->get_menu_item_dropdown_icon_css( $attributes, 'Tablet' ),
106 $this->get_menu_item_dropdown_icon_css( $attributes, 'Mobile' )
107 );
108 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover > .ablocks-menu-item__dropdown-icon svg', $this->get_menu_item_dropdown_icon_hover_css( $attributes ) );
109 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper', $this->get_hamburger_menu_wrapper_css( $attributes ) );
110 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger ',
111 $this->get_hamburger_menu_css( $attributes ),
112 $this->get_hamburger_menu_css( $attributes, 'Tablet' ),
113 $this->get_hamburger_menu_css( $attributes, 'Mobile' ),
114 );
115 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger:hover ',
116 $this->get_hamburgerHoverCSS( $attributes ),
117 $this->get_hamburgerHoverCSS( $attributes, 'Tablet' ),
118 $this->get_hamburgerHoverCSS( $attributes, 'Mobile' ),
119 );
120 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger .ablocks-menu__trigger-item ', $this->get_hamburger_menu_item_css( $attributes ) );
121
122 return $css_generator->generate_css();
123 }
124 public function build_css_v2( $attributes ) {
125 $css_generator = new CssGeneratorV2( $attributes, $this->block_name );
126 // Wrapper CSS
127 $css_generator->add_class_styles(
128 '{{WRAPPER}} .ablocks-menu',
129 $this->get_menu_css( $attributes, '' ),
130 $this->get_menu_css( $attributes, 'Tablet' ),
131 $this->get_menu_css( $attributes, 'Mobile' )
132 );
133 $css_generator->add_class_styles(
134 '{{WRAPPER}}.ablocks-menu',
135 $this->get_menu_css( $attributes, '' ),
136 $this->get_menu_css( $attributes, 'Tablet' ),
137 $this->get_menu_css( $attributes, 'Mobile' )
138 );
139 $css_generator->add_class_styles(
140 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item',
141 $this->get_menu_item_css( $attributes ),
142 $this->get_menu_item_css( $attributes, 'Tablet' ),
143 $this->get_menu_item_css( $attributes, 'Mobile' )
144 );
145 $css_generator->add_class_styles(
146 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item .ablocks-menu-item__link',
147 $this->get_menu_item_css( $attributes ),
148 $this->get_menu_item_css( $attributes, 'Tablet' ),
149 $this->get_menu_item_css( $attributes, 'Mobile' )
150 );
151 $css_generator->add_class_styles(
152 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover',
153 $this->get_menu_item_hover_css( $attributes, '' ),
154 $this->get_menu_item_hover_css( $attributes, 'Tablet' ),
155 $this->get_menu_item_hover_css( $attributes, 'Mobile' )
156 );
157 $css_generator->add_class_styles(
158 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item .ablocks-menu-item__link:hover',
159 $this->get_menu_item_hover_css( $attributes, '' ),
160 $this->get_menu_item_hover_css( $attributes, 'Tablet' ),
161 $this->get_menu_item_hover_css( $attributes, 'Mobile' )
162 );
163 $css_generator->add_class_styles(
164 '{{WRAPPER}} .ablocks-block--menu-child-sub',
165 $this->get_sub_menu_css( $attributes, '' ),
166 $this->get_sub_menu_css( $attributes, 'Tablet' ),
167 $this->get_sub_menu_css( $attributes, 'Mobile' ),
168 );
169 $css_generator->add_class_styles(
170 '{{WRAPPER}} .ablocks-block--menu-child-sub:hover',
171 $this->get_sub_menu_hover_css( $attributes, '' ),
172 $this->get_sub_menu_hover_css( $attributes, 'Tablet' ),
173 $this->get_sub_menu_hover_css( $attributes, 'Mobile' ),
174 );
175 $css_generator->add_class_styles(
176 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item',
177 $this->get_subMenu_responsive_css( $attributes, '' ),
178 $this->get_subMenu_responsive_css( $attributes, 'Tablet' ),
179 $this->get_subMenu_responsive_css( $attributes, 'Mobile' ),
180 );
181 $css_generator->add_class_styles(
182 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item:hover',
183 $this->get_subMenu_responsive_hover_css( $attributes, '' ),
184 );
185 $css_generator->add_class_styles(
186 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-block--menu-item .ablocks-menu-item__link',
187 $this->get_subMenu_responsive_text_css( $attributes, '' ),
188 $this->get_subMenu_responsive_text_css( $attributes, 'Tablet' ),
189 $this->get_subMenu_responsive_text_css( $attributes, 'Mobile' ),
190 );
191 $css_generator->add_class_styles(
192 '{{WRAPPER}} .ablocks-block--menu-child-sub .ablocks-menu-item:hover .ablocks-menu-item__link',
193 $this->get_subMenu__text_hover_css( $attributes )
194 );
195 $css_generator->add_class_styles(
196 '{{WRAPPER}} .ablocks-menu-child-mega',
197 $this->getMegaMenuCSS( $attributes ),
198 $this->getMegaMenuCSS( $attributes, 'Tablet' ),
199 $this->getMegaMenuCSS( $attributes, 'Mobile' )
200 );
201 $css_generator->add_class_styles(
202 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item > .ablocks-menu-item__link',
203 $this->get_menu_item_link_css( $attributes, '' ),
204 $this->get_menu_item_link_css( $attributes, 'Tablet' ),
205 $this->get_menu_item_link_css( $attributes, 'Mobile' )
206 );
207 $css_generator->add_class_styles(
208 '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover > .ablocks-menu-item__link ',
209 $this->get_menu_item_link_hover_css( $attributes, '' ),
210 );
211 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item > .ablocks-menu-item__dropdown-icon svg',
212 $this->get_menu_item_dropdown_icon_css( $attributes ),
213 $this->get_menu_item_dropdown_icon_css( $attributes, 'Tablet' ),
214 $this->get_menu_item_dropdown_icon_css( $attributes, 'Mobile' )
215 );
216 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-main-menu > .ablocks-menu-item:hover > .ablocks-menu-item__dropdown-icon svg', $this->get_menu_item_dropdown_icon_hover_css( $attributes ) );
217 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper', $this->get_hamburger_menu_wrapper_css( $attributes ) );
218 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger ',
219 $this->get_hamburger_menu_css( $attributes ),
220 $this->get_hamburger_menu_css( $attributes, 'Tablet' ),
221 $this->get_hamburger_menu_css( $attributes, 'Mobile' ),
222 );
223 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger:hover ',
224 $this->get_hamburgerHoverCSS( $attributes ),
225 $this->get_hamburgerHoverCSS( $attributes, 'Tablet' ),
226 $this->get_hamburgerHoverCSS( $attributes, 'Mobile' ),
227 );
228 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-menu__trigger-wrapper .ablocks-menu__trigger .ablocks-menu__trigger-item ',
229 $this->get_hamburger_menu_item_css( $attributes )
230 );
231 // menu active syle
232 $css_generator->add_class_styles( '{{WRAPPER}} .ablocks-block--menu-item-active',
233 $this->get_menu_active_styles_css( $attributes ),
234 $this->get_menu_active_styles_css( $attributes, 'Tablet' ),
235 $this->get_menu_active_styles_css( $attributes, 'Mobile' )
236 );
237 return $css_generator->generate_css();
238 }
239
240 private function get_menu_css( $attributes, $device = '' ) {
241 $css = [];
242 $padding = isset( $attributes['padding'] ) ? $attributes['padding'] : '';
243
244 if ( ! empty( $attributes['alignment'] ) ) {
245 $css['justify-content'] = $attributes['alignment'];
246 }
247 return array_merge(
248 Dimensions::get_css( $padding, 'padding', $device ),
249 $css
250 );
251 }
252 public function build_css( $attributes ) {
253 if ( isset( $attributes['blockVersion'] ) && (int) $attributes['blockVersion'] === 2 ) {
254 return $this->build_css_v2( $attributes );
255 }
256 return $this->build_css_v1( $attributes );
257 }
258
259
260
261 private function get_menu_item_css( $attributes, $device = '' ) {
262 $menu_border_css = ! empty( $attributes['menuItemBorder'] ) ? Border::get_css( $attributes['menuItemBorder'], '', $device ) : array();
263 $typographyValueGlobal = ! empty( $attributes['menuItemTypographyGlobal'] ) ? $attributes['menuItemTypographyGlobal'] : array();
264 $css = array_merge(
265 $menu_border_css,
266 isset( $attributes['menuItemTypography'] ) ? Typography::get_css( $attributes['menuItemTypography'], '', $device, $typographyValueGlobal ) : [],
267 Dimensions::get_css( isset( $attributes['menuItemPadding'] ) ? $attributes['menuItemPadding'] : [], 'padding', $device ),
268 Dimensions::get_css( isset( $attributes['menuItemMargin'] ) ? $attributes['menuItemMargin'] : [], 'margin', $device )
269 );
270
271 if ( isset( $attributes[ 'menuItemDirection' . $device ] ) && ! empty( $attributes[ 'menuItemDirection' . $device ] ) ) {
272 $css['flex-direction'] = $attributes[ 'menuItemDirection' . $device ];
273 }
274
275 // Justify content
276 if ( isset( $attributes[ 'menuItemJustify' . $device ] ) && ! empty( $attributes[ 'menuItemJustify' . $device ] ) ) {
277 $css['justify-content'] = $attributes[ 'menuItemJustify' . $device ];
278 }
279
280 // Align items
281 if ( isset( $attributes[ 'menuItemAlign' . $device ] ) && ! empty( $attributes[ 'menuItemAlign' . $device ] ) ) {
282 $css['align-items'] = $attributes[ 'menuItemAlign' . $device ];
283 }
284 if ( ! empty( $attributes['menuItemTransition'] ) ) {
285 $css['transition'] = $attributes['menuItemTransition'] . 's';
286 }
287 if (
288 ( $attributes['sideBarMenuDevice'] ?? null ) === 'tablet' && in_array( $device, [ 'Tablet', 'Mobile' ], true ) ||
289 ( ( $attributes['sideBarMenuDevice'] ?? null ) !== 'tablet' && $device === 'Mobile' )
290 ) {
291 $css['background'] = Color::get_css( isset( $attributes['menuResponsiveBackground'] ) ? $attributes['menuResponsiveBackground'] : '' );
292 }
293 return array_merge(
294 [ 'color' => Color::get_css( isset( $attributes['menuItemTextColor'] ) ? $attributes['menuItemTextColor'] : '' ) ],
295 [ 'background' => Color::get_css( isset( $attributes['menuItemBackground'] ) ? $attributes['menuItemBackground'] : '' ) ],
296 $css
297 );
298 }
299 private function get_menu_item_link_css( $attributes, $device = '' ) {
300 $css = [];
301 if (
302 ( $attributes['sideBarMenuDevice'] ?? null ) === 'tablet' && in_array( $device, [ 'Tablet', 'Mobile' ], true ) ||
303 ( ( $attributes['sideBarMenuDevice'] ?? null ) !== 'tablet' && $device === 'Mobile' )
304 ) {
305 $css['color'] = Color::get_css( isset( $attributes['menuResponsiveTextColor'] ) ? $attributes['menuResponsiveTextColor'] : '' ) . ' !important';
306
307 }
308 return array_merge(
309 [ 'color' => Color::get_css( isset( $attributes['menuItemTextColor'] ) ? $attributes['menuItemTextColor'] : '' ) ],
310 $css
311 );
312 }
313
314 private function get_menu_item_hover_css( $attributes, $device = '' ) {
315 return array_merge(
316 [ 'color' => Color::get_css( isset( $attributes['menuItemTextColorH'] ) ? $attributes['menuItemTextColorH'] : '' ) ],
317 [ 'background' => Color::get_css( isset( $attributes['menuItemBackgroundH'] ) ? $attributes['menuItemBackgroundH'] : '' ) ],
318 Border::get_hover_css( isset( $attributes['menuItemBorder'] ) ? $attributes['menuItemBorder'] : [], $device )
319 );
320 }
321 private function get_menu_item_link_hover_css( $attributes ) {
322 return [ 'color' => Color::get_css( isset( $attributes['menuItemTextColorH'] ) ? $attributes['menuItemTextColorH'] : '' ) ];
323 }
324 private function get_sub_menu_css( $attributes, $device = '' ) {
325 $css = [];
326 if ( isset( $attributes['menuItemBorder']['commonWidth'] ) ) {
327 $css['margin-top'] = $attributes['menuItemBorder']['commonWidth'] . 'px';
328 }
329 if ( isset( $attributes['menuItemBorder']['bottomWidth'] ) ) {
330 $css['margin-top'] = $attributes['menuItemBorder']['bottomWidth'] . 'px';
331 }
332 return array_merge(
333 $css,
334 Range::get_css([
335 'attributeValue' => $attributes['subMenuWidth'],
336 'attribute_object_key' => 'value',
337 'isResponsive' => true,
338 'defaultValue' => 250,
339 'hasUnit' => true,
340 'unitDefaultValue' => 'px',
341 'property' => 'width',
342 'device' => $device,
343 ]),
344 BoxShadow::get_css( ! empty( $attributes['subMenuBoxShadow'] ) ? $attributes['subMenuBoxShadow'] : '', $device ),
345 Dimensions::get_css( $attributes['subMenuPadding'], 'padding', $device ),
346 Border::get_css( $attributes['subMenuBorder'], '', $device ),
347 );
348 }
349 private function get_sub_menu_hover_css( $attributes, $device = '' ) {
350 return array_merge(
351 Border::get_hover_css( $attributes['subMenuBorder'], '', $device ),
352 BoxShadow::get_hover_css( $attributes['subMenuBoxShadow'], '', $device )
353 );
354 }
355 private function get_subMenu_responsive_css( $attributes, $device = '' ) {
356 $css = [];
357 if ( ! empty( $attributes['subMenuItemTransition'] ) ) {
358 $css['transition-duration'] = $attributes['subMenuItemTransition'] . 's';
359 }
360 if (
361 ( isset( $attributes['sideBarMenuDevice'] ) && $attributes['sideBarMenuDevice'] === 'tablet' && in_array( $device, [ 'Tablet', 'Mobile' ], true ) ) ||
362 ( isset( $attributes['sideBarMenuDevice'] ) && $attributes['sideBarMenuDevice'] !== 'tablet' && $device === 'Mobile' )
363 ) {
364 $css['background'] = Color::get_css( isset( $attributes['subMenuResponsiveBg'] ) ? $attributes['subMenuResponsiveBg'] : '' ) . '!important';
365 }
366 return array_merge(
367 [ 'background' => Color::get_css( isset( $attributes['subMenuItemBackground'] ) ? $attributes['subMenuItemBackground'] : '' ) ],
368 $css
369 );
370 }
371
372 private function get_subMenu_responsive_hover_css( $attributes ) {
373 return array_merge(
374 [ 'color' => Color::get_css( isset( $attributes['subMenuItemTextColorH'] ) ? $attributes['subMenuItemTextColorH'] : '' ) ],
375 [ 'background' => Color::get_css( isset( $attributes['subMenuItemBackgroundH'] ) ? $attributes['subMenuItemBackgroundH'] : '' ) ]
376 );
377 }
378 private function get_subMenu_responsive_text_css( $attributes, $device = '' ) {
379 $css = [];
380 if (
381 ( $attributes['sideBarMenuDevice'] ?? null ) === 'tablet' && in_array( $device, [ 'Tablet', 'Mobile' ], true ) ||
382 ( ( $attributes['sideBarMenuDevice'] ?? null ) !== 'tablet' && $device === 'Mobile' )
383 ) {
384 $css['color'] = Color::get_css( isset( $attributes['subMenuResponsiveColor'] ) ? $attributes['subMenuResponsiveColor'] : '' ) . ' !important';
385 }
386
387 return array_merge(
388 [ 'color' => Color::get_css( isset( $attributes['subMenuItemTextColor'] ) ? $attributes['subMenuItemTextColor'] : '' ) ],
389 $css
390 );
391 }
392 private function get_subMenu__text_hover_css( $attributes, $device = '' ) {
393 return [ 'color' => Color::get_css( isset( $attributes['subMenuItemTextColorH'] ) ? $attributes['subMenuItemTextColorH'] : '' ) ];
394 }
395 private function getMegaMenuCSS( $attributes, $device = '' ) {
396 $css = [];
397 if ( isset( $attributes['sideBarMenuDevice'] ) && $attributes['sideBarMenuDevice'] === 'tablet' && $device === 'Tablet' ) {
398 $css['position'] = 'static !important';
399 }
400 return $css;
401 }
402
403
404 private function get_menu_item_dropdown_icon_css( $attributes, $device = '' ) {
405 $css = [];
406 if (
407 ( $attributes['sideBarMenuDevice'] ?? null ) === 'tablet' && in_array( $device, [ 'Tablet', 'Mobile' ], true ) ||
408 ( ( $attributes['sideBarMenuDevice'] ?? null ) !== 'tablet' && $device === 'Mobile' )
409 ) {
410 $css['fill'] = Color::get_css( isset( $attributes['menuResponsiveTextColor'] ) ? $attributes['menuResponsiveTextColor'] : '' ) . ' !important';
411 }
412 return array_merge(
413 [ 'fill' => Color::get_css( isset( $attributes['menuItemTextColor'] ) ? $attributes['menuItemTextColor'] : '' ) ],
414 $css
415 );
416 }
417 private function get_menu_item_dropdown_icon_hover_css( $attributes ) {
418 return [ 'fill' => Color::get_css( isset( $attributes['menuItemTextColorH'] ) ? $attributes['menuItemTextColorH'] : '' ) ];
419 }
420 private function get_hamburger_menu_wrapper_css( $attributes ) {
421 $css = [];
422 if ( isset( $attributes['hamburgerAlignment'] ) ) {
423 $css['justify-content'] = $attributes['hamburgerAlignment'];
424 }
425 return $css;
426 }
427 public function get_hamburger_menu_css( $attributes, $device = '' ) {
428 $hamburger_border_css = ! empty( $attributes['hamburgerBorder'] ) ? Border::get_css( $attributes['hamburgerBorder'], '', $device ) : array();
429 $css = array_merge(
430 $hamburger_border_css,
431 Dimensions::get_css( isset( $attributes['hamburgerPadding'] ) ? $attributes['hamburgerPadding'] : [], 'padding', $device ),
432 [ 'background' => Color::get_css( isset( $attributes['hamburgerBackground'] ) ? $attributes['hamburgerBackground'] : '' ) ],
433 );
434 $height_humber = 30 + ( isset( $attributes['hamburgerHeight.value'] ) ? $attributes['hamburgerHeight.value'] : 0 );
435 if ( $height_humber ) {
436 $css['height'] = "{$height_humber}px";
437 }
438
439 return $css;
440 }
441 public function get_hamburgerHoverCSS( $attributes, $device = '' ) {
442 $css = Border::get_hover_css( isset( $attributes['hamburgerBorder'] ) ? $attributes['hamburgerBorder'] : [], $device );
443 return $css;
444 }
445
446
447 public function get_hamburger_menu_item_css( $attributes, $device = '' ) {
448 return array_merge(
449 [ 'background' => Color::get_css( isset( $attributes['hamburgerColor'] ) ? $attributes['hamburgerColor'] : '' ) ],
450 Range::get_css([
451 'attributeValue' => $attributes['hamburgerHeight'],
452 'attribute_object_key' => 'value',
453 'isResponsive' => false,
454 'defaultValue' => 3,
455 'hasUnit' => true,
456 'unitDefaultValue' => 'px',
457 'property' => 'height',
458 'device' => $device,
459 ]),
460 Range::get_css([
461 'attributeValue' => $attributes['hamburgerWidth'],
462 'attribute_object_key' => 'value',
463 'isResponsive' => false,
464 'defaultValue' => 30,
465 'hasUnit' => true,
466 'unitDefaultValue' => 'px',
467 'property' => 'width',
468 'device' => $device,
469 ])
470 );
471 }
472 // menu active color syle
473 public function get_menu_active_styles_css( $attributes, $device = '' ) {
474 return array_merge(
475 [ 'color' => Color::get_css( isset( $attributes['menuActveColor'] ) ? $attributes['menuActveColor'] : '' ) ],
476 [ 'background' => Color::get_css( isset( $attributes['menuActveColorBg'] ) ? $attributes['menuActveColorBg'] : '' ) ],
477 );
478 }
479 }
480