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

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

97 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\Notice;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Alignment;
11 use ABlocks\Controls\Typography;
12 use ABlocks\Controls\TextShadow;
13 use ABlocks\Controls\TextStroke;
14 use ABlocks\Controls\Dimensions;
15 use ABlocks\Controls\Icon;
16
17 class Block extends BlockBaseAbstract {
18 protected $block_name = 'notice';
19
20 public function build_css( $attributes ) {
21 $css_generator = new CssGenerator( $attributes, $this->block_name );
22 $css_generator->add_class_styles(
23 '{{WRAPPER}} .ablocks-notice-header',
24 $this->get_notice_header_css( $attributes ),
25 $this->get_notice_header_css( $attributes, 'Tablet' ),
26 $this->get_notice_header_css( $attributes, 'Mobile' )
27 );
28 $css_generator->add_class_styles(
29 '{{WRAPPER}} .ablocks-notice-header .ablocks-notice-title',
30 $this->get_notice_header_title_css( $attributes ),
31 $this->get_notice_header_title_css( $attributes, 'Tablet' ),
32 $this->get_notice_header_title_css( $attributes, 'Mobile' )
33 );
34
35 // Icon CSS
36 $css_generator->add_class_styles(
37 '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap',
38 Icon::get_wrapper_css( $attributes ),
39 Icon::get_wrapper_css( $attributes, 'Tablet' ),
40 Icon::get_wrapper_css( $attributes, 'Mobile' )
41 );
42
43 $css_generator->add_class_styles(
44 '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon',
45 Icon::get_element_image_css( $attributes ),
46 Icon::get_element_image_css( $attributes, 'Tablet' ),
47 Icon::get_element_image_css( $attributes, 'Mobile' ),
48 );
49 $css_generator->add_class_styles(
50 '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap img.ablocks-image-icon:hover',
51 Icon::get_element_image_hover_css( $attributes ),
52 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
53 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
54 );
55 $css_generator->add_class_styles(
56 '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon',
57 Icon::get_element_css( $attributes ),
58 Icon::get_element_css( $attributes, 'Tablet' ),
59 Icon::get_element_css( $attributes, 'Mobile' ),
60 );
61 $css_generator->add_class_styles(
62 '{{WRAPPER}} .ablocks-notice-header .ablocks-icon-wrap svg.ablocks-svg-icon:hover',
63 Icon::get_element_image_hover_css( $attributes ),
64 Icon::get_element_image_hover_css( $attributes, 'Tablet' ),
65 Icon::get_element_image_hover_css( $attributes, 'Mobile' ),
66 );
67
68 return $css_generator->generate_css();
69 }
70
71 public function get_notice_header_css( $attributes, $device = '' ) {
72 $css = [];
73 if ( ! empty( $attributes['backgroundColor'] ) ) {
74 $css['background'] = $attributes['backgroundColor'];
75 }
76 return array_merge(
77 Dimensions::get_css( $attributes['noticeHeaderPadding'], 'padding', $device ),
78 $css
79 );
80 }
81
82 public function get_notice_header_title_css( $attributes, $device = '' ) {
83 $css = [];
84 if ( ! empty( $attributes['textColor'] ) ) {
85 $css['color'] = $attributes['textColor'];
86 }
87 return array_merge(
88 Alignment::get_css( $attributes['alignment'], 'justify-content', $device ),
89 Typography::get_css( $attributes['typography'], '', $device ),
90 TextShadow::get_css( $attributes['textShadow'], '', $device ),
91 TextStroke::get_css( $attributes['textStroke'], '', $device ),
92 $css,
93 );
94 }
95
96 }
97