PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.9.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.9.0
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 / flip-box / block.php

block.php in aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder 2.9.0, at includes/blocks/flip-box/block.php

133 lines 4.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ABlocks\Blocks\FlipBox;
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 use ABlocks\Classes\BlockBaseAbstract;
9 use ABlocks\Classes\CssGenerator;
10 use ABlocks\Controls\Background;
11 use ABlocks\Controls\Border;
12 use ABlocks\Controls\Dimensions;
13 use ABlocks\Controls\Range;
14
15
16 class Block extends BlockBaseAbstract {
17 protected $block_name = 'flip-box';
18
19 // No Dom optimization needed
20 public function build_css( $attributes ) {
21
22 // Generate CSS start
23 $css_generator = new CssGenerator( $attributes );
24
25 $css_generator->add_class_styles(
26 '{{WRAPPER}} .ablocks-block-container:first-child',
27 $this->get_flipbox_wrapper_css( $attributes )
28 );
29
30 $css_generator->add_class_styles(
31 '{{WRAPPER}} .ablocks-flipbox__front > div:nth-child(1)',
32 $this->get_front_card_css( $attributes ),
33 $this->get_front_card_css( $attributes, 'Tablet' ),
34 $this->get_front_card_css( $attributes, 'Mobile' )
35 );
36
37 $css_generator->add_class_styles(
38 '{{WRAPPER}} .ablocks-flipbox__back > div:nth-child(1)',
39 $this->get_back_card_css( $attributes ),
40 $this->get_back_card_css( $attributes, 'Tablet' ),
41 $this->get_back_card_css( $attributes, 'Mobile' )
42 );
43
44 $css_generator->add_class_styles(
45 '{{WRAPPER}} .ablocks-flipbox__front:hover > div:nth-child(1)',
46 $this->get_front_card_hover_css( $attributes ),
47 $this->get_front_card_hover_css( $attributes, 'Tablet' ),
48 $this->get_front_card_hover_css( $attributes, 'Mobile' )
49 );
50
51 $css_generator->add_class_styles(
52 '{{WRAPPER}} .ablocks-flipbox__back:hover > div:nth-child(1)',
53 $this->get_back_card_hover_css( $attributes ),
54 $this->get_back_card_hover_css( $attributes, 'Tablet' ),
55 $this->get_back_card_hover_css( $attributes, 'Mobile' )
56 );
57
58 return $css_generator->generate_css();
59 }
60
61 public function get_flipbox_wrapper_css( $attributes ) {
62
63 return (
64 Range::get_css([
65 'attributeValue' => $attributes['transitionSpeed'],
66 'attribute_object_key' => 'value',
67 'defaultValue' => 0.6,
68 'unitDefaultValue' => 's',
69 'property' => 'transition',
70 ])
71 );
72 }
73
74 public function get_front_card_css( $attributes, $device = '' ) {
75 $css = [];
76 $css = array_merge(
77 Background::get_css( $attributes['frontCardBackground'], 'background', $device ),
78 Dimensions::get_css( $attributes['frontPadding'], 'padding', $device ),
79 Border::get_css( $attributes['cardBorder'], $device )
80 );
81
82 return $css;
83 }
84
85 public function get_back_card_css( $attributes, $device = '' ) {
86 $css = [];
87 $css = array_merge(
88 Background::get_css( $attributes['backCardBackground'], 'background', $device ),
89 Dimensions::get_css( $attributes['backPadding'], 'padding', $device ),
90 Border::get_css( $attributes['cardBorder'], $device )
91 );
92
93 return $css;
94 }
95
96 public function get_front_card_hover_css( $attributes, $device = '' ) {
97 $css = [];
98 $css = array_merge(
99 Background::get_hover_css( $attributes['frontCardBackground'], 'background', $device ),
100 Dimensions::get_css( $attributes['frontPadding'], 'padding', $device ),
101 Border::get_hover_css( $attributes['cardBorder'], $device )
102 );
103
104 return $css;
105 }
106
107 public function get_back_card_hover_css( $attributes, $device = '' ) {
108 $css = [];
109 $css = array_merge(
110 Background::get_hover_css( $attributes['backCardBackground'], 'background', $device ),
111 Dimensions::get_css( $attributes['backPadding'], 'padding', $device ),
112 Border::get_hover_css( $attributes['cardBorder'], $device )
113 );
114
115 return $css;
116 }
117
118 public function get_card_height_css( $attributes, $device = '' ) {
119 $css = [];
120 // find max height of front and back card
121 $front_height = isset( $attributes['frontPadding']['padding']['top'] ) ? $attributes['frontPadding']['padding']['top'] : 0;
122 $front_height += isset( $attributes['frontPadding']['padding']['bottom'] ) ? $attributes['frontPadding']['padding']['bottom'] : 0;
123 $back_height = isset( $attributes['backPadding']['padding']['top'] ) ? $attributes['backPadding']['padding']['top'] : 0;
124 $back_height += isset( $attributes['backPadding']['padding']['bottom'] ) ? $attributes['backPadding']['padding']['bottom'] : 0;
125 $max_height = max( $front_height, $back_height );
126
127 $css['height'] = $max_height . 'px';
128
129 return $css;
130 }
131
132 }
133