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

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

66 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Paragraph;
3
4 use ABlocks\Classes\BlockBaseAbstract;
5 use ABlocks\Classes\CssGenerator;
6 use ABlocks\Controls\Alignment;
7 use ABlocks\Controls\TextShadow;
8 use ABlocks\Controls\TextStroke;
9 use ABlocks\Controls\Typography;
10
11 class Block extends BlockBaseAbstract {
12 protected $block_name = 'paragraph';
13
14 public function build_css( $attributes ) {
15
16 $css_generator = new CssGenerator( $attributes, $this->block_name );
17
18 $css_generator->add_class_styles(
19 '{{WRAPPER}}',
20 $this->get_wrapper_css( $attributes ),
21 $this->get_wrapper_css( $attributes, 'Tablet' ),
22 $this->get_wrapper_css( $attributes, 'Mobile' ),
23 );
24
25 $desktop_paragraph_text_style = $this->get_paragraph_text_css( $attributes );
26
27 if ( ! empty( $attributes['textColor'] ) ) {
28 $desktop_paragraph_text_style['color'] = $attributes['textColor'];
29 }
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .ablocks-paragraph-text',
32 $desktop_paragraph_text_style,
33 $this->get_paragraph_text_css( $attributes, 'Tablet' ),
34 $this->get_paragraph_text_css( $attributes, 'Mobile' ),
35 );
36
37 $css_generator->add_class_styles(
38 '{{WRAPPER}} .ablocks-paragraph-text-drop-caps::first-letter',
39 $this->get_paragraph_drop_text_css( $attributes ),
40 $this->get_paragraph_drop_text_css( $attributes, 'Tablet' ),
41 $this->get_paragraph_drop_text_css( $attributes, 'Mobile' ),
42 );
43 return $css_generator->generate_css();
44 }
45
46 public function get_wrapper_css( $attributes, $device = '' ) {
47 return isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], 'text-align', $device ) : [];
48 }
49
50 public function get_paragraph_text_css( $attributes, $device = '' ) {
51 return array_merge(
52 isset( $attributes['typography'] ) ? Typography::get_css( $attributes['typography'], '', $device ) : [],
53 isset( $attributes['textStroke'] ) ? TextStroke::get_css( $attributes['textStroke'], '', $device ) : [],
54 isset( $attributes['textShadow'] ) ? TextShadow::get_css( $attributes['textShadow'], '', $device ) : [],
55 );
56 }
57
58 public function get_paragraph_drop_text_css( $attributes, $device = '' ) {
59 $css = [];
60 if ( ! empty( $attributes['dropCapsTextColor'] ) ) {
61 $css['color'] = $attributes['dropCapsTextColor'];
62 }
63 return $css;
64 }
65 }
66