App.jsx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
// Build a React.js HTML CSS & Gmail Email Renderer & iFrame Viewer With CSS in JSX Using react-email import React from "react"; import { Letter } from "react-letter"; const App = () => { // Simulated Gmail-style email content const emailContent = ` <html> <head> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f6f6f6; } .email-container { max-width: 600px; margin: 20px auto; background: #ffffff; border: 1px solid #ddd; border-radius: 5px; overflow: hidden; } .email-header { background-color: #4285f4; color: #ffffff; padding: 20px; text-align: center; } .email-body { padding: 20px; } .email-footer { background-color: #f1f1f1; text-align: center; padding: 10px; font-size: 12px; color: #555; } a { color: #4285f4; text-decoration: none; } a:hover { text-decoration: underline; } </style> </head> <body> <div class="email-container"> <div class="email-header"> <h1>Welcome to Our Service!</h1> </div> <div class="email-body"> <p>Dear User,</p> <p>We're excited to have you on board. Here are a few things you can explore:</p> <ul> <li><a href="https://example.com/features">Discover Features</a></li> <li><a href="https://example.com/support">Get Support</a></li> <li><a href="https://example.com/settings">Manage Settings</a></li> </ul> <p>Thank you for choosing our service!</p> <p>Best Regards,</p> <p>The Example Team</p> </div> <div class="email-footer"> <p>© 2024 Example Inc. All rights reserved.</p> <p> <a href="https://example.com/unsubscribe">Unsubscribe</a> | <a href="https://example.com/privacy">Privacy Policy</a> </p> </div> </div> </body> </html> `; // Function to rewrite external links const rewriteExternalLinks = (url) => { return `${url}?utm_source=email`; }; return ( <div style={{ padding: "20px" }}> <h2>Rendered Email:</h2> <div style={{ width: "100%" }}> <Letter html={emailContent} useIframe={true} iframeTitle="Sample Gmail Email" rewriteExternalLinks={rewriteExternalLinks} allowedSchemas={["http", "https", "mailto"]} className="email-wrapper" preserveCssPriority={true} style={{ width: "100%", border: "none" }} /> </div> <style jsx>{` iframe { width: 100% !important; height:100vh !important; } `}</style> </div> ); }; export default App; |