| 1 | import { |
| 2 | Body, |
| 3 | Button, |
| 4 | Container, |
| 5 | Head, |
| 6 | Html, |
| 7 | Img, |
| 8 | Link, |
| 9 | Preview, |
| 10 | Section, |
| 11 | Text, |
| 12 | } from '@react-email/components'; |
| 13 | import type { ReactNode } from 'react'; |
| 14 | |
| 15 | import { brand, mono, sans } from './theme.js'; |
| 16 | |
| 17 | export const text = { |
| 18 | paragraph: { |
| 19 | fontSize: '14px', |
| 20 | lineHeight: '22px', |
| 21 | color: brand.foreground, |
| 22 | margin: '0 0 16px', |
| 23 | }, |
| 24 | strong: { fontWeight: 600, color: brand.foreground }, |
| 25 | muted: { |
| 26 | fontSize: '13px', |
| 27 | lineHeight: '20px', |
| 28 | color: brand.muted, |
| 29 | margin: '0', |
| 30 | }, |
| 31 | } as const; |
| 32 | |
| 33 | /** Mirrors the `default` button variant: bg-primary, rounded-lg, text-sm. */ |
| 34 | export function ActionButton({ |
| 35 | href, |
| 36 | children, |
| 37 | }: { |
| 38 | href: string; |
| 39 | children: ReactNode; |
| 40 | }) { |
| 41 | return ( |
| 42 | <Section style={{ margin: '20px 0 16px' }}> |
| 43 | <Button |
| 44 | href={href} |
| 45 | style={{ |
| 46 | backgroundColor: brand.primary, |
| 47 | borderRadius: '10px', |
| 48 | color: brand.primaryFg, |
| 49 | display: 'block', |
| 50 | fontFamily: sans, |
| 51 | fontSize: '14px', |
| 52 | fontWeight: 500, |
| 53 | padding: '10px 16px', |
| 54 | textAlign: 'center', |
| 55 | }} |
| 56 | > |
| 57 | {children} |
| 58 | </Button> |
| 59 | </Section> |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | /** The raw link, for clients that strip buttons. */ |
| 64 | export function LinkFallback({ href }: { href: string }) { |
| 65 | return ( |
| 66 | <> |
| 67 | <Text style={{ ...text.muted, fontSize: '12px', margin: '0 0 4px' }}> |
| 68 | Button not working? Paste this link into your browser: |
| 69 | </Text> |
| 70 | <Text |
| 71 | style={{ |
| 72 | ...text.muted, |
| 73 | fontFamily: mono, |
| 74 | fontSize: '12px', |
| 75 | lineHeight: '19px', |
| 76 | margin: '0 0 16px', |
| 77 | wordBreak: 'break-all', |
| 78 | }} |
| 79 | > |
| 80 | <Link href={href} style={{ color: brand.primary }}> |
| 81 | {href} |
| 82 | </Link> |
| 83 | </Text> |
| 84 | </> |
| 85 | ); |
| 86 | } |
| 87 | |
| 88 | export function EmailLayout({ |
| 89 | preview, |
| 90 | heading, |
| 91 | appUrl, |
| 92 | children, |
| 93 | }: { |
| 94 | preview: string; |
| 95 | heading: string; |
| 96 | appUrl: string; |
| 97 | children: ReactNode; |
| 98 | }) { |
| 99 | return ( |
| 100 | <Html lang="en"> |
| 101 | <Head /> |
| 102 | <Preview>{preview}</Preview> |
| 103 | <Body |
| 104 | style={{ |
| 105 | backgroundColor: brand.background, |
| 106 | fontFamily: sans, |
| 107 | margin: 0, |
| 108 | padding: '40px 16px', |
| 109 | }} |
| 110 | > |
| 111 | <Container style={{ maxWidth: '440px', padding: 0 }}> |
| 112 | {/* Same lockup as the app header: ghost mark, then the wordmark. */} |
| 113 | <Link |
| 114 | href={appUrl} |
| 115 | style={{ |
| 116 | color: brand.foreground, |
| 117 | display: 'inline-block', |
| 118 | fontSize: '16px', |
| 119 | fontWeight: 600, |
| 120 | letterSpacing: '-0.01em', |
| 121 | marginBottom: '16px', |
| 122 | textDecoration: 'none', |
| 123 | }} |
| 124 | > |
| 125 | <Img |
| 126 | alt="" |
| 127 | height="20" |
| 128 | src={`${appUrl}/email/ghost-mark.png`} |
| 129 | style={{ display: 'inline-block', verticalAlign: '-4px' }} |
| 130 | width="20" |
| 131 | /> |
| 132 | <span style={{ paddingLeft: '8px' }}>Ghost</span> |
| 133 | </Link> |
| 134 | |
| 135 | {/* Same card as the auth forms: white, hairline border, rounded-xl. */} |
| 136 | <Section |
| 137 | style={{ |
| 138 | backgroundColor: brand.card, |
| 139 | border: `1px solid ${brand.border}`, |
| 140 | borderRadius: '14px', |
| 141 | padding: '24px', |
| 142 | }} |
| 143 | > |
| 144 | <Text |
| 145 | style={{ |
| 146 | color: brand.foreground, |
| 147 | fontSize: '20px', |
| 148 | fontWeight: 600, |
| 149 | letterSpacing: '-0.01em', |
| 150 | lineHeight: '28px', |
| 151 | margin: '0 0 16px', |
| 152 | }} |
| 153 | > |
| 154 | {heading} |
| 155 | </Text> |
| 156 | {children} |
| 157 | </Section> |
| 158 | |
| 159 | <Text |
| 160 | style={{ |
| 161 | ...text.muted, |
| 162 | fontSize: '12px', |
| 163 | margin: '16px 0 0', |
| 164 | textAlign: 'center', |
| 165 | }} |
| 166 | > |
| 167 | <Link href={appUrl} style={{ color: brand.muted }}> |
| 168 | Ghost |
| 169 | </Link> |
| 170 | {' · host your git repositories, issues and pull requests.'} |
| 171 | </Text> |
| 172 | </Container> |
| 173 | </Body> |
| 174 | </Html> |
| 175 | ); |
| 176 | } |