PluginProbe
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder / 2.14.0
aBlocks – Gutenberg Blocks, User Dashboard Builder, Popup Builder, Form Builder & Animation Builder v2.14.0
2.14.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 All 81 releases
← All changes | includes/blocks/flip-box/block.php +136 -0 2.7.5 → 2.14.0 View file →
@@ -1,0 +1,136 @@
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 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_front_card_css( $attributes, $device ); } )
36 + );
37 +
38 + $css_generator->add_class_styles(
39 + '{{WRAPPER}} .ablocks-flipbox__back > div:nth-child(1)',
40 + $this->get_back_card_css( $attributes ),
41 + $this->get_back_card_css( $attributes, 'Tablet' ),
42 + $this->get_back_card_css( $attributes, 'Mobile' ),
43 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_back_card_css( $attributes, $device ); } )
44 + );
45 +
46 + $css_generator->add_class_styles(
47 + '{{WRAPPER}} .ablocks-flipbox__front:hover > div:nth-child(1)',
48 + $this->get_front_card_hover_css( $attributes ),
49 + $this->get_front_card_hover_css( $attributes, 'Tablet' ),
50 + $this->get_front_card_hover_css( $attributes, 'Mobile' ),
51 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_front_card_hover_css( $attributes, $device ); } )
52 + );
53 +
54 + $css_generator->add_class_styles(
55 + '{{WRAPPER}} .ablocks-flipbox__back:hover > div:nth-child(1)',
56 + $this->get_back_card_hover_css( $attributes ),
57 + $this->get_back_card_hover_css( $attributes, 'Tablet' ),
58 + $this->get_back_card_hover_css( $attributes, 'Mobile' ),
59 + $css_generator->custom_device_map( function ( $device ) use ( $attributes ) { return $this->get_back_card_hover_css( $attributes, $device ); } )
60 + );
61 +
62 + return $css_generator->generate_css();
63 + }
64 +
65 + public function get_flipbox_wrapper_css( $attributes ) {
66 +
67 + return (
68 + Range::get_css([
69 + 'attributeValue' => $attributes['transitionSpeed'],
70 + 'attribute_object_key' => 'value',
71 + 'defaultValue' => 0.6,
72 + 'unitDefaultValue' => 's',
73 + 'property' => 'transition',
74 + ])
75 + );
76 + }
77 +
78 + public function get_front_card_css( $attributes, $device = '' ) {
79 + $css = [];
80 + $css = array_merge(
81 + Background::get_css( $attributes['frontCardBackground'], 'background', $device ),
82 + Dimensions::get_css( $attributes['frontPadding'], 'padding', $device ),
83 + Border::get_css( $attributes['cardBorder'], $device )
84 + );
85 +
86 + return $css;
87 + }
88 +
89 + public function get_back_card_css( $attributes, $device = '' ) {
90 + $css = [];
91 + $css = array_merge(
92 + Background::get_css( $attributes['backCardBackground'], 'background', $device ),
93 + Dimensions::get_css( $attributes['backPadding'], 'padding', $device ),
94 + Border::get_css( $attributes['cardBorder'], $device )
95 + );
96 +
97 + return $css;
98 + }
99 +
100 + public function get_front_card_hover_css( $attributes, $device = '' ) {
101 + $css = [];
102 + $css = array_merge(
103 + Background::get_hover_css( $attributes['frontCardBackground'], 'background', $device ),
104 + Dimensions::get_css( $attributes['frontPadding'], 'padding', $device ),
105 + Border::get_hover_css( $attributes['cardBorder'], $device )
106 + );
107 +
108 + return $css;
109 + }
110 +
111 + public function get_back_card_hover_css( $attributes, $device = '' ) {
112 + $css = [];
113 + $css = array_merge(
114 + Background::get_hover_css( $attributes['backCardBackground'], 'background', $device ),
115 + Dimensions::get_css( $attributes['backPadding'], 'padding', $device ),
116 + Border::get_hover_css( $attributes['cardBorder'], $device )
117 + );
118 +
119 + return $css;
120 + }
121 +
122 + public function get_card_height_css( $attributes, $device = '' ) {
123 + $css = [];
124 + // find max height of front and back card
125 + $front_height = isset( $attributes['frontPadding']['padding']['top'] ) ? $attributes['frontPadding']['padding']['top'] : 0;
126 + $front_height += isset( $attributes['frontPadding']['padding']['bottom'] ) ? $attributes['frontPadding']['padding']['bottom'] : 0;
127 + $back_height = isset( $attributes['backPadding']['padding']['top'] ) ? $attributes['backPadding']['padding']['top'] : 0;
128 + $back_height += isset( $attributes['backPadding']['padding']['bottom'] ) ? $attributes['backPadding']['padding']['bottom'] : 0;
129 + $max_height = max( $front_height, $back_height );
130 +
131 + $css['height'] = $max_height . 'px';
132 +
133 + return $css;
134 + }
135 +
136 +}