-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMetaCampaignLayoutChoices.php
More file actions
70 lines (66 loc) · 3.71 KB
/
Copy pathMetaCampaignLayoutChoices.php
File metadata and controls
70 lines (66 loc) · 3.71 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
<?php
namespace MatchBot\Domain;
class MetaCampaignLayoutChoices
{
/**
* Returns a hard-coded banner layout appropriate for the given meta-campaign slug. For now
* hard-coded, but in future all these details may become a property of a meta-campaign entered in SF and stored
* in the DB.
*
* Hex colours should generally match those defined at link below. This is not automatically enforced.
* https://github.com/thebiggive/components/blob/main/src/globals/variables.scss
*
* For now all image files are just examples for testing - this is not yet used in production.
*/
public static function forSlug(MetaCampaign $metaCampaign): ?BannerLayout
{
// It may be that we don't ever need to set a specific different focal area for each campaign,
// so sharing one object here. If confirmed we can delete this class.
$focalArea = new FocalAreaBox();
$campaignBannerUriFromSF = $metaCampaign->getBannerUri();
return match ($metaCampaign->getSlug()->slug) {
'local-test' => new BannerLayout(
backgroundColour: Colour::fromHex('#F6F6F6'),
textBackgroundColour: Colour::fromHex('#FFE500'),
textColour: Colour::black(),
focalArea: $focalArea,
imageUri: 'https://picsum.photos/id/88/1700/500',
),
default => new BannerLayout(
backgroundColour: \is_null($campaignBannerUriFromSF) ? Colour::fromHex('#2C089B') : Colour::fromHex('#F6F6F6'),
textBackgroundColour: match ($metaCampaign->getFamily()) {
// colours taken from variables.scss at https://github.com/thebiggive/components/blob/c096dcaa499ece7080a363d4157bc2e1cd1c5c92/src/globals/variables.scss#L17
CampaignFamily::christmasChallenge => Colour::fromHex('#B30510'),
CampaignFamily::greenMatchFund => Colour::fromHex('#50B400'),
CampaignFamily::summerGive => Colour::fromHex('#F07D00'),
CampaignFamily::womenGirls => Colour::fromHex('#6E0887'),
CampaignFamily::artsforImpact => Colour::fromHex('#BF387D'),
CampaignFamily::smallCharity => Colour::fromHex('#EE2C65'),
CampaignFamily::emergencyMatch => Colour::fromHex('#FFE500'),
CampaignFamily::mentalHealthFund => Colour::fromHex('#62CFC9'),
CampaignFamily::multiCurrency => Colour::fromHex('#2C089B'),
CampaignFamily::imf => Colour::fromHex('#2C089B'),
CampaignFamily::regularGiving => Colour::fromHex('#2C089B'),
null => Colour::fromHex('#2C089B'),
},
textColour: match ($metaCampaign->getFamily()) {
// all white or black, chosen to contrast with colours above.
CampaignFamily::christmasChallenge => Colour::white(),
CampaignFamily::greenMatchFund => Colour::white(),
CampaignFamily::summerGive => Colour::black(),
CampaignFamily::womenGirls => Colour::white(),
CampaignFamily::artsforImpact => Colour::white(),
CampaignFamily::smallCharity => Colour::white(),
CampaignFamily::emergencyMatch => Colour::black(),
CampaignFamily::mentalHealthFund => Colour::black(),
CampaignFamily::multiCurrency => Colour::white(),
CampaignFamily::imf => Colour::white(),
CampaignFamily::regularGiving => Colour::white(),
null => Colour::white(),
},
focalArea: $focalArea,
imageUri: $campaignBannerUriFromSF?->__toString(),
),
};
}
}