Skip to content

Commit

Permalink
Welcome template (#416)
Browse files Browse the repository at this point in the history
* add new welcome template

* pull over new templates

* update snaps

* Create silly-boats-mix.md

* fix

* code review

* add new assets

* trigger
  • Loading branch information
elliothursh authored Dec 14, 2022
1 parent 048cb32 commit d870690
Show file tree
Hide file tree
Showing 80 changed files with 1,730 additions and 421 deletions.
6 changes: 6 additions & 0 deletions .changeset/silly-boats-mix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"mailing": patch
"mailing-core": patch
---

Add new Welcome template to emails.
3 changes: 2 additions & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"*.{js,jsx,ts,tsx}": "eslint --fix",
"*.rb": "rubocop --autocorrect",
"packages/cli/src/emails/**/*.{ts,tsx}": "scripts/generate-emails-js"
"packages/cli/src/__mocks__/emails/**/*.{ts,tsx}": "scripts/generate-emails __mocks__/emails",
"packages/cli/src/emails/**/*.{ts,tsx}": "scripts/generate-emails emails"
}
23 changes: 3 additions & 20 deletions e2e/mailing_tests/cypress/e2e/index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,17 @@ describe("index page tests", () => {
});

it("should redirect index to previewFunction with tree", () => {
cy.location("pathname").should(
"eq",
"/previews/AccountCreated/accountCreated"
);
cy.location("pathname").should("eq", "/previews/Welcome/preview");

cy.contains("accountCreated")
cy.contains("preview")
.should("have.attr", "aria-selected", "true")
.should("have.attr", "role", "treeitem");
cy.contains("Emails")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "aria-selected", "false")
.should("have.attr", "role", "treeitem");
cy.contains("Reservation")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "role", "treeitem")
.should("have.attr", "role", "treeitem");
cy.contains("ResetPassword")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "role", "treeitem");

cy.contains("reservationChanged").click();
cy.location("pathname").should(
"eq",
"/previews/Reservation/reservationChanged"
);

cy.contains("Compact view").click();

cy.get("[aria-selected=true]").contains("reservationChanged");
cy.get("[aria-selected=true]").contains("preview");
});
});
27 changes: 12 additions & 15 deletions e2e/mailing_tests/jest/__snapshots__/exportPreviews.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,26 @@
exports[`exportPreviews command cli --minify runs on templates 1`] = `
"mailing Exporting minified preview html to
mailing ./previews_html/
mailing |-- account_created_account_created.html
mailing |-- new_sign_in_new_sign_in.html
mailing |-- reservation_reservation_changed.html
mailing |-- reservation_reservation_confirmed.html
mailing |-- reservation_reservation_with_error.html
mailing |-- reset_password_reset_password.html
mailing ✅ Processed 6 previews
mailing |-- welcome_preview.html
mailing ✅ Processed 1 previews
"
`;

exports[`exportPreviews command cli halts on lint errors runs on templates 1`] = `""`;
exports[`exportPreviews command cli halts on lint errors runs on templates 1`] = `
"mailing Exporting preview html to
mailing ./previews_html/
mailing |-- welcome_preview.html
mailing ✅ Processed 1 previews
"
`;

exports[`exportPreviews command cli runs on templates 1`] = `
"mailing Exporting preview html to
mailing ./previews_html/
mailing |-- account_created_account_created.html
mailing |-- new_sign_in_new_sign_in.html
mailing |-- reservation_reservation_changed.html
mailing |-- reservation_reservation_confirmed.html
mailing |-- reservation_reservation_with_error.html
mailing |-- reset_password_reset_password.html
mailing ✅ Processed 6 previews
mailing |-- welcome_preview.html
mailing ✅ Processed 1 previews
"
`;
23 changes: 3 additions & 20 deletions packages/cli/cypress/e2e/index.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,17 @@ describe("index page tests", () => {
});

