Implement modular email template system with preview and testing

- Create modular EmailTemplateRenderer with master shell and content separation
- Build reusable email components library (buttons, alerts, OTP boxes, etc.)
- Add EmailTemplatePreview component with master/content preview modes
- Implement test email functionality for each notification template
- Update NotifikasiTab to use new preview system with shortcode processing
- Add dummy shortcode data for testing (nama, email, order_id, etc.)
- Maintain design consistency between web and email

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
dwindown
2025-12-22 19:56:23 +07:00
parent 6e7b8eea1c
commit efc085e231
4 changed files with 967 additions and 46 deletions

310
email-master-template.html Normal file
View File

@@ -0,0 +1,310 @@
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Notification</title>
<style>
/* =========================================
1. CLIENT RESETS (The Boring Stuff)
========================================= */
body, table, td, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
table, td { mso-table-lspace: 0pt; mso-table-rspace: 0pt; }
img { -ms-interpolation-mode: bicubic; border: 0; height: auto; line-height: 100%; outline: none; text-decoration: none; }
table { border-collapse: collapse !important; }
body { height: 100% !important; margin: 0 !important; padding: 0 !important; width: 100% !important; background-color: #FFFFFF; }
/* =========================================
2. MASTER TYPOGRAPHY & VARS
========================================= */
:root {
--color-black: #000000;
--color-white: #FFFFFF;
--color-gray: #F4F4F5;
--color-success: #00A651;
--color-danger: #E11D48;
--border-thick: 2px solid #000000;
--border-thin: 1px solid #000000;
--shadow-hard: 4px 4px 0px 0px #000000;
}
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #000000;
-webkit-font-smoothing: antialiased;
}
/* =========================================
3. TIPTAP / DYNAMIC CONTENT POLISH
These rules automatically style raw HTML
========================================= */
/* Headings */
.tiptap-content h1 {
font-size: 28px;
font-weight: 800;
margin: 0 0 20px 0;
letter-spacing: -1px;
line-height: 1.1;
}
.tiptap-content h2 {
font-size: 20px;
font-weight: 700;
margin: 25px 0 15px 0;
text-transform: uppercase;
letter-spacing: 0.5px;
border-bottom: 2px solid #000;
padding-bottom: 5px;
display: inline-block;
}
.tiptap-content p {
font-size: 16px;
line-height: 1.6;
margin: 0 0 20px 0;
color: #333;
}
/* Standard Links */
.tiptap-content a {
color: #000000;
text-decoration: underline;
font-weight: 700;
text-underline-offset: 3px;
}
/* Lists */
.tiptap-content ul, .tiptap-content ol {
margin: 0 0 20px 0;
padding-left: 20px;
}
.tiptap-content li {
margin-bottom: 8px;
font-size: 16px;
padding-left: 5px;
}
/* TABLES (Brutalist Style) */
.tiptap-content table {
width: 100%;
border: 2px solid #000;
margin-bottom: 25px;
border-collapse: collapse;
}
.tiptap-content th {
background-color: #000;
color: #FFF;
padding: 12px;
text-align: left;
font-size: 14px;
text-transform: uppercase;
font-weight: 700;
border: 1px solid #000;
}
.tiptap-content td {
padding: 12px;
border: 1px solid #000;
font-size: 15px;
vertical-align: top;
}
/* Zebra Striping */
.tiptap-content tr:nth-child(even) td {
background-color: #F8F8F8;
}
/* BUTTONS (Class: .btn) */
.btn {
display: inline-block;
background-color: #000;
color: #FFF !important;
padding: 14px 28px;
font-weight: 700;
text-transform: uppercase;
text-decoration: none !important;
font-size: 16px;
border: 2px solid #000;
box-shadow: 4px 4px 0px 0px #000000; /* Hard Shadow */
margin: 10px 0;
transition: all 0.1s;
}
.btn:hover {
transform: translate(2px, 2px);
box-shadow: 2px 2px 0px 0px #000000;
}
.btn-full { width: 100%; text-align: center; box-sizing: border-box; }
/* CODE BLOCKS & OTP */
.tiptap-content pre {
background-color: #F4F4F5;
border: 2px solid #000;
padding: 15px;
overflow-x: auto;
margin-bottom: 20px;
}
.tiptap-content code {
font-family: 'Courier New', Courier, monospace;
font-size: 14px;
color: #E11D48; /* Highlight color for inline code */
background-color: #F4F4F5;
padding: 2px 4px;
}
/* Special OTP Style */
.otp-box {
background-color: #F4F4F5;
border: 2px dashed #000;
padding: 20px;
text-align: center;
margin: 20px 0;
letter-spacing: 5px;
font-family: 'Courier New', Courier, monospace;
font-size: 32px;
font-weight: 700;
color: #000;
}
/* BLOCKQUOTES / ALERTS */
.tiptap-content blockquote {
margin: 0 0 20px 0;
padding: 15px 20px;
border-left: 6px solid #000;
background-color: #F9F9F9;
font-style: italic;
font-weight: 500;
}
/* Contextual Alerts */
.alert-success { background-color: #E6F4EA; border-left-color: #00A651; color: #005A2B; }
.alert-danger { background-color: #FFE4E6; border-left-color: #E11D48; color: #881337; }
/* =========================================
4. RESPONSIVE
========================================= */
@media screen and (max-width: 600px) {
.email-container { width: 100% !important; border-left: 0 !important; border-right: 0 !important; }
.content-padding { padding: 30px 20px !important; }
.stack-mobile { display: block !important; width: 100% !important; }
}
</style>
</head>
<body style="margin: 0; padding: 0; background-color: #FFFFFF;">
<!-- 100% WRAPPER -->
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="background-color: #FFFFFF;">
<tr>
<td align="center" style="padding: 40px 0;">
<!-- MAIN CONTAINER (600px) -->
<!-- The "Hard Box" Look -->
<table border="0" cellpadding="0" cellspacing="0" width="600" class="email-container" style="background-color: #FFFFFF; border: 2px solid #000000; width: 600px; min-width: 320px;">
<!-- HEADER -->
<tr>
<td align="left" style="background-color: #000000; padding: 25px 40px; border-bottom: 2px solid #000000;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left">
<!-- LOGO (White text) -->
<div style="font-family: 'Helvetica Neue', sans-serif; font-size: 24px; font-weight: 900; color: #FFFFFF; letter-spacing: -1px; text-transform: uppercase;">
BRAND<span style="color: #888;">UI</span>
</div>
</td>
<td align="right">
<!-- Optional: Small Date or Tag -->
<div style="font-family: monospace; font-size: 12px; color: #888;">
NOTIF #2025
</div>
</td>
</tr>
</table>
</td>
</tr>
<!-- BODY CONTENT -->
<tr>
<td class="content-padding" style="padding: 40px 40px 60px 40px;">
<!--
DYNAMIC CONTENT WRAPPER (.tiptap-content)
This is where your Tiptap HTML will be injected.
-->
<div class="tiptap-content">
<!-- EXAMPLE 1: Standard Typography -->
<h1>Verify your login</h1>
<p>Halo <strong>Alex</strong>, kami mendeteksi permintaan masuk dari perangkat baru. Gunakan kode di bawah ini untuk menyelesaikan proses login.</p>
<!-- EXAMPLE 2: OTP / CODE BLOCK -->
<div class="otp-box">
829-103
</div>
<p>Kode ini akan kedaluwarsa dalam <strong>5 menit</strong>. Jika ini bukan Anda, abaikan email ini.</p>
<!-- EXAMPLE 3: TABLE (Auto-styled) -->
<h2>Rincian Perangkat</h2>
<table>
<thead>
<tr>
<th>Parameter</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>IP Address</td>
<td><code>192.168.1.1</code></td>
</tr>
<tr>
<td>Lokasi</td>
<td>Jakarta, Indonesia</td>
</tr>
<tr>
<td>Browser</td>
<td>Chrome on MacOS</td>
</tr>
</tbody>
</table>
<!-- EXAMPLE 4: CONTEXTUAL ALERT (Blockquote style) -->
<blockquote class="alert-danger">
<strong>Penting:</strong> Jangan pernah membagikan kode OTP ini kepada siapa pun, termasuk staf kami.
</blockquote>
<!-- EXAMPLE 5: BUTTON -->
<p style="margin-top: 30px;">
<a href="#" class="btn btn-full">
Amankan Akun Saya
</a>
</p>
</div>
<!-- END DYNAMIC CONTENT -->
</td>
</tr>
<!-- FOOTER -->
<tr>
<td style="padding: 30px 40px; border-top: 2px solid #000000; background-color: #F4F4F5; color: #000;">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="left" style="font-size: 12px; line-height: 18px; font-family: monospace; color: #555;">
<p style="margin: 0 0 10px 0; font-weight: bold;">PT BRUTALIST DIGITAL</p>
<p style="margin: 0 0 15px 0;">Menara Karya Lt. 20, Jakarta Selatan</p>
<p style="margin: 0;">
<a href="#" style="color: #000; text-decoration: underline;">Ubah Preferensi</a> &nbsp;|&nbsp;
<a href="#" style="color: #000; text-decoration: underline;">Unsubscribe</a>
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END MAIN CONTAINER -->
</td>
</tr>
</table>
</body>
</html>