|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Integrations\Gutenberg\Blocks; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Shortcodes\SiteReviewsSummaryShortcode; |
|
6
|
|
|
|
|
7
|
|
|
class SiteReviewsSummaryBlock extends Block |
|
8
|
|
|
{ |
|
9
|
|
|
public static function shortcodeClass(): string |
|
10
|
|
|
{ |
|
11
|
|
|
return SiteReviewsSummaryShortcode::class; |
|
12
|
|
|
} |
|
13
|
|
|
|
|
14
|
|
|
protected function blockClassAttr(array $attributes): string |
|
15
|
|
|
{ |
|
16
|
|
|
$attr = []; |
|
17
|
|
|
if (!empty($attributes['styleAlign'])) { |
|
18
|
|
|
$attr[] = "items-justified-{$attributes['styleAlign']}"; |
|
19
|
|
|
} |
|
20
|
|
|
if (!empty($attributes['styleRatingColor']) || !empty($attributes['styleRatingColorCustom'])) { |
|
21
|
|
|
$attr[] = 'has-custom-color'; |
|
22
|
|
|
} |
|
23
|
|
|
return implode(' ', $attr); |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
protected function blockStyleAttr(array $attributes): string |
|
27
|
|
|
{ |
|
28
|
|
|
$attr = []; |
|
29
|
|
|
if (!empty($attributes['styleRatingColor'])) { |
|
30
|
|
|
$attr[] = "--glsr-bar-bg: var(--wp--preset--color--{$attributes['styleRatingColor']});"; |
|
31
|
|
|
$attr[] = '--glsr-summary-star-bg: var(--glsr-bar-bg);'; |
|
32
|
|
|
} elseif (!empty($attributes['styleRatingColorCustom'])) { |
|
33
|
|
|
$attr[] = "--glsr-bar-bg: {$attributes['styleRatingColorCustom']};"; |
|
34
|
|
|
$attr[] = '--glsr-summary-star-bg: var(--glsr-bar-bg);'; |
|
35
|
|
|
} |
|
36
|
|
|
if (!empty($attributes['styleBarSize'])) { |
|
37
|
|
|
$attr[] = "--glsr-bar-size: {$attributes['styleBarSize']};"; |
|
38
|
|
|
} |
|
39
|
|
|
if (!empty($attributes['styleBarSpacing'])) { |
|
40
|
|
|
$attr[] = "--glsr-bar-spacing: {$attributes['styleBarSpacing']};"; |
|
41
|
|
|
} |
|
42
|
|
|
if (!empty($attributes['styleStarSize'])) { |
|
43
|
|
|
$attr[] = "--glsr-summary-star: {$attributes['styleStarSize']};"; |
|
44
|
|
|
} |
|
45
|
|
|
if (!empty($attributes['styleMaxWidth'])) { |
|
46
|
|
|
$attr[] = "--glsr-max-w: {$attributes['styleMaxWidth']};"; |
|
47
|
|
|
} else { |
|
48
|
|
|
$attr[] = "--glsr-max-w: none"; |
|
49
|
|
|
} |
|
50
|
|
|
return implode('', $attr); |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|