Skip to content

Commit

Permalink
chore: add real content to sample emails and a screenshot to README
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmazza committed May 2, 2022
1 parent 60fa960 commit 6b33f92
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 19 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Swoosh Gallery

**A gallery of previews for your emails.**
Preview and display your Swoosh mailers to everyone.

## Installation

Expand All @@ -19,6 +19,10 @@ Documentation can be generated with [ExDoc](https://github.com/elixir-lang/ex_do
and published on [HexDocs](https://hexdocs.pm). Once published, the docs can
be found at <https://hexdocs.pm/swoosh_gallery>.

## Screenshot

![](assets/docs/screenshot.png)

## Contributing

1. Download the project.
Expand Down
Binary file added assets/docs/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 10 additions & 10 deletions lib/swoosh/gallery/templates/preview.html.eex
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
<!-- preview -->
<h1 class="text-2xl font-semibold text-gray-900">
Preview: <%= @preview.preview_details.title %>
Preview: <%= @preview.preview_details.title %>
</h1>

<div class="bg-white shadow overflow-hidden sm:rounded-lg mt-5">
<div class="px-4 py-5 sm:px-6">
<div class="p-4">
<p class="max-w-2xl text-sm text-gray-500 leading-6">
<%= @preview.preview_details.description %>
</p>
</div>
<div class="border-t border-gray-200 px-4 py-5 sm:p-0">
<div class="border-t border-gray-200">
<dl class="sm:divide-y sm:divide-gray-200">
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">Subject</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= @preview.email.subject %>
</dd>
</div>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">From</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= render_recipient(@preview.email.from) %>
</dd>
</div>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">To</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= render_recipient(@preview.email.to) %>
</dd>
</div>
<%= if cc = render_recipient(@preview.email.cc) do %>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">CC</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= cc %>
</dd>
</div>
<% end %>
<%= if bcc = render_recipient(@preview.email.bcc) do %>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">BCC</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<%= bcc %>
Expand All @@ -47,7 +47,7 @@
<% end %>

<%= if Enum.any?(@preview.email.attachments) do %>
<div class="py-4 sm:py-5 sm:grid sm:grid-cols-3 sm:gap-4 sm:px-6">
<div class="p-4 sm:grid sm:grid-cols-3">
<dt class="text-sm font-medium text-gray-500">Attachments</dt>
<dd class="mt-1 text-sm text-gray-900 sm:mt-0 sm:col-span-2">
<ul role="list" class="border border-gray-200 rounded-md divide-y divide-gray-200">
Expand Down Expand Up @@ -91,7 +91,7 @@
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 relative mt-2">
<iframe x-ref="iframe" title="Email HTML preview" aria-label="Email HTML preview" name="frame-html"
class="w-full rounded-lg overflow-hidden sm:rounded-r-none" style="height: 100vh"
class="w-full rounded-lg overflow-hidden sm:rounded-r-none" style="height: 70vh"
src="<%= preview_path(@preview, @base_path, path: "/preview.html") %>"></iframe>
</div>
<div class="max-w-7xl mx-auto px-4 sm:px-6 md:px-8 my-4">
Expand Down
4 changes: 2 additions & 2 deletions sample/lib/sample/mailer/notifications/new_follower_mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ defmodule Sample.Mailer.Notifications.NewFollowerMailer do
new()
|> from("[email protected]")
|> to({user.name, user.email})
|> subject("Great!, #{follower.name} is following you")
|> subject("Great! #{follower.name} is following you")
|> render_body("new_follower.html", user: user, follower: follower)
end

def preview, do: welcome(%{email: "[email protected]", name: "Test User!"}, %{name: "The Follower"})
def preview, do: welcome(%{email: "[email protected]", name: "Test User!"}, %{name: "Another User"})

def preview_details do
[
Expand Down
6 changes: 3 additions & 3 deletions sample/lib/sample/mailer/user_mailer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ defmodule Sample.Mailer.UserMailer do
new()
|> from("[email protected]")
|> to({user.name, user.email})
|> subject("Welcome to Sample App")
|> subject("Welcome to Sample App!")
|> render_body("welcome.html", user: user)
end

def preview, do: welcome(%{email: "[email protected]", name: "Test User!"})
def preview, do: welcome(%{email: "[email protected]", name: "Test User"})

def preview_details do
[
title: "Welcome to Sample",
title: "Welcome Email",
description: "First email to welcome users into the platform"
]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Great! <%= @follower.name %> is following you</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet"> </head>

<body>
<div class="flex items-center justify-center py-32 p-5 bg-blue-100 min-w-screen">
<div class="max-w-xl p-8 text-center text-gray-800 bg-white shadow-xl rounded-2xl">
<h3 class="text-2xl"><%= @follower.name %> is now following you!</h3>
<div class="flex justify-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-24 h-24 text-green-400" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197M13 7a4 4 0 11-8 0 4 4 0 018 0z" />
</svg>
</div>
<p>
Hey <%= @user.name %>, this is only a head's up that <%= @follower.name %> is now following your posts
</p>
<p class="mt-4">
<a class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium rounded shadow-md">Click bere to see their feed</a>
</p>
</div>
</div>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You have a new message</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="flex items-center justify-center py-32 p-5 bg-blue-100 min-w-screen">
<div class="max-w-xl p-8 text-center text-gray-800 bg-white shadow-xl rounded-2xl">
<h3 class="text-2xl">You got mail</h3>
<div class="flex justify-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-24 h-24 text-green-400" viewBox="0 0 20 20" fill="currentColor">
<path d="M8.707 7.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l2-2a1 1 0 00-1.414-1.414L11 7.586V3a1 1 0 10-2 0v4.586l-.293-.293z" />
<path d="M3 5a2 2 0 012-2h1a1 1 0 010 2H5v7h2l1 2h4l1-2h2V5h-1a1 1 0 110-2h1a2 2 0 012 2v10a2 2 0 01-2 2H5a2 2 0 01-2-2V5z" />
</svg>
</div>
<p>Hey <%= @user.name %>, you have a new message</p>
<p class="mt-4">
<a class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium rounded shadow-md">Click here to read it</a>
</p>
</div>
</div>
</body>
</html>
28 changes: 27 additions & 1 deletion sample/lib/sample_web/templates/user_mailer/download.html.eex
Original file line number Diff line number Diff line change
@@ -1 +1,27 @@
<p>Hey <%= @user.name %>, here is the file you asked</p>
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>You download is ready</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="flex items-center justify-center py-32 p-5 bg-blue-100 min-w-screen">
<div class="max-w-xl p-8 text-center text-gray-800 bg-white shadow-xl rounded-2xl">
<h3 class="text-2xl">You download is ready</h3>
<div class="flex justify-center">
<svg xmlns="http://www.w3.org/2000/svg" class="w-24 h-24 text-green-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M3 17a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm3.293-7.707a1 1 0 011.414 0L9 10.586V3a1 1 0 112 0v7.586l1.293-1.293a1 1 0 111.414 1.414l-3 3a1 1 0 01-1.414 0l-3-3a1 1 0 010-1.414z" clip-rule="evenodd" />
</svg>
</div>
<p>Hey <%= @user.name %>, here is the file you asked</p>
<p class="mt-4">
<a class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium rounded shadow-md">Click to download</a>
</p>
</div>
</div>
</body>
</html>
23 changes: 21 additions & 2 deletions sample/lib/sample_web/templates/user_mailer/welcome.html.eex
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
<h1>Welcome to Sample, <%= @user.name %>!</h1>
<!DOCTYPE html>
<html lang="en">

<p>This is a sample email that is delivered when a person first join the platform.</p>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Welcome!</title>
<link href="https://unpkg.com/tailwindcss@^2/dist/tailwind.min.css" rel="stylesheet">
</head>
<body>
<div class="flex items-center justify-center py-32 p-5 bg-blue-100 min-w-screen">
<div class="max-w-xl p-8 text-center text-gray-800 bg-white shadow-xl rounded-2xl">
<h3 class="text-2xl">Welcome to Sample, <%= @user.name %>!</h3>
<p class="mt-4">This is a sample email that is delivered when a person first join the platform.</p>
<p class="mt-4">
<a class="inline-block px-6 py-2.5 bg-blue-600 text-white font-medium rounded shadow-md">Get started with the app</a>
</p>
</div>
</div>
</body>
</html>

0 comments on commit 6b33f92

Please sign in to comment.