1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

Dynamic primary color borders on e-mails

This commit is contained in:
Benjamin Beganović 2020-09-18 14:27:20 +02:00
parent 8d6b9ece92
commit 792f9717f7
3 changed files with 34 additions and 19 deletions

View File

@ -37,6 +37,8 @@ class TemplateEngine
private $settings_entity; private $settings_entity;
private $settings;
public function __construct($body, $subject, $entity, $entity_id, $template) public function __construct($body, $subject, $entity, $entity_id, $template)
{ {
$this->body = $body; $this->body = $body;
@ -77,8 +79,10 @@ class TemplateEngine
{ {
if ($this->entity_obj) { if ($this->entity_obj) {
$this->settings_entity = $this->entity_obj->client; $this->settings_entity = $this->entity_obj->client;
$this->settings = $this->settings_entity->getMergedSettings();
} else { } else {
$this->settings_entity = auth()->user()->company(); $this->settings_entity = auth()->user()->company();
$this->settings = $this->settings_entity->settings;
} }
return $this; return $this;
@ -168,6 +172,7 @@ class TemplateEngine
$data['body'] = '$body'; $data['body'] = '$body';
$data['footer'] = ''; $data['footer'] = '';
$data['signature'] = $this->settings_entity->getSetting('email_signature'); $data['signature'] = $this->settings_entity->getSetting('email_signature');
$data['settings'] = $this->settings;
if ($email_style == 'custom') { if ($email_style == 'custom') {
$wrapper = $this->settings_entity->getSetting('email_style_custom'); $wrapper = $this->settings_entity->getSetting('email_style_custom');

View File

@ -1,10 +1,10 @@
@component('email.template.master', ['design' => 'light']) @component('email.template.master', ['design' => 'light', 'settings' => $settings])
@slot('header') @slot('header')
@component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png']) @component('email.components.header', ['p' => $body, 'logo' => 'https://www.invoiceninja.com/wp-content/uploads/2019/01/InvoiceNinja-Logo-Round-300x300.png'])
@if(isset($title)) @if(isset($title))
{{$title}} {{$title}}
@endif @endif
@endcomponent @endcomponent

View File

@ -1,5 +1,5 @@
@php @php
if(!isset($design)) $design = 'light'; if(!isset($design)) $design = 'light';
@endphp @endphp
<!DOCTYPE html> <!DOCTYPE html>
@ -11,36 +11,46 @@
<title>@yield('title')</title> <title>@yield('title')</title>
</head> </head>
@if($design == 'dark') <style>
<style> :root {
* { --primary-color: {{ $settings->primary_color }};
color: #cbd5e0 !important; }
}
</style> .border-primary {
@endif border-color: var(--primary-color);
}
</style>
@if($design == 'dark')
<style>
* {
color: #cbd5e0 !important;
}
</style>
@endif
<body class="{{ $design == 'light' ? 'bg-gray-200' : 'bg-gray-800' }} my-10 font-sans {{ $design == 'light' ? 'text-gray-700' : 'text-gray-400' }}"> <body class="{{ $design == 'light' ? 'bg-gray-200' : 'bg-gray-800' }} my-10 font-sans {{ $design == 'light' ? 'text-gray-700' : 'text-gray-400' }}">
<div class="grid grid-cols-6"> <div class="grid grid-cols-6">
<div class="col-start-2 col-span-4"> <div class="col-span-4 col-start-2">
<div class="{{ $design == 'light' ? 'bg-white' : 'bg-gray-900' }} shadow border-t-2 {{ $design == 'light' ? 'border-green-500' : 'border-gray-800' }}"> <div class="{{ $design == 'light' ? 'bg-white' : 'bg-gray-900' }} shadow border-t-2 {{ $design == 'light' ? 'border-primary' : 'border-gray-800' }}">
<div class="px-10"> <div class="px-10">
{{ $header }} {{ $header }}
</div> </div>
<div id="text" class="px-10 py-6 flex flex-col"> <div id="text" class="flex flex-col px-10 py-6">
@isset($greeting) @isset($greeting)
{{ $greeting }} {{ $greeting }}
@endisset @endisset
{{ $slot }} {{ $slot }}
@isset($signature) @isset($signature)
{{ $signature }} {{ $signature }}
@endisset @endisset
</div> </div>
</div> </div>
@isset($below_card) @isset($below_card)
<div id="bottomText" class="text-center my-4 px-10"> <div id="bottomText" class="px-10 my-4 text-center">
{{ $below_card }} {{ $below_card }}
</div> </div>
@endisset @endisset