1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Breakdance; |
4
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Contracts\ShortcodeContract; |
6
|
|
|
use GeminiLabs\SiteReviews\Helpers\Arr; |
7
|
|
|
use GeminiLabs\SiteReviews\Helpers\Str; |
8
|
|
|
|
9
|
|
|
trait ElementTrait |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @return array |
13
|
|
|
*/ |
14
|
|
|
public static function actions() |
15
|
|
|
{ |
16
|
|
|
return glsr()->filterArray('breakdance/element/actions', static::bdActions(), static::bdShortcode()->tag); |
|
|
|
|
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @return array |
21
|
|
|
*/ |
22
|
|
|
public static function badge() |
23
|
|
|
{ |
24
|
|
|
return [ |
25
|
|
|
'backgroundColor' => '', |
26
|
|
|
'label' => ' ', // empty because we use this to display an icon |
27
|
|
|
'textColor' => '', |
28
|
|
|
]; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public static function bdActions(): array |
32
|
|
|
{ |
33
|
|
|
return [ |
34
|
|
|
'onMountedElement' => [[ |
35
|
|
|
'script' => 'GLSR_init();', |
36
|
|
|
]], |
37
|
|
|
// 'onPropertyChange' => [[ |
38
|
|
|
// 'script' => 'GLSR_init();', |
39
|
|
|
// ]], |
40
|
|
|
]; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
public static function bdDependencies(): array |
44
|
|
|
{ |
45
|
|
|
return [ |
46
|
|
|
[ |
47
|
|
|
'builderCondition' => 'return true;', |
48
|
|
|
'frontendCondition' => 'return false;', |
49
|
|
|
'inlineStyles' => [ |
50
|
|
|
'%%SELECTOR%% a, %%SELECTOR%% button {pointer-events: none}', |
51
|
|
|
], |
52
|
|
|
], |
53
|
|
|
]; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
abstract public static function bdShortcode(): ShortcodeContract; |
57
|
|
|
|
58
|
|
|
abstract public static function bdShortcodeClass(): string; |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @return string |
62
|
|
|
*/ |
63
|
|
|
public static function category() |
64
|
|
|
{ |
65
|
|
|
return glsr()->id; |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
static function className() |
|
|
|
|
69
|
|
|
{ |
70
|
|
|
return 'breakdance-'.Str::dashCase(static::bdShortcode()->tag); |
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
public static function dependencies() |
74
|
|
|
{ |
75
|
|
|
return glsr()->filterArray('breakdance/element/dependencies', static::bdDependencies(), static::bdShortcode()->tag); |
|
|
|
|
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @return string |
80
|
|
|
*/ |
81
|
|
|
public static function name() |
82
|
|
|
{ |
83
|
|
|
return static::bdShortcode()->name(); |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
/** |
87
|
|
|
* @return array |
88
|
|
|
*/ |
89
|
|
|
public static function nestingRule() |
90
|
|
|
{ |
91
|
|
|
return [ |
92
|
|
|
'type' => 'final', |
93
|
|
|
]; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string[] |
98
|
|
|
*/ |
99
|
|
|
public static function propertyPathsToSsrElementWhenValueChanges() |
100
|
|
|
{ |
101
|
|
|
return [ |
102
|
|
|
'content', |
103
|
|
|
// 'design', |
104
|
|
|
]; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
/** |
108
|
|
|
* @return array |
109
|
|
|
*/ |
110
|
|
|
public static function settings() |
111
|
|
|
{ |
112
|
|
|
return [ |
113
|
|
|
'bypassPointerEvents' => true, |
114
|
|
|
'disableAI' => true, |
115
|
|
|
]; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* @return array[] |
120
|
|
|
*/ |
121
|
|
|
public static function settingsControls() |
122
|
|
|
{ |
123
|
|
|
return []; |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
/** |
127
|
|
|
* @param mixed $propertiesData |
128
|
|
|
* @param mixed $parentPropertiesData |
129
|
|
|
* @param bool $isBuilder |
130
|
|
|
* @param int $repeaterItemNodeId |
131
|
|
|
* |
132
|
|
|
* @return string |
133
|
|
|
*/ |
134
|
|
|
public static function ssr($propertiesData, $parentPropertiesData = [], $isBuilder = false, $repeaterItemNodeId = null) |
|
|
|
|
135
|
|
|
{ |
136
|
|
|
$args = static::ssrArgs(Arr::consolidate($propertiesData)); |
137
|
|
|
return static::bdShortcode()->build($args, 'breakdance', false); |
138
|
|
|
} |
139
|
|
|
|
140
|
|
|
abstract public static function ssrArgs(array $propertiesData): array; |
141
|
|
|
|
142
|
|
|
/** |
143
|
|
|
* @return string |
144
|
|
|
*/ |
145
|
|
|
public static function slug() |
146
|
|
|
{ |
147
|
|
|
return __CLASS__; |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
/** |
151
|
|
|
* @return string |
152
|
|
|
*/ |
153
|
|
|
public static function template() |
154
|
|
|
{ |
155
|
|
|
return '%%SSR%%'; |
156
|
|
|
} |
157
|
|
|
} |
158
|
|
|
|