Spaces:
Running

admagic / index.html
frederic54's picture
Add 3 files
401662a verified
Raw History Blame Contribute Delete
50.5 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AdMagic - Transform Your Product Images</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
.dropzone {
border: 2px dashed #ccc;
transition: all 0.3s;
}
.dropzone.active {
border-color: #4f46e5;
background-color: rgba(79, 70, 229, 0.05);
}
.template-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}
.color-option {
width: 30px;
height: 30px;
cursor: pointer;
transition: transform 0.2s;
}
.color-option:hover {
transform: scale(1.1);
}
.color-option.selected {
border: 2px solid #000;
transform: scale(1.1);
}
.preview-container {
perspective: 1000px;
}
.preview-device {
transition: all 0.3s;
}
.preview-device:hover {
transform: translateY(-5px);
}
#adPreview {
transition: all 0.3s;
}
.slider {
-webkit-appearance: none;
width: 100%;
height: 8px;
border-radius: 4px;
background: #ddd;
outline: none;
}
.slider::-webkit-slider-thumb {
-webkit-appearance: none;
appearance: none;
width: 18px;
height: 18px;
border-radius: 50%;
background: #4f46e5;
cursor: pointer;
}
.slider::-moz-range-thumb {
width: 18px;
height: 18px;
border-radius: 50%;
background: #4f46e5;
cursor: pointer;
}
.step-indicator {
width: 30px;
height: 30px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
}
.step-indicator.active {
background-color: #4f46e5;
color: white;
}
.step-indicator.completed {
background-color: #10b981;
color: white;
}
</style>
</head>
<body class="bg-gray-50">
<div class="container mx-auto px-4 py-8 max-w-7xl">
<!-- Header -->
<header class="mb-10 text-center">
<h1 class="text-4xl font-bold text-indigo-700 mb-2">AdMagic</h1>
<p class="text-lg text-gray-600">Transform your product images into captivating advertisements in minutes</p>
</header>
<!-- Progress Steps -->
<div class="flex justify-between items-center mb-10 px-10 relative">
<div class="absolute top-1/2 left-0 right-0 h-1 bg-gray-200 -z-10"></div>
<div class="flex flex-col items-center">
<div id="step1Indicator" class="step-indicator active">1</div>
<span class="mt-2 text-sm font-medium">Upload Image</span>
</div>
<div class="flex flex-col items-center">
<div id="step2Indicator" class="step-indicator">2</div>
<span class="mt-2 text-sm font-medium">Choose Template</span>
</div>
<div class="flex flex-col items-center">
<div id="step3Indicator" class="step-indicator">3</div>
<span class="mt-2 text-sm font-medium">Customize</span>
</div>
<div class="flex flex-col items-center">
<div id="step4Indicator" class="step-indicator">4</div>
<span class="mt-2 text-sm font-medium">Branding</span>
</div>
<div class="flex flex-col items-center">
<div id="step5Indicator" class="step-indicator">5</div>
<span class="mt-2 text-sm font-medium">Export</span>
</div>
</div>
<!-- Main Content Area -->
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Left Panel - Controls -->
<div class="lg:col-span-1 bg-white rounded-xl shadow-md p-6 h-fit sticky top-6">
<div id="step1" class="step-content">
<h2 class="text-xl font-semibold mb-4">Upload Your Product Image</h2>
<div id="dropzone" class="dropzone rounded-lg p-8 text-center mb-4">
<i class="fas fa-cloud-upload-alt text-4xl text-indigo-500 mb-3"></i>
<p class="mb-2">Drag & drop your image here</p>
<p class="text-sm text-gray-500 mb-4">or</p>
<label for="fileUpload" class="bg-indigo-600 text-white px-4 py-2 rounded-md cursor-pointer hover:bg-indigo-700 transition">
Browse Files
</label>
<input type="file" id="fileUpload" accept="image/*" class="hidden">
</div>
<div id="imagePreviewContainer" class="hidden mb-4">
<h3 class="font-medium mb-2">Image Preview</h3>
<div class="border rounded-lg overflow-hidden">
<img id="imagePreview" src="" alt="Preview" class="w-full">
</div>
</div>
<div id="enhancementControls" class="hidden">
<h3 class="font-medium mb-2">Image Enhancement</h3>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium mb-1">Brightness</label>
<input type="range" min="0" max="200" value="100" class="slider" id="brightnessSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div>
<label class="block text-sm font-medium mb-1">Contrast</label>
<input type="range" min="0" max="200" value="100" class="slider" id="contrastSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div>
<label class="block text-sm font-medium mb-1">Saturation</label>
<input type="range" min="0" max="200" value="100" class="slider" id="saturationSlider">
<div class="flex justify-between text-xs text-gray-500">
<span>0%</span>
<span>100%</span>
<span>200%</span>
</div>
</div>
<div class="flex space-x-2">
<button id="autoEnhanceBtn" class="flex-1 bg-indigo-100 text-indigo-700 px-3 py-1 rounded text-sm hover:bg-indigo-200">
Auto Enhance
</button>
<button id="resetEnhancementBtn" class="flex-1 bg-gray-100 text-gray-700 px-3 py-1 rounded text-sm hover:bg-gray-200">
Reset
</button>
</div>
</div>
</div>
<button id="nextStep1Btn" class="w-full bg-indigo-600 text-white py-2 rounded-md mt-4 hover:bg-indigo-700 disabled:bg-indigo-300 disabled:cursor-not-allowed" disabled>
Next: Choose Template
</button>
</div>
<div id="step2" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Choose a Template</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Industry</label>
<select id="industrySelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="all">All Industries</option>
<option value="fashion">Fashion</option>
<option value="food">Food & Beverage</option>
<option value="electronics">Electronics</option>
<option value="beauty">Beauty & Cosmetics</option>
<option value="home">Home & Living</option>
</select>
</div>
<div class="grid grid-cols-2 gap-3 mb-4" id="templateGallery">
<!-- Templates will be loaded here -->
</div>
<div class="flex space-x-2">
<button id="backStep2Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep2Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700 disabled:bg-indigo-300 disabled:cursor-not-allowed" disabled>
Next: Customize
</button>
</div>
</div>
<div id="step3" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Customize Your Ad</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Headline</label>
<input type="text" id="headlineInput" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter catchy headline">
<div class="mt-1 flex flex-wrap gap-1" id="suggestedHeadlines">
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">Summer Sale!</span>
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">Limited Time Offer</span>
<span class="text-xs bg-gray-100 px-2 py-1 rounded cursor-pointer hover:bg-gray-200">New Collection</span>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Description</label>
<textarea id="descriptionInput" rows="3" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Enter product description"></textarea>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Call to Action</label>
<input type="text" id="ctaInput" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="e.g. Shop Now, Learn More">
</div>
<div class="flex space-x-2">
<button id="backStep3Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep3Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700">
Next: Branding
</button>
</div>
</div>
<div id="step4" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Add Your Branding</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Upload Logo</label>
<div class="flex items-center">
<div id="logoPreview" class="w-16 h-16 border rounded-md flex items-center justify-center bg-gray-100 mr-3 overflow-hidden">
<i class="fas fa-camera text-gray-400"></i>
</div>
<label for="logoUpload" class="bg-gray-100 text-gray-700 px-3 py-1 rounded text-sm hover:bg-gray-200 cursor-pointer">
Choose File
</label>
<input type="file" id="logoUpload" accept="image/*" class="hidden">
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Brand Colors</label>
<div class="flex flex-wrap gap-2 mt-2">
<div class="color-option bg-indigo-600 rounded-full selected" data-color="#4f46e5"></div>
<div class="color-option bg-red-600 rounded-full" data-color="#dc2626"></div>
<div class="color-option bg-green-600 rounded-full" data-color="#16a34a"></div>
<div class="color-option bg-yellow-500 rounded-full" data-color="#eab308"></div>
<div class="color-option bg-pink-600 rounded-full" data-color="#db2777"></div>
<div class="color-option bg-purple-600 rounded-full" data-color="#9333ea"></div>
<div class="color-option bg-blue-600 rounded-full" data-color="#2563eb"></div>
<div class="color-option bg-gray-800 rounded-full" data-color="#1f2937"></div>
</div>
<div class="mt-2">
<label class="inline-flex items-center">
<input type="checkbox" id="customColorToggle" class="rounded border-gray-300 text-indigo-600 focus:ring-indigo-500">
<span class="ml-2 text-sm">Use custom color</span>
</label>
<div id="customColorPicker" class="mt-2 hidden">
<input type="color" id="brandColorPicker" class="w-full h-10">
</div>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Font Style</label>
<select id="fontSelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="'Inter', sans-serif">Inter (Modern)</option>
<option value="'Playfair Display', serif">Playfair Display (Elegant)</option>
<option value="'Roboto', sans-serif">Roboto (Clean)</option>
<option value="'Montserrat', sans-serif">Montserrat (Bold)</option>
<option value="'Open Sans', sans-serif">Open Sans (Friendly)</option>
</select>
</div>
<div class="flex space-x-2">
<button id="backStep4Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="nextStep4Btn" class="flex-1 bg-indigo-600 text-white py-2 rounded-md hover:bg-indigo-700">
Next: Export
</button>
</div>
</div>
<div id="step5" class="step-content hidden">
<h2 class="text-xl font-semibold mb-4">Export Your Ad</h2>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Format</label>
<div class="flex space-x-2">
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="png" class="mr-1" checked> PNG
</label>
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="jpg" class="mr-1"> JPG
</label>
<label class="flex-1 border rounded-md px-3 py-2 text-center cursor-pointer hover:bg-gray-50">
<input type="radio" name="exportFormat" value="pdf" class="mr-1"> PDF
</label>
</div>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Quality</label>
<select id="qualitySelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="high">High (Recommended)</option>
<option value="medium">Medium</option>
<option value="low">Low</option>
</select>
</div>
<div class="mb-6">
<label class="block text-sm font-medium mb-1">Size</label>
<select id="sizeSelect" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500">
<option value="original">Original Size</option>
<option value="instagram">Instagram Post (1080x1080)</option>
<option value="facebook">Facebook Ad (1200x628)</option>
<option value="twitter">Twitter Post (1200x675)</option>
<option value="pinterest">Pinterest Pin (1000x1500)</option>
</select>
</div>
<div class="flex space-x-2">
<button id="backStep5Btn" class="flex-1 bg-gray-200 text-gray-700 py-2 rounded-md hover:bg-gray-300">
Back
</button>
<button id="exportBtn" class="flex-1 bg-green-600 text-white py-2 rounded-md hover:bg-green-700 flex items-center justify-center">
<i class="fas fa-download mr-2"></i> Export
</button>
</div>
<div class="mt-4">
<p class="text-sm font-medium mb-2">Share directly:</p>
<div class="flex space-x-2">
<button class="bg-blue-500 text-white p-2 rounded-full hover:bg-blue-600">
<i class="fab fa-facebook-f"></i>
</button>
<button class="bg-blue-400 text-white p-2 rounded-full hover:bg-blue-500">
<i class="fab fa-twitter"></i>
</button>
<button class="bg-pink-600 text-white p-2 rounded-full hover:bg-pink-700">
<i class="fab fa-instagram"></i>
</button>
<button class="bg-red-600 text-white p-2 rounded-full hover:bg-red-700">
<i class="fab fa-pinterest-p"></i>
</button>
</div>
</div>
</div>
</div>
<!-- Right Panel - Preview -->
<div class="lg:col-span-2">
<div class="bg-white rounded-xl shadow-md p-6 mb-6">
<h2 class="text-xl font-semibold mb-4">Ad Preview</h2>
<div class="preview-container">
<div class="flex justify-center space-x-4 mb-6">
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium" data-size="desktop">
<i class="fas fa-desktop mr-1"></i> Desktop
</button>
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium" data-size="tablet">
<i class="fas fa-tablet-alt mr-1"></i> Tablet
</button>
<button class="preview-device bg-gray-100 px-4 py-2 rounded-lg text-sm font-medium active" data-size="mobile">
<i class="fas fa-mobile-alt mr-1"></i> Mobile
</button>
</div>
<div class="flex justify-center">
<div id="previewFrame" class="border-8 border-gray-800 rounded-3xl w-full max-w-md bg-gray-800 p-1">
<div id="adPreview" class="bg-white w-full aspect-[9/16] overflow-hidden relative">
<!-- Ad content will be rendered here -->
<div class="absolute inset-0 flex items-center justify-center text-gray-400">
<div class="text-center">
<i class="fas fa-ad text-4xl mb-2"></i>
<p>Your ad preview will appear here</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Feedback Section -->
<div class="bg-white rounded-xl shadow-md p-6">
<h2 class="text-xl font-semibold mb-4">Help Us Improve</h2>
<p class="text-gray-600 mb-4">We'd love to hear your feedback about AdMagic. What features would you like to see?</p>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Your Feedback</label>
<textarea id="feedbackInput" rows="3" class="w-full border rounded-md px-3 py-2 focus:outline-none focus:ring-2 focus:ring-indigo-500" placeholder="Share your thoughts..."></textarea>
</div>
<div class="mb-4">
<label class="block text-sm font-medium mb-1">Rating</label>
<div class="flex space-x-1">
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="1">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="2">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="3">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="4">
<i class="far fa-star text-2xl"></i>
</button>
<button class="text-gray-400 hover:text-yellow-500 feedback-star" data-rating="5">
<i class="far fa-star text-2xl"></i>
</button>
</div>
</div>
<button id="submitFeedbackBtn" class="bg-indigo-600 text-white px-4 py-2 rounded-md hover:bg-indigo-700">
Submit Feedback
</button>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Step management
let currentStep = 1;
// DOM elements
const stepContents = document.querySelectorAll('.step-content');
const stepIndicators = [
document.getElementById('step1Indicator'),
document.getElementById('step2Indicator'),
document.getElementById('step3Indicator'),
document.getElementById('step4Indicator'),
document.getElementById('step5Indicator')
];
// Navigation buttons
const nextButtons = [
document.getElementById('nextStep1Btn'),
document.getElementById('nextStep2Btn'),
document.getElementById('nextStep3Btn'),
document.getElementById('nextStep4Btn')
];
const backButtons = [
document.getElementById('backStep2Btn'),
document.getElementById('backStep3Btn'),
document.getElementById('backStep4Btn'),
document.getElementById('backStep5Btn')
];
// Initialize template gallery
initializeTemplates();
// Initialize event listeners
setupEventListeners();
function setupEventListeners() {
// File upload
const dropzone = document.getElementById('dropzone');
const fileUpload = document.getElementById('fileUpload');
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, preventDefaults, false);
});
['dragenter', 'dragover'].forEach(eventName => {
dropzone.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
dropzone.addEventListener(eventName, unhighlight, false);
});
dropzone.addEventListener('drop', handleDrop, false);
fileUpload.addEventListener('change', handleFileSelect, false);
// Image enhancement controls
const brightnessSlider = document.getElementById('brightnessSlider');
const contrastSlider = document.getElementById('contrastSlider');
const saturationSlider = document.getElementById('saturationSlider');
const autoEnhanceBtn = document.getElementById('autoEnhanceBtn');
const resetEnhancementBtn = document.getElementById('resetEnhancementBtn');
brightnessSlider.addEventListener('input', updateImageEnhancement);
contrastSlider.addEventListener('input', updateImageEnhancement);
saturationSlider.addEventListener('input', updateImageEnhancement);
autoEnhanceBtn.addEventListener('click', autoEnhanceImage);
resetEnhancementBtn.addEventListener('click', resetEnhancement);
// Navigation
nextButtons.forEach((btn, index) => {
btn.addEventListener('click', () => goToStep(index + 2));
});
backButtons.forEach((btn, index) => {
btn.addEventListener('click', () => goToStep(index + 1));
});
// Template selection
document.getElementById('industrySelect').addEventListener('change', filterTemplates);
// Branding
document.getElementById('logoUpload').addEventListener('change', handleLogoUpload);
document.querySelectorAll('.color-option').forEach(option => {
option.addEventListener('click', selectBrandColor);
});
document.getElementById('customColorToggle').addEventListener('change', toggleCustomColorPicker);
document.getElementById('brandColorPicker').addEventListener('input', updateCustomBrandColor);
document.getElementById('fontSelect').addEventListener('change', updateFontStyle);
// Suggested headlines
document.querySelectorAll('#suggestedHeadlines span').forEach(span => {
span.addEventListener('click', applySuggestedHeadline);
});
// Text inputs
document.getElementById('headlineInput').addEventListener('input', updateAdPreview);
document.getElementById('descriptionInput').addEventListener('input', updateAdPreview);
document.getElementById('ctaInput').addEventListener('input', updateAdPreview);
// Preview devices
document.querySelectorAll('.preview-device').forEach(btn => {
btn.addEventListener('click', switchPreviewDevice);
});
// Export
document.getElementById('exportBtn').addEventListener('click', exportAd);
// Feedback
document.querySelectorAll('.feedback-star').forEach(star => {
star.addEventListener('click', rateApp);
});
document.getElementById('submitFeedbackBtn').addEventListener('click', submitFeedback);
}
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
function highlight() {
dropzone.classList.add('active');
}
function unhighlight() {
dropzone.classList.remove('active');
}
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
handleFiles(files);
}
function handleFileSelect(e) {
const files = e.target.files;
handleFiles(files);
}
function handleFiles(files) {
if (files.length > 0) {
const file = files[0];
if (file.type.match('image.*')) {
const reader = new FileReader();
reader.onload = function(e) {
const imagePreview = document.getElementById('imagePreview');
const imagePreviewContainer = document.getElementById('imagePreviewContainer');
const enhancementControls = document.getElementById('enhancementControls');
const nextStep1Btn = document.getElementById('nextStep1Btn');
imagePreview.src = e.target.result;
imagePreviewContainer.classList.remove('hidden');
enhancementControls.classList.remove('hidden');
nextStep1Btn.disabled = false;
// Store original image for reset functionality
originalImageSrc = e.target.result;
// Update ad preview
updateAdPreview();
};
reader.readAsDataURL(file);
} else {
alert('Please upload an image file.');
}
}
}
function handleLogoUpload(e) {
const files = e.target.files;
if (files.length > 0) {
const file = files[0];
if (file.type.match('image.*')) {
const reader = new FileReader();
reader.onload = function(e) {
const logoPreview = document.getElementById('logoPreview');
logoPreview.innerHTML = `<img src="${e.target.result}" class="w-full h-full object-contain">`;
// Update ad preview with logo
updateAdPreview();
};
reader.readAsDataURL(file);
}
}
}
let originalImageSrc = '';
function updateImageEnhancement() {
const imagePreview = document.getElementById('imagePreview');
const brightness = document.getElementById('brightnessSlider').value;
const contrast = document.getElementById('contrastSlider').value;
const saturation = document.getElementById('saturationSlider').value;
imagePreview.style.filter = `brightness(${brightness}%) contrast(${contrast}%) saturate(${saturation}%)`;
// Update ad preview
updateAdPreview();
}
function autoEnhanceImage() {
// Simulate auto-enhance by setting "optimal" values
document.getElementById('brightnessSlider').value = 110;
document.getElementById('contrastSlider').value = 120;
document.getElementById('saturationSlider').value = 115;
updateImageEnhancement();
}
function resetEnhancement() {
document.getElementById('brightnessSlider').value = 100;
document.getElementById('contrastSlider').value = 100;
document.getElementById('saturationSlider').value = 100;
updateImageEnhancement();
}
function initializeTemplates() {
const templateGallery = document.getElementById('templateGallery');
// Sample templates data (in a real app, this would come from a database)
const templates = [
{ id: 1, name: 'Modern', industry: 'all', thumbnail: 'https://via.placeholder.com/150/4f46e5/ffffff?text=Modern' },
{ id: 2, name: 'Elegant', industry: 'fashion', thumbnail: 'https://via.placeholder.com/150/db2777/ffffff?text=Elegant' },
{ id: 3, name: 'Bold', industry: 'electronics', thumbnail: 'https://via.placeholder.com/150/1f2937/ffffff?text=Bold' },
{ id: 4, name: 'Fresh', industry: 'food', thumbnail: 'https://via.placeholder.com/150/16a34a/ffffff?text=Fresh' },
{ id: 5, name: 'Minimal', industry: 'all', thumbnail: 'https://via.placeholder.com/150/ffffff/1f2937?text=Minimal' },
{ id: 6, name: 'Vibrant', industry: 'beauty', thumbnail: 'https://via.placeholder.com/150/eab308/ffffff?text=Vibrant' }
];
// Render templates
templates.forEach(template => {
const templateCard = document.createElement('div');
templateCard.className = 'template-card border rounded-lg overflow-hidden cursor-pointer transition';
templateCard.dataset.id = template.id;
templateCard.dataset.industry = template.industry;
templateCard.innerHTML = `
<img src="${template.thumbnail}" alt="${template.name}" class="w-full h-24 object-cover">
<div class="p-2 text-center">
<p class="text-sm font-medium">${template.name}</p>
</div>
`;
templateCard.addEventListener('click', () => selectTemplate(template.id));
templateGallery.appendChild(templateCard);
});
}
function filterTemplates() {
const industry = document.getElementById('industrySelect').value;
const templates = document.querySelectorAll('.template-card');
templates.forEach(template => {
if (industry === 'all' || template.dataset.industry === industry) {
template.style.display = 'block';
} else {
template.style.display = 'none';
}
});
}
let selectedTemplateId = null;
function selectTemplate(id) {
selectedTemplateId = id;
// Highlight selected template
document.querySelectorAll('.template-card').forEach(card => {
if (card.dataset.id == id) {
card.classList.add('ring-2', 'ring-indigo-500');
} else {
card.classList.remove('ring-2', 'ring-indigo-500');
}
});
// Enable next button
document.getElementById('nextStep2Btn').disabled = false;
// Update ad preview
updateAdPreview();
}
function applySuggestedHeadline(e) {
document.getElementById('headlineInput').value = e.target.textContent;
updateAdPreview();
}
let selectedBrandColor = '#4f46e5';
function selectBrandColor(e) {
selectedBrandColor = e.target.dataset.color;
// Update color selection UI
document.querySelectorAll('.color-option').forEach(option => {
option.classList.remove('selected');
});
e.target.classList.add('selected');
// Hide custom color picker if it's visible
document.getElementById('customColorToggle').checked = false;
document.getElementById('customColorPicker').classList.add('hidden');
// Update ad preview
updateAdPreview();
}
function toggleCustomColorPicker(e) {
const picker = document.getElementById('customColorPicker');
if (e.target.checked) {
picker.classList.remove('hidden');
} else {
picker.classList.add('hidden');
}
}
function updateCustomBrandColor(e) {
selectedBrandColor = e.target.value;
// Update ad preview
updateAdPreview();
}
function updateFontStyle() {
const font = document.getElementById('fontSelect').value;
// In a real app, you would load the font dynamically
updateAdPreview();
}
function switchPreviewDevice(e) {
const previewFrame = document.getElementById('previewFrame');
const size = e.target.dataset.size;
// Update active button
document.querySelectorAll('.preview-device').forEach(btn => {
btn.classList.remove('active', 'bg-indigo-100', 'text-indigo-700');
btn.classList.add('bg-gray-100');
});
e.target.classList.remove('bg-gray-100');
e.target.classList.add('active', 'bg-indigo-100', 'text-indigo-700');
// Update preview frame
if (size === 'desktop') {
previewFrame.classList.remove('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.classList.add('border', 'rounded-lg', 'max-w-4xl');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[9/16]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[16/9]');
} else if (size === 'tablet') {
previewFrame.classList.remove('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.classList.add('border-4', 'rounded-xl', 'max-w-lg');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[9/16]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[4/3]');
} else { // mobile
previewFrame.classList.remove('border', 'rounded-lg', 'max-w-4xl');
previewFrame.classList.add('border-8', 'rounded-3xl', 'max-w-md');
previewFrame.querySelector('#adPreview').classList.remove('aspect-[16/9]', 'aspect-[4/3]');
previewFrame.querySelector('#adPreview').classList.add('aspect-[9/16]');
}
}
function updateAdPreview() {
const adPreview = document.getElementById('adPreview');
const imagePreview = document.getElementById('imagePreview');
const headline = document.getElementById('headlineInput').value;
const description = document.getElementById('descriptionInput').value;
const cta = document.getElementById('ctaInput').value;
const logoPreview = document.getElementById('logoPreview').querySelector('img');
// Clear previous content
adPreview.innerHTML = '';
// Add background (image or color)
if (imagePreview.src) {
const bgDiv = document.createElement('div');
bgDiv.className = 'absolute inset-0 overflow-hidden';
const bgImg = document.createElement('img');
bgImg.src = imagePreview.src;
bgImg.style.filter = imagePreview.style.filter;
bgImg.className = 'w-full h-full object-cover';
bgDiv.appendChild(bgImg);
adPreview.appendChild(bgDiv);
// Add overlay for better text visibility
const overlay = document.createElement('div');
overlay.className = 'absolute inset-0 bg-black bg-opacity-30';
adPreview.appendChild(overlay);
} else {
adPreview.style.backgroundColor = selectedBrandColor;
}
// Add content based on template (simplified for demo)
const contentDiv = document.createElement('div');
contentDiv.className = 'relative z-10 h-full flex flex-col p-6 text-white';
// Add logo if uploaded
if (logoPreview) {
const logoDiv = document.createElement('div');
logoDiv.className = 'mb-4';
const logoImg = document.createElement('img');
logoImg.src = logoPreview.src;
logoImg.className = 'h-10 object-contain';
logoDiv.appendChild(logoImg);
contentDiv.appendChild(logoDiv);
}
// Add headline if provided
if (headline) {
const headlineDiv = document.createElement('h2');
headlineDiv.className = 'text-3xl font-bold mb-2';
headlineDiv.textContent = headline;
contentDiv.appendChild(headlineDiv);
}
// Add description if provided
if (description) {
const descDiv = document.createElement('p');
descDiv.className = 'text-lg mb-4';
descDiv.textContent = description;
contentDiv.appendChild(descDiv);
}
// Add CTA button if provided
if (cta) {
const ctaDiv = document.createElement('div');
ctaDiv.className = 'mt-auto';
const ctaBtn = document.createElement('button');
ctaBtn.className = 'bg-white text-indigo-700 px-6 py-2 rounded-full font-medium shadow-lg hover:bg-gray-100 transition';
ctaBtn.textContent = cta;
ctaDiv.appendChild(ctaBtn);
contentDiv.appendChild(ctaDiv);
}
adPreview.appendChild(contentDiv);
}
function goToStep(step) {
// Hide current step
document.getElementById(`step${currentStep}`).classList.add('hidden');
stepIndicators[currentStep - 1].classList.remove('active', 'completed');
// Update current step
currentStep = step;
// Show new step
document.getElementById(`step${currentStep}`).classList.remove('hidden');
// Update step indicators
for (let i = 0; i < stepIndicators.length; i++) {
if (i < currentStep - 1) {
stepIndicators[i].classList.add('completed');
stepIndicators[i].classList.remove('active');
} else if (i === currentStep - 1) {
stepIndicators[i].classList.add('active');
stepIndicators[i].classList.remove('completed');
} else {
stepIndicators[i].classList.remove('active', 'completed');
}
}
// Scroll to top of controls
document.querySelector('.lg\\:col-span-1').scrollTo(0, 0);
}
function exportAd() {
// In a real app, this would use a library like html2canvas to export the ad
alert('Your ad has been exported! (This is a demo - in a real app, the ad would be downloaded)');
// Show success message
const exportBtn = document.getElementById('exportBtn');
const originalText = exportBtn.innerHTML;
exportBtn.innerHTML = '<i class="fas fa-check mr-2"></i> Success!';
exportBtn.classList.remove('bg-green-600', 'hover:bg-green-700');
exportBtn.classList.add('bg-green-500');
// Reset button after delay
setTimeout(() => {
exportBtn.innerHTML = originalText;
exportBtn.classList.remove('bg-green-500');
exportBtn.classList.add('bg-green-600', 'hover:bg-green-700');
}, 2000);
}
function rateApp(e) {
const rating = parseInt(e.target.dataset.rating);
const stars = document.querySelectorAll('.feedback-star');
stars.forEach((star, index) => {
if (index < rating) {
star.innerHTML = '<i class="fas fa-star text-2xl text-yellow-500"></i>';
} else {
star.innerHTML = '<i class="far fa-star text-2xl text-gray-400"></i>';
}
});
}
function submitFeedback() {
const feedback = document.getElementById('feedbackInput').value;
const stars = document.querySelectorAll('.feedback-star i.fas.fa-star').length;
if (feedback || stars > 0) {
// In a real app, this would send the feedback to a server
alert('Thank you for your feedback!');
document.getElementById('feedbackInput').value = '';
// Reset stars
document.querySelectorAll('.feedback-star').forEach(star => {
star.innerHTML = '<i class="far fa-star text-2xl text-gray-400"></i>';
});
} else {
alert('Please provide feedback or a rating before submitting.');
}
}
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=frederic54/admagic" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>