it("should redirect index to previewFunction with tree", () => {
cy.location("pathname").should(
"eq",
"/previews/AccountCreated/accountCreated"
);
cy.location("pathname").should("eq", "/previews/Welcome/preview");

cy.contains("accountCreated")
cy.contains("preview")
.should("have.attr", "aria-selected", "true")
.should("have.attr", "role", "treeitem");
cy.contains("Emails")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "aria-selected", "false")
.should("have.attr", "role", "treeitem");
cy.contains("Reservation")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "role", "treeitem")
.should("have.attr", "role", "treeitem");
cy.contains("ResetPassword")
.should("have.attr", "aria-expanded", "true")
.should("have.attr", "role", "treeitem");

cy.contains("reservationChanged").click();
cy.location("pathname").should(
"eq",
"/previews/Reservation/reservationChanged"
);

cy.contains("Compact view").click();

cy.get("[aria-selected=true]").contains("reservationChanged");
cy.get("[aria-selected=true]").contains("preview");
});
});
File renamed without changes.
File renamed without changes.
121 changes: 121 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/BaseLayout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import React from "react";
import {
Mjml,
MjmlBody,
MjmlHead,
MjmlFont,
MjmlStyle,
MjmlAttributes,
MjmlAll,
MjmlRaw,
MjmlPreview,
} from "mjml-react";
import { colors, screens, themeDefaults, spacing } from "../theme";

export default function BaseLayout({ width, children, preview }) {
return (
<Mjml>
<MjmlHead>
{preview && <MjmlPreview>{preview}</MjmlPreview>}
<MjmlRaw>
<meta name="color-scheme" content="light dark" />
<meta name="supported-color-schemes" content="light dark" />
</MjmlRaw>
<MjmlFont
name="Inter"
href="https://fonts.googleapis.com/css2?family=Inter:wght@400;700"
/>
<MjmlAttributes>
<MjmlAll {...themeDefaults} />
</MjmlAttributes>
<MjmlStyle>{`
body {
-webkit-font-smoothing: antialiased;
}
a {
color: inherit
}
.gutter {
padding-left: ${spacing.s7}px;
padding-right: ${spacing.s7}px;
}
.no-wrap {
white-space: nowrap;
}
.dark-mode {
display: none;
max-width: 0px;
max-height: 0px;
overflow: hidden;
mso-hide: all;
}
.hidden {
display: none;
max-width: 0px;
max-height: 0px;
overflow: hidden;
mso-hide: all;
}
.lg-hidden {
display: none;
max-width: 0px;
max-height: 0px;
overflow: hidden;
mso-hide: all;
}
/* Large screens */
@media (min-width:${screens.xs}) {
.lg-gutter {
padding-left: ${spacing.s7}px !important;
padding-right: ${spacing.s7}px !important;
}
.sm-hidden {
display: none;
max-width: 0px;
max-height: 0px;
overflow: hidden;
mso-hide: all;
}
.lg-hidden {
display: block !important;
max-width: none !important;
max-height: none !important;
overflow: visible !important;
mso-hide: none !important;
}
}
/* Dark Mode */
@media (prefers-color-scheme: dark) {
body {
background: ${colors.black};
}
.invert > * {
filter: invert(1) !important;
}
.text > * {
color: #fff !important;
}
.dark-mode {
display: inherit !important;
max-width: none !important;
max-height: none !important;
overflow: visible !important;
mso-hide: none !important;
}
.light-mode {
display: none;
max-width: 0px;
max-height: 0px;
overflow: hidden;
mso-hide: all;
}
}
`}</MjmlStyle>
</MjmlHead>

<MjmlBody width={width}>{children}</MjmlBody>
</Mjml>
);
}
32 changes: 32 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/Button.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from "react";
import { MjmlButton } from "mjml-react";
import { colors, fontSize, borderRadius, lineHeight, spacing } from "../theme";

