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 / advance-list-item / block.php

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

222 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\AdvanceListItem;
3
4 use ABlocks\Classes\BlockBaseAbstract;
5 use ABlocks\Classes\CssGenerator;
6 use ABlocks\Controls\Alignment;
7 use ABlocks\Controls\Dimensions;
8 use ABlocks\Controls\Typography;
9 use ABlocks\Controls\TextShadow;
10 use ABlocks\Controls\TextStroke;
11 use ABlocks\Controls\Width;
12 use ABlocks\Controls\Border;
13 use ABlocks\Controls\Icon;
14 use ABlocks\Controls\Range;
15
16 class Block extends BlockBaseAbstract {
17
18 protected $parent_block_name = 'advance-lists';
19 protected $block_name = 'advance-list-item';
20
21 public function build_css( $attributes ) {
22 // Generate CSS
23 $css_generator = new CssGenerator( $attributes );
24
25 $css_generator->add_class_styles(
26 '{{WRAPPER}}.ablocks-block--advance-list-item .ablocks-block-container',
27 $this->get_container_css( $attributes, '' ),
28 $this->get_container_css( $attributes, 'Tablet' ),
29 $this->get_container_css( $attributes, 'Mobile' ),
30 );
31 // Marker
32 $css_generator->add_class_styles(
33 '{{WRAPPER}}.ablocks-block--advance-list-item .advance-list-item-marker',
34 $this->get_marker_css( $attributes, '' ),
35 $this->get_marker_css( $attributes, 'Tablet' ),
36 $this->get_marker_css( $attributes, 'Mobile' ),
37 );
38 // Icon Style
39 $css_generator->add_class_styles(
40 '{{WRAPPER}} .ablocks-icon-wrap',
41 Icon::get_wrapper_css( $attributes ),
42 Icon::get_wrapper_css( $attributes, 'Tablet' ),
43 Icon::get_wrapper_css( $attributes, 'Mobile' )
44 );
45 $css_generator->add_class_styles(
46 '{{WRAPPER}} .ablocks-icon-wrap img.ablocks-image-icon',
47 Icon::get_element_image_css( $attributes ),
48 Icon::get_element_image_css( $attributes, 'Tablet' ),
49 Icon::get_element_image_css( $attributes, 'Mobile' ),
50 );
51 $css_generator->add_class_styles(
52 '{{WRAPPER}} .ablocks-icon-wrap svg.ablocks-svg-icon',
53 Icon::get_element_css( $attributes ),
54 Icon::get_element_css( $attributes, 'Tablet' ),
55 Icon::get_element_css( $attributes, 'Mobile' ),
56 );
57
58 // text
59 $desktop_paragraph_text_style = $this->get_paragraph_text_css( $attributes );
60 if ( ! empty( $attributes['textColor'] ) ) {
61 $desktop_paragraph_text_style['color'] = $attributes['textColor'];
62 }
63 $css_generator->add_class_styles(
64 '{{WRAPPER}} .ablocks-block-container .ablocks-advance-list-item-text',
65 $desktop_paragraph_text_style,
66 $this->get_paragraph_text_css( $attributes, 'Tablet' ),
67 $this->get_paragraph_text_css( $attributes, 'Mobile' ),
68 );
69 $css_generator->add_class_styles(
70 '{{WRAPPER}} .ablocks-block-container .ablocks-advance-list-item-text-drop-caps::first-letter',
71 $this->get_paragraph_drop_text_css( $attributes ),
72 $this->get_paragraph_drop_text_css( $attributes, 'Tablet' ),
73 $this->get_paragraph_drop_text_css( $attributes, 'Mobile' ),
74 );
75
76 // Divider CSS
77 $css_generator->add_class_styles(
78 '{{WRAPPER}} .ablocks-advance-list-item-divider__pattern-' . ( $attributes['dividerType'] === 'mask-style' ? 'mask' : 'css' ),
79 $this->get_divider_css( $attributes, '' ),
80 $this->get_divider_css( $attributes, 'Tablet' ),
81 $this->get_divider_css( $attributes, 'Mobile' ),
82 );
83
84 return $css_generator->generate_css();
85 }
86
87
88 public function get_marker_css( $attributes, $device = '' ) {
89 $css = [];
90
91 if ( ! empty( $attributes['shapeColor'] ) && $attributes['markerType'] === 'Shapes' ) {
92 $css['border-color'] = $attributes['shapeColor'] . ' !important';
93 }
94 if ( ! empty( $attributes['shapeSize'][ 'value' . $device ] ) ) {
95 $shapeSize = $attributes['shapeSize'][ 'value' . $device ] . 'px';
96
97 if ( $attributes['markerType'] === 'Emoji' ) {
98 $css['font-size'] = $shapeSize;
99 } else {
100 if ( in_array( $attributes['shapeType'], [ 'inset', 'outset', 'ridge' ], true ) ) {
101 $css['border'] = $shapeSize . ' ' . $attributes['shapeType'];
102 } else {
103 $css['border-bottom'] = $shapeSize . ' ' . $attributes['shapeType'];
104 $css['width'] = $shapeSize;
105 }
106 }
107 }
108 return $css;
109 }
110
111 public function get_container_css( $attributes, $device = '' ) {
112 $css = [];
113 if ( ! empty( $attributes['alignment'][ 'value' . $device ] ) && $attributes['alignment'][ 'value' . $device ] === 'flex-start' ) {
114 if ( ! empty( $attributes['iconAlignment'][ 'value' . $device ] ) && $attributes['iconAlignment'][ 'value' . $device ] ) {
115 $css['justify-content'] = 'flex-start';
116 } else {
117 $css['justify-content'] = 'flex-end';
118 };
119 } elseif ( ! empty( $attributes['alignment'][ 'value' . $device ] ) && $attributes['alignment'][ 'value' . $device ] === 'flex-end' ) {
120 if ( ! empty( $attributes['iconAlignment'][ 'value' . $device ] ) && $attributes['iconAlignment'][ 'value' . $device ] === 'row' ) {
121 $css['justify-content'] = 'flex-end';
122 } else {
123 $css['justify-content'] = 'flex-start';
124 };
125 } else {
126 $css['justify-content'] = 'center';
127 }
128 return array_merge(
129 $css,
130 isset( $attributes['iconAlignment'] ) ? Alignment::get_css( $attributes['iconAlignment'], 'flex-direction', $device ) : [],
131 Range::get_css([
132 'attributeValue' => $attributes['innerGap'],
133 'attribute_object_key' => 'value',
134 'isResponsive' => true,
135 'defaultValue' => null,
136 'hasUnit' => true,
137 'unitDefaultValue' => 'px',
138 'property' => 'gap',
139 'device' => $device,
140 ]),
141 );
142 }
143
144 public function get_paragraph_text_css( $attributes, $device = '' ) {
145 return array_merge(
146 isset( $attributes['listTypography'] ) ? Typography::get_css( $attributes['listTypography'], '', $device ) : [],
147 isset( $attributes['listTextStroke'] ) ? TextStroke::get_css( $attributes['listTextStroke'], '', $device ) : [],
148 isset( $attributes['listTextShadow'] ) ? TextShadow::get_css( $attributes['listTextShadow'] ) : [],
149 );
150 }
151 public function get_paragraph_drop_text_css( $attributes, $device = '' ) {
152 $css = [];
153 if ( ! empty( $attributes['dropCapsTextColor'] ) ) {
154 $css['color'] = $attributes['dropCapsTextColor'];
155 }
156 return $css;
157 }
158
159 public function get_divider_css( $attributes, $device = '' ) {
160 $css = [];
161 $divider_width = isset( $attributes['width'][ 'value' . $device ] ) ? $attributes['width'][ 'value' . $device ] : 60;
162 $divider_color = isset( $attributes['color'] ) ? $attributes['color'] : '#000000';
163 $default_Unit = '%';
164
165 if ( ! empty( $attributes['listsDirection'][ 'value' . $device ] ) && $attributes['listsDirection'][ 'value' . $device ] === 'row' ) {
166 $css['display'] = 'none';
167 } else {
168 $css['display'] = 'block';
169 }
170 if ( ! empty( $attributes['color'] ) ) {
171 $css['--ablocks-divider-pattern-color'] = $divider_color;
172 }
173
174 $moreRangeCSS = [];
175 if ( isset( $attributes['dividerType'] ) && $attributes['dividerType'] === 'mask-style' && isset( $attributes['size'] ) && ! empty( $attributes['size'] ) ) {
176 $moreRangeCSS = Range::get_css([
177 'attributeValue' => $attributes['size'],
178 'attribute_object_key' => 'value',
179 'isResponsive' => false,
180 'defaultValue' => null,
181 'hasUnit' => false,
182 'unitDefaultValue' => 'px',
183 'property' => '--ablocks-divider-pattern-height',
184 ]);
185 } elseif ( isset( $attributes['weight'] ) && ! empty( $attributes['weight'] ) ) {
186 $moreRangeCSS = Range::get_css([
187 'attributeValue' => $attributes['weight'],
188 'attribute_object_key' => 'value',
189 'isResponsive' => false,
190 'defaultValue' => null,
191 'hasUnit' => false,
192 'unitDefaultValue' => 'px',
193 'property' => '--ablocks-divider-pattern-weight',
194 ]);
195 }//end if
196
197 if ( ! empty( $attributes['dividerPatternUrl'] ) ) {
198 if ( $attributes['dividerType'] === 'mask-style' ) {
199 $css['--ablocks-divider-pattern-url'] = 'url(' . $attributes['dividerPatternUrl'] . ')';
200 } else {
201 $css['--ablocks-divider-pattern-style'] = $attributes['dividerPatternUrl'];
202 }
203 }
204
205 return array_merge(
206 $css,
207 Range::get_css([
208 'attributeValue' => $attributes['width'],
209 'attribute_object_key' => 'value',
210 'isResponsive' => true,
211 'defaultValue' => null,
212 'hasUnit' => false,
213 'unitDefaultValue' => '%',
214 'property' => 'width',
215 'device' => $device,
216 ]),
217 $moreRangeCSS,
218 );
219 }
220
221 }
222