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

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

108 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\FormPassword;
3
4 use ABlocks\Controls\Dimensions;
5 use ABlocks\Controls\Border;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit;
9 }
10
11 use ABlocks\Classes\BlockBaseAbstract;
12 use ABlocks\Classes\CssGenerator;
13
14 class Block extends BlockBaseAbstract {
15 protected $parent_block_name = 'form-builder';
16 protected $block_name = 'form-password';
17
18 public function build_css( $attributes ) {
19 $css_generator = new CssGenerator( $attributes );
20 $css_generator->add_class_styles(
21 '{{WRAPPER}}',
22 $this->get_wrapper_css( $attributes ),
23 $this->get_wrapper_css( $attributes, 'Tablet' ),
24 $this->get_wrapper_css( $attributes, 'Mobile' )
25 );
26 $css_generator->add_class_styles(
27 '{{WRAPPER}}.ablocks-block--form-password',
28 $this->get_input_block_main_wrapper( $attributes ),
29 $this->get_input_block_main_wrapper( $attributes, 'Tablet' ),
30 $this->get_input_block_main_wrapper( $attributes, 'Mobile' ),
31 );
32
33 // Generate button icon CSS start
34 $css_generator->add_class_styles(
35 '{{WRAPPER}} .ablocks-form-builder__input-icon .ablocks-icon-wrap',
36 $this->get_icon_wrapper_css( $attributes ),
37 $this->get_icon_wrapper_css( $attributes, 'Tablet' ),
38 $this->get_icon_wrapper_css( $attributes, 'Mobile' )
39 );
40
41 $css_generator->add_class_styles(
42 '{{WRAPPER}} .ablocks-form-builder__input-show-icon',
43 $this->get_icon_space_css( $attributes ),
44 $this->get_icon_space_css( $attributes, 'Tablet' ),
45 $this->get_icon_space_css( $attributes, 'Mobile' )
46 );
47 $css_generator->add_class_styles(
48 '{{WRAPPER}} .ablocks-form-builder__input-toggle-password .ablocks-icon-wrap ',
49 $this->get_password_show_hide_icon_wrapper_css( $attributes )
50 );
51 return $css_generator->generate_css();
52 }
53
54 public function get_wrapper_css() {
55 // phpcs:ignore Squiz.PHP.NonExecutableCode.ReturnNotRequired
56 return;
57 }
58 public function get_input_block_main_wrapper( $attributes, $device = '' ) {
59 $css = [];
60 $css['display'] = 'inline-block';
61 $css['box-sizing'] = 'border-box';
62 $css['padding'] = '0px 2px';
63 if ( isset( $attributes['inputWidth'] ) ) {
64 $css['width'] = ( $attributes['inputWidth'] - 1 ) . '%';
65 }
66
67 return $css;
68 }
69 public function get_icon_wrapper_css( $attributes, $device = '' ) {
70 $css = [];
71
72 // Check for 'inputIconSize' in the attributes and set font-size
73 if ( isset( $attributes['inputIconSize'] ) ) {
74 $css['font-size'] = $attributes['inputIconSize'] . 'px';
75 }
76
77 // Check for 'iconColor' in the attributes and set fill color
78 if ( isset( $attributes['iconColor'] ) ) {
79 $css['fill'] = $attributes['iconColor'];
80 }
81
82 return $css;
83 }
84 public function get_icon_space_css( $attributes, $device = '' ) {
85 $css = [];
86
87 // Check for 'inputIconSpace' in the attributes and set padding-left
88 if ( isset( $attributes['inputIconSpace'] ) ) {
89 $css['padding-left'] = $attributes['inputIconSpace'] . 'px';
90 }
91
92 return $css;
93 }
94 public function get_password_show_hide_icon_wrapper_css( $attributes ) {
95 $password_show_hide_icon_wrapper_css = [];
96
97 if ( isset( $attributes['passwordShowHideIconSize'] ) ) {
98 $password_show_hide_icon_wrapper_css['font-size'] = $attributes['passwordShowHideIconSize'] . 'px';
99 }
100
101 if ( ! empty( $attributes['passwordIconColor'] ) ) {
102 $password_show_hide_icon_wrapper_css['fill'] = $attributes['passwordIconColor'];
103 }
104
105 return $password_show_hide_icon_wrapper_css;
106 }
107 }
108