export default function Button(props) {
return (
<>
<MjmlButton
lineHeight={lineHeight.tight}
fontSize={fontSize.base}
height={spacing.s8}
align="left"
backgroundColor={colors.black}
color={colors.neutral100}
borderRadius={borderRadius.base}
cssClass="light-mode"
{...props}
/>
<MjmlButton
lineHeight={lineHeight.tight}
fontSize={fontSize.base}
height={spacing.s8}
align="left"
backgroundColor={colors.gold}
color={colors.black}
borderRadius={borderRadius.base}
cssClass="dark-mode"
{...props}
/>
</>
);
}
34 changes: 34 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from "react";
import { MjmlSection, MjmlColumn, MjmlText } from "mjml-react";
import { EMAIL_PREFERENCES_URL } from "mailing-core";
import { colors, fontSize, spacing } from "../theme";

export default function Footer({ includeUnsubscribe }) {
return (
<MjmlSection cssClass="gutter">
<MjmlColumn>
<MjmlText
paddingTop={spacing.s9}
paddingBottom={spacing.s10}
fontSize={fontSize.sm}
color={colors.neutral400}
>
© {new Date().getFullYear()} BookBook
{includeUnsubscribe && (
<>
&nbsp;&nbsp;·&nbsp;&nbsp;
<a
href={EMAIL_PREFERENCES_URL}
target="_blank"
rel="noreferrer"
style={{ textDecoration: "none" }}
>
Unsubscribe
</a>
</>
)}
</MjmlText>
</MjmlColumn>
</MjmlSection>
);
}
20 changes: 20 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/Header.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from "react";
import { MjmlSection, MjmlColumn, MjmlImage } from "mjml-react";

const Header = ({ loose }) => {
return (
<MjmlSection padding={loose ? "48px 0 40px" : "48px 0 24px"}>
<MjmlColumn>
<MjmlImage
padding="0 24px 0"
width="49px"
height="54px"
align="center"
src="https://s3.amazonaws.com/lab.campsh.com/bb-transparent%402x.png"
cssClass="invert"
/>
</MjmlColumn>
</MjmlSection>
);
};
export default Header;
17 changes: 17 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/Heading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import Text from "./Text";
import { fontFamily, lineHeight, fontWeight, fontSize } from "../theme";

const defaultProps = {
fontFamily: fontFamily.sans,
fontWeight: fontWeight.normal,
lineHeight: lineHeight.tight,
fontSize: fontSize.lg,
};
export default function Heading(props) {
return (
<Text {...defaultProps} {...props}>
{props.children}
</Text>
);
}
17 changes: 17 additions & 0 deletions packages/cli/src/__mocks__/emails-js/components/Text.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from "react";
import { MjmlText } from "mjml-react";

export default function Text({ children, maxWidth, ...props }) {
if (maxWidth) {
return (
<MjmlText {...props} cssClass="text">
<div style={{ maxWidth }}>{children}</div>
</MjmlText>
);
} else
return (
<MjmlText {...props} cssClass="text">
{children}
</MjmlText>
);
}
19 changes: 19 additions & 0 deletions packages/cli/src/__mocks__/emails-js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import nodemailer from "nodemailer";
import { buildSendMail } from "mailing-core";

const transport = nodemailer.createTransport({
pool: true,
host: "smtp.example.com",
port: 465,
secure: true,
auth: {
user: "username",
pass: "password",
},
});
const sendMail = buildSendMail({
transport,
defaultFrom: "[email protected]",
configPath: "./mailing.config.json",
});
export default sendMail;
Loading

3 comments on commit d870690

@vercel
Copy link

@vercel vercel bot commented on d870690 Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on d870690 Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web-emails – ./packages/web

mailing-web.vercel.app
emails.mailing.run
web-emails-git-main-sofn.vercel.app
web-emails-sofn.vercel.app

@vercel
Copy link

@vercel vercel bot commented on d870690 Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

web – ./packages/web

www.mailing.run
web-git-main-sofn.vercel.app
web-rho-puce.vercel.app
web-sofn.vercel.app
mailing.run

Please sign in to comment.