Saad4web's picture
Get inspired from the example and build web app like studio pictures maker for content branding on topic related vpn and mobile apps and software like top vpn can use etc ... Also using the listing like ul / li ... And add more improvements, also add bg image ability <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tech Brand Studio</title> <script src="https://cdn.tailwindcss.com"></script> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;900&display=swap" rel="stylesheet"> <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script> <style> body { font-family: 'Inter', sans-serif; background-color: #111827; /* bg-gray-900 */ } /* Custom scrollbar for a more modern look */ ::-webkit-scrollbar { width: 8px; } ::-webkit-scrollbar-track { background: #1f2937; /* bg-gray-800 */ } ::-webkit-scrollbar-thumb { background: #4b5563; /* bg-gray-600 */ border-radius: 4px; } ::-webkit-scrollbar-thumb:hover { background: #6b7280; /* bg-gray-500 */ } .glassmorphism { background: rgba(31, 41, 55, 0.5); /* bg-gray-800 with opacity */ backdrop-filter: blur(10px); border: 1px solid rgba(255, 255, 255, 0.1); } .preview-card-aspect-square { aspect-ratio: 1 / 1; } .preview-card-aspect-portrait { aspect-ratio: 9 / 16; } .preview-card-aspect-landscape { aspect-ratio: 16 / 9; } </style> </head> <body class="text-white"> <div class="flex flex-col lg:flex-row min-h-screen"> <!-- Left Panel: Controls --> <aside class="w-full lg:w-1/3 xl:w-1/4 p-4 lg:p-6 space-y-6 overflow-y-auto lg:h-screen"> <header class="text-center lg:text-left"> <h1 class="text-2xl font-bold text-cyan-400">Tech Brand Studio</h1> <p class="text-sm text-gray-400">Create content for VPNs & Software</p> </header> <!-- Brand Manager --> <div class="glassmorphism p-4 rounded-xl space-y-4"> <h2 class="text-lg font-semibold border-b border-gray-700 pb-2 flex items-center"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-cyan-400" viewBox="0 0 20 20" fill="currentColor"><path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd" /></svg> Brand Manager </h2> <input type="text" id="brandName" placeholder="Your Brand Name" class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition" onkeyup="updatePreview()"> <input type="text" id="brandTagline" placeholder="Your tagline here" class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition" onkeyup="updatePreview()"> <div class="grid grid-cols-2 gap-4"> <label for="logoUpload" class="w-full text-center bg-gray-700 hover:bg-gray-600 cursor-pointer rounded-md px-3 py-2 transition">Upload Logo</label> <input type="file" id="logoUpload" class="hidden" accept="image/*" onchange="handleLogoUpload(event)"> <input type="color" id="brandColor" value="#22d3ee" class="w-full bg-gray-700 rounded-md cursor-pointer" oninput="updatePreview()"> </div> </div> <!-- AI Assistant --> <div class="glassmorphism p-4 rounded-xl space-y-4"> <h2 class="text-lg font-semibold border-b border-gray-700 pb-2 flex items-center"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-cyan-400" viewBox="0 0 20 20" fill="currentColor"><path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z" /></svg> AI Assistant </h2> <select id="contentTopic" class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition"> <option>Online Privacy</option> <option>Top 5 VPNs</option> <option>Cybersecurity Threats</option> <option>Data Encryption Explained</option> <option>Benefits of a VPN</option> </select> <select id="contentStyle" class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition"> <option>Informative</option> <option>Urgent Security Alert</option> <option>Top List</option> <option>Myth vs. Fact</option> <option>Promotional</option> </select> <button id="generateButton" onclick="generateContent()" class="w-full bg-cyan-600 hover:bg-cyan-500 rounded-md px-3 py-2 font-semibold transition flex items-center justify-center"> <span id="generateButtonText">Generate Ideas</span> <svg id="generateSpinner" class="animate-spin -ml-1 mr-3 h-5 w-5 text-white hidden" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"> <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle> <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path> </svg> </button> <div id="apiError" class="text-red-400 text-sm hidden mt-2"></div> </div> <!-- Quick Templates --> <div class="glassmorphism p-4 rounded-xl space-y-4"> <h2 class="text-lg font-semibold border-b border-gray-700 pb-2 flex items-center"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-cyan-400" viewBox="0 0 20 20" fill="currentColor"><path d="M5 3a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2V5a2 2 0 00-2-2H5zM5 11a2 2 0 00-2 2v2a2 2 0 002 2h2a2 2 0 002-2v-2a2 2 0 00-2-2H5zM11 5a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2V5zM11 13a2 2 0 012-2h2a2 2 0 012 2v2a2 2 0 01-2 2h-2a2 2 0 01-2-2v-2z" /></svg> Quick Templates </h2> <div class="grid grid-cols-2 gap-4"> <button class="bg-red-600 hover:bg-red-500 p-3 rounded-md transition" onclick="applyTemplate('alert')">Security Alert</button> <button class="bg-blue-600 hover:bg-blue-500 p-3 rounded-md transition" onclick="applyTemplate('list')">Top VPN List</button> <button class="bg-purple-600 hover:bg-purple-500 p-3 rounded-md transition" onclick="applyTemplate('feature')">Feature Spotlight</button> <button class="bg-green-600 hover:bg-green-500 p-3 rounded-md transition" onclick="applyTemplate('fact')">Did You Know?</button> </div> </div> <!-- Content Editor --> <div class="glassmorphism p-4 rounded-xl space-y-4"> <h2 class="text-lg font-semibold border-b border-gray-700 pb-2 flex items-center"> <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-cyan-400" viewBox="0 0 20 20" fill="currentColor"><path d="M17.414 2.586a2 2 0 00-2.828 0L7 10.172V13h2.828l7.586-7.586a2 2 0 000-2.828z" /><path fill-rule="evenodd" d="M2 6a2 2 0 012-2h4a1 1 0 010 2H4v10h10v-4a1 1 0 112 0v4a2 2 0 01-2 2H4a2 2 0 01-2-2V6z" clip-rule="evenodd" /></svg> Content Editor </h2> <input type="text" id="headline" placeholder="Your amazing headline..." class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition" onkeyup="updatePreview()"> <textarea id="description" placeholder="Tell your story..." rows="4" class="w-full bg-gray-900 border border-gray-700 rounded-md px-3 py-2 focus:ring-2 focus:ring-cyan-500 focus:outline-none transition" onkeyup="updatePreview()"></textarea> </div> </aside> <!-- Right Panel: Preview & Actions --> <main class="w-full lg:w-2/3 xl:w-3/4 p-4 lg:p-10 flex flex-col items-center justify-center bg-gray-900"> <!-- Aspect Ratio Controls --> <div class="mb-4 flex items-center space-x-2 bg-gray-800 p-1 rounded-lg"> <button id="aspect-square" onclick="changeAspectRatio('square')" class="px-3 py-1 rounded-md bg-cyan-600">1:1</button> <button id="aspect-portrait" onclick="changeAspectRatio('portrait')" class="px-3 py-1 rounded-md">9:16</button> <button id="aspect-landscape" onclick="changeAspectRatio('landscape')" class="px-3 py-1 rounded-md">16:9</button> </div> <!-- Live Preview --> <div id="preview-container" class="w-full max-w-2xl"> <div id="previewCard" class="preview-card-aspect-square w-full rounded-2xl p-8 lg:p-12 flex flex-col justify-center items-center text-center transition-all duration-500" style="background: linear-gradient(45deg, #1e3a8a, #4c1d95);"> <div id="logoContainer" class="mb-4"> <img id="logoPreview" src="https://placehold.co/100x100/transparent/FFFFFF?text=Logo" class="max-h-24" alt="Brand Logo"> </div> <h3 id="headlinePreview" class="text-3xl md:text-4xl font-black text-white" style="text-shadow: 2px 2px 8px rgba(0,0,0,0.5);">Your Amazing Headline Here!</h3> <div id="descriptionPreview" class="mt-4 text-lg text-gray-200"> <p>Add your description to tell the full story and engage your audience with compelling content.</p> </div> <div id="brandPreview" class="mt-8 text-sm text-gray-400"> <span id="brandNamePreview">Your Brand</span> | <span id="brandTaglinePreview">Your Tagline</span> </div> </div> </div> <!-- Action Buttons --> <div class="mt-6 flex space-x-4"> <button onclick="exportImage()" class="bg-green-600 hover:bg-green-500 text-white font-bold py-2 px-6 rounded-lg transition-transform transform hover:scale-105">Export as PNG</button> </div> </main> </div> <script> // --- STATE & ELEMENTS --- const brandNameEl = document.getElementById('brandName'); const brandTaglineEl = document.getElementById('brandTagline'); const brandColorEl = document.getElementById('brandColor'); const headlineEl = document.getElementById('headline'); const descriptionEl = document.getElementById('description'); const logoUploadEl = document.getElementById('logoUpload'); const previewCardEl = document.getElementById('previewCard'); const logoPreviewEl = document.getElementById('logoPreview'); const headlinePreviewEl = document.getElementById('headlinePreview'); const descriptionPreviewEl = document.getElementById('descriptionPreview'); const brandNamePreviewEl = document.getElementById('brandNamePreview'); const brandTaglinePreviewEl = document.getElementById('brandTaglinePreview'); let currentTemplate = 'default'; // --- PREVIEW UPDATE FUNCTIONS --- /** * Main function to update the live preview based on user inputs. * It gathers all values and calls specific update functions. */ function updatePreview() { const brandName = brandNameEl.value || "Your Brand"; const brandTagline = brandTaglineEl.value || "Your Tagline"; const headline = headlineEl.value || "Your Amazing Headline Here!"; const description = descriptionEl.value; const color = brandColorEl.value; // Update text content brandNamePreviewEl.textContent = brandName; brandTaglinePreviewEl.textContent = brandTagline; headlinePreviewEl.textContent = headline; // Update description, handling the list template specifically if (currentTemplate === 'list' && description) { const items = description.split('\n').filter(item => item.trim() !== ''); const listHtml = `<ul class="list-disc list-inside text-left mx-auto max-w-md space-y-2">${items.map(item => `<li>${item}</li>`).join('')}</ul>`; descriptionPreviewEl.innerHTML = listHtml; } else { descriptionPreviewEl.innerHTML = `<p>${description || "Add your description to tell the full story..."}</p>`; } // Update colors previewCardEl.style.background = `linear-gradient(45deg, ${getDarkerColor(color)}, ${color})`; } /** * Handles the logo file upload and displays it in the preview. * @param {Event} event - The file input change event. */ function handleLogoUpload(event) { const file = event.target.files[0]; if (file) { const reader = new FileReader(); reader.onload = function(e) { logoPreviewEl.src = e.target.result; } reader.readAsDataURL(file); } } /** * Changes the aspect ratio of the preview card. * @param {string} aspect - 'square', 'portrait', or 'landscape'. */ function changeAspectRatio(aspect) { const card = document.getElementById('previewCard'); const buttons = document.querySelectorAll('#aspect-square, #aspect-portrait, #aspect-landscape'); buttons.forEach(btn => btn.classList.remove('bg-cyan-600')); document.getElementById(`aspect-${aspect}`).classList.add('bg-cyan-600'); card.classList.remove('preview-card-aspect-square', 'preview-card-aspect-portrait', 'preview-card-aspect-landscape'); card.classList.add(`preview-card-aspect-${aspect}`); } // --- TEMPLATE & AI FUNCTIONS --- /** * Applies a pre-defined template to the content editor. * @param {string} templateName - The name of the template to apply. */ function applyTemplate(templateName) { currentTemplate = templateName; switch(templateName) { case 'alert': headlineEl.value = "URGENT: Security Alert!"; descriptionEl.value = "A new threat has been detected. Update your software immediately to stay protected. Your digital safety is our top priority."; break; case 'list': headlineEl.value = "Top 5 VPNs for 2025"; descriptionEl.value = "Lightning VPN: Best for speed\nSecureShell: Top for privacy\nGlobeTrotter VPN: Ideal for streaming\nPrivacyPeak: Excellent for beginners\nIronClad VPN: Most secure option"; break; case 'feature': headlineEl.value = "New Feature: Kill Switch"; descriptionEl.value = "Our new automatic Kill Switch feature ensures your IP address is never exposed, even if your VPN connection drops unexpectedly."; break; case 'fact': headlineEl.value = "Did You Know?"; descriptionEl.value = "Using a VPN can help you save money on flights and subscriptions by changing your virtual location."; break; } updatePreview(); } /** * Generates content using the Gemini API based on selected topic and style. */ async function generateContent() { const topic = document.getElementById('contentTopic').value; const style = document.getElementById('contentStyle').value; const generateButton = document.getElementById('generateButton'); const buttonText = document.getElementById('generateButtonText'); const spinner = document.getElementById('generateSpinner'); const apiError = document.getElementById('apiError'); // Show loading state buttonText.textContent = "Generating..."; spinner.classList.remove('hidden'); generateButton.disabled = true; apiError.classList.add('hidden'); // Determine if the request is for a list const isList = style.toLowerCase().includes('list') || topic.toLowerCase().includes('list'); currentTemplate = isList ? 'list' : 'default'; const prompt = `You are a marketing expert for tech products. Generate content for a social media graphic. Topic: "${topic}" Style: "${style}" Provide a short, punchy headline (max 10 words) and a brief description (max 40 words). ${isList ? "For the description, provide a bulleted list of 5 items, with each item on a new line. Do not use markdown like '*' or '-' for the list items." : ""} Return the response as a JSON object with two keys: "headline" and "description".`; try { const apiKey = ""; // API key is handled by the environment const apiUrl = `https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-05-20:generateContent?key=${apiKey}`; const payload = { contents: [{ role: "user", parts: [{ text: prompt }] }], generationConfig: { responseMimeType: "application/json", responseSchema: { type: "OBJECT", properties: { "headline": { "type": "STRING" }, "description": { "type": "STRING" } }, required: ["headline", "description"] } } }; const response = await fetch(apiUrl, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(payload) }); if (!response.ok) { throw new Error(`API error: ${response.statusText}`); } const result = await response.json(); if (result.candidates && result.candidates.length > 0) { const text = result.candidates[0].content.parts[0].text; const parsedJson = JSON.parse(text); headlineEl.value = parsedJson.headline; descriptionEl.value = parsedJson.description; updatePreview(); } else { throw new Error("No content generated. The response was empty."); } } catch (error) { console.error("Error fetching from Gemini API:", error); apiError.textContent = `Failed to generate content. ${error.message}`; apiError.classList.remove('hidden'); - Initial Deployment
aa41d8a verified