Spaces:
Running
селай сервис по создпнии баннера с помощью ии - прислается полный текст поста, затем ии анализирует и выдает на выбор варианты заголовка, затем после выбора заголовка автоматически подстраивается и делается задний фон который подходит по теме и делается в виде градиентного R 248
Browse filesG 216
B 72 ---
R 248
G 216
B 72 ---- задний фон делается на все рабочее пронстранство ----- затем автоматически делается подсчет подходящих картинок и делается веб поиск каринок - затем дается выбор какие элементы должны быьть --- после выбора с низ удаляется задий фон и делается белый контур (можно все редактировать в настройках) ---в процессе можно редактировать все жлементы - размеры увета градиетны положение прозрачность толщини контура логотип и вообще все ----- рабочее пронстранство - 16:9 ---с права все элементы в виде слоев которые можно перемящить меняя слои , нажимать на редактирование (что над слоями появляется овно редактирования элемента) - справа все элементы набора - --- также кнопка эеспорта полной картинки в виде пнг --- --- сделай все очень красиво ---
- README.md +8 -5
- components/header.js +6 -0
- index.html +111 -19
- script.js +274 -0
- style.css +106 -18
|
@@ -1,10 +1,13 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: BannerCraft AI Studio
|
| 3 |
+
colorFrom: pink
|
| 4 |
+
colorTo: blue
|
| 5 |
+
emoji: 🐳
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite-v3
|
| 10 |
---
|
| 11 |
|
| 12 |
+
# Welcome to your new DeepSite project!
|
| 13 |
+
This project was created with [DeepSite](https://huggingface.co/deepsite).
|
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class HeaderBanner extends HTMLElement {
|
| 2 |
+
connectedCallback() {
|
| 3 |
+
this.attachShadow({ mode: 'open' });
|
| 4 |
+
this.shadowRoot.innerHTML = `
|
| 5 |
+
<style>
|
| 6 |
+
:host
|
|
@@ -1,19 +1,111 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>BannerCraft AI Studio</title>
|
| 7 |
+
<link rel="stylesheet" href="style.css">
|
| 8 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
</head>
|
| 12 |
+
<body class="bg-gray-50 min-h-screen">
|
| 13 |
+
<!-- Header -->
|
| 14 |
+
<header-banner></header-banner>
|
| 15 |
+
|
| 16 |
+
<div class="flex flex-col lg:flex-row h-screen">
|
| 17 |
+
<!-- Main Content Area -->
|
| 18 |
+
<main class="flex-1 p-6 overflow-auto">
|
| 19 |
+
<div class="max-w-6xl mx-auto">
|
| 20 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
| 21 |
+
<!-- Input Panel -->
|
| 22 |
+
<div class="lg:col-span-1 bg-white rounded-xl shadow-lg p-6">
|
| 23 |
+
<h2 class="text-xl font-bold text-gray-800 mb-4">Create Your Banner</h2>
|
| 24 |
+
<div class="space-y-4">
|
| 25 |
+
<div>
|
| 26 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Post Content</label>
|
| 27 |
+
<textarea id="postContent" class="w-full h-32 p-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-yellow-400 focus:border-transparent" placeholder="Paste your post content here..."></textarea>
|
| 28 |
+
</div>
|
| 29 |
+
<button id="analyzeBtn" class="w-full bg-gradient-to-r from-yellow-400 to-yellow-500 hover:from-yellow-500 hover:to-yellow-600 text-white font-semibold py-3 px-4 rounded-lg transition duration-300 flex items-center justify-center">
|
| 30 |
+
<i data-feather="zap" class="mr-2"></i> Analyze with AI
|
| 31 |
+
</button>
|
| 32 |
+
|
| 33 |
+
<!-- Headline Selection -->
|
| 34 |
+
<div id="headlineSection" class="hidden">
|
| 35 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Select Headline</label>
|
| 36 |
+
<div id="headlineOptions" class="space-y-2">
|
| 37 |
+
<!-- Headlines will be inserted here -->
|
| 38 |
+
</div>
|
| 39 |
+
</div>
|
| 40 |
+
|
| 41 |
+
<!-- Image Search Results -->
|
| 42 |
+
<div id="imageSearchSection" class="hidden">
|
| 43 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Choose Background Image</label>
|
| 44 |
+
<div id="imageResults" class="grid grid-cols-2 gap-2 max-h-60 overflow-y-auto">
|
| 45 |
+
<!-- Images will be inserted here -->
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
</div>
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
<!-- Canvas Preview -->
|
| 52 |
+
<div class="lg:col-span-2">
|
| 53 |
+
<div class="bg-white rounded-xl shadow-lg p-6 h-full">
|
| 54 |
+
<div class="flex justify-between items-center mb-4">
|
| 55 |
+
<h2 class="text-xl font-bold text-gray-800">Banner Preview</h2>
|
| 56 |
+
<button id="exportBtn" class="bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg flex items-center">
|
| 57 |
+
<i data-feather="download" class="mr-2"></i> Export PNG
|
| 58 |
+
</button>
|
| 59 |
+
</div>
|
| 60 |
+
|
| 61 |
+
<!-- Banner Canvas -->
|
| 62 |
+
<div id="bannerCanvas" class="relative w-full aspect-video bg-gradient-to-br from-yellow-300 to-yellow-400 rounded-lg overflow-hidden border-4 border-white shadow-lg">
|
| 63 |
+
<!-- Elements will be added here dynamically -->
|
| 64 |
+
<div id="canvasElements" class="absolute inset-0">
|
| 65 |
+
<!-- Placeholder elements -->
|
| 66 |
+
<div class="absolute top-1/2 left-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center">
|
| 67 |
+
<h3 class="text-3xl font-bold text-white drop-shadow-lg">Your Banner</h3>
|
| 68 |
+
<p class="text-white mt-2">Start creating with AI</p>
|
| 69 |
+
</div>
|
| 70 |
+
</div>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<!-- Element Controls -->
|
| 74 |
+
<div id="elementControls" class="mt-4 hidden">
|
| 75 |
+
<div class="grid grid-cols-2 md:grid-cols-4 gap-3">
|
| 76 |
+
<button class="bg-blue-100 hover:bg-blue-200 text-blue-700 py-2 px-3 rounded-lg flex items-center justify-center">
|
| 77 |
+
<i data-feather="type" class="mr-1"></i> Text
|
| 78 |
+
</button>
|
| 79 |
+
<button class="bg-blue-100 hover:bg-blue-200 text-blue-700 py-2 px-3 rounded-lg flex items-center justify-center">
|
| 80 |
+
<i data-feather="image" class="mr-1"></i> Image
|
| 81 |
+
</button>
|
| 82 |
+
<button class="bg-blue-100 hover:bg-blue-200 text-blue-700 py-2 px-3 rounded-lg flex items-center justify-center">
|
| 83 |
+
<i data-feather="square" class="mr-1"></i> Shape
|
| 84 |
+
</button>
|
| 85 |
+
<button class="bg-blue-100 hover:bg-blue-200 text-blue-700 py-2 px-3 rounded-lg flex items-center justify-center">
|
| 86 |
+
<i data-feather="star" class="mr-1"></i> Logo
|
| 87 |
+
</button>
|
| 88 |
+
</div>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
</div>
|
| 93 |
+
</div>
|
| 94 |
+
</main>
|
| 95 |
+
|
| 96 |
+
<!-- Layers Panel -->
|
| 97 |
+
<aside-layers></aside-layers>
|
| 98 |
+
</div>
|
| 99 |
+
|
| 100 |
+
<!-- Web Components -->
|
| 101 |
+
<script src="components/header.js"></script>
|
| 102 |
+
<script src="components/aside-layers.js"></script>
|
| 103 |
+
|
| 104 |
+
<!-- Scripts -->
|
| 105 |
+
<script src="script.js"></script>
|
| 106 |
+
<script>
|
| 107 |
+
feather.replace();
|
| 108 |
+
</script>
|
| 109 |
+
<script src="https://huggingface.co/deepsite/deepsite-badge.js"></script>
|
| 110 |
+
</body>
|
| 111 |
+
</html>
|
|
@@ -0,0 +1,274 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Global state
|
| 2 |
+
let currentState = {
|
| 3 |
+
postContent: '',
|
| 4 |
+
headlines: [],
|
| 5 |
+
selectedHeadline: null,
|
| 6 |
+
backgroundImage: null,
|
| 7 |
+
elements: [],
|
| 8 |
+
selectedElement: null
|
| 9 |
+
};
|
| 10 |
+
|
| 11 |
+
// DOM Elements
|
| 12 |
+
const postContentEl = document.getElementById('postContent');
|
| 13 |
+
const analyzeBtn = document.getElementById('analyzeBtn');
|
| 14 |
+
const headlineSection = document.getElementById('headlineSection');
|
| 15 |
+
const headlineOptions = document.getElementById('headlineOptions');
|
| 16 |
+
const imageSearchSection = document.getElementById('imageSearchSection');
|
| 17 |
+
const imageResults = document.getElementById('imageResults');
|
| 18 |
+
const bannerCanvas = document.getElementById('bannerCanvas');
|
| 19 |
+
const canvasElements = document.getElementById('canvasElements');
|
| 20 |
+
const elementControls = document.getElementById('elementControls');
|
| 21 |
+
const exportBtn = document.getElementById('exportBtn');
|
| 22 |
+
|
| 23 |
+
// Initialize
|
| 24 |
+
document.addEventListener('DOMContentLoaded', () => {
|
| 25 |
+
setupEventListeners();
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
// Event Listeners
|
| 29 |
+
function setupEventListeners() {
|
| 30 |
+
analyzeBtn.addEventListener('click', handleAnalyzeClick);
|
| 31 |
+
exportBtn.addEventListener('click', handleExportClick);
|
| 32 |
+
|
| 33 |
+
// Drag and drop for canvas elements
|
| 34 |
+
canvasElements.addEventListener('dragstart', handleDragStart);
|
| 35 |
+
canvasElements.addEventListener('dragover', handleDragOver);
|
| 36 |
+
canvasElements.addEventListener('drop', handleDrop);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
// Handle Analyze Button Click
|
| 40 |
+
async function handleAnalyzeClick() {
|
| 41 |
+
const content = postContentEl.value.trim();
|
| 42 |
+
if (!content) {
|
| 43 |
+
alert('Please enter some post content');
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
currentState.postContent = content;
|
| 48 |
+
|
| 49 |
+
// Show loading state
|
| 50 |
+
analyzeBtn.innerHTML = '<i data-feather="loader" class="animate-spin mr-2"></i> Analyzing...';
|
| 51 |
+
feather.replace();
|
| 52 |
+
|
| 53 |
+
try {
|
| 54 |
+
// Simulate AI processing
|
| 55 |
+
await new Promise(resolve => setTimeout(resolve, 1500));
|
| 56 |
+
|
| 57 |
+
// Generate sample headlines
|
| 58 |
+
currentState.headlines = [
|
| 59 |
+
"Transform Your Business Today",
|
| 60 |
+
"Unlock New Possibilities",
|
| 61 |
+
"Innovate Your Future",
|
| 62 |
+
"Discover Amazing Solutions",
|
| 63 |
+
"Elevate Your Brand"
|
| 64 |
+
];
|
| 65 |
+
|
| 66 |
+
renderHeadlineOptions();
|
| 67 |
+
headlineSection.classList.remove('hidden');
|
| 68 |
+
|
| 69 |
+
// Simulate image search
|
| 70 |
+
await new Promise(resolve => setTimeout(resolve, 1000));
|
| 71 |
+
renderImageResults();
|
| 72 |
+
imageSearchSection.classList.remove('hidden');
|
| 73 |
+
|
| 74 |
+
} catch (error) {
|
| 75 |
+
console.error('Analysis failed:', error);
|
| 76 |
+
alert('Analysis failed. Please try again.');
|
| 77 |
+
} finally {
|
| 78 |
+
analyzeBtn.innerHTML = '<i data-feather="zap" class="mr-2"></i> Analyze with AI';
|
| 79 |
+
feather.replace();
|
| 80 |
+
}
|
| 81 |
+
}
|
| 82 |
+
|
| 83 |
+
// Render Headline Options
|
| 84 |
+
function renderHeadlineOptions() {
|
| 85 |
+
headlineOptions.innerHTML = '';
|
| 86 |
+
|
| 87 |
+
currentState.headlines.forEach((headline, index) => {
|
| 88 |
+
const headlineEl = document.createElement('div');
|
| 89 |
+
headlineEl.className = 'p-3 border border-gray-200 rounded-lg cursor-pointer hover:bg-yellow-50 transition';
|
| 90 |
+
headlineEl.innerHTML = `
|
| 91 |
+
<div class="font-medium">${headline}</div>
|
| 92 |
+
`;
|
| 93 |
+
headlineEl.addEventListener('click', () => selectHeadline(index));
|
| 94 |
+
headlineOptions.appendChild(headlineEl);
|
| 95 |
+
});
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// Select Headline
|
| 99 |
+
function selectHeadline(index) {
|
| 100 |
+
currentState.selectedHeadline = currentState.headlines[index];
|
| 101 |
+
|
| 102 |
+
// Update UI to show selection
|
| 103 |
+
const headlineItems = headlineOptions.querySelectorAll('div');
|
| 104 |
+
headlineItems.forEach((item, i) => {
|
| 105 |
+
if (i === index) {
|
| 106 |
+
item.classList.add('bg-yellow-100', 'border-yellow-400');
|
| 107 |
+
} else {
|
| 108 |
+
item.classList.remove('bg-yellow-100', 'border-yellow-400');
|
| 109 |
+
}
|
| 110 |
+
});
|
| 111 |
+
|
| 112 |
+
// Apply to canvas
|
| 113 |
+
updateCanvasWithHeadline();
|
| 114 |
+
}
|
| 115 |
+
|
| 116 |
+
// Render Image Results
|
| 117 |
+
function renderImageResults() {
|
| 118 |
+
imageResults.innerHTML = '';
|
| 119 |
+
|
| 120 |
+
// Generate sample images
|
| 121 |
+
for (let i = 0; i < 6; i++) {
|
| 122 |
+
const imgEl = document.createElement('img');
|
| 123 |
+
imgEl.src = `http://static.photos/technology/320x240/${i + 1}`;
|
| 124 |
+
imgEl.alt = `Background option ${i + 1}`;
|
| 125 |
+
imgEl.className = 'rounded-lg cursor-pointer hover:opacity-80 transition';
|
| 126 |
+
imgEl.addEventListener('click', () => selectBackgroundImage(imgEl.src));
|
| 127 |
+
imageResults.appendChild(imgEl);
|
| 128 |
+
}
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
// Select Background Image
|
| 132 |
+
function selectBackgroundImage(src) {
|
| 133 |
+
currentState.backgroundImage = src;
|
| 134 |
+
|
| 135 |
+
// Update canvas background
|
| 136 |
+
bannerCanvas.style.background = `linear-gradient(to bottom right, var(--primary-yellow), var(--secondary-yellow)), url('${src}')`;
|
| 137 |
+
bannerCanvas.style.backgroundSize = 'cover';
|
| 138 |
+
bannerCanvas.style.backgroundPosition = 'center';
|
| 139 |
+
|
| 140 |
+
// Show element controls
|
| 141 |
+
elementControls.classList.remove('hidden');
|
| 142 |
+
|
| 143 |
+
// Add sample elements
|
| 144 |
+
addSampleElements();
|
| 145 |
+
}
|
| 146 |
+
|
| 147 |
+
// Update Canvas with Headline
|
| 148 |
+
function updateCanvasWithHeadline() {
|
| 149 |
+
// Clear previous headline
|
| 150 |
+
const existingHeadline = document.querySelector('.headline-element');
|
| 151 |
+
if (existingHeadline) {
|
| 152 |
+
existingHeadline.remove();
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
if (currentState.selectedHeadline) {
|
| 156 |
+
const headlineEl = document.createElement('div');
|
| 157 |
+
headlineEl.className = 'canvas-element headline-element absolute top-10 left-10 p-4 bg-white bg-opacity-90 rounded-lg shadow-lg';
|
| 158 |
+
headlineEl.draggable = true;
|
| 159 |
+
headlineEl.dataset.id = 'headline';
|
| 160 |
+
headlineEl.innerHTML = `
|
| 161 |
+
<h2 class="text-2xl font-bold text-gray-800">${currentState.selectedHeadline}</h2>
|
| 162 |
+
`;
|
| 163 |
+
headlineEl.addEventListener('click', () => selectElement('headline'));
|
| 164 |
+
canvasElements.appendChild(headlineEl);
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
// Add Sample Elements
|
| 169 |
+
function addSampleElements() {
|
| 170 |
+
// Add logo
|
| 171 |
+
const logoEl = document.createElement('div');
|
| 172 |
+
logoEl.className = 'canvas-element absolute top-10 right-10 w-16 h-16 bg-white rounded-full flex items-center justify-center shadow-lg';
|
| 173 |
+
logoEl.draggable = true;
|
| 174 |
+
logoEl.dataset.id = 'logo';
|
| 175 |
+
logoEl.innerHTML = `
|
| 176 |
+
<i data-feather="star" class="text-yellow-500"></i>
|
| 177 |
+
`;
|
| 178 |
+
logoEl.addEventListener('click', () => selectElement('logo'));
|
| 179 |
+
canvasElements.appendChild(logoEl);
|
| 180 |
+
|
| 181 |
+
// Add CTA button
|
| 182 |
+
const ctaEl = document.createElement('div');
|
| 183 |
+
ctaEl.className = 'canvas-element absolute bottom-10 left-10 px-6 py-3 bg-blue-600 text-white rounded-lg shadow-lg cursor-pointer hover:bg-blue-700 transition';
|
| 184 |
+
ctaEl.draggable = true;
|
| 185 |
+
ctaEl.dataset.id = 'cta';
|
| 186 |
+
ctaEl.innerHTML = `
|
| 187 |
+
<span class="font-semibold">Get Started</span>
|
| 188 |
+
`;
|
| 189 |
+
ctaEl.addEventListener('click', () => selectElement('cta'));
|
| 190 |
+
canvasElements.appendChild(ctaEl);
|
| 191 |
+
|
| 192 |
+
feather.replace();
|
| 193 |
+
}
|
| 194 |
+
|
| 195 |
+
// Select Element
|
| 196 |
+
function selectElement(id) {
|
| 197 |
+
// Remove previous selections
|
| 198 |
+
document.querySelectorAll('.canvas-element').forEach(el => {
|
| 199 |
+
el.classList.remove('selected');
|
| 200 |
+
});
|
| 201 |
+
|
| 202 |
+
// Select new element
|
| 203 |
+
const element = document.querySelector(`.canvas-element[data-id="${id}"]`);
|
| 204 |
+
if (element) {
|
| 205 |
+
element.classList.add('selected');
|
| 206 |
+
currentState.selectedElement = id;
|
| 207 |
+
|
| 208 |
+
// Show element controls
|
| 209 |
+
showElementControls(element);
|
| 210 |
+
}
|
| 211 |
+
}
|
| 212 |
+
|
| 213 |
+
// Show Element Controls
|
| 214 |
+
function showElementControls(element) {
|
| 215 |
+
// Remove existing controls
|
| 216 |
+
const existingControls = element.querySelector('.element-controls');
|
| 217 |
+
if (existingControls) existingControls.remove();
|
| 218 |
+
|
| 219 |
+
// Create controls
|
| 220 |
+
const controls = document.createElement('div');
|
| 221 |
+
controls.className = 'element-controls';
|
| 222 |
+
controls.innerHTML = `
|
| 223 |
+
<button class="control-btn" title="Move"><i data-feather="move"></i></button>
|
| 224 |
+
<button class="control-btn" title="Edit"><i data-feather="edit"></i></button>
|
| 225 |
+
<button class="control-btn" title="Delete"><i data-feather="trash-2"></i></button>
|
| 226 |
+
`;
|
| 227 |
+
|
| 228 |
+
element.appendChild(controls);
|
| 229 |
+
feather.replace();
|
| 230 |
+
|
| 231 |
+
// Add control event listeners
|
| 232 |
+
controls.querySelector('[title="Delete"]').addEventListener('click', (e) => {
|
| 233 |
+
e.stopPropagation();
|
| 234 |
+
element.remove();
|
| 235 |
+
});
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
// Drag and Drop Handlers
|
| 239 |
+
function handleDragStart(e) {
|
| 240 |
+
if (e.target.classList.contains('canvas-element')) {
|
| 241 |
+
e.dataTransfer.setData('text/plain', e.target.dataset.id);
|
| 242 |
+
setTimeout(() => e.target.classList.add('dragging'), 0);
|
| 243 |
+
}
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
function handleDragOver(e) {
|
| 247 |
+
e.preventDefault();
|
| 248 |
+
e.dataTransfer.dropEffect = 'move';
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
function handleDrop(e) {
|
| 252 |
+
e.preventDefault();
|
| 253 |
+
const id = e.dataTransfer.getData('text/plain');
|
| 254 |
+
const element = document.querySelector(`.canvas-element[data-id="${id}"]`);
|
| 255 |
+
|
| 256 |
+
if (element) {
|
| 257 |
+
element.classList.remove('dragging');
|
| 258 |
+
|
| 259 |
+
// Calculate position relative to canvas
|
| 260 |
+
const rect = bannerCanvas.getBoundingClientRect();
|
| 261 |
+
const x = e.clientX - rect.left;
|
| 262 |
+
const y = e.clientY - rect.top;
|
| 263 |
+
|
| 264 |
+
// Position element
|
| 265 |
+
element.style.left = `${x - element.offsetWidth / 2}px`;
|
| 266 |
+
element.style.top = `${y - element.offsetHeight / 2}px`;
|
| 267 |
+
}
|
| 268 |
+
}
|
| 269 |
+
|
| 270 |
+
// Handle Export
|
| 271 |
+
function handleExportClick() {
|
| 272 |
+
alert('Export functionality would save your banner as PNG');
|
| 273 |
+
// In a real implementation, this would use html2canvas or similar
|
| 274 |
+
}
|
|
@@ -1,28 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
body {
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
}
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
margin-top: 0;
|
| 9 |
}
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
margin-bottom: 10px;
|
| 15 |
-
margin-top: 5px;
|
| 16 |
}
|
| 17 |
|
| 18 |
-
.
|
| 19 |
-
|
| 20 |
-
margin: 0 auto;
|
| 21 |
-
padding: 16px;
|
| 22 |
-
border: 1px solid lightgray;
|
| 23 |
-
border-radius: 16px;
|
| 24 |
}
|
| 25 |
|
| 26 |
-
.
|
| 27 |
-
|
|
|
|
| 28 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
|
| 2 |
+
|
| 3 |
+
:root {
|
| 4 |
+
--primary-yellow: #f8d848;
|
| 5 |
+
--secondary-yellow: #f8c828;
|
| 6 |
+
--accent-blue: #3b82f6;
|
| 7 |
+
--light-gray: #f9fafb;
|
| 8 |
+
--dark-gray: #1f2937;
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
* {
|
| 12 |
+
margin: 0;
|
| 13 |
+
padding: 0;
|
| 14 |
+
box-sizing: border-box;
|
| 15 |
+
font-family: 'Inter', sans-serif;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
body {
|
| 19 |
+
background-color: var(--light-gray);
|
| 20 |
+
color: var(--dark-gray);
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/* Custom Scrollbar */
|
| 24 |
+
::-webkit-scrollbar {
|
| 25 |
+
width: 8px;
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
::-webkit-scrollbar-track {
|
| 29 |
+
background: #f1f1f1;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
::-webkit-scrollbar-thumb {
|
| 33 |
+
background: #c5c5c5;
|
| 34 |
+
border-radius: 4px;
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
::-webkit-scrollbar-thumb:hover {
|
| 38 |
+
background: #a0a0a0;
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
/* Canvas Elements */
|
| 42 |
+
.canvas-element {
|
| 43 |
+
position: absolute;
|
| 44 |
+
cursor: move;
|
| 45 |
+
user-select: none;
|
| 46 |
+
}
|
| 47 |
+
|
| 48 |
+
.canvas-element.selected {
|
| 49 |
+
outline: 2px dashed #3b82f6;
|
| 50 |
+
outline-offset: 2px;
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
.element-controls {
|
| 54 |
+
position: absolute;
|
| 55 |
+
top: -35px;
|
| 56 |
+
left: 0;
|
| 57 |
+
display: flex;
|
| 58 |
+
gap: 5px;
|
| 59 |
+
background: rgba(255, 255, 255, 0.9);
|
| 60 |
+
padding: 5px;
|
| 61 |
+
border-radius: 6px;
|
| 62 |
+
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
.control-btn {
|
| 66 |
+
background: #f3f4f6;
|
| 67 |
+
border: none;
|
| 68 |
+
width: 28px;
|
| 69 |
+
height: 28px;
|
| 70 |
+
border-radius: 4px;
|
| 71 |
+
display: flex;
|
| 72 |
+
align-items: center;
|
| 73 |
+
justify-content: center;
|
| 74 |
+
cursor: pointer;
|
| 75 |
+
transition: all 0.2s;
|
| 76 |
}
|
| 77 |
|
| 78 |
+
.control-btn:hover {
|
| 79 |
+
background: #e5e7eb;
|
|
|
|
| 80 |
}
|
| 81 |
|
| 82 |
+
/* Layer Items */
|
| 83 |
+
.layer-item {
|
| 84 |
+
transition: all 0.2s ease;
|
|
|
|
|
|
|
| 85 |
}
|
| 86 |
|
| 87 |
+
.layer-item:hover {
|
| 88 |
+
background-color: #f3f4f6;
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
}
|
| 90 |
|
| 91 |
+
.layer-item.active {
|
| 92 |
+
background-color: #dbeafe;
|
| 93 |
+
border-left: 3px solid #3b82f6;
|
| 94 |
}
|
| 95 |
+
|
| 96 |
+
/* Responsive Adjustments */
|
| 97 |
+
@media (max-width: 1024px) {
|
| 98 |
+
.layers-panel {
|
| 99 |
+
position: fixed;
|
| 100 |
+
right: 0;
|
| 101 |
+
top: 0;
|
| 102 |
+
height: 100vh;
|
| 103 |
+
transform: translateX(100%);
|
| 104 |
+
transition: transform 0.3s ease;
|
| 105 |
+
z-index: 50;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
.layers-panel.open {
|
| 109 |
+
transform: translateX(0);
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
.dragging {
|
| 114 |
+
opacity: 0.5;
|
| 115 |
+
transform: scale(0.98);
|
| 116 |
+
}
|