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
ablocks / includes / blocks / single-accordion / block.php

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

184 lines 8.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\SingleAccordion;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Typography;
11 use ABlocks\Controls\TextShadow;
12 use ABlocks\Controls\TextStroke;
13 use ABlocks\Controls\Border;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Range;
16 use ABlocks\Controls\Color;
17
18
19 class Block extends BlockBaseAbstract {
20 protected $parent_block_name = 'accordion';
21 protected $block_name = 'single-accordion';
22
23 public function build_css( $attributes ) {
24 $css_generator = new CssGenerator( $attributes );
25 $css_generator->add_class_styles(
26 '{{WRAPPER}}.ablocks-block--single-accordion',
27 $this->get_item_css( $attributes ),
28 $this->get_item_css( $attributes, 'Tablet' ),
29 $this->get_item_css( $attributes, 'Mobile' ),
30 );
31 $css_generator->add_class_styles(
32 '{{WRAPPER}}.ablocks-block--single-accordion:hover',
33 $this->get_item_hover_css( $attributes ),
34 $this->get_item_hover_css( $attributes, 'Tablet' ),
35 $this->get_item_hover_css( $attributes, 'Mobile' ),
36 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_item_hover_css( $attributes, $device ); } )
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', $this->get_title_hover_css( $attributes ),
46 $this->get_title_hover_css( $attributes, 'Tablet' ),
47 $this->get_title_hover_css( $attributes, 'Mobile' ),
48 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_title_hover_css( $attributes, $device ); } )
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 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_title_active_css( $attributes, $device ); } )
56 );
57 $css_generator->add_class_styles(
58 '{{WRAPPER}} .ablocks-block--single-accordion__heading',
59 $this->get_panel_css( $attributes ),
60 $this->get_panel_css( $attributes, 'Tablet' ),
61 $this->get_panel_css( $attributes, 'Mobile' ),
62 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_panel_css( $attributes, $device ); } )
63 );
64 $css_generator->add_class_styles(
65 '{{WRAPPER}} .ablocks-block--single-accordion__heading:hover',
66 $this->get_panel_hover_css( $attributes ),
67 $this->get_panel_hover_css( $attributes, 'Tablet' ),
68 $this->get_panel_hover_css( $attributes, 'Mobile' ),
69 );
70 $css_generator->add_class_styles(
71 '{{WRAPPER}}.ablocks-block--single-accordion-is-selected .ablocks-block--single-accordion__heading',
72 $this->get_panel_active_css( $attributes ),
73 $this->get_panel_active_css( $attributes, 'Tablet' ),
74 $this->get_panel_active_css( $attributes, 'Mobile' ),
75 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_panel_active_css( $attributes, $device ); } )
76 );
77 $css_generator->add_class_styles(
78 '{{WRAPPER}} .ablocks-block--single-accordion__heading svg.ablocks-svg-icon',
79 $this->get_icon_css( $attributes )
80 );
81 $css_generator->add_class_styles(
82 '{{WRAPPER}} .ablocks-block--single-accordion__heading:hover svg.ablocks-svg-icon',
83 $this->get_icon_hover_css( $attributes )
84 );
85 $css_generator->add_class_styles(
86 '{{WRAPPER}} .ablocks-block--single-accordion__body-content',
87 $this->get_content_css( $attributes ),
88 $this->get_content_css( $attributes, 'Tablet' ),
89 $this->get_content_css( $attributes, 'Mobile' ),
90 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_css( $attributes, $device ); } )
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 $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_content_hover_css( $attributes, $device ); } )
98 );
99 return $css_generator->generate_css();
100 }
101 public function get_item_css( $attributes, $device = '' ) {
102 $css = [];
103 return array_merge(
104 Range::get_css([
105 'attributeValue' => $attributes['itemSpace'],
106 'attribute_object_key' => 'value',
107 'isResponsive' => false,
108 'property' => 'margin-bottom',
109 'hasUnit' => false,
110 'unitDefaultValue' => 'px',
111 'device' => $device,
112 ] ),
113 $css,
114 Border::get_css( $attributes['itemBorder'], '', $device )
115 );
116 }
117 public function get_item_hover_css( $attributes, $device = '' ) {
118 return array_merge(
119 Border::get_hover_css( $attributes['itemBorder'], '', $device )
120 );
121 }
122 public function get_title_css( $attributes, $device = '' ) {
123 $typographyValueGlobal = ! empty( $attributes['headerTypographyGlobal'] ) ? $attributes['headerTypographyGlobal'] : array();
124 $typography_css = Typography::get_css( $attributes['headerTypography'], '', $device, $typographyValueGlobal );
125 $textShadowCss = TextShadow::get_css( $attributes['headerTextShadow'], '', $device );
126 $textStrokeCss = TextStroke::get_css( $attributes['headerTextStroke'], '', $device );
127 return array_merge(
128 [ 'color' => Color::get_css( isset( $attributes['headerTextColor'] ) ? $attributes['headerTextColor'] : '' ) ],
129 $typography_css,
130 $textShadowCss,
131 $textStrokeCss
132 );
133 }
134
135 public function get_title_hover_css( $attributes, $device = '' ) {
136 return [ 'color' => Color::get_css( isset( $attributes['headerTextColorH'] ) ? $attributes['headerTextColorH'] : '' ) ];
137 }
138 public function get_title_active_css( $attributes, $device = '' ) {
139 return [ 'color' => Color::get_css( isset( $attributes['headerTextActiveColor'] ) ? $attributes['headerTextActiveColor'] : '' ) ];
140 }
141 public function get_panel_css( $attributes, $device = '' ) {
142 return array_merge(
143 [ 'background' => Color::get_css( isset( $attributes['headerBackgroundColor'] ) ? $attributes['headerBackgroundColor'] : '' ) ],
144 Border::get_css( $attributes['headerBorder'], '', $device ),
145 Dimensions::get_css( $attributes['headerPadding'], 'padding', $device )
146 );
147 }
148 public function get_panel_hover_css( $attributes, $device = '' ) {
149 return array_merge(
150 [ 'background' => Color::get_css( isset( $attributes['headerBackgroundColorH'] ) ? $attributes['headerBackgroundColorH'] : '' ) ],
151 Border::get_hover_css( $attributes['headerBorder'], '', $device )
152 );
153 }
154 public function get_panel_active_css( $attributes, $device = '' ) {
155 return [ 'background' => Color::get_css( isset( $attributes['headerBackgroundActiveColor'] ) ? $attributes['headerBackgroundActiveColor'] : '' ) ];
156 }
157 public function get_icon_css( $attributes, $device = '' ) {
158 return array_merge(
159 [ 'fill' => Color::get_css( isset( $attributes['iconColor'] ) ? $attributes['iconColor'] : '' ) . ' !important' ],
160 Range::get_css( [
161 'attributeValue' => $attributes['iconSize'],
162 'attribute_object_key' => 'value',
163 'isResponsive' => false,
164 'property' => 'font-size',
165 'device' => $device,
166 ] )
167 );
168 }
169
170 public function get_icon_hover_css( $attributes ) {
171 return [ 'fill' => Color::get_css( isset( $attributes['iconColorH'] ) ? $attributes['iconColorH'] : '' ) . ' !important' ];
172
173 }
174 public function get_content_css( $attributes, $device = '' ) {
175 return array_merge(
176 [ 'background' => Color::get_css( isset( $attributes['bodyBackground'] ) ? $attributes['bodyBackground'] : '' ) ],
177 Dimensions::get_css( $attributes['bodyPadding'], 'padding', $device )
178 );
179 }
180 public function get_content_hover_css( $attributes, $device = '' ) {
181 return [ 'background' => Color::get_css( isset( $attributes['bodyBackgroundH'] ) ? $attributes['bodyBackgroundH'] : '' ) ];
182 }
183 }
184