• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / #12116

pending completion
#12116

push

circleci

web-flow
Merge pull request #2801 from mozilla/MNTOR-1145-Fix-email-image-loading

fix: Email template images

282 of 1281 branches covered (22.01%)

Branch coverage included in aggregate %.

959 of 3457 relevant lines covered (27.74%)

2.25 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/views/email-2022.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import AppConstants from '../app-constants.js'
6
import { getMessage } from '../utils/fluent.js'
7

8
const companyAddress = '2 Harrison St. #175, San Francisco, California 94105 USA'
×
9
const links = (data) => ({
×
10
  faq: 'https://support.mozilla.org/kb/firefox-monitor-faq',
11
  hibp: 'https://haveibeenpwned.com/',
12
  legal: `https://www.mozilla.org/about/legal?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`,
13
  termsAndPrivacy: `https://www.mozilla.org/privacy/firefox-monitor?utm_source=fx-monitor&utm_medium=email&utm_campaign=${data.utmCampaign}&utm_content=email-footer-link`
14
})
15

16
const images = {
×
17
  header: `${AppConstants.SERVER_URL}/images/person-at-desk.webp`,
18
  footer: `${AppConstants.SERVER_URL}/images/mozilla-logo-bw.webp`,
19
  logoDark: `${AppConstants.SERVER_URL}/images/monitor-logo-transparent-dark-mode.webp`,
20
  logoLight: `${AppConstants.SERVER_URL}/images/monitor-logo-bg-light.webp`
21
}
22

23
const bodyStyle = `
×
24
  color: black;
25
  font: normal 16px/1.2 sans-serif;
26
`
27

28
const tableStyle = `
×
29
  margin: auto;
30
  max-width: 1080px;
31
  text-align: center;
32
  width: 100%;
33
`
34

35
const headeLogoStyle = `
×
36
  background-size: 240px 50px;
37
  background: #f9f9fa url('${images.logoLight}')
38
  height: 100px;
39
  no-repeat 50%;
40
`
41

42
const headeTableStyle = `
×
43
  background-color: #321c64;
44
  color: white;
45
  height: 331px;
46
  text-align: left;
47
  width: 100%;
48
`
49

50
const headerImageContainerStyle = `
×
51
  vertical-align: bottom;
52
  width: 50%;
53
`
54

55
const headerImageStyle = `
×
56
  display: block;
57
  margin-left: auto;
58
  max-width: 100%;
59
  object-fit: cover;
60
  object-position: left;
61
`
62

63
const footerContainerStyle = `
×
64
  background: #f9f9fa;
65
  border-top: 1px solid #dddddd;
66
  padding: 24px 0;
67
`
68

69
const footerImageStyle = `
×
70
  display: block;
71
  margin: 24px auto 0;
72
`
73

74
const emailHeader = (data) => `
×
75
  <tr class='logo'>
76
    <td
77
      height='100'
78
      style='${headeLogoStyle}'
79
    ></td>
80
  </tr>
81
  <tr class='header'>
82
    <td>
83
      <table
84
        border='0'
85
        cellpadding='0'
86
        cellspacing='0'
87
        role='presentation'
88
        style='${headeTableStyle}'
89
      >
90
        <tr>
91
          <td>
92
            <h1>
93
              ${getMessage(data.heading)}
94
            </h1>
95
            <p>
96
              ${getMessage(data.subhead)}
97
            </p>
98
          </td>
99
          <td
100
            background-color: #321c64;
101
            class='header-image'
102
            style='${headerImageContainerStyle}'
103
          >
104
            <img
105
              alt=''
106
              height='331'
107
              src='${images.header}'
108
              style='${headerImageStyle}'
109
              width='476'
110
            >
111
          </td>
112
        </tr>
113
      </table>
114
    </td>
115
  </tr>
116
`
117

118
const emailFooter = (data) => `
×
119
  <tr class='footer'>
120
    <td style='${footerContainerStyle}'>
121
      <p>
122
        ${getEmailFooterCopy(data)}
123
      </p>
124
      <p>
125
        ${getMessage('email-2022-hibp-attribution', {
126
          'hibp-link-attr': `href='${links(data).hibp}' rel='noopener'`
127
        })}
128
      </p>
129
      <img
130
        alt='${getMessage('mozilla')}'
131
        src='${images.footer}'
132
        style='${footerImageStyle}'
133
        width='130px'
134
      >
135
      <p>
136
        ${companyAddress}
137
      </p>
138
      <p>
139
        <a href='${links(data).legal}'>
140
          ${getMessage('legal')}
141
        </a>
142
        ${' • '}
143
        <a href='${links(data).termsAndPrivacy}'>
144
          ${getMessage('terms-and-privacy')}
145
        </a>
146
      </p>
147
    </td>
148
  </tr>
149
`
150

151
function getEmailFooterCopy (data) {
152
  const unsubLink = `
×
153
    <a href='${data.unsubscribeUrl}'>
154
      ${getMessage('email-unsub-link')}
155
    </a>
156
  `
157
  const faqLink = `
×
158
    <a href='${links(data).faq}'>${getMessage('frequently-asked-questions')}</a>
159
  `
160

161
  return getMessage('email-footer-blurb', {
×
162
    unsubLink,
163
    faqLink
164
  })
165
}
166

167
const getTemplate = (data, partial) => `
×
168
  <!doctype html>
169
  <html>
170
    <head>
171
      <meta name='viewport' content='width=device-width, initial-scale=1.0' />
172
      <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
173

174
      <title>
175
        ${getMessage('brand-fx-monitor')}
176
      </title>
177

178
      <style>
179
        * {
180
          margin: 0;
181
          padding: 0;
182
        }
183

184
        body {
185
          color: black;
186
          font: normal 16px/1.2 sans-serif;
187
        }
188

189
        h1,
190
        p {
191
          margin: 12px auto;
192
          max-width: 600px;
193
          padding: 0 24px;
194
        }
195

196
        a {
197
          color: #592acb;
198
          text-decoration: none;
199
        }
200

201
        table {
202
          table-layout: fixed;
203
        }
204

205
        @media screen and (max-width:600px) {
206
          .header-image {
207
            display: none;
208
          }
209
        }
210

211
        @media (prefers-color-scheme: dark) {
212
          .logo > td {
213
            background-image: url('${images.logoDark}')
214
          }
215
        }
216
      </style>
217
    </head>
218

219
    <body style='${bodyStyle}'>
220
      <table
221
        border='0'
222
        cellpadding='0'
223
        cellspacing='0'
224
        role='presentation'
225
        style='${tableStyle}'
226
      >
227
        ${emailHeader({
228
          heading: 'email-verify-heading',
229
          subhead: 'email-verify-subhead'
230
        })}
231
        ${partial}
232
        ${emailFooter(data)}
233
      </table>
234
    </body>
235
  </html>
236
`
237

238
export { getTemplate }
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc