-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBannerLayout.php
More file actions
90 lines (85 loc) · 3.28 KB
/
BannerLayout.php
File metadata and controls
90 lines (85 loc) · 3.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace MatchBot\Domain;
use Laminas\Diactoros\Uri;
use OpenApi\Attributes as OA;
use Psr\Http\Message\UriInterface;
/**
* Details of how the banner should be layed out for a given meta-campaign. Only includes details that
* we don't already have in SF, as initially will be hard-coded.
*/
#[OA\Schema(description: "Banner layout configuration for campaign display")]
readonly class BannerLayout implements \JsonSerializable
{
#[OA\Property(
property: "imageUri",
description: "URI for the banner image",
type: "string",
format: "uri",
example: "https://example.com/banner.jpg"
)]
public ?UriInterface $imageUri;
public function __construct(
#[OA\Property(
property: "backgroundColour",
description: "Background color shown during loading or if image fails to load. Should be similar to the image color.",
ref: "#/components/schemas/Colour"
)]
/**
* Only shown during loading and/or if an image fails to load - behind the image.
* Should therefore be a similar colour to most of the image.
*/
public Colour $backgroundColour,
#[OA\Property(
property: "textBackgroundColour",
description: "Color for the text background, should contrast with the image",
ref: "#/components/schemas/Colour"
)]
/**
* Should contrast with the image
*/
public Colour $textBackgroundColour,
#[OA\Property(
property: "textColour",
description: "Color for the text, should contrast with the text background (typically black or white)",
ref: "#/components/schemas/Colour"
)]
/**
* Should contrast with the text background - typically expected to be black or white
*/
public Colour $textColour,
#[OA\Property(
property: "focalArea",
description: "Box that indicates the position of any image subject, to be preserved in crops",
ref: "#/components/schemas/FocalAreaBox"
)]
/**
* Box that indicates the position of any image subject, to be preserved in crops.
*/
public FocalAreaBox $focalArea,
/**
* Optional - if given overrides the image chosen in SF for this campaign. May be needed here
* to allow changing the image and the text colour at the same moment to make sure we always maintain
* readability.
*/
?string $imageUri = null,
) {
$this->imageUri = $imageUri === null ? null : new Uri($imageUri);
}
/**
* @return array<string, array<string, int>|string>
*/
#[\Override] public function jsonSerialize(): array
{
return [
'backgroundColour' => $this->backgroundColour->toHex(),
'textBackgroundColour' => $this->textBackgroundColour->toHex(),
'textColour' => $this->textColour->toHex(),
'focalArea' => [
'topLeftXpos' => $this->focalArea->topLeftXpos,
'topLeftYpos' => $this->focalArea->topLeftYpos,
'bottomRightXpos' => $this->focalArea->bottomRightXpos,
'bottomRightYpos' => $this->focalArea->bottomRightYpos,
],
];
}
}