Skip to content

Commit c911c5a

Browse files
authored
[chores:ui] Improved email template for narrow screens
* [enhancement] Improved email template for narrow screens * [req-change] Increased the resolution of icons * [req-changes] Updated email template
1 parent ef95929 commit c911c5a

File tree

4 files changed

+75
-31
lines changed

4 files changed

+75
-31
lines changed
217 Bytes
Loading
67 Bytes
Loading

openwisp_utils/admin_theme/templates/openwisp_utils/email_template.html

Lines changed: 74 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,42 +6,41 @@
66
<meta charset="UTF-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1.0">
88
{% block styles %}
9-
<style type="text/css">
10-
:root {
11-
--muted-fg-color: #777;
12-
--loud-fg-color: #333;
13-
--muted-bg-color: #F2F4F7;
14-
--muted-border-color: #D0D5DD;
15-
}
16-
9+
<style>
1710
body {
1811
min-width: 250px;
1912
background: #fff;
2013
margin: 0;
2114
padding: 0;
15+
font-family: Arial, Helvetica, sans-serif;
2216
}
2317

2418
.email-info {
25-
margin: 0.9rem auto;
26-
font-size: 0.8em;
19+
margin: 0.75rem auto;
20+
font-size: 0.75rem;
2721
font-weight: 400;
22+
line-height: 1.25rem;
2823
color: #777;
2924
text-align: center;
3025
}
3126

27+
.email-info a {
28+
color: inherit !important;
29+
}
30+
3231
.container {
3332
background: #fff;
34-
padding: 20px 0;
33+
padding: 1.5rem 0;
3534
}
3635

3736
.box {
3837
width: auto;
3938
max-width: 700px;
40-
padding: 1.5rem 0.94rem 2.1rem 0.94rem;
39+
padding: 1rem 0.94rem;
4140
background-color: #fff;
4241
border-radius: 12px;
43-
border: outset 1px #eee;
44-
margin: 0px auto 1rem auto;
42+
border: 1px solid #EAECF0;
43+
margin: 0 auto;
4544
line-height: 27px;
4645
box-shadow: 0px 20px 24px -4px rgba(16, 24, 40, 0.08), 0px 8px 8px -4px rgba(16, 24, 40, 0.03);
4746
}
@@ -63,7 +62,7 @@
6362

6463
.sysname-container {
6564
width: fit-content;
66-
margin: 1rem auto 0 auto;
65+
margin: 1rem auto 0.25rem auto;
6766
background-color: #F2F4F7;
6867
padding: 0 0.5em;
6968
border: solid #D0D5DD 1px;
@@ -84,30 +83,45 @@
8483

8584
.call-to-action {
8685
text-align: center;
87-
margin-top: 1.88rem;
86+
margin-top: 1.5rem;
8887
}
8988

9089
.email-title {
9190
font-weight: 600;
9291
font-size: 1.13rem;
93-
width: fit-content;
94-
margin: auto;
95-
margin-top: 1rem;
92+
text-align: center;
93+
line-height: 1.75rem;
9694
color: #101828;
9795
}
9896

9997
.subtitle {
10098
font-weight: 400;
10199
font-size: 0.88rem;
102-
width: fit-content;
103-
margin: 0 auto 0.88em auto;
100+
line-height: 1.25rem;
101+
text-align: center;
102+
margin-top: 0.1rem;
104103
color: #475467;
105104
}
106105

106+
hr {
107+
border: 1px solid #EBECF0;
108+
}
109+
110+
.email-title + hr,
111+
.subtitle + hr {
112+
margin: 0.9rem 2.6rem 1rem 2.6rem;
113+
display: none;
114+
}
115+
116+
.email-content {
117+
margin-top: 1rem;
118+
}
119+
107120
.msg {
108-
color: #000000;
121+
color: #0F1729;
109122
margin: 20px 0;
110-
font-size: medium;
123+
line-height: 1.20rem;
124+
font-size: 0.875rem;;
111125
}
112126

113127
.btn {
@@ -118,7 +132,7 @@
118132
font-weight: 600;
119133
font-size: 1rem;
120134
line-height: 1.5rem;
121-
padding: 0.63rem 1rem;
135+
padding: 0.5rem 1rem;
122136
color: #344054 !important;
123137
box-sizing: border-box;
124138
box-shadow: 0px 1px 2px rgba(16, 24, 40, 0.05), inset 0px 0px 0px 1px rgba(16, 24, 40, 0.18), inset 0px -2px 0px rgba(16, 24, 40, 0.05);
@@ -135,15 +149,42 @@
135149
}
136150

137151
.footer {
152+
margin-top: 1rem;
138153
height: 40px;
139154
text-align: center;
140155
color: #475467;
141156
}
142157

143158
.footer p {
144-
font-size: 12px;
159+
font-size: 0.75rem;
160+
line-height: 1.25rem;
145161
margin: 0 auto;
146-
line-height: 20px;
162+
}
163+
164+
@media screen and (max-width: 768px) {
165+
.box {
166+
margin-right: 0.5rem;
167+
margin-left: 0.5rem;
168+
padding: 1rem;
169+
padding-bottom: 1.1rem;
170+
}
171+
172+
.email-tile + hr,
173+
.subtitle + hr {
174+
display: block;
175+
}
176+
177+
.email-content {
178+
margin: 0;
179+
}
180+
181+
.call-to-action {
182+
margin-top: 1rem;
183+
}
184+
185+
.footer {
186+
margin: 0.5rem auto 0.875rem auto;
187+
}
147188
}
148189
</style>
149190
{% endblock styles %}
@@ -157,7 +198,7 @@
157198
</div>
158199
{% endblock logo %}
159200
{% block email_info %}
160-
<div class="email-info">This email is sent to <u>{{ recipients }}</u> from [{{ site_name }}]</div>
201+
<div class="email-info">This email is sent to <u>{{ recipients }}</u> from <a href="{{ site_url }}{% url 'admin:index' %}">[{{ site_name }}]</a></div>
161202
{% endblock email_info %}
162203
<div class="box">
163204
{% block mail_header %}
@@ -172,9 +213,12 @@
172213
<div class="subtitle">{{ subtitle }}</div>
173214
{% endif %}
174215
{% endblock mail_header %}
175-
{% block mail_body %}
176-
<div class="msg">{{ message | safe }}</div>
177-
{% endblock mail_body %}
216+
<hr>
217+
<div class="email-content">
218+
{% block mail_body %}
219+
<div class="msg">{{ message | safe }}</div>
220+
{% endblock mail_body %}
221+
</div>
178222
{% block call_to_action %}
179223
{% if call_to_action_url %}
180224
<div class="call-to-action">

tests/test_project/tests/test_email.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def test_email(self):
2929
email.alternatives[0][0],
3030
)
3131
# test email doesn't contain link
32-
self.assertNotIn("<a href", email.alternatives[0][0])
32+
self.assertNotIn('class="btn">', email.alternatives[0][0])
3333
self.assertEqual(email.attachments[0].get_payload(), "Test attachment")
3434

3535
def test_email_action_text_and_url(self):

0 commit comments

Comments
 (0)