Skip to content

Commit d75518e

Browse files
authored
Dark mode emails (#398)
* Add dark mode * Add dark mode * Add dark mode
1 parent b948666 commit d75518e

22 files changed

+1511
-1140
lines changed

packages/email/README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import { Button as ReactEmailButton } from "@react-email/components";
2+
import type React from "react";
3+
import { getEmailInlineStyles, getEmailThemeClasses } from "./theme";
4+
5+
interface ButtonProps {
6+
href: string;
7+
children: React.ReactNode;
8+
variant?: "primary" | "secondary";
9+
className?: string;
10+
}
11+
12+
export function Button({
13+
href,
14+
children,
15+
variant = "primary",
16+
className = "",
17+
}: ButtonProps) {
18+
const themeClasses = getEmailThemeClasses();
19+
const lightStyles = getEmailInlineStyles("light");
20+
21+
const baseClasses =
22+
"bg-transparent text-[14px] font-medium no-underline text-center px-6 py-3 border border-solid";
23+
const variantClasses =
24+
variant === "primary"
25+
? themeClasses.button
26+
: "border-gray-300 text-gray-600";
27+
28+
// Inline styles for maximum email client compatibility
29+
const buttonStyle =
30+
variant === "primary"
31+
? {
32+
color: lightStyles.button.color,
33+
borderColor: lightStyles.button.borderColor,
34+
}
35+
: {
36+
color: "#6b7280",
37+
borderColor: "#d1d5db",
38+
};
39+
40+
return (
41+
<ReactEmailButton
42+
className={`${baseClasses} ${variantClasses} ${className}`}
43+
href={href}
44+
style={buttonStyle}
45+
>
46+
{children}
47+
</ReactEmailButton>
48+
);
49+
}

packages/email/components/column.tsx

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Img, Row, Section, Text } from "@react-email/components";
2+
import { getEmailThemeClasses } from "./theme";
23

34
type Props = {
45
title: string;
@@ -8,6 +9,8 @@ type Props = {
89
};
910

1011
export function Column({ title, description, footer, imgSrc }: Props) {
12+
const themeClasses = getEmailThemeClasses();
13+
1114
return (
1215
<Section className="text-left p-0 m-0 text-left">
1316
<Section className="p-0 m-0 w-full w-full w-[265px] inline-block align-top box-border mb-4 md:mb-0 text-left">
@@ -17,9 +20,13 @@ export function Column({ title, description, footer, imgSrc }: Props) {
1720
</Section>
1821
<Section className="inline-block align-top box-border w-full w-[280px] text-left">
1922
<Section className="text-left p-0 m-0">
20-
<Text className="pt-0 m-0 font-medium mb-2">{title}</Text>
21-
<Text className="text-[#707070] p-0 m-0">{description}</Text>
22-
<Text className="text-[#707070] p-0 mt-2">{footer}</Text>
23+
<Text className={`pt-0 m-0 font-medium mb-2 ${themeClasses.text}`}>
24+
{title}
25+
</Text>
26+
<Text className={`p-0 m-0 ${themeClasses.mutedText}`}>
27+
{description}
28+
</Text>
29+
<Text className={`p-0 mt-2 ${themeClasses.mutedText}`}>{footer}</Text>
2330
</Section>
2431
</Section>
2532
</Section>

packages/email/components/dual-column.tsx

Lines changed: 0 additions & 48 deletions
This file was deleted.

0 commit comments

Comments
 (0)