Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add stories for header and footer components #5525

Merged
merged 2 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/emails/StorybookEmailRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const StorybookEmailRenderer = (props: Props) => {
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
align-items: stretch;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The emails apparently only looked wide because the content made the container grow, but with just the footer/header, they were very cramped 😅

gap: 20px;
}
.wrapper .plaintext {
Expand Down Expand Up @@ -89,7 +89,7 @@ export const StorybookEmailRenderer = (props: Props) => {
`
: renderResult.html,
}}
className={props.emulateDarkMode ? "dark-mode-enforced" : ""}
className={`body ${props.emulateDarkMode ? "dark-mode-enforced" : ""}`}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't end up needing this class. Could remove it too, I guess 🤷

/>
</section>
<section className="plaintext">
Expand Down
43 changes: 43 additions & 0 deletions src/emails/components/EmailFooter.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type { Meta, StoryObj } from "@storybook/react";
import { FC } from "react";
import { StorybookEmailRenderer } from "../StorybookEmailRenderer";
import { EmailFooter, Props } from "./EmailFooter";
import { getL10n } from "../../app/functions/l10n/storybookAndJest";

const meta: Meta<FC<Props>> = {
title: "Emails/Components/Footer",
component: (props: Props) => (
<StorybookEmailRenderer plainTextVersion={null}>
<mjml>
<mj-body>
<EmailFooter {...props} />
</mj-body>
</mjml>
</StorybookEmailRenderer>
),
args: {
l10n: getL10n("en"),
utm_campaign: "storybook",
},
};

export default meta;
type Story = StoryObj<FC<Props>>;

export const RepeatEmail: Story = {
name: "Repeat email",
args: {
isOneTimeEmail: false,
},
};

export const OneTimeEmail: Story = {
name: "One-time email",
args: {
isOneTimeEmail: true,
},
};
33 changes: 33 additions & 0 deletions src/emails/components/EmailHeader.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type { Meta, StoryObj } from "@storybook/react";
import { FC } from "react";
import { StorybookEmailRenderer } from "../StorybookEmailRenderer";
import { EmailHeader, Props } from "./EmailHeader";
import { getL10n } from "../../app/functions/l10n/storybookAndJest";

const meta: Meta<FC<Props>> = {
title: "Emails/Components/Header",
component: (props: Props) => (
<StorybookEmailRenderer plainTextVersion={null}>
<mjml>
<mj-body>
<EmailHeader {...props} />
</mj-body>
</mjml>
</StorybookEmailRenderer>
),
args: {
l10n: getL10n("en"),
utm_campaign: "storybook",
},
};

export default meta;
type Story = StoryObj<FC<Props>>;

export const EmailHeaderStory: Story = {
name: "Header",
};
37 changes: 37 additions & 0 deletions src/emails/components/EmailHero.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type { Meta, StoryObj } from "@storybook/react";
import { FC } from "react";
import { StorybookEmailRenderer } from "../StorybookEmailRenderer";
import { EmailHero, Props } from "./EmailHero";
import { getL10n } from "../../app/functions/l10n/storybookAndJest";

const meta: Meta<FC<Props>> = {
title: "Emails/Components/Hero",
component: (props: Props) => (
<StorybookEmailRenderer plainTextVersion={null}>
<mjml>
<mj-body>
<EmailHero {...props} />
</mj-body>
</mjml>
</StorybookEmailRenderer>
),
args: {
l10n: getL10n("en"),
utm_campaign: "storybook",
},
};

export default meta;
type Story = StoryObj<FC<Props>>;

export const EmailHeroStory: Story = {
name: "Hero",
args: {
heading: "Email heading",
subheading: "Email subheading",
},
};
40 changes: 40 additions & 0 deletions src/emails/components/RedesignedEmailFooter.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type { Meta, StoryObj } from "@storybook/react";
import { FC } from "react";
import { StorybookEmailRenderer } from "../StorybookEmailRenderer";
import { RedesignedEmailFooter, Props } from "./EmailFooter";
import { getL10n } from "../../app/functions/l10n/storybookAndJest";

const meta: Meta<FC<Props>> = {
title: "Emails/Components/Redesigned footer",
component: (props: Props) => (
<StorybookEmailRenderer plainTextVersion={null}>
<mjml>
<mj-body>
<RedesignedEmailFooter {...props} />
</mj-body>
</mjml>
</StorybookEmailRenderer>
),
args: {
l10n: getL10n("en"),
utm_campaign: "storybook",
},
};

export default meta;
type Story = StoryObj<FC<Props>>;

export const RepeatEmail: Story = {
name: "Without unsubscribe link",
};

export const WithUnsubscribeLink: Story = {
name: "With unsubscribe link",
args: {
unsubscribeLink: "https://example.com/unsubscribe",
},
};
4 changes: 2 additions & 2 deletions src/emails/templates/boilerplate/BoilerplateEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

import { SanitizedSubscriberRow } from "../../../app/functions/server/sanitize";
import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import { EmailFooter } from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";

export type Props = {
subscriber: SanitizedSubscriberRow;
Expand Down
9 changes: 6 additions & 3 deletions src/emails/templates/breachAlert/BreachAlertEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@

import type { SubscriberRow } from "knex/types/tables";
import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter, RedesignedEmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import {
EmailFooter,
RedesignedEmailFooter,
} from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";
import { HibpLikeDbBreach } from "../../../utils/hibp";
import { BreachCard } from "../../components/BreachCard";
import { FeatureFlagName } from "../../../db/tables/featureFlags";
Expand All @@ -19,7 +22,7 @@ import { DashboardSummary } from "../../../app/functions/server/dashboard";
import { ResolutionRelevantBreachDataTypes } from "../../../app/functions/universal/breach";
import { EmailBanner } from "../../components/EmailBanner";
import { DataPointCount } from "../../components/EmailDataPointCount";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";

export type Props = {
l10n: ExtendedReactLocalization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { EmailFooter } from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";

export type Props = {
l10n: ExtendedReactLocalization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import type { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { RedesignedEmailFooter } from "../EmailFooter";
import { RedesignedEmailFooter } from "../../components/EmailFooter";
import { EmailHero } from "../../components/EmailHero";
import { DataPointCount } from "../../components/EmailDataPointCount";
import { DashboardSummary } from "../../../app/functions/server/dashboard";
import { EmailBanner } from "../../components/EmailBanner";
import { getPremiumSubscriptionUrl } from "../../../app/functions/server/getPremiumSubscriptionInfo";
import { isEligibleForPremium } from "../../../app/functions/universal/premium";
import { getSignupLocaleCountry } from "../../functions/getSignupLocaleCountry";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";
import { SanitizedSubscriberRow } from "../../../app/functions/server/sanitize";
import { sumSanitizedDataPoints } from "../../functions/reduceSanitizedDataPoints";
import { modifyAttributionsForUrl } from "../../../app/functions/universal/attributions";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import { DashboardSummary } from "../../../app/functions/server/dashboard";
import { SanitizedSubscriberRow } from "../../../app/functions/server/sanitize";
import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { EmailFooter } from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";

export type Props = {
subscriber: SanitizedSubscriberRow;
Expand Down
6 changes: 3 additions & 3 deletions src/emails/templates/signupReport/SignupReportEmail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

import { Fragment } from "react";
import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import { EmailFooter } from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";
import { HibpLikeDbBreach } from "../../../utils/hibp";
import { BreachCard } from "../../components/BreachCard";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";

export type Props = {
l10n: ExtendedReactLocalization;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

import { SanitizedSubscriberRow } from "../../../app/functions/server/sanitize";
import { ExtendedReactLocalization } from "../../../app/functions/l10n";
import { EmailFooter } from "../EmailFooter";
import { EmailHeader } from "../EmailHeader";
import { HeaderStyles, MetaTags } from "../HeaderStyles";
import { EmailFooter } from "../../components/EmailFooter";
import { EmailHeader } from "../../components/EmailHeader";
import { HeaderStyles, MetaTags } from "../../components/HeaderStyles";

export type Props = {
l10n: ExtendedReactLocalization;
Expand Down
Loading