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