BaseEmailLayout.tsx 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import * as React from "react";
  2. import { Body, Container, Head, Hr, Html, Img, Preview, Section, Text, Tailwind } from "@react-email/components";
  3. import { SiteConfig } from "@/shared/config/site-config";
  4. interface BaseEmailLayoutProps {
  5. previewText: string;
  6. children: React.ReactNode;
  7. }
  8. // Consistent styling variables
  9. const primaryColor = "#2563EB"; // Blue-600
  10. // eslint-disable-next-line quotes
  11. const fontFamily = 'Inter, "Helvetica Neue", Helvetica, Arial, sans-serif';
  12. const containerPadding = "32px"; // p-8
  13. const mainBgColor = "#f9fafb"; // bg-gray-50
  14. const containerBgColor = "#ffffff"; // bg-white
  15. const textColor = "#374151"; // text-gray-700
  16. const lightTextColor = "#6b7280"; // text-gray-500
  17. const borderColor = "#e5e7eb"; // border-gray-200
  18. export const BaseEmailLayout = ({ previewText, children }: BaseEmailLayoutProps) => (
  19. <Html>
  20. <Head>
  21. {/* Font import */}
  22. <link href="https://fonts.googleapis.com" rel="preconnect" />
  23. <link crossOrigin="" href="https://fonts.gstatic.com" rel="preconnect" />
  24. <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;600&display=swap" rel="stylesheet" />
  25. </Head>
  26. <Preview>{previewText}</Preview>
  27. <Tailwind
  28. config={{
  29. theme: {
  30. extend: {
  31. colors: {
  32. primary: primaryColor,
  33. text: textColor,
  34. lightText: lightTextColor,
  35. },
  36. fontFamily: {
  37. sans: [fontFamily],
  38. },
  39. borderColor: {
  40. DEFAULT: borderColor,
  41. },
  42. },
  43. },
  44. }}
  45. >
  46. <Body className="mx-auto my-auto bg-gray-50 font-sans" style={{ backgroundColor: mainBgColor }}>
  47. <Container
  48. className="mx-auto my-10 max-w-md rounded-lg border border-solid bg-white shadow-sm"
  49. style={{
  50. padding: containerPadding,
  51. backgroundColor: containerBgColor,
  52. borderColor: borderColor,
  53. }}
  54. >
  55. {/* Logo Section */}
  56. <Section className="mb-6 text-center">
  57. <Img alt={`${SiteConfig.title} Logo`} className="mx-auto" height="36" src={SiteConfig.cdnIcon} width="auto" />
  58. </Section>
  59. {/* Email specific content */}
  60. {children}
  61. {/* Footer Section */}
  62. <Hr className="my-6 border-t" style={{ borderColor: borderColor }} />
  63. <Section>
  64. <Text className="text-lightText text-sm" style={{ color: lightTextColor }}>
  65. Best regards,
  66. <br />
  67. The {SiteConfig.title} Team
  68. </Text>
  69. {/* Optional: Add company address or other info here if needed */}
  70. {/* <Text className="text-xs text-gray-400">{SiteConfig.company.address}</Text> */}
  71. </Section>
  72. </Container>
  73. </Body>
  74. </Tailwind>
  75. </Html>
  76. );