Develop a responsive email build system wiring MJML tokens, dark-mode testing, and…
- User
Develop a responsive email build system wiring MJML tokens, dark-mode testing, and localization hooks.
Assistant
Develop a responsive email build system wiring MJML tokens, dark-mode testing, and localization hooks.
The user wants an email build system with:
This is a sophisticated build tool/system, not a visual animation page. I'll create an interactive dashboard that:
Let me create a comprehensive, visually striking email build system interface with:
I'll use a sophisticated color scheme - maybe a dark slate/charcoal base with cyan/teal accents for a technical, professional feel.
A comprehensive email development environment with token management, dark-mode testing, and localization support. Here's my approach:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MJML Email Build System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Space+Grotesk:wght@400;500;600;700&display=swap" rel="stylesheet">
<script>
tailwind.config = {
darkMode: 'class',
theme: {
extend: {
fontFamily: {
mono: ['JetBrains Mono', 'monospace'],
display: ['Space Grotesk', 'sans-serif'],
}
}
}
}
</script>
<style>
:root {
--bg: #0f1419;
--bg-elevated: #1a2129;
--bg-card: #222d38;
--fg: #e7edf4;
--fg-muted: #8899a6;
--accent: #00d4aa;
--accent-hover: #00f5c4;
--accent-dim: rgba(0, 212, 170, 0.15);
--border: #2f3d4a;
--error: #ff6b6b;
--warning: #ffc857;
--success: #00d4aa;
}
* {
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
}
body {
background: var(--bg);
color: var(--fg);
font-family: 'Space Grotesk', sans-serif;
}
.bg-noise {
background-image:
radial-gradient(ellipse at 20% 0%, rgba(0, 212, 170, 0.08) 0%, transparent 50%),
radial-gradient(ellipse at 80% 100%, rgba(0, 180, 220, 0.05) 0%, transparent 50%);
}
.grid-pattern {
background-image:
linear-gradient(rgba(47, 61, 74, 0.3) 1px, transparent 1px),
linear-gradient(90deg, rgba(47, 61, 74, 0.3) 1px, transparent 1px);
background-size: 24px 24px;
}
.token-tag {
background: var(--accent-dim);
color: var(--accent);
border: 1px solid rgba(0, 212, 170, 0.3);
}
.code-editor {
background: var(--bg);
border: 1px solid var(--border);
font-family: 'JetBrains Mono', monospace;
line-height: 1.6;
}
.code-editor:focus {
outline: none;
border-color: var(--accent);
box-shadow: 0 0 0 3px var(--accent-dim);
}
.preview-frame {
background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.preview-frame.dark-mode {
background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}
.tab-active {
color: var(--accent);
border-bottom: 2px solid var(--accent);
}
.btn-primary {
background: var(--accent);
color: var(--bg);
transition: all 0.2s ease;
}
.btn-primary:hover {
background: var(--accent-hover);
transform: translateY(-1px);
box-shadow: 0 4px 20px rgba(0, 212, 170, 0.3);
}
.btn-primary:active {
transform: translateY(0);
}
.btn-secondary {
background: var(--bg-card);
color: var(--fg);
border: 1px solid var(--border);
transition: all 0.2s ease;
}
.btn-secondary:hover {
border-color: var(--accent);
color: var(--accent);
}
.sidebar-item {
transition: all 0.15s ease;
}
.sidebar-item:hover {
background: var(--bg-card);
}
.sidebar-item.active {
background: var(--accent-dim);
color: var(--accent);
border-left: 3px solid var(--accent);
}
.fade-in {
animation: fadeIn 0.4s ease forwards;
}
.slide-up {
animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes slideUp {
from {
opacity: 0;
transform: translateY(20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.stagger-1 { animation-delay: 0.1s; }
.stagger-2 { animation-delay: 0.2s; }
.stagger-3 { animation-delay: 0.3s; }
.stagger-4 { animation-delay: 0.4s; }
@media (prefers-reduced-motion: reduce) {
.fade-in, .slide-up {
animation: none;
opacity: 1;
transform: none;
}
}
.language-badge {
font-size: 10px;
padding: 2px 6px;
border-radius: 4px;
text-transform: uppercase;
font-weight: 600;
}
.build-output {
background: var(--bg);
border: 1px solid var(--border);
max-height: 200px;
overflow-y: auto;
}
.status-dot {
width: 8px;
height: 8px;
border-radius: 50%;
animation: pulse 2s infinite;
}
@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.5; }
}
.tooltip {
position: relative;
}
.tooltip::after {
content: attr(data-tooltip);
position: absolute;
bottom: 100%;
left: 50%;
transform: translateX(-50%);
background: var(--bg-card);
color: var(--fg);
padding: 4px 8px;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 0.2s;
}
.tooltip:hover::after {
opacity: 1;
}
.drag-handle {
cursor: grab;
}
.drag-handle:active {
cursor: grabbing;
}
</style>
</head>
<body class="min-h-screen bg-noise">
<div class="flex h-screen overflow-hidden">
<!-- Sidebar -->
<aside class="w-64 border-r border-[var(--border)] flex flex-col bg-[var(--bg-elevated)]">
<div class="p-4 border-b border-[var(--border)]">
<div class="flex items-center gap-3">
<div class="w-10 h-10 rounded-lg bg-[var(--accent-dim)] flex items-center justify-center">
<svg class="w-6 h-6 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 8l7.89 5.26a2 2 0 002.22 0L21 8M5 19h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"/>
</svg>
</div>
<div>
<h1 class="font-semibold text-lg">Email Forge</h1>
<p class="text-xs text-[var(--fg-muted)]">MJML Build System</p>
</div>
</div>
</div>
<nav class="flex-1 p-2 overflow-y-auto">
<div class="mb-4">
<p class="px-3 py-2 text-xs font-semibold text-[var(--fg-muted)] uppercase tracking-wider">Build</p>
<button class="sidebar-item active w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="templates">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 5a1 1 0 011-1h14a1 1 0 011 1v2a1 1 0 01-1 1H5a1 1 0 01-1-1V5zM4 13a1 1 0 011-1h6a1 1 0 011 1v6a1 1 0 01-1 1H5a1 1 0 01-1-1v-6zM16 13a1 1 0 011-1h2a1 1 0 011 1v6a1 1 0 01-1 1h-2a1 1 0 01-1-1v-6z"/>
</svg>
Templates
</button>
<button class="sidebar-item w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="tokens">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"/>
</svg>
Tokens
</button>
<button class="sidebar-item w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="localization">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 5h12M9 3v2m1.048 9.5A18.022 18.022 0 016.412 9m6.088 9h7M11 21l5-10 5 10M12.751 5C11.783 10.77 8.07 15.61 3 18.129"/>
</svg>
Localization
</button>
</div>
<div class="mb-4">
<p class="px-3 py-2 text-xs font-semibold text-[var(--fg-muted)] uppercase tracking-wider">Test</p>
<button class="sidebar-item w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="preview">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
</svg>
Preview
</button>
<button class="sidebar-item w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="darkmode">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
</svg>
Dark Mode
</button>
</div>
<div>
<p class="px-3 py-2 text-xs font-semibold text-[var(--fg-muted)] uppercase tracking-wider">Export</p>
<button class="sidebar-item w-full text-left px-3 py-2 rounded-lg flex items-center gap-3" data-section="build">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
</svg>
Build Pipeline
</button>
</div>
</nav>
<div class="p-4 border-t border-[var(--border)]">
<div class="flex items-center gap-2 text-sm">
<div class="status-dot bg-[var(--success)]"></div>
<span class="text-[var(--fg-muted)]">System Ready</span>
</div>
</div>
</aside>
<!-- Main Content -->
<main class="flex-1 flex flex-col overflow-hidden">
<!-- Header -->
<header class="h-14 border-b border-[var(--border)] flex items-center justify-between px-6 bg-[var(--bg-elevated)]">
<div class="flex items-center gap-4">
<h2 class="font-semibold" id="section-title">Templates</h2>
<span class="text-xs text-[var(--fg-muted)] bg-[var(--bg-card)] px-2 py-1 rounded">v2.4.0</span>
</div>
<div class="flex items-center gap-3">
<button id="dark-mode-toggle" class="btn-secondary px-3 py-1.5 rounded-lg text-sm flex items-center gap-2" aria-label="Toggle dark mode preview">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
</svg>
Dark Mode
</button>
<button id="build-btn" class="btn-primary px-4 py-1.5 rounded-lg text-sm font-semibold flex items-center gap-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.752 11.168l-3.197-2.132A1 1 0 0010 9.87v4.263a1 1 0 001.555.832l3.197-2.132a1 1 0 000-1.664z"/>
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Build All
</button>
</div>
</header>
<!-- Content Area -->
<div class="flex-1 flex overflow-hidden">
<!-- Editor Panel -->
<div class="flex-1 flex flex-col overflow-hidden" id="editor-panel">
<!-- Templates Section -->
<section id="templates-section" class="flex-1 flex overflow-hidden">
<div class="flex-1 p-6 overflow-y-auto">
<div class="mb-6 flex items-center justify-between">
<div>
<h3 class="text-lg font-semibold">Email Templates</h3>
<p class="text-sm text-[var(--fg-muted)]">Select a template to edit</p>
</div>
<button class="btn-secondary px-3 py-1.5 rounded-lg text-sm flex items-center gap-2" id="new-template-btn">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
</svg>
New Template
</button>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-4" id="templates-grid">
<!-- Templates will be rendered here -->
</div>
</div>
</section>
<!-- Tokens Section -->
<section id="tokens-section" class="flex-1 overflow-hidden hidden">
<div class="h-full flex">
<div class="flex-1 p-6 overflow-y-auto">
<div class="mb-6">
<h3 class="text-lg font-semibold">Design Tokens</h3>
<p class="text-sm text-[var(--fg-muted)]">Reusable variables for consistent styling</p>
</div>
<div class="space-y-6" id="tokens-container">
<!-- Color Tokens -->
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-3 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 21a4 4 0 01-4-4V5a2 2 0 012-2h4a2 2 0 012 2v12a4 4 0 01-4 4zm0 0h12a2 2 0 002-2v-4a2 2 0 00-2-2h-2.343M11 7.343l1.657-1.657a2 2 0 012.828 0l2.829 2.829a2 2 0 010 2.828l-8.486 8.485M7 17h.01"/>
</svg>
Colors
</h4>
<div class="grid grid-cols-2 md:grid-cols-4 gap-3" id="color-tokens"></div>
</div>
<!-- Spacing Tokens -->
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-3 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 8V4m0 0h4M4 4l5 5m11-1V4m0 0h-4m4 0l-5 5M4 16v4m0 0h4m-4 0l5-5m11 5l-5-5m5 5v-4m0 4h-4"/>
</svg>
Spacing
</h4>
<div class="flex flex-wrap gap-2" id="spacing-tokens"></div>
</div>
<!-- Typography Tokens -->
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-3 flex items-center gap-2">
<svg class="w-5 h-5 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16"/>
</svg>
Typography
</h4>
<div class="space-y-2" id="typography-tokens"></div>
</div>
</div>
</div>
<!-- Token Editor Sidebar -->
<div class="w-80 border-l border-[var(--border)] p-4 bg-[var(--bg-elevated)] overflow-y-auto">
<h4 class="font-semibold mb-4">Token Editor</h4>
<div class="space-y-4">
<div>
<label class="block text-sm text-[var(--fg-muted)] mb-1">Token Name</label>
<input type="text" id="token-name" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]" placeholder="e.g., primary-color">
</div>
<div>
<label class="block text-sm text-[var(--fg-muted)] mb-1">Token Value</label>
<input type="text" id="token-value" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]" placeholder="e.g., #00d4aa">
</div>
<div>
<label class="block text-sm text-[var(--fg-muted)] mb-1">Category</label>
<select id="token-category" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded-lg px-3 py-2 text-sm focus:outline-none focus:border-[var(--accent)]">
<option value="colors">Colors</option>
<option value="spacing">Spacing</option>
<option value="typography">Typography</option>
</select>
</div>
<button class="btn-primary w-full py-2 rounded-lg text-sm font-semibold" id="add-token-btn">Add Token</button>
</div>
<div class="mt-6 pt-6 border-t border-[var(--border)]">
<h5 class="font-semibold mb-3 text-sm">Token Usage</h5>
<div class="code-editor p-3 rounded-lg text-xs text-[var(--fg-muted)]">
<pre><mj-text>
{{tokens.primaryColor}}
</mj-text>
<mj-section padding="
{{tokens.spacingLg}}">
...
</mj-section></pre>
</div>
</div>
</div>
</div>
</section>
<!-- Localization Section -->
<section id="localization-section" class="flex-1 overflow-hidden hidden">
<div class="h-full flex">
<div class="flex-1 p-6 overflow-y-auto">
<div class="mb-6 flex items-center justify-between">
<div>
<h3 class="text-lg font-semibold">Localization Strings</h3>
<p class="text-sm text-[var(--fg-muted)]">Manage multi-language content</p>
</div>
<div class="flex items-center gap-2">
<select id="language-select" class="bg-[var(--bg-card)] border border-[var(--border)] rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:border-[var(--accent)]">
<option value="en">English (EN)</option>
<option value="es">Spanish (ES)</option>
<option value="fr">French (FR)</option>
<option value="de">German (DE)</option>
<option value="ja">Japanese (JA)</option>
</select>
<button class="btn-secondary px-3 py-1.5 rounded-lg text-sm" id="add-lang-btn">Add Language</button>
</div>
</div>
<div class="space-y-3" id="localization-strings">
<!-- Localization strings will be rendered here -->
</div>
</div>
<!-- Localization Hooks Panel -->
<div class="w-80 border-l border-[var(--border)] p-4 bg-[var(--bg-elevated)] overflow-y-auto">
<h4 class="font-semibold mb-4">Hook Variables</h4>
<div class="space-y-3" id="hook-variables">
<!-- Hook variables will be rendered here -->
</div>
<div class="mt-6 pt-6 border-t border-[var(--border)]">
<h5 class="font-semibold mb-3 text-sm">Usage in MJML</h5>
<div class="code-editor p-3 rounded-lg text-xs text-[var(--fg-muted)]">
<pre><mj-text>
{{i18n.welcome_message}}
</mj-text>
<mj-button>
{{i18n.cta_button}}
</mj-button></pre>
</div>
</div>
<button class="btn-secondary w-full py-2 rounded-lg text-sm mt-4" id="export-i18n-btn">
Export JSON
</button>
</div>
</div>
</section>
<!-- Preview Section -->
<section id="preview-section" class="flex-1 overflow-hidden hidden">
<div class="h-full flex">
<div class="flex-1 p-6 overflow-y-auto">
<div class="mb-4 flex items-center justify-between">
<div>
<h3 class="text-lg font-semibold">Live Preview</h3>
<p class="text-sm text-[var(--fg-muted)]">Real-time email rendering</p>
</div>
<div class="flex items-center gap-2">
<button class="btn-secondary px-3 py-1.5 rounded-lg text-sm device-btn active" data-device="desktop">Desktop</button>
<button class="btn-secondary px-3 py-1.5 rounded-lg text-sm device-btn" data-device="mobile">Mobile</button>
</div>
</div>
<div class="flex justify-center">
<div id="preview-container" class="preview-frame rounded-xl shadow-2xl overflow-hidden transition-all duration-300" style="width: 600px;">
<div class="p-8">
<div id="email-preview"></div>
</div>
</div>
</div>
</div>
<!-- Code View -->
<div class="w-96 border-l border-[var(--border)] flex flex-col bg-[var(--bg-elevated)]">
<div class="p-4 border-b border-[var(--border)]">
<div class="flex items-center gap-2">
<button class="tab-active px-3 py-1.5 text-sm font-medium" data-tab="mjml">MJML</button>
<button class="px-3 py-1.5 text-sm font-medium text-[var(--fg-muted)]" data-tab="html">HTML</button>
</div>
</div>
<div class="flex-1 p-4 overflow-y-auto">
<pre id="code-view" class="code-editor p-4 rounded-lg text-xs overflow-auto h-full"></pre>
</div>
</div>
</div>
</section>
<!-- Dark Mode Section -->
<section id="darkmode-section" class="flex-1 overflow-hidden hidden">
<div class="h-full p-6 overflow-y-auto">
<div class="mb-6">
<h3 class="text-lg font-semibold">Dark Mode Testing</h3>
<p class="text-sm text-[var(--fg-muted)]">Test email appearance in dark mode clients</p>
</div>
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<!-- Light Mode Preview -->
<div>
<div class="flex items-center gap-2 mb-3">
<svg class="w-5 h-5 text-[var(--warning)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z"/>
</svg>
<span class="font-medium">Light Mode</span>
</div>
<div class="preview-frame rounded-xl shadow-lg p-6">
<div id="light-preview"></div>
</div>
</div>
<!-- Dark Mode Preview -->
<div>
<div class="flex items-center gap-2 mb-3">
<svg class="w-5 h-5 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z"/>
</svg>
<span class="font-medium">Dark Mode</span>
</div>
<div class="preview-frame dark-mode rounded-xl shadow-lg p-6">
<div id="dark-preview"></div>
</div>
</div>
</div>
<!-- Dark Mode Settings -->
<div class="mt-8 bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-4">Dark Mode Color Overrides</h4>
<div class="grid grid-cols-1 md:grid-cols-3 gap-4" id="dark-mode-overrides">
<!-- Dark mode overrides will be rendered here -->
</div>
</div>
<!-- Client Support Matrix -->
<div class="mt-6 bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-4">Client Support Matrix</h4>
<div class="grid grid-cols-2 md:grid-cols-4 gap-3" id="client-support">
<!-- Client support info will be rendered here -->
</div>
</div>
</div>
</section>
<!-- Build Section -->
<section id="build-section" class="flex-1 overflow-hidden hidden">
<div class="h-full p-6 overflow-y-auto">
<div class="mb-6">
<h3 class="text-lg font-semibold">Build Pipeline</h3>
<p class="text-sm text-[var(--fg-muted)]">Generate production-ready email templates</p>
</div>
<!-- Build Configuration -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-6">
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-4">Build Configuration</h4>
<div class="space-y-4">
<div class="flex items-center justify-between">
<span class="text-sm">Minify Output</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="minify-toggle" class="sr-only peer" checked>
<div class="w-9 h-5 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"></div>
</label>
</div>
<div class="flex items-center justify-between">
<span class="text-sm">Inline Styles</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="inline-toggle" class="sr-only peer" checked>
<div class="w-9 h-5 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"></div>
</label>
</div>
<div class="flex items-center justify-between">
<span class="text-sm">Generate Text Version</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="text-toggle" class="sr-only peer">
<div class="w-9 h-5 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"></div>
</label>
</div>
<div class="flex items-center justify-between">
<span class="text-sm">Include Dark Mode Styles</span>
<label class="relative inline-flex items-center cursor-pointer">
<input type="checkbox" id="dark-toggle" class="sr-only peer" checked>
<div class="w-9 h-5 bg-[var(--border)] peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[var(--accent)]"></div>
</label>
</div>
</div>
</div>
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-4">Output Languages</h4>
<div class="space-y-2" id="output-languages">
<!-- Language checkboxes will be rendered here -->
</div>
</div>
</div>
<!-- Build Output -->
<div class="bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<div class="flex items-center justify-between mb-4">
<h4 class="font-semibold">Build Output</h4>
<div class="flex items-center gap-2">
<span id="build-status" class="text-sm text-[var(--fg-muted)]">Ready</span>
<button class="btn-primary px-4 py-1.5 rounded-lg text-sm font-semibold" id="run-build-btn">
Run Build
</button>
</div>
</div>
<div class="build-output rounded-lg p-4 font-mono text-sm" id="build-log">
<div class="text-[var(--fg-muted)]">[ready] Build system initialized</div>
<div class="text-[var(--fg-muted)]">[ready] Waiting for build command...</div>
</div>
</div>
<!-- Generated Files -->
<div class="mt-6 bg-[var(--bg-card)] rounded-xl p-4 border border-[var(--border)]">
<h4 class="font-semibold mb-4">Generated Files</h4>
<div class="space-y-2" id="generated-files">
<!-- Generated files will be listed here -->
</div>
</div>
</div>
</section>
</div>
</div>
</main>
</div>
<!-- Toast Notification -->
<div id="toast" class="fixed bottom-4 right-4 bg-[var(--bg-card)] border border-[var(--border)] px-4 py-3 rounded-lg shadow-xl transform translate-y-20 opacity-0 transition-all duration-300 flex items-center gap-3">
<svg class="w-5 h-5 text-[var(--success)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"/>
</svg>
<span id="toast-message">Action completed</span>
</div>
<script>
// ============================================
// DATA INITIALIZATION
// ============================================
const emailTemplates = [
{
id: 'welcome',
name: 'Welcome Email',
description: 'Onboarding email for new users',
thumbnail: 'welcome',
category: 'Transactional',
lastModified: '2024-01-15'
},
{
id: 'newsletter',
name: 'Monthly Newsletter',
description: 'Regular newsletter template',
thumbnail: 'newsletter',
category: 'Marketing',
lastModified: '2024-01-14'
},
{
id: 'password-reset',
name: 'Password Reset',
description: 'Security email for password recovery',
thumbnail: 'security',
category: 'Transactional',
lastModified: '2024-01-13'
},
{
id: 'promo',
name: 'Promotional Offer',
description: 'Sales and promotional campaigns',
thumbnail: 'promo',
category: 'Marketing',
lastModified: '2024-01-12'
}
];
const designTokens = {
colors: [
{ name: 'primary', value: '#00d4aa', description: 'Primary brand color' },
{ name: 'secondary', value: '#0f1419', description: 'Secondary dark color' },
{ name: 'accent', value: '#ffc857', description: 'Accent highlight' },
{ name: 'error', value: '#ff6b6b', description: 'Error states' },
{ name: 'success', value: '#00d4aa', description: 'Success states' },
{ name: 'text', value: '#1a2129', description: 'Body text' },
{ name: 'textLight', value: '#8899a6', description: 'Muted text' },
{ name: 'background', value: '#ffffff', description: 'Email background' }
],
spacing: [
{ name: 'xs', value: '4px' },
{ name: 'sm', value: '8px' },
{ name: 'md', value: '16px' },
{ name: 'lg', value: '24px' },
{ name: 'xl', value: '32px' },
{ name: '2xl', value: '48px' }
],
typography: [
{ name: 'headingFont', value: 'Space Grotesk, sans-serif' },
{ name: 'bodyFont', value: 'system-ui, sans-serif' },
{ name: 'headingSize', value: '28px' },
{ name: 'bodySize', value: '16px' },
{ name: 'smallSize', value: '14px' }
]
};
const darkModeOverrides = [
{ token: 'background', light: '#ffffff', dark: '#1a1a2e' },
{ token: 'text', light: '#1a2129', dark: '#e7edf4' },
{ token: 'textLight', light: '#8899a6', dark: '#a0aec0' },
{ token: 'cardBg', light: '#f8f9fa', dark: '#222d38' }
];
const clientSupport = [
{ name: 'Gmail', supported: true, notes: 'Full support' },
{ name: 'Outlook', supported: true, notes: 'Partial support' },
{ name: 'Apple Mail', supported: true, notes: 'Full support' },
{ name: 'Yahoo', supported: false, notes: 'No dark mode' }
];
const localizationStrings = {
en: {
welcome_message: 'Welcome to our platform!',
cta_button: 'Get Started',
footer_text: 'You received this email because you signed up.',
unsubscribe: 'Unsubscribe',
company_name: 'Email Forge'
},
es: {
welcome_message: 'Bienvenido a nuestra plataforma!',
cta_button: 'Comenzar',
footer_text: 'Recibiste este correo porque te registraste.',
unsubscribe: 'Darse de baja',
company_name: 'Email Forge'
},
fr: {
welcome_message: 'Bienvenue sur notre plateforme!',
cta_button: 'Commencer',
footer_text: 'Vous avez reçu cet email parce que vous vous êtes inscrit.',
unsubscribe: 'Se désabonner',
company_name: 'Email Forge'
},
de: {
welcome_message: 'Willkommen auf unserer Plattform!',
cta_button: 'Loslegen',
footer_text: 'Sie haben diese E-Mail erhalten, weil Sie sich angemeldet haben.',
unsubscribe: 'Abmelden',
company_name: 'Email Forge'
},
ja: {
welcome_message: '私たちのプラットフォームへようこそ!',
cta_button: '始める',
footer_text: '登録されたため、このメールを受け取りました。',
unsubscribe: '購読解除',
company_name: 'Email Forge'
}
};
const hookVariables = [
{ name: 'user.firstName', description: 'Recipient first name' },
{ name: 'user.lastName', description: 'Recipient last name' },
{ name: 'user.email', description: 'Recipient email' },
{ name: 'company.name', description: 'Company name' },
{ name: 'company.logo', description: 'Logo URL' },
{ name: 'unsubscribeUrl', description: 'Unsubscribe link' },
{ name: 'webVersionUrl', description: 'Web version link' }
];
// ============================================
// STATE MANAGEMENT
// ============================================
let currentSection = 'templates';
let selectedTemplate = null;
let currentLanguage = 'en';
let isDarkMode = false;
let selectedDevice = 'desktop';
// ============================================
// DOM ELEMENTS
// ============================================
const sectionTitle = document.getElementById('section-title');
const templatesGrid = document.getElementById('templates-grid');
const colorTokensContainer = document.getElementById('color-tokens');
const spacingTokensContainer = document.getElementById('spacing-tokens');
const typographyTokensContainer = document.getElementById('typography-tokens');
const localizationStringsContainer = document.getElementById('localization-strings');
const hookVariablesContainer = document.getElementById('hook-variables');
const darkModeOverridesContainer = document.getElementById('dark-mode-overrides');
const clientSupportContainer = document.getElementById('client-support');
const outputLanguagesContainer = document.getElementById('output-languages');
const generatedFilesContainer = document.getElementById('generated-files');
const emailPreview = document.getElementById('email-preview');
const lightPreview = document.getElementById('light-preview');
const darkPreview = document.getElementById('dark-preview');
const codeView = document.getElementById('code-view');
const buildLog = document.getElementById('build-log');
const buildStatus = document.getElementById('build-status');
const toast = document.getElementById('toast');
const toastMessage = document.getElementById('toast-message');
const previewContainer = document.getElementById('preview-container');
const languageSelect = document.getElementById('language-select');
// ============================================
// UTILITY FUNCTIONS
// ============================================
function showToast(message) {
toastMessage.textContent = message;
toast.classList.remove('translate-y-20', 'opacity-0');
setTimeout(() => {
toast.classList.add('translate-y-20', 'opacity-0');
}, 3000);
}
function generateId() {
return Math.random().toString(36).substr(2, 9);
}
// ============================================
// RENDER FUNCTIONS
// ============================================
function renderTemplates() {
templatesGrid.innerHTML = emailTemplates.map((template, index) => `
<div class="bg-[var(--bg-card)] rounded-xl border border-[var(--border)] overflow-hidden slide-up stagger-${index % 4 + 1} cursor-pointer hover:border-[var(--accent)] transition-all" data-template="${template.id}">
<div class="h-40 bg-gradient-to-br from-[var(--accent-dim)] to-[var(--bg)] flex items-center justify-center">
<div class="w-32 h-24 bg-white rounded shadow-lg flex flex-col items-center justify-center p-2">
<div class="w-full h-2 bg-[var(--accent)] rounded mb-1"></div>
<div class="w-3/4 h-1.5 bg-gray-200 rounded mb-1"></div>
<div class="w-1/2 h-1.5 bg-gray-200 rounded mb-2"></div>
<div class="w-full h-6 bg-[var(--accent-dim)] rounded"></div>
</div>
</div>
<div class="p-4">
<div class="flex items-start justify-between mb-2">
<h4 class="font-semibold">${template.name}</h4>
<span class="token-tag text-xs px-2 py-0.5 rounded">${template.category}</span>
</div>
<p class="text-sm text-[var(--fg-muted)] mb-3">${template.description}</p>
<div class="flex items-center justify-between text-xs text-[var(--fg-muted)]">
<span>Modified: ${template.lastModified}</span>
<button class="text-[var(--accent)] hover:underline" onclick="editTemplate('${template.id}')">Edit</button>
</div>
</div>
</div>
`).join('');
// Add click handlers
document.querySelectorAll('[data-template]').forEach(el => {
el.addEventListener('click', (e) => {
if (!e.target.classList.contains('hover:underline')) {
selectTemplate(el.dataset.template);
}
});
});
}
function renderColorTokens() {
colorTokensContainer.innerHTML = designTokens.colors.map(token => `
<div class="flex items-center gap-2 p-2 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="w-8 h-8 rounded" style="background-color: ${token.value}"></div>
<div class="flex-1 min-w-0">
<div class="text-sm font-medium truncate">${token.name}</div>
<div class="text-xs text-[var(--fg-muted)]">${token.value}</div>
</div>
<button class="p-1 hover:bg-[var(--bg-card)] rounded" onclick="copyToken('${token.value}')" aria-label="Copy token value">
<svg class="w-4 h-4 text-[var(--fg-muted)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 16H6a2 2 0 01-2-2V6a2 2 0 012-2h8a2 2 0 012 2v2m-6 12h8a2 2 0 002-2v-8a2 2 0 00-2-2h-8a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</button>
</div>
`).join('');
}
function renderSpacingTokens() {
spacingTokensContainer.innerHTML = designTokens.spacing.map(token => `
<div class="flex items-center gap-2 p-2 px-3 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="w-4 h-4 bg-[var(--accent)] rounded-sm" style="width: ${token.value}"></div>
<span class="text-sm">${token.name}</span>
<span class="text-xs text-[var(--fg-muted)]">${token.value}</span>
</div>
`).join('');
}
function renderTypographyTokens() {
typographyTokensContainer.innerHTML = designTokens.typography.map(token => `
<div class="flex items-center justify-between p-2 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<span class="text-sm font-medium">${token.name}</span>
<code class="text-xs text-[var(--fg-muted)] bg-[var(--bg-card)] px-2 py-1 rounded">${token.value}</code>
</div>
`).join('');
}
function renderLocalizationStrings() {
const strings = localizationStrings[currentLanguage] || {};
localizationStringsContainer.innerHTML = Object.entries(strings).map(([key, value]) => `
<div class="bg-[var(--bg-card)] rounded-lg p-3 border border-[var(--border)] flex items-center gap-4">
<div class="flex-1">
<div class="text-sm font-mono text-[var(--accent)] mb-1">{{i18n.${key}}}</div>
<input type="text" value="${value}" class="w-full bg-[var(--bg)] border border-[var(--border)] rounded px-3 py-1.5 text-sm focus:outline-none focus:border-[var(--accent)]" data-key="${key}" onchange="updateLocalization('${key}', this.value)">
</div>
<span class="language-badge bg-[var(--accent-dim)] text-[var(--accent)]">${currentLanguage.toUpperCase()}</span>
</div>
`).join('');
}
function renderHookVariables() {
hookVariablesContainer.innerHTML = hookVariables.map(hook => `
<div class="p-2 rounded-lg bg-[var(--bg)] border border-[var(--border)] cursor-pointer hover:border-[var(--accent)] transition-colors" onclick="copyToken('{{${hook.name}}}')">
<div class="text-sm font-mono text-[var(--accent)]">{{${hook.name}}}</div>
<div class="text-xs text-[var(--fg-muted)]">${hook.description}</div>
</div>
`).join('');
}
function renderDarkModeOverrides() {
darkModeOverridesContainer.innerHTML = darkModeOverrides.map(override => `
<div class="p-3 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="text-sm font-medium mb-2">${override.token}</div>
<div class="flex items-center gap-2 mb-2">
<div class="w-6 h-6 rounded border border-[var(--border)]" style="background-color: ${override.light}"></div>
<input type="text" value="${override.light}" class="flex-1 bg-transparent border-none text-xs text-[var(--fg-muted)] focus:outline-none">
</div>
<div class="flex items-center gap-2">
<div class="w-6 h-6 rounded border border-[var(--border)]" style="background-color: ${override.dark}"></div>
<input type="text" value="${override.dark}" class="flex-1 bg-transparent border-none text-xs text-[var(--fg-muted)] focus:outline-none">
</div>
</div>
`).join('');
}
function renderClientSupport() {
clientSupportContainer.innerHTML = clientSupport.map(client => `
<div class="p-3 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="flex items-center gap-2 mb-2">
<div class="w-3 h-3 rounded-full ${client.supported ? 'bg-[var(--success)]' : 'bg-[var(--error)]'}"></div>
<span class="font-medium text-sm">${client.name}</span>
</div>
<div class="text-xs text-[var(--fg-muted)]">${client.notes}</div>
</div>
`).join('');
}
function renderOutputLanguages() {
const languages = Object.keys(localizationStrings);
outputLanguagesContainer.innerHTML = languages.map(lang => `
<label class="flex items-center gap-2 p-2 rounded-lg bg-[var(--bg)] border border-[var(--border)] cursor-pointer hover:border-[var(--accent)]">
<input type="checkbox" checked class="w-4 h-4 accent-[var(--accent)]">
<span class="text-sm">${lang.toUpperCase()}</span>
<span class="text-xs text-[var(--fg-muted)] ml-auto">${localizationStrings[lang] ? Object.keys(localizationStrings[lang]).length : 0} strings</span>
</label>
`).join('');
}
function renderGeneratedFiles() {
const templates = emailTemplates.map(t => t.id);
const languages = Object.keys(localizationStrings);
const files = [];
templates.forEach(template => {
languages.forEach(lang => {
files.push(`${template}-${lang}.html`);
});
});
generatedFilesContainer.innerHTML = files.slice(0, 8).map((file, i) => `
<div class="flex items-center justify-between p-2 rounded-lg bg-[var(--bg)] border border-[var(--border)]">
<div class="flex items-center gap-2">
<svg class="w-4 h-4 text-[var(--accent)]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<span class="text-sm">${file}</span>
</div>
<button class="text-xs text-[var(--accent)] hover:underline">Download</button>
</div>
`).join('');
if (files.length > 8) {
generatedFilesContainer.innerHTML += `
<div class="text-center text-sm text-[var(--fg-muted)] py-2">
+${files.length - 8} more files
</div>
`;
}
}
function renderEmailPreview(container, isDark = false) {
const strings = localizationStrings[currentLanguage];
const primaryColor = isDark ? '#00d4aa' : '#00d4aa';
const bgColor = isDark ? '#1a1a2e' : '#ffffff';
const textColor = isDark ? '#e7edf4' : '#1a2129';
const mutedColor = isDark ? '#a0aec0' : '#8899a6';
container.innerHTML = `
<div style="font-family: system-ui, sans-serif; background: ${bgColor}; color: ${textColor};">
<div style="text-align: center; padding: 20px 0;">
<div style="font-size: 24px; font-weight: bold; color: ${primaryColor};">${strings.company_name}</div>
</div>
<div style="padding: 32px 24px; text-align: center;">
<h1 style="font-size: 28px; font-weight: bold; margin-bottom: 16px; color: ${textColor};">${strings.welcome_message}</h1>
<p style="color: ${mutedColor}; margin-bottom: 24px; line-height: 1.6;">
We're excited to have you on board. Get started with our platform today.
</p>
<a href="#" style="display: inline-block; background: ${primaryColor}; color: ${bgColor}; padding: 14px 32px; border-radius: 8px; text-decoration: none; font-weight: 600;">
${strings.cta_button}
</a>
</div>
<div style="border-top: 1px solid ${isDark ? '#2f3d4a' : '#e5e7eb'}; padding: 24px; text-align: center;">
<p style="font-size: 12px; color: ${mutedColor};">${strings.footer_text}</p>
<a href="#" style="font-size: 12px; color: ${primaryColor};">${strings.unsubscribe}</a>
</div>
</div>
`;
}
function renderCodeView() {
const strings = localizationStrings[currentLanguage];
const mjmlCode = `<mjml>
<mj-head>
<mj-title>Welcome Email</mj-title>
<mj-attributes>
<mj-text font-family="system-ui, sans-serif"/>
<mj-button background-color="{{tokens.primary}}"/>
</mj-attributes>
</mj-head>
<mj-body background-color="{{tokens.background}}">
<mj-section padding="{{tokens.spacingLg}}">
<mj-column>
<mj-text align="center" font-size="24px" font-weight="bold" color="{{tokens.primary}}">
{{i18n.company_name}}
</mj-text>
</mj-column>
</mj-section>
<mj-section padding="{{tokens.spacingXl}}">
<mj-column>
<mj-text align="center" font-size="28px" font-weight="bold">
{{i18n.welcome_message}}
</mj-text>
<mj-text align="center" color="{{tokens.textLight}}">
We're excited to have you on board.
</mj-text>
<mj-button align="center" href="#">
{{i18n.cta_button}}
</mj-button>
</mj-column>
</mj-section>
<mj-section padding="{{tokens.spacingLg}}">
<mj-column>
<mj-text align="center" font-size="12px" color="{{tokens.textLight}}">
{{i18n.footer_text}}
</mj-text>
<mj-text align="center">
<a href="{{unsubscribeUrl}}">{{i18n.unsubscribe}}</a>
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>`;
codeView.textContent = mjmlCode;
}
// ============================================
// EVENT HANDLERS
// ============================================
function switchSection(section) {
currentSection = section;
// Update sidebar
document.querySelectorAll('.sidebar-item').forEach(item => {
item.classList.remove('active');
if (item.dataset.section === section) {
item.classList.add('active');
}
});
// Update title
const titles = {
templates: 'Templates',
tokens: 'Design Tokens',
localization: 'Localization',
preview: 'Live Preview',
darkmode: 'Dark Mode Testing',
build: 'Build Pipeline'
};
sectionTitle.textContent = titles[section] || section;
// Show/hide sections
document.querySelectorAll('section[id$="-section"]').forEach(sec => {
sec.classList.add('hidden');
});
const targetSection = document.getElementById(`${section}-section`);
if (targetSection) {
targetSection.classList.remove('hidden');
}
// Special rendering for certain sections
if (section === 'preview') {
renderEmailPreview(emailPreview, isDarkMode);
renderCodeView();
}
if (section === 'darkmode') {
renderEmailPreview(lightPreview, false);
renderEmailPreview(darkPreview, true);
}
}
function selectTemplate(templateId) {
selectedTemplate = templateId;
showToast(`Selected template: ${templateId}`);
switchSection('preview');
}
function editTemplate(templateId) {
selectedTemplate = templateId;
showToast(`Editing template: ${templateId}`);
switchSection('preview');
}
function copyToken(value) {
navigator.clipboard.writeText(value).then(() => {
showToast('Copied to clipboard');
});
}
function updateLocalization(key, value) {
if (!localizationStrings[currentLanguage]) {
localizationStrings[currentLanguage] = {};
}
localizationStrings[currentLanguage][key] = value;
showToast('Localization updated');
}
function toggleDarkMode() {
isDarkMode = !isDarkMode;
const toggle = document.getElementById('dark-mode-toggle');
if (isDarkMode) {
toggle.classList.add('bg-[var(--accent-dim)]');
toggle.style.borderColor = 'var(--accent)';
toggle.style.color = 'var(--accent)';
} else {
toggle.classList.remove('bg-[var(--accent-dim)]');
toggle.style.borderColor = '';
toggle.style.color = '';
}
if (currentSection === 'preview') {
if (isDarkMode) {
previewContainer.classList.add('dark-mode');
} else {
previewContainer.classList.remove('dark-mode');
}
renderEmailPreview(emailPreview, isDarkMode);
}
}
function setDevice(device) {
selectedDevice = device;
const width = device === 'mobile' ? '375px' : '600px';
previewContainer.style.width = width;
document.querySelectorAll('.device-btn').forEach(btn => {
btn.classList.remove('active', 'bg-[var(--accent-dim)]');
if (btn.dataset.device === device) {
btn.classList.add('active', 'bg-[var(--accent-dim)]');
}
});
}
async function runBuild() {
buildStatus.textContent = 'Building...';
buildStatus.style.color = 'var(--warning)';
const logs = [
'[build] Starting build process...',
'[build] Loading templates...',
`[build] Found ${emailTemplates.length} templates`,
'[build] Processing tokens...',
'[build] Resolving localization strings...',
'[build] Generating HTML output...',
'[build] Applying dark mode styles...',
'[build] Minifying output...',
'[build] Build complete!'
];
buildLog.innerHTML = '';
for (let i = 0; i < logs.length; i++) {
await new Promise(resolve => setTimeout(resolve, 300));
const logLine = document.createElement('div');
logLine.textContent = logs[i];
logLine.style.color = i === logs.length - 1 ? 'var(--success)' : 'var(--fg-muted)';
buildLog.appendChild(logLine);
buildLog.scrollTop = buildLog.scrollHeight;
}
buildStatus.textContent = 'Complete';
buildStatus.style.color = 'var(--success)';
showToast('Build completed successfully!');
renderGeneratedFiles();
}
// ============================================
// INITIALIZATION
// ============================================
function init() {
// Render all sections
renderTemplates();
renderColorTokens();
renderSpacingTokens();
renderTypographyTokens();
renderLocalizationStrings();
renderHookVariables();
renderDarkModeOverrides();
renderClientSupport();
renderOutputLanguages();
renderGeneratedFiles();
// Navigation handlers
document.querySelectorAll('.sidebar-item[data-section]').forEach(item => {
item.addEventListener('click', () => {
switchSection(item.dataset.section);
});
});
// Dark mode toggle
document.getElementById('dark-mode-toggle').addEventListener('click', toggleDarkMode);
// Device buttons
document.querySelectorAll('.device-btn').forEach(btn => {
btn.addEventListener('click', () => {
setDevice(btn.dataset.device);
});
});
// Language select
languageSelect.addEventListener('change', (e) => {
currentLanguage = e.target.value;
renderLocalizationStrings();
if (currentSection === 'preview') {
renderEmailPreview(emailPreview, isDarkMode);
renderCodeView();
}
});
// Build button
document.getElementById('build-btn').addEventListener('click', () => {
switchSection('build');
});
// Run build button
document.getElementById('run-build-btn').addEventListener('click', runBuild);
// Add token button
document.getElementById('add-token-btn').addEventListener('click', () => {
const name = document.getElementById('token-name').value;
const value = document.getElementById('token-value').value;
const category = document.getElementById('token-category').value;
if (name && value) {
designTokens[category].push({ name, value });
showToast(`Token "${name}" added to ${category}`);
// Re-render tokens
renderColorTokens();
renderSpacingTokens();
renderTypographyTokens();
// Clear inputs
document.getElementById('token-name').value = '';
document.getElementById('token-value').value = '';
}
});
// New template button
document.getElementById('new-template-btn').addEventListener('click', () => {
const id = generateId();
emailTemplates.push({
id,
name: 'New Template',
description: 'Custom email template',
thumbnail: 'custom',
category: 'Custom',
lastModified: new Date().toISOString().split('T')[0]
});
renderTemplates();
showToast('New template created');
});
// Export i18n button
document.getElementById('export-i18n-btn').addEventListener('click', () => {
const dataStr = JSON.stringify(localizationStrings, null, 2);
const blob = new Blob([dataStr], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'localization.json';
a.click();
URL.revokeObjectURL(url);
showToast('Localization exported');
});
// Tab switching in preview
document.querySelectorAll('[data-tab]').forEach(tab => {
tab.addEventListener('click', () => {
document.querySelectorAll('[data-tab]').forEach(t => {
t.classList.remove('tab-active');
t.classList.add('text-[var(--fg-muted)]');
});
tab.classList.add('tab-active');
tab.classList.remove('text-[var(--fg-muted)]');
});
});
}
// Start the app
init();
</script>
</body>
</html>