Skip to content

Commit

Permalink
feat(email): use multiple colors when sending multiple quotes
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineAugusti committed May 16, 2015
1 parent 8528889 commit 5ded35e
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 13 deletions.
28 changes: 28 additions & 0 deletions app/TeenQuotes/Mail/Composers/IndexQuotesComposer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace TeenQuotes\Mail\Composers;

use TeenQuotes\Tools\Colors\ColorGeneratorInterface;

class IndexQuotesComposer
{
/**
* @var ColorGeneratorInterface
*/
private $colorGenerator;

public function __construct(ColorGeneratorInterface $colorGenerator)
{
$this->colorGenerator = $colorGenerator;
}

/**
* Add data to the view.
*
* @param \Illuminate\View\View $view
*/
public function compose($view)
{
$view->with('colorGenerator', $this->colorGenerator);
}
}
5 changes: 5 additions & 0 deletions app/TeenQuotes/Mail/MailServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,10 @@ private function registerViewComposers()
$this->app['view']->composer([
'emails.welcome',
], 'TeenQuotes\Mail\Composers\WelcomeViewComposer');

// When listing multiple quotes
$this->app['view']->composer([
'emails.quotes.multiple',
], 'TeenQuotes\Mail\Composers\IndexQuotesComposer');
}
}
5 changes: 4 additions & 1 deletion ressources/views/emails/layout/html/style.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@
#container #body-content .quote {
background-color: #27AE60;
color: #FFFFFF;
border-bottom-width: 2px;
border-bottom-style: solid;
border-bottom-color: #27AE60;
padding: 10px 10px 15px 10px;
margin: 25px 15px 25px 15px;
}
Expand Down Expand Up @@ -77,4 +80,4 @@
#footer-disclaimer {
font-size: 90%;
}
</style>
</style>
8 changes: 3 additions & 5 deletions ressources/views/emails/newsletters/daily.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
{{ Lang::get('email.hiWithLogin', ['login' => '*|LOGIN|*']) }}
<br/><br/>
{{ Lang::get('newsletters.someQuotesPublishedToday') }}

@foreach ($quotes as $quote)
@include('emails.quotes.single', compact('quote'))
@endforeach

@include('emails.quotes.multiple', compact('quotes'))

{{ Lang::get('newsletters.otherQuotesToRead', ['login' => '*|LOGIN|*']) }}
@stop

<!-- Link to edit email settings -->
@include('emails.newsletters.editSettings', ['login' => '*|LOGIN|*'])
@include('emails.newsletters.editSettings', ['login' => '*|LOGIN|*'])
8 changes: 3 additions & 5 deletions ressources/views/emails/newsletters/weekly.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
{{ Lang::get('email.hiWithLogin', ['login' => '*|LOGIN|*']) }}
<br/><br/>
{{ Lang::get('newsletters.beenWaitingForLong') }}

@foreach ($quotes as $quote)
@include('emails.quotes.single', compact('quote'))
@endforeach

@include('emails.quotes.multiple', compact('quotes'))

{{ Lang::get('newsletters.callToVisitWebsite') }}
@stop

<!-- Link to edit email settings -->
@include('emails.newsletters.editSettings', ['login' => '*|LOGIN|*'])
@include('emails.newsletters.editSettings', ['login' => '*|LOGIN|*'])
3 changes: 3 additions & 0 deletions ressources/views/emails/quotes/multiple.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@foreach ($quotes as $quote)
@include('emails.quotes.single', compact('quote'))
@endforeach
13 changes: 11 additions & 2 deletions ressources/views/emails/quotes/single.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<div class="quote">
@if (isset($colorGenerator))
<?php
$darkColorQuote = $colorGenerator->darken(20);
$colorQuote = $colorGenerator->nextColor();
?>
<div class="quote" style="background-color:<?= $colorQuote; ?>;border-bottom-color:<?= $darkColorQuote; ?>">
@else
<div class="quote">
@endif

{{{ $quote->content}}}
<div class="info">
@if ($quote->isPublished())
Expand All @@ -12,4 +21,4 @@
<a href="{{ URL::route('users.show', $quote->user->login) }}">{{{ $quote->user->login }}}</a>
</div>
</div>
</div>
</div>

0 comments on commit 5ded35e

Please sign in to comment.