1.2.3 • Published 2 years ago

mjml-signoff v1.2.3

Weekly downloads
-
License
AGPL-3.0-or-later
Repository
github
Last release
2 years ago

npm GitHub release (latest SemVer) Release Date MJML 4.0+ valid License: AGPL-3.0+ Pull Requests welcome


This MJML component is brought to you by Premail, and the following documentation can also be found at https://premail.dev/docs/components/mjml-signoff


Designed for the sign-off or signature section at the bottom of your email content, the <mj-signoff> tag allows you to easily include an image alongside your signature such as a photo or logo, which is a common best practice in many types of emails:

Example of generated markup from the MJML Signoff component


Usage

Coding

This MJML:

<mjml>
  <mj-body>
    <mj-section>
      <mj-column>
        <mj-signoff
          closing="Thank you,"
          name="John Q. Public"
          title="Your Friendly Neighbor"
          image-src="https://picsum.photos/75/100"
          image-width="75px"
          image-height="100px"
          image-alt=""
        >
          <p><a href="https://example.com">Example, Inc.</a></p>
        </mj-signoff>
      </mj-column>
    </mj-section>
  </mj-body>
</mjml>

Will produce the following visual representation:

Example of generated markup from the MJML Signoff component

The closing, name and title strings are all optional, as are an additional title2 and title3 strings. These strings cannot contain HTML elements, however any content within the element itself is placed in the text column below the optional strings -- for instance, the wrapped and linked company name shown above. <mj-signoff> need not have any content within its tags, however.

The wrapper <p> and <div> elements are only inserted if the corresponding strings are set. A simplified version of the generated HTML is:

<div class="signoff">
  <!-- table markup -->
  <div class="signoff__image-wrapper">
    <!-- table markup, class="signoff__image" -->
    <img />
    <!-- table markup -->
  </div>
  <div class="signoff__text-wrapper">
    <!-- table markup, class="signoff__text" -->
    <p class="signoff__closing"><!-- if string is set --></p>
    <p class="signoff__name"><!-- if string is set --></p>
    <p class="signoff__title"><!-- if string is set --></p>
    <p class="signoff__title2"><!-- if string is set --></p>
    <p class="signoff__title3"><!-- if string is set --></p>
    <div class="signoff__custom">
      <!-- if <mj-signoff> element has content -->
    </div>
    <!-- table markup -->
  </div>
  <!-- table markup -->
</div>

The order of the image and text columns is reversed if image-position is set to right.

Styling

The following mj-class elements are available for styling with <mj-attributes>:

  • signoff
  • signoff__image-wrapper
  • signoff__image
  • signoff__text-wrapper
  • signoff__text

And the following CSS classes are available for styling with <mj-style>:

  • signoff
  • signoff__image-wrapper
  • signoff__image
  • signoff__text-wrapper
  • signoff__text
  • signoff__closing
  • signoff__name
  • signoff__title
  • signoff__title2
  • signoff__title3
  • signoff__custom

You can see how each of these are used in the example MJML file.

Options

Available options for <mj-signoff>:

optionunitdetailsdefault value
closingstringOptional closing, e.g. Thank you,none
namestringOptional name, e.g. John Q. Publicnone
titlestringOptional title, e.g. Your Friendly Neighbornone
title2stringOptional title line two, e.g. Example, Inc.none
title3stringOptional title line three, e.g. (202) 555-1212none
section-paddingpixelsApplies to entire element10px 0
section-alignleft, center, rightAlignment of element as a wholeleft
background-colorcolorApplies to entire elementnone
image-positionleft, rightWhere the image should appear relative to the textleft
image-paddingpixelsApplies only to the image columnnone
image-srcURLLocation of imagenone
image-widthpixelsWidth of imagenone
image-heightpixelsHeight of imagenone
image-altstringAlternative text for image (you may legitimately wish to leave this blank; see the spec for graphical representation, decorative images and example 2 here)none
text-column-paddingpixelsApplies only to the text column0 10px

Adding this to your emails

In your MJML project directory, install this package via npm:

npm install mjml-signoff

In your build process script (such as gulp), require the package:

const mjmlSignoff = require('mjml-signoff')

or

import mjmlSignoff from mjml-signoff

Finally, add the package to your .mjmlconfig:

{
  "packages": ["mjml-signoff"]
}

You can now use <mj-signoff> in your MJML emails.

Fork or contribute to this component

If you want to edit this component, first grab it via git:

git clone https://github.com/premail/mjml-signoff.git

Navigate to the folder and install:

cd mjml-signoff
npm install

Edit the component script file in ./components/, then run gulp build or gulp watch to compile. We include sheerun/modern-node, which formats and lints code automatically on commits using Prettier and ESLint. You can use npm run format and npm run lint on their own as well.

To run tests, use npm run test

If you want to use a forked version of this component in your emails without having to publish it to npm, see premail/mjml-custom-component for a guide.

Alternatives

As an alternative to <mjml-signoff>, you can use the <mj-group> element, but note its warning for iOS 9.

If you are not using an image in your sign-off, or you are including an image on a line by itself (such as an image of a signature) you can simply use the default <mj-image> and <mj-text> elements.

Security

Legalese: This component is provided "as is" without any warranty. Use at your own risk.

For more information and to report security issues, please refer to our security documentation.

License

mjml-signoff is licensed under the GNU Affero General Public License v3.0 or later. To be clear: This license only covers the component's code, not any content you generate using it.

For the legal details of the AGPL, see the complete LICENSE.

1.2.0

2 years ago

1.2.3

2 years ago

1.2.2

2 years ago

1.2.1

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.1

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago