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

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

170 lines 6.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\AdvanceLists;
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\Range;
14
15 class Block extends BlockBaseAbstract {
16
17 protected $block_name = 'advance-lists';
18
19 public function build_css( $attributes ) {
20 // Generate CSS
21 $css_generator = new CssGenerator( $attributes );
22 // Wrapper CSS
23 $css_generator->add_class_styles(
24 '{{WRAPPER}}',
25 $this->get_wrapper_css( $attributes, '' ),
26 $this->get_wrapper_css( $attributes, 'Tablet' ),
27 $this->get_wrapper_css( $attributes, 'Mobile' ),
28 );
29
30 $css_generator->add_class_styles(
31 '{{WRAPPER}}.ablocks-block--advance-lists > .ablocks-block-container',
32 $this->get_container_css( $attributes, '' ),
33 $this->get_container_css( $attributes, 'Tablet' ),
34 $this->get_container_css( $attributes, 'Mobile' ),
35 );
36
37 // text
38 $desktop_paragraph_text_style = $this->get_paragraph_text_css( $attributes );
39 if ( ! empty( $attributes['textColor'] ) ) {
40 $desktop_paragraph_text_style['color'] = $attributes['textColor'];
41 }
42 $css_generator->add_class_styles(
43 '{{WRAPPER}} .ablocks-block-container .ablocks-advance-list-item-text',
44 $desktop_paragraph_text_style,
45 $this->get_paragraph_text_css( $attributes, 'Tablet' ),
46 $this->get_paragraph_text_css( $attributes, 'Mobile' ),
47 );
48 $css_generator->add_class_styles(
49 '{{WRAPPER}} .ablocks-block-container .ablocks-advance-list-item-text-drop-caps::first-letter',
50 $this->get_paragraph_drop_text_css( $attributes ),
51 $this->get_paragraph_drop_text_css( $attributes, 'Tablet' ),
52 $this->get_paragraph_drop_text_css( $attributes, 'Mobile' ),
53 );
54
55 // Divider CSS
56 $css_generator->add_class_styles(
57 '{{WRAPPER}} .ablocks-advance-list-item-divider__pattern-' . ( $attributes['dividerType'] === 'mask-style' ? 'mask' : 'css' ),
58 $this->get_divider_css( $attributes, '' ),
59 $this->get_divider_css( $attributes, 'Tablet' ),
60 $this->get_divider_css( $attributes, 'Mobile' ),
61 );
62 return $css_generator->generate_css();
63 }
64
65 public function get_wrapper_css( $attributes, $device = '' ) {
66 $typography = isset( $attributes['typography'] ) ? $attributes['typography'] : '';
67 $alignment = isset( $attributes['alignment'] ) ? $attributes['alignment'] : '';
68 return array_merge(
69 Alignment::get_css( $alignment, 'text-align', $device ),
70 Typography::get_css( $typography, $device ),
71 );
72 }
73
74 public function get_container_css( $attributes, $device = '' ) {
75 $css = [];
76 if ( ! empty( $attributes['listsDirection'][ 'value' . $device ] ) ) {
77 $css['flex-direction'] = $attributes['listsDirection'][ 'value' . $device ];
78 }
79 $listsDirection = ! empty( $attributes['listsDirection'][ 'value' . $device ] ) && $attributes['listsDirection'][ 'value' . $device ];
80 $alignment = isset( $attributes['alignment'] ) ? $attributes['alignment'] : '';
81 return array_merge(
82 $css,
83 Alignment::get_css( $alignment, ( $listsDirection && $attributes['listsDirection'][ 'value' . $device ] === 'row' ) ? 'justify-content' : 'align-items', $device ),
84 Range::get_css([
85 'attributeValue' => $attributes['columnGap'],
86 'attribute_object_key' => 'value',
87 'isResponsive' => true,
88 'defaultValue' => null,
89 'hasUnit' => true,
90 'unitDefaultValue' => 'px',
91 'property' => 'gap',
92 'device' => $device,
93 ]),
94 );
95 }
96
97 public function get_paragraph_text_css( $attributes, $device = '' ) {
98 return array_merge(
99 isset( $attributes['listTypography'] ) ? Typography::get_css( $attributes['listTypography'], '', $device ) : [],
100 isset( $attributes['listTextStroke'] ) ? TextStroke::get_css( $attributes['listTextStroke'], '', $device ) : [],
101 isset( $attributes['listTextShadow'] ) ? TextShadow::get_css( $attributes['listTextShadow'] ) : [],
102 );
103 }
104 public function get_paragraph_drop_text_css( $attributes, $device = '' ) {
105 $css = [];
106 if ( ! empty( $attributes['dropCapsTextColor'] ) ) {
107 $css['color'] = $attributes['dropCapsTextColor'];
108 }
109 return $css;
110 }
111
112 public function get_divider_css( $attributes, $device = '' ) {
113 $css = [];
114 $divider_width = isset( $attributes['width'][ 'value' . $device ] ) ? $attributes['width'][ 'value' . $device ] : 60;
115 $divider_color = isset( $attributes['color'] ) ? $attributes['color'] : '#000000';
116 $default_Unit = '%';
117
118 if ( ! empty( $attributes['color'] ) ) {
119 $css['--ablocks-divider-pattern-color'] = $divider_color;
120 }
121
122 $moreRangeCSS = [];
123 if ( isset( $attributes['dividerType'] ) && $attributes['dividerType'] === 'mask-style' && isset( $attributes['size'] ) && ! empty( $attributes['size'] ) ) {
124 $moreRangeCSS = Range::get_css([
125 'attributeValue' => $attributes['size'],
126 'attribute_object_key' => 'value',
127 'isResponsive' => false,
128 'defaultValue' => null,
129 'hasUnit' => false,
130 'unitDefaultValue' => 'px',
131 'property' => '--ablocks-divider-pattern-height',
132 ]);
133 } elseif ( isset( $attributes['weight'] ) && ! empty( $attributes['weight'] ) ) {
134 $moreRangeCSS = Range::get_css([
135 'attributeValue' => $attributes['weight'],
136 'attribute_object_key' => 'value',
137 'isResponsive' => false,
138 'defaultValue' => null,
139 'hasUnit' => false,
140 'unitDefaultValue' => 'px',
141 'property' => '--ablocks-divider-pattern-weight',
142 ]);
143 }//end if
144
145 if ( ! empty( $attributes['dividerPatternUrl'] ) ) {
146 if ( $attributes['dividerType'] === 'mask-style' ) {
147 $css['--ablocks-divider-pattern-url'] = 'url(' . $attributes['dividerPatternUrl'] . ')';
148 } else {
149 $css['--ablocks-divider-pattern-style'] = $attributes['dividerPatternUrl'];
150 }
151 }
152
153 return array_merge(
154 $css,
155 Range::get_css([
156 'attributeValue' => $attributes['width'],
157 'attribute_object_key' => 'value',
158 'isResponsive' => true,
159 'defaultValue' => null,
160 'hasUnit' => false,
161 'unitDefaultValue' => '%',
162 'property' => 'width',
163 'device' => $device,
164 ]),
165 $moreRangeCSS,
166 );
167 }
168
169 }
170