Skip to content

Commit

Permalink
Add stories for header and footer components
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinnl committed Jan 23, 2025
1 parent 1892fff commit 8d6ca90
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/emails/StorybookEmailRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export const StorybookEmailRenderer = (props: Props) => {
padding: 20px;
display: flex;
flex-direction: column;
align-items: center;
align-items: stretch;
gap: 20px;
}
.wrapper .plaintext {
Expand Down Expand Up @@ -93,7 +93,7 @@ export const StorybookEmailRenderer = (props: Props) => {
`
: renderResult.html,
}}
className={props.emulateDarkMode ? "dark-mode-enforced" : ""}
className={`body ${props.emulateDarkMode ? "dark-mode-enforced" : ""}`}
/>
</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",
},
};

0 comments on commit 8d6ca90

Please sign in to comment.