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

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

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