Skip to content

Commit

Permalink
feat: Use Twig global for main_color variable
Browse files Browse the repository at this point in the history
  • Loading branch information
roadiz-ci committed Aug 29, 2024
1 parent cf20871 commit 44384f8
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/Controller/CustomFormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ private function prepareAndHandleCustomFormAssignation(
'fields' => $customFormsEntity->getFields(),
'head' => [
'siteTitle' => $this->settingsBag->get('site_name'),
'mainColor' => $this->settingsBag->get('main_color'),
]
];
$helper = $this->customFormHelperFactory->createHelper($customFormsEntity);
Expand Down
7 changes: 1 addition & 6 deletions src/Mailer/EmailManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,17 +113,12 @@ public function renderPlainTextEmailBody(): string
}

/**
* Added mainColor and headerImageSrc assignation
* to display email header.
* Added headerImageSrc assignation to display email header.
*
* @return $this
*/
public function appendWebsiteIcon(): static
{
if (empty($this->assignation['mainColor']) && null !== $this->settingsBag) {
$this->assignation['mainColor'] = $this->settingsBag->get('main_color');
}

if (empty($this->assignation['headerImageSrc']) && null !== $this->settingsBag) {
$adminImage = $this->settingsBag->getDocument('admin_image');
if ($adminImage instanceof DocumentInterface && null !== $this->documentUrlGenerator) {
Expand Down
1 change: 1 addition & 0 deletions src/TwigExtension/RoadizExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function getGlobals(): array
'nodeTypes' => $this->nodeTypesBag,
],
'chroot_resolver' => $this->chrootResolver,
'main_color' => $this->settingsBag->get('main_color'),
'meta' => [
'siteName' => $this->settingsBag->get('site_name'),
'siteCopyright' => $this->settingsBag->get('site_copyright'),
Expand Down
4 changes: 2 additions & 2 deletions templates/customForm/base_custom_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
{% include '@RoadizRozier/admin/meta-icon.html.twig' %}
{# CSS scripts inclusions / Using webpack #}
{% include '@RoadizRozier/partials/css-inject.html.twig' %}
{% if head.mainColor %}
{% if main_color %}
<style>
:root {
--rz-accent-color: {{ head.mainColor|raw }};
--rz-accent-color: {{ main_color|raw }};
--rz-accent-color-lighter: color-mix(in srgb, var(--rz-accent-color) var(--color-light-mix), white);
--rz-accent-color-darker: color-mix(in srgb, var(--rz-accent-color) var(--color-darker-mix), black);
--rz-accent-color-darkest: color-mix(in srgb, var(--rz-accent-color) var(--color-darkest-mix), black);
Expand Down
2 changes: 1 addition & 1 deletion templates/email/base_email.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<table class="main" width="100%" cellpadding="0" cellspacing="0">
{% if headerImageSrc is defined %}
<tr>
<td class="header-image-wrap aligncenter"{% if mainColor is defined %}style="background-color: {{ mainColor }};"{% endif %}>
<td class="header-image-wrap aligncenter"{% if main_color is defined %}style="background-color: {{ main_color }};"{% endif %}>
<img class="header-image" src="{{ headerImageSrc }}" alt="{{ title }}" />
</td>
</tr>
Expand Down

0 comments on commit 44384f8

Please sign in to comment.