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

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

57 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\DualButton;
3
4 use ABlocks\Classes\BlockBaseAbstract;
5 use ABlocks\Controls\Alignment;
6 use ABlocks\Classes\CssGenerator;
7 use ABlocks\Controls\Range;
8
9
10 class Block extends BlockBaseAbstract {
11 protected $block_name = 'dual-button';
12
13 public function build_css( $attributes ) {
14
15 $css_generator = new CssGenerator( $attributes, $this->block_name );
16
17 $css_generator->add_class_styles(
18 '{{WRAPPER}}.ablocks-block--dual-button > .ablocks-block-container',
19 $this->getDualButtonCss( $attributes ),
20 $this->getDualButtonCss( $attributes, 'Tablet' ),
21 $this->getDualButtonCss( $attributes, 'Mobile' )
22 );
23
24 return $css_generator->generate_css();
25 }
26
27 public function getDualButtonCss( $attributes, $device = '' ) {
28 $css = [];
29 $stack = isset( $attributes['stack'] ) ? $attributes['stack'] : '';
30
31 $css['flex-wrap'] = 'wrap';
32 if ( $stack === 'vertical' ) {
33 $css['flex-direction'] = 'column';
34 $css['display'] = 'flex';
35 }
36
37 if ( $stack === 'horizontal' ) {
38 $css['flex-direction'] = 'row';
39 $css['display'] = 'flex';
40 }
41 return array_merge(
42 Range::get_css([
43 'attributeValue' => $attributes['gap'],
44 'attribute_object_key' => 'value',
45 'isResponsive' => true,
46 'defaultValue' => 20,
47 'hasUnit' => true,
48 'unitDefaultValue' => 'px',
49 'property' => 'gap',
50 'device' => $device,
51 ]),
52 $css,
53 isset( $attributes['alignment'] ) ? Alignment::get_css( $attributes['alignment'], $attributes['stack'] === 'horizontal' ? 'justify-content' : 'align-items', $device ) : [],
54 );
55 }
56 }
57