|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Divi\Modules\SiteReviewsForm; |
|
4
|
|
|
|
|
5
|
|
|
use ET\Builder\FrontEnd\Module\Style; |
|
6
|
|
|
use ET\Builder\Packages\Module\Options\Text\TextClassnames; |
|
7
|
|
|
use ET\Builder\Packages\StyleLibrary\Utils\StyleDeclarations; |
|
8
|
|
|
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract; |
|
9
|
|
|
use GeminiLabs\SiteReviews\Integrations\Divi\Defaults\ModuleClassnamesDefaults; |
|
10
|
|
|
use GeminiLabs\SiteReviews\Integrations\Divi\Defaults\ModuleStylesDefaults; |
|
11
|
|
|
use GeminiLabs\SiteReviews\Integrations\Divi\Modules\DiviModule; |
|
12
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsFormShortcode; |
|
13
|
|
|
|
|
14
|
|
|
class Module extends DiviModule |
|
15
|
|
|
{ |
|
16
|
|
|
public static function blockName(): string |
|
17
|
|
|
{ |
|
18
|
|
|
return 'glsr-divi/form'; |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* This method is equivalent to "module-styles.tsx". |
|
23
|
|
|
*/ |
|
24
|
|
|
public static function module_styles(array $args): void |
|
25
|
|
|
{ |
|
26
|
|
|
$args = glsr(ModuleStylesDefaults::class)->merge($args); |
|
27
|
|
|
$attrs = $args['attrs']; |
|
28
|
|
|
$baseSelector = '.et-db #page-container .et_pb_section'; |
|
29
|
|
|
$elements = $args['elements']; |
|
30
|
|
|
$orderClass = $args['orderClass']; |
|
31
|
|
|
$settings = $args['settings']; |
|
32
|
|
|
Style::add([ |
|
33
|
|
|
'id' => $args['id'], |
|
34
|
|
|
'name' => $args['name'], |
|
35
|
|
|
'orderIndex' => $args['orderIndex'], |
|
36
|
|
|
'storeInstance' => $args['storeInstance'], |
|
37
|
|
|
'styles' => [ |
|
38
|
|
|
$elements->style([ |
|
39
|
|
|
'attrName' => 'module', |
|
40
|
|
|
'styleProps' => [ |
|
41
|
|
|
'advancedStyles' => [ |
|
42
|
|
|
[ |
|
43
|
|
|
'componentName' => 'divi/common', |
|
44
|
|
|
'props' => [ |
|
45
|
|
|
'attr' => $attrs['module']['advanced']['text']['text'] ?? [], |
|
46
|
|
|
'declarationFunction' => static::orientationStyleDeclaration(), |
|
47
|
|
|
'selector' => implode(',', [ |
|
48
|
|
|
"{$baseSelector} {$orderClass} .glsr-field:not(.glsr-layout-inline) .glsr-field-subgroup > *", |
|
49
|
|
|
"{$baseSelector} {$orderClass} .glsr-layout-inline .glsr-field-subgroup", |
|
50
|
|
|
"{$baseSelector} {$orderClass} .glsr-range-options input:checked + label", |
|
51
|
|
|
"{$baseSelector} {$orderClass} .glsr-range-options:not(:has(input:checked))::after", |
|
52
|
|
|
"{$baseSelector} {$orderClass} .glsr-star-rating", |
|
53
|
|
|
]), |
|
54
|
|
|
], |
|
55
|
|
|
], |
|
56
|
|
|
[ |
|
57
|
|
|
'componentName' => 'divi/text', |
|
58
|
|
|
'props' => [ |
|
59
|
|
|
'attr' => $attrs['module']['advanced']['text'] ?? [], |
|
60
|
|
|
'propertySelectors' => [ |
|
61
|
|
|
'textShadow' => [ |
|
62
|
|
|
'desktop' => [ |
|
63
|
|
|
'value' => [ |
|
64
|
|
|
'text-shadow' => implode(',', [ |
|
65
|
|
|
"{$baseSelector} {$orderClass} .glsr-field", |
|
66
|
|
|
"{$baseSelector} {$orderClass} .glsr-input", |
|
67
|
|
|
"{$baseSelector} {$orderClass} .glsr-select", |
|
68
|
|
|
"{$baseSelector} {$orderClass} .glsr-textarea", |
|
69
|
|
|
]), |
|
70
|
|
|
], |
|
71
|
|
|
], |
|
72
|
|
|
], |
|
73
|
|
|
], |
|
74
|
|
|
], |
|
75
|
|
|
], |
|
76
|
|
|
], |
|
77
|
|
|
'defaultPrintedStyleAttrs' => $args['defaultPrintedStyleAttrs']['module']['decoration'] ?? [], |
|
78
|
|
|
'disabledOn' => [ |
|
79
|
|
|
'disabledModuleVisibility' => $settings['disabledModuleVisibility'] ?? null, |
|
80
|
|
|
], |
|
81
|
|
|
], |
|
82
|
|
|
]), |
|
83
|
|
|
$elements->style([ |
|
84
|
|
|
'attrName' => 'button', |
|
85
|
|
|
]), |
|
86
|
|
|
], |
|
87
|
|
|
]); |
|
88
|
|
|
} |
|
89
|
|
|
|
|
90
|
|
|
public static function shortcodeInstance(): ShortcodeContract |
|
91
|
|
|
{ |
|
92
|
|
|
static $shortcode; |
|
93
|
|
|
if (empty($shortcode)) { |
|
94
|
|
|
$shortcode = glsr(SiteReviewsFormShortcode::class); |
|
95
|
|
|
} |
|
96
|
|
|
return $shortcode; |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
protected static function orientationStyleDeclaration(): callable |
|
100
|
|
|
{ |
|
101
|
|
|
return static function (array $args): string { |
|
102
|
|
|
$orientation = $args['attrValue']['orientation'] ?? null; |
|
103
|
|
|
$declarations = new StyleDeclarations([ |
|
104
|
|
|
'important' => true, |
|
105
|
|
|
'returnType' => 'string', |
|
106
|
|
|
]); |
|
107
|
|
|
if ($orientation) { |
|
108
|
|
|
$declarations->add('display', 'flex'); |
|
109
|
|
|
$declarations->add('justify-content', $orientation); |
|
110
|
|
|
} |
|
111
|
|
|
return $declarations->value(); |
|
112
|
|
|
}; |
|
113
|
|
|
} |
|
114
|
|
|
} |
|
115
|
|
|
|