Skip to content

akashleo/email-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

5 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Email Builder - Professional Email Template Editor

A modern, user-friendly email template builder that allows users to upload HTML email templates, identify editable content, and customize them without coding knowledge.

๐ŸŽฏ Project Purpose

This application serves as a no-code email template editor, enabling users to:

  • Upload existing HTML email templates
  • Automatically identify editable text and image elements
  • Select specific parts for customization
  • Edit content through an intuitive interface
  • Preview changes in real-time
  • Download the modified HTML template

๐Ÿ—๏ธ Project Structure

Frontend Framework

  • Next.js 13.5.1 with TypeScript
  • React 18.2.0 for component architecture
  • Tailwind CSS for styling with shadcn/ui component library

State Management

  • Zustand for lightweight, efficient state management
  • Centralized store managing upload, editing, and preview states

Key Directories

email-builder/
โ”œโ”€โ”€ app/                    # Next.js App Router pages
โ”‚   โ”œโ”€โ”€ page.tsx           # Login/landing page
โ”‚   โ”œโ”€โ”€ upload/page.tsx    # File upload and part selection
โ”‚   โ”œโ”€โ”€ edit/page.tsx      # Content editing interface
โ”‚   โ”œโ”€โ”€ layout.tsx         # Root layout component
โ”‚   โ””โ”€โ”€ globals.css        # Global styles and Tailwind configuration
โ”œโ”€โ”€ components/            # React components
โ”‚   โ”œโ”€โ”€ ui/               # shadcn/ui component library
โ”‚   โ”œโ”€โ”€ file-upload.tsx   # Drag & drop file upload component
โ”‚   โ”œโ”€โ”€ editable-parts-selector.tsx  # Part selection interface
โ”‚   โ”œโ”€โ”€ editable-parts-editor.tsx    # Content editing interface
โ”‚   โ””โ”€โ”€ preview-modal.tsx # Email preview modal
โ”œโ”€โ”€ lib/                  # Core utilities and logic
โ”‚   โ”œโ”€โ”€ email-parser.ts   # HTML parsing and element identification
โ”‚   โ”œโ”€โ”€ store.ts          # Zustand state management
โ”‚   โ””โ”€โ”€ utils.ts          # Utility functions
โ””โ”€โ”€ hooks/                # React hooks
    โ””โ”€โ”€ use-toast.ts      # Toast notification system

๐Ÿ”„ Application Flow

1. Authentication (Simulated)

  • Simple login interface for demo purposes
  • Redirects to upload page after "authentication"

2. File Upload & Parsing

  • File Upload Component (components/file-upload.tsx)

    • Drag & drop HTML file upload
    • File validation (HTML files only, max 10MB)
    • Real-time error handling
  • HTML Parser (lib/email-parser.ts)

    • Automatically scans uploaded HTML for editable elements
    • Identifies text content in: p, h1-h6, span, div, td, th, a
    • Locates image elements with src attributes
    • Generates unique selectors for each element

3. Part Selection

  • Editable Parts Selector (components/editable-parts-selector.tsx)
    • Displays all identified editable elements
    • Categorizes content: Text Content vs Images
    • Checkbox selection interface
    • Real-time selection counter

4. Content Editing

  • Parts Editor (components/editable-parts-editor.tsx)
    • Individual editing interface for each selected part
    • Text areas for text content
    • URL inputs for image sources
    • Save/cancel functionality per element

5. Preview & Download

  • Preview Modal (components/preview-modal.tsx)
    • Real-time preview of edited email template
    • Sandboxed iframe for safe HTML rendering
    • Download functionality for final HTML file

๐Ÿ› ๏ธ Technical Architecture

State Management (lib/store.ts)

The Zustand store manages the entire application state:

interface EmailStore {
  // Upload state
  uploadedFile: File | null
  uploadedHtml: string
  uploadError: string | null
  
  // Editable parts
  editableParts: EditablePart[]
  selectedParts: EditablePart[]
  
  // Preview state
  previewHtml: string
  isPreviewOpen: boolean
  
  // Actions for state management
}

HTML Parsing Logic (lib/email-parser.ts)

  • DOM Parser: Uses browser's native DOMParser to analyze HTML structure
  • Element Identification: Traverses DOM tree to find editable content
  • Selector Generation: Creates CSS selectors for precise element targeting
  • Content Extraction: Safely extracts text content and image sources

UI Components

Built with shadcn/ui for consistency and accessibility:

  • Form components (Input, Textarea, Button)
  • Layout components (Card, Dialog, ScrollArea)
  • Feedback components (Alert, Badge, Toast)

๐Ÿš€ Features

Core Functionality

  • โœ… HTML email template upload
  • โœ… Automatic editable element detection
  • โœ… Selective content editing
  • โœ… Real-time preview
  • โœ… HTML download functionality

User Experience

  • โœ… Drag & drop file upload
  • โœ… Responsive design (mobile-friendly)
  • โœ… Intuitive multi-step workflow
  • โœ… Error handling and validation
  • โœ… Toast notifications

Technical Features

  • โœ… Type-safe TypeScript implementation
  • โœ… Efficient state management with Zustand
  • โœ… Component composition with shadcn/ui
  • โœ… Static site generation ready (output: 'export')

๐Ÿ”ง Development Setup

Prerequisites

  • Node.js 18+ and npm/yarn
  • Modern web browser with ES6+ support

Installation

# Clone the repository
git clone <repository-url>
cd email-builder

# Install dependencies
npm install

# Start development server
npm run dev

# Build for production
npm run build

Key Dependencies

  • Core: Next.js, React, TypeScript
  • State: Zustand
  • UI: shadcn/ui, Tailwind CSS, Lucide icons
  • File Handling: react-dropzone
  • Forms: react-hook-form with validation

๐Ÿ“ฑ Responsive Design

The application is fully responsive with:

  • Mobile-first design approach
  • Flexible grid layouts using CSS Grid and Flexbox
  • Responsive navigation and modals
  • Touch-friendly interface elements

๐Ÿ” Security Considerations

  • HTML Sanitization: Preview uses sandboxed iframe
  • File Validation: Strict file type and size checking
  • XSS Prevention: Safe content handling throughout
  • Client-side Processing: No server-side storage of user data

๐ŸŽจ Design System

Color Scheme

  • Uses CSS custom properties for theming
  • Light mode with neutral color palette
  • Accessible contrast ratios
  • Consistent spacing using Tailwind's scale

Typography

  • Inter font family for clean, modern appearance
  • Hierarchical heading structure
  • Proper line heights and letter spacing

๐Ÿšฆ Usage Workflow

  1. Start โ†’ Access the application at /
  2. Login โ†’ Use simulated authentication (any email)
  3. Upload โ†’ Drag & drop HTML email template
  4. Select โ†’ Choose editable parts from parsed content
  5. Edit โ†’ Modify text content and image URLs
  6. Preview โ†’ Review changes in real-time
  7. Download โ†’ Save the customized HTML template

๐Ÿ”ฎ Potential Enhancements

  • Rich Text Editor: WYSIWYG editing for text content
  • Image Upload: Direct image hosting instead of URLs
  • Template Library: Pre-built email templates
  • Version History: Save and restore editing sessions
  • Real Email Testing: Integration with email testing services
  • Collaboration: Multi-user editing capabilities

๐Ÿ“„ License & Contributions

This project demonstrates modern React/Next.js development patterns and can serve as a foundation for commercial email builder applications.

About

No code Email-Builder/Modifier tool for editing business emails.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published