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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="pt-BR">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>SiteBuilder Pro - Gerador de Sites</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
| 9 |
+
<style>
|
| 10 |
+
.resizable {
|
| 11 |
+
resize: both;
|
| 12 |
+
overflow: auto;
|
| 13 |
+
min-width: 300px;
|
| 14 |
+
min-height: 200px;
|
| 15 |
+
}
|
| 16 |
+
.component-placeholder {
|
| 17 |
+
border: 2px dashed #ccc;
|
| 18 |
+
padding: 20px;
|
| 19 |
+
text-align: center;
|
| 20 |
+
margin: 10px 0;
|
| 21 |
+
border-radius: 8px;
|
| 22 |
+
background-color: #f9f9f9;
|
| 23 |
+
}
|
| 24 |
+
.component-selected {
|
| 25 |
+
border: 2px solid #3b82f6;
|
| 26 |
+
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
|
| 27 |
+
}
|
| 28 |
+
#previewFrame {
|
| 29 |
+
width: 100%;
|
| 30 |
+
height: 100%;
|
| 31 |
+
border: none;
|
| 32 |
+
background: white;
|
| 33 |
+
}
|
| 34 |
+
.sidebar {
|
| 35 |
+
transition: all 0.3s ease;
|
| 36 |
+
}
|
| 37 |
+
.sidebar-collapsed {
|
| 38 |
+
width: 60px !important;
|
| 39 |
+
}
|
| 40 |
+
.sidebar-collapsed .sidebar-text {
|
| 41 |
+
display: none;
|
| 42 |
+
}
|
| 43 |
+
.sidebar-collapsed .fa-lg {
|
| 44 |
+
font-size: 1.5rem !important;
|
| 45 |
+
}
|
| 46 |
+
.draggable-component {
|
| 47 |
+
cursor: grab;
|
| 48 |
+
user-select: none;
|
| 49 |
+
}
|
| 50 |
+
.draggable-component:active {
|
| 51 |
+
cursor: grabbing;
|
| 52 |
+
}
|
| 53 |
+
</style>
|
| 54 |
+
</head>
|
| 55 |
+
<body class="bg-gray-100 h-screen flex flex-col">
|
| 56 |
+
<!-- Barra de navegação superior -->
|
| 57 |
+
<nav class="bg-blue-600 text-white p-4 shadow-md flex justify-between items-center">
|
| 58 |
+
<div class="flex items-center space-x-2">
|
| 59 |
+
<i class="fas fa-code fa-lg"></i>
|
| 60 |
+
<h1 class="text-xl font-bold">SiteBuilder Pro</h1>
|
| 61 |
+
</div>
|
| 62 |
+
<div class="flex space-x-4">
|
| 63 |
+
<button id="exportBtn" class="bg-white text-blue-600 px-4 py-2 rounded-md hover:bg-blue-50 transition">
|
| 64 |
+
<i class="fas fa-download mr-2"></i>Exportar
|
| 65 |
+
</button>
|
| 66 |
+
<button id="saveBtn" class="bg-blue-700 px-4 py-2 rounded-md hover:bg-blue-800 transition">
|
| 67 |
+
<i class="fas fa-save mr-2"></i>Salvar
|
| 68 |
+
</button>
|
| 69 |
+
</div>
|
| 70 |
+
</nav>
|
| 71 |
+
|
| 72 |
+
<div class="flex flex-1 overflow-hidden">
|
| 73 |
+
<!-- Sidebar de componentes -->
|
| 74 |
+
<div id="componentsSidebar" class="sidebar bg-gray-800 text-white w-64 flex flex-col transition-all duration-300">
|
| 75 |
+
<div class="p-4 border-b border-gray-700 flex justify-between items-center">
|
| 76 |
+
<h2 class="text-lg font-semibold sidebar-text">Componentes</h2>
|
| 77 |
+
<button id="toggleSidebar" class="text-gray-400 hover:text-white">
|
| 78 |
+
<i class="fas fa-chevron-left fa-lg"></i>
|
| 79 |
+
</button>
|
| 80 |
+
</div>
|
| 81 |
+
<div class="p-4 overflow-y-auto flex-1">
|
| 82 |
+
<div class="mb-6">
|
| 83 |
+
<h3 class="text-sm uppercase text-gray-400 mb-2 sidebar-text">Básicos</h3>
|
| 84 |
+
<div class="space-y-2">
|
| 85 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 86 |
+
draggable="true" data-type="header">
|
| 87 |
+
<i class="fas fa-heading mr-3 sidebar-text"></i>
|
| 88 |
+
<span class="sidebar-text">Cabeçalho</span>
|
| 89 |
+
</div>
|
| 90 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 91 |
+
draggable="true" data-type="paragraph">
|
| 92 |
+
<i class="fas fa-paragraph mr-3 sidebar-text"></i>
|
| 93 |
+
<span class="sidebar-text">Parágrafo</span>
|
| 94 |
+
</div>
|
| 95 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 96 |
+
draggable="true" data-type="button">
|
| 97 |
+
<i class="fas fa-square mr-3 sidebar-text"></i>
|
| 98 |
+
<span class="sidebar-text">Botão</span>
|
| 99 |
+
</div>
|
| 100 |
+
</div>
|
| 101 |
+
</div>
|
| 102 |
+
|
| 103 |
+
<div class="mb-6">
|
| 104 |
+
<h3 class="text-sm uppercase text-gray-400 mb-2 sidebar-text">Mídia</h3>
|
| 105 |
+
<div class="space-y-2">
|
| 106 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 107 |
+
draggable="true" data-type="image">
|
| 108 |
+
<i class="fas fa-image mr-3 sidebar-text"></i>
|
| 109 |
+
<span class="sidebar-text">Imagem</span>
|
| 110 |
+
</div>
|
| 111 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 112 |
+
draggable="true" data-type="video">
|
| 113 |
+
<i class="fas fa-video mr-3 sidebar-text"></i>
|
| 114 |
+
<span class="sidebar-text">Vídeo</span>
|
| 115 |
+
</div>
|
| 116 |
+
</div>
|
| 117 |
+
</div>
|
| 118 |
+
|
| 119 |
+
<div class="mb-6">
|
| 120 |
+
<h3 class="text-sm uppercase text-gray-400 mb-2 sidebar-text">Layout</h3>
|
| 121 |
+
<div class="space-y-2">
|
| 122 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 123 |
+
draggable="true" data-type="section">
|
| 124 |
+
<i class="fas fa-square-full mr-3 sidebar-text"></i>
|
| 125 |
+
<span class="sidebar-text">Seção</span>
|
| 126 |
+
</div>
|
| 127 |
+
<div class="draggable-component bg-gray-700 p-3 rounded-md cursor-move hover:bg-gray-600 transition flex items-center"
|
| 128 |
+
draggable="true" data-type="columns">
|
| 129 |
+
<i class="fas fa-columns mr-3 sidebar-text"></i>
|
| 130 |
+
<span class="sidebar-text">Colunas</span>
|
| 131 |
+
</div>
|
| 132 |
+
</div>
|
| 133 |
+
</div>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
<!-- Área de edição -->
|
| 138 |
+
<div class="flex-1 flex flex-col bg-white">
|
| 139 |
+
<div class="border-b p-4 flex space-x-4">
|
| 140 |
+
<div class="flex items-center space-x-2">
|
| 141 |
+
<i class="fas fa-desktop text-gray-600"></i>
|
| 142 |
+
<span>Desktop</span>
|
| 143 |
+
</div>
|
| 144 |
+
<div class="flex items-center space-x-2">
|
| 145 |
+
<i class="fas fa-tablet-alt text-gray-400"></i>
|
| 146 |
+
<span>Tablet</span>
|
| 147 |
+
</div>
|
| 148 |
+
<div class="flex items-center space-x-2">
|
| 149 |
+
<i class="fas fa-mobile-alt text-gray-400"></i>
|
| 150 |
+
<span>Mobile</span>
|
| 151 |
+
</div>
|
| 152 |
+
</div>
|
| 153 |
+
<div id="editorArea" class="flex-1 overflow-auto p-8 bg-gray-100">
|
| 154 |
+
<div id="canvas" class="bg-white shadow-lg mx-auto w-full max-w-4xl min-h-screen">
|
| 155 |
+
<!-- Componentes serão adicionados aqui -->
|
| 156 |
+
<div class="component-placeholder" id="dropZone">
|
| 157 |
+
Arraste componentes aqui para começar
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
|
| 163 |
+
<!-- Painel de propriedades -->
|
| 164 |
+
<div class="w-64 bg-white border-l border-gray-200 p-4 overflow-y-auto">
|
| 165 |
+
<h2 class="text-lg font-semibold mb-4">Propriedades</h2>
|
| 166 |
+
<div id="propertyPanel">
|
| 167 |
+
<div class="text-gray-500 italic">Selecione um componente para editar suas propriedades</div>
|
| 168 |
+
</div>
|
| 169 |
+
</div>
|
| 170 |
+
</div>
|
| 171 |
+
|
| 172 |
+
<!-- Modal de exportação -->
|
| 173 |
+
<div id="exportModal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
|
| 174 |
+
<div class="bg-white rounded-lg p-6 w-full max-w-2xl">
|
| 175 |
+
<div class="flex justify-between items-center mb-4">
|
| 176 |
+
<h3 class="text-xl font-bold">Exportar Site</h3>
|
| 177 |
+
<button id="closeExportModal" class="text-gray-500 hover:text-gray-700">
|
| 178 |
+
<i class="fas fa-times"></i>
|
| 179 |
+
</button>
|
| 180 |
+
</div>
|
| 181 |
+
<div class="mb-4">
|
| 182 |
+
<label class="block text-gray-700 mb-2">Nome do Site</label>
|
| 183 |
+
<input type="text" id="siteName" class="w-full p-2 border rounded-md" placeholder="Meu Site Incrível">
|
| 184 |
+
</div>
|
| 185 |
+
<div class="mb-6">
|
| 186 |
+
<label class="block text-gray-700 mb-2">Formato</label>
|
| 187 |
+
<div class="flex space-x-4">
|
| 188 |
+
<label class="flex items-center">
|
| 189 |
+
<input type="radio" name="exportFormat" value="html" checked class="mr-2">
|
| 190 |
+
<span>HTML Completo</span>
|
| 191 |
+
</label>
|
| 192 |
+
<label class="flex items-center">
|
| 193 |
+
<input type="radio" name="exportFormat" value="zip" class="mr-2">
|
| 194 |
+
<span>Arquivo ZIP</span>
|
| 195 |
+
</label>
|
| 196 |
+
</div>
|
| 197 |
+
</div>
|
| 198 |
+
<div class="flex justify-end space-x-3">
|
| 199 |
+
<button id="cancelExport" class="px-4 py-2 border rounded-md hover:bg-gray-100">Cancelar</button>
|
| 200 |
+
<button id="confirmExport" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700">Exportar</button>
|
| 201 |
+
</div>
|
| 202 |
+
</div>
|
| 203 |
+
</div>
|
| 204 |
+
|
| 205 |
+
<script>
|
| 206 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 207 |
+
// Variáveis globais
|
| 208 |
+
let selectedComponent = null;
|
| 209 |
+
let components = [];
|
| 210 |
+
let nextId = 1;
|
| 211 |
+
|
| 212 |
+
// Elementos DOM
|
| 213 |
+
const canvas = document.getElementById('canvas');
|
| 214 |
+
const dropZone = document.getElementById('dropZone');
|
| 215 |
+
const propertyPanel = document.getElementById('propertyPanel');
|
| 216 |
+
const componentsSidebar = document.getElementById('componentsSidebar');
|
| 217 |
+
const toggleSidebar = document.getElementById('toggleSidebar');
|
| 218 |
+
const exportBtn = document.getElementById('exportBtn');
|
| 219 |
+
const exportModal = document.getElementById('exportModal');
|
| 220 |
+
const closeExportModal = document.getElementById('closeExportModal');
|
| 221 |
+
const cancelExport = document.getElementById('cancelExport');
|
| 222 |
+
const confirmExport = document.getElementById('confirmExport');
|
| 223 |
+
|
| 224 |
+
// Event listeners para componentes arrastáveis
|
| 225 |
+
document.querySelectorAll('.draggable-component').forEach(component => {
|
| 226 |
+
component.addEventListener('dragstart', function(e) {
|
| 227 |
+
e.dataTransfer.setData('text/plain', this.dataset.type);
|
| 228 |
+
});
|
| 229 |
+
});
|
| 230 |
+
|
| 231 |
+
// Event listeners para a área de drop
|
| 232 |
+
canvas.addEventListener('dragover', function(e) {
|
| 233 |
+
e.preventDefault();
|
| 234 |
+
this.classList.add('bg-blue-50');
|
| 235 |
+
});
|
| 236 |
+
|
| 237 |
+
canvas.addEventListener('dragleave', function() {
|
| 238 |
+
this.classList.remove('bg-blue-50');
|
| 239 |
+
});
|
| 240 |
+
|
| 241 |
+
canvas.addEventListener('drop', function(e) {
|
| 242 |
+
e.preventDefault();
|
| 243 |
+
this.classList.remove('bg-blue-50');
|
| 244 |
+
|
| 245 |
+
const componentType = e.dataTransfer.getData('text/plain');
|
| 246 |
+
if (componentType) {
|
| 247 |
+
addComponent(componentType, e.clientX, e.clientY);
|
| 248 |
+
}
|
| 249 |
+
});
|
| 250 |
+
|
| 251 |
+
// Função para adicionar um novo componente
|
| 252 |
+
function addComponent(type, x, y) {
|
| 253 |
+
const id = 'component-' + nextId++;
|
| 254 |
+
let componentHtml = '';
|
| 255 |
+
let defaultProps = {};
|
| 256 |
+
|
| 257 |
+
// Criar HTML baseado no tipo de componente
|
| 258 |
+
switch(type) {
|
| 259 |
+
case 'header':
|
| 260 |
+
componentHtml = `
|
| 261 |
+
<h1 class="text-4xl font-bold mb-4" contenteditable="true">Título Principal</h1>
|
| 262 |
+
`;
|
| 263 |
+
defaultProps = {
|
| 264 |
+
text: 'Título Principal',
|
| 265 |
+
size: '4xl',
|
| 266 |
+
color: '#000000',
|
| 267 |
+
alignment: 'left'
|
| 268 |
+
};
|
| 269 |
+
break;
|
| 270 |
+
case 'paragraph':
|
| 271 |
+
componentHtml = `
|
| 272 |
+
<p class="text-gray-700 mb-4" contenteditable="true">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris.</p>
|
| 273 |
+
`;
|
| 274 |
+
defaultProps = {
|
| 275 |
+
text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam in dui mauris.',
|
| 276 |
+
color: '#374151',
|
| 277 |
+
alignment: 'left'
|
| 278 |
+
};
|
| 279 |
+
break;
|
| 280 |
+
case 'button':
|
| 281 |
+
componentHtml = `
|
| 282 |
+
<button class="bg-blue-600 text-white px-6 py-2 rounded-md hover:bg-blue-700 transition">Botão</button>
|
| 283 |
+
`;
|
| 284 |
+
defaultProps = {
|
| 285 |
+
text: 'Botão',
|
| 286 |
+
bgColor: '#2563eb',
|
| 287 |
+
textColor: '#ffffff',
|
| 288 |
+
size: 'medium',
|
| 289 |
+
rounded: 'md'
|
| 290 |
+
};
|
| 291 |
+
break;
|
| 292 |
+
case 'image':
|
| 293 |
+
componentHtml = `
|
| 294 |
+
<img src="https://via.placeholder.com/800x400" alt="Imagem de exemplo" class="w-full h-auto">
|
| 295 |
+
`;
|
| 296 |
+
defaultProps = {
|
| 297 |
+
src: 'https://via.placeholder.com/800x400',
|
| 298 |
+
alt: 'Imagem de exemplo',
|
| 299 |
+
width: '100%',
|
| 300 |
+
alignment: 'center'
|
| 301 |
+
};
|
| 302 |
+
break;
|
| 303 |
+
case 'section':
|
| 304 |
+
componentHtml = `
|
| 305 |
+
<div class="p-8 bg-gray-100 rounded-lg">
|
| 306 |
+
<div class="component-placeholder">Adicione componentes dentro desta seção</div>
|
| 307 |
+
</div>
|
| 308 |
+
`;
|
| 309 |
+
defaultProps = {
|
| 310 |
+
bgColor: '#f3f4f6',
|
| 311 |
+
padding: '8',
|
| 312 |
+
rounded: 'lg'
|
| 313 |
+
};
|
| 314 |
+
break;
|
| 315 |
+
default:
|
| 316 |
+
return;
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
// Criar elemento do componente
|
| 320 |
+
const componentElement = document.createElement('div');
|
| 321 |
+
componentElement.className = 'component mb-6 p-4 relative';
|
| 322 |
+
componentElement.id = id;
|
| 323 |
+
componentElement.innerHTML = componentHtml;
|
| 324 |
+
componentElement.dataset.type = type;
|
| 325 |
+
|
| 326 |
+
// Adicionar menu de contexto
|
| 327 |
+
const contextMenu = document.createElement('div');
|
| 328 |
+
contextMenu.className = 'absolute top-0 right-0 bg-white shadow-md rounded-md hidden';
|
| 329 |
+
contextMenu.innerHTML = `
|
| 330 |
+
<button class="component-delete px-3 py-1 text-red-500 hover:bg-red-50 w-full text-left">
|
| 331 |
+
<i class="fas fa-trash mr-2"></i>Excluir
|
| 332 |
+
</button>
|
| 333 |
+
<button class="component-duplicate px-3 py-1 text-blue-500 hover:bg-blue-50 w-full text-left">
|
| 334 |
+
<i class="fas fa-copy mr-2"></i>Duplicar
|
| 335 |
+
</button>
|
| 336 |
+
`;
|
| 337 |
+
componentElement.appendChild(contextMenu);
|
| 338 |
+
|
| 339 |
+
// Mostrar menu de contexto ao clicar com o botão direito
|
| 340 |
+
componentElement.addEventListener('contextmenu', function(e) {
|
| 341 |
+
e.preventDefault();
|
| 342 |
+
document.querySelectorAll('.component-context-menu').forEach(menu => {
|
| 343 |
+
menu.classList.add('hidden');
|
| 344 |
+
});
|
| 345 |
+
contextMenu.classList.remove('hidden');
|
| 346 |
+
|
| 347 |
+
// Posicionar o menu próximo ao cursor
|
| 348 |
+
const rect = this.getBoundingClientRect();
|
| 349 |
+
contextMenu.style.top = (e.clientY - rect.top) + 'px';
|
| 350 |
+
contextMenu.style.left = (e.clientX - rect.left) + 'px';
|
| 351 |
+
});
|
| 352 |
+
|
| 353 |
+
// Esconder menu quando clicar em outro lugar
|
| 354 |
+
document.addEventListener('click', function() {
|
| 355 |
+
contextMenu.classList.add('hidden');
|
| 356 |
+
});
|
| 357 |
+
|
| 358 |
+
// Event listeners para os botões do menu de contexto
|
| 359 |
+
contextMenu.querySelector('.component-delete').addEventListener('click', function() {
|
| 360 |
+
componentElement.remove();
|
| 361 |
+
components = components.filter(c => c.id !== id);
|
| 362 |
+
if (selectedComponent === id) {
|
| 363 |
+
selectedComponent = null;
|
| 364 |
+
updatePropertyPanel();
|
| 365 |
+
}
|
| 366 |
+
});
|
| 367 |
+
|
| 368 |
+
contextMenu.querySelector('.component-duplicate').addEventListener('click', function() {
|
| 369 |
+
addComponent(type, x, y);
|
| 370 |
+
});
|
| 371 |
+
|
| 372 |
+
// Selecionar componente ao clicar
|
| 373 |
+
componentElement.addEventListener('click', function(e) {
|
| 374 |
+
if (e.target.closest('.component-delete, .component-duplicate')) return;
|
| 375 |
+
|
| 376 |
+
// Desselecionar todos os componentes
|
| 377 |
+
document.querySelectorAll('.component').forEach(c => {
|
| 378 |
+
c.classList.remove('component-selected');
|
| 379 |
+
});
|
| 380 |
+
|
| 381 |
+
// Selecionar este componente
|
| 382 |
+
this.classList.add('component-selected');
|
| 383 |
+
selectedComponent = id;
|
| 384 |
+
updatePropertyPanel();
|
| 385 |
+
});
|
| 386 |
+
|
| 387 |
+
// Adicionar ao canvas (removendo o placeholder se for o primeiro componente)
|
| 388 |
+
if (dropZone && canvas.children.length === 1) {
|
| 389 |
+
canvas.removeChild(dropZone);
|
| 390 |
+
}
|
| 391 |
+
canvas.appendChild(componentElement);
|
| 392 |
+
|
| 393 |
+
// Adicionar aos componentes
|
| 394 |
+
components.push({
|
| 395 |
+
id: id,
|
| 396 |
+
type: type,
|
| 397 |
+
props: defaultProps,
|
| 398 |
+
html: componentElement.innerHTML
|
| 399 |
+
});
|
| 400 |
+
}
|
| 401 |
+
|
| 402 |
+
// Atualizar painel de propriedades
|
| 403 |
+
function updatePropertyPanel() {
|
| 404 |
+
if (!selectedComponent) {
|
| 405 |
+
propertyPanel.innerHTML = '<div class="text-gray-500 italic">Selecione um componente para editar suas propriedades</div>';
|
| 406 |
+
return;
|
| 407 |
+
}
|
| 408 |
+
|
| 409 |
+
const component = components.find(c => c.id === selectedComponent);
|
| 410 |
+
if (!component) return;
|
| 411 |
+
|
| 412 |
+
let propertiesHtml = '';
|
| 413 |
+
|
| 414 |
+
switch(component.type) {
|
| 415 |
+
case 'header':
|
| 416 |
+
propertiesHtml = `
|
| 417 |
+
<div class="mb-4">
|
| 418 |
+
<label class="block text-gray-700 mb-1">Texto</label>
|
| 419 |
+
<input type="text" class="w-full p-2 border rounded-md component-prop"
|
| 420 |
+
data-prop="text" value="${component.props.text}">
|
| 421 |
+
</div>
|
| 422 |
+
<div class="mb-4">
|
| 423 |
+
<label class="block text-gray-700 mb-1">Tamanho</label>
|
| 424 |
+
<select class="w-full p-2 border rounded-md component-prop" data-prop="size">
|
| 425 |
+
<option value="xs" ${component.props.size === 'xs' ? 'selected' : ''}>Pequeno</option>
|
| 426 |
+
<option value="sm" ${component.props.size === 'sm' ? 'selected' : ''}>Médio Pequeno</option>
|
| 427 |
+
<option value="base" ${component.props.size === 'base' ? 'selected' : ''}>Normal</option>
|
| 428 |
+
<option value="lg" ${component.props.size === 'lg' ? 'selected' : ''}>Médio Grande</option>
|
| 429 |
+
<option value="xl" ${component.props.size === 'xl' ? 'selected' : ''}>Grande</option>
|
| 430 |
+
<option value="2xl" ${component.props.size === '2xl' ? 'selected' : ''}>Extra Grande</option>
|
| 431 |
+
<option value="3xl" ${component.props.size === '3xl' ? 'selected' : ''}>3XL</option>
|
| 432 |
+
<option value="4xl" ${component.props.size === '4xl' ? 'selected' : ''}>4XL</option>
|
| 433 |
+
<option value="5xl" ${component.props.size === '5xl' ? 'selected' : ''}>5XL</option>
|
| 434 |
+
</select>
|
| 435 |
+
</div>
|
| 436 |
+
<div class="mb-4">
|
| 437 |
+
<label class="block text-gray-700 mb-1">Cor do Texto</label>
|
| 438 |
+
<input type="color" class="w-full p-1 border rounded-md component-prop"
|
| 439 |
+
data-prop="color" value="${component.props.color}">
|
| 440 |
+
</div>
|
| 441 |
+
<div class="mb-4">
|
| 442 |
+
<label class="block text-gray-700 mb-1">Alinhamento</label>
|
| 443 |
+
<div class="flex space-x-2">
|
| 444 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'left' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 445 |
+
data-prop="alignment" data-value="left">
|
| 446 |
+
<i class="fas fa-align-left"></i>
|
| 447 |
+
</button>
|
| 448 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'center' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 449 |
+
data-prop="alignment" data-value="center">
|
| 450 |
+
<i class="fas fa-align-center"></i>
|
| 451 |
+
</button>
|
| 452 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'right' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 453 |
+
data-prop="alignment" data-value="right">
|
| 454 |
+
<i class="fas fa-align-right"></i>
|
| 455 |
+
</button>
|
| 456 |
+
</div>
|
| 457 |
+
</div>
|
| 458 |
+
`;
|
| 459 |
+
break;
|
| 460 |
+
case 'button':
|
| 461 |
+
propertiesHtml = `
|
| 462 |
+
<div class="mb-4">
|
| 463 |
+
<label class="block text-gray-700 mb-1">Texto</label>
|
| 464 |
+
<input type="text" class="w-full p-2 border rounded-md component-prop"
|
| 465 |
+
data-prop="text" value="${component.props.text}">
|
| 466 |
+
</div>
|
| 467 |
+
<div class="mb-4">
|
| 468 |
+
<label class="block text-gray-700 mb-1">Cor de Fundo</label>
|
| 469 |
+
<input type="color" class="w-full p-1 border rounded-md component-prop"
|
| 470 |
+
data-prop="bgColor" value="${component.props.bgColor}">
|
| 471 |
+
</div>
|
| 472 |
+
<div class="mb-4">
|
| 473 |
+
<label class="block text-gray-700 mb-1">Cor do Texto</label>
|
| 474 |
+
<input type="color" class="w-full p-1 border rounded-md component-prop"
|
| 475 |
+
data-prop="textColor" value="${component.props.textColor}">
|
| 476 |
+
</div>
|
| 477 |
+
<div class="mb-4">
|
| 478 |
+
<label class="block text-gray-700 mb-1">Tamanho</label>
|
| 479 |
+
<select class="w-full p-2 border rounded-md component-prop" data-prop="size">
|
| 480 |
+
<option value="small" ${component.props.size === 'small' ? 'selected' : ''}>Pequeno</option>
|
| 481 |
+
<option value="medium" ${component.props.size === 'medium' ? 'selected' : ''}>Médio</option>
|
| 482 |
+
<option value="large" ${component.props.size === 'large' ? 'selected' : ''}>Grande</option>
|
| 483 |
+
</select>
|
| 484 |
+
</div>
|
| 485 |
+
<div class="mb-4">
|
| 486 |
+
<label class="block text-gray-700 mb-1">Borda Arredondada</label>
|
| 487 |
+
<select class="w-full p-2 border rounded-md component-prop" data-prop="rounded">
|
| 488 |
+
<option value="none" ${component.props.rounded === 'none' ? 'selected' : ''}>Nenhuma</option>
|
| 489 |
+
<option value="sm" ${component.props.rounded === 'sm' ? 'selected' : ''}>Pouco</option>
|
| 490 |
+
<option value="md" ${component.props.rounded === 'md' ? 'selected' : ''}>Médio</option>
|
| 491 |
+
<option value="lg" ${component.props.rounded === 'lg' ? 'selected' : ''}>Grande</option>
|
| 492 |
+
<option value="full" ${component.props.rounded === 'full' ? 'selected' : ''}>Completo</option>
|
| 493 |
+
</select>
|
| 494 |
+
</div>
|
| 495 |
+
`;
|
| 496 |
+
break;
|
| 497 |
+
case 'image':
|
| 498 |
+
propertiesHtml = `
|
| 499 |
+
<div class="mb-4">
|
| 500 |
+
<label class="block text-gray-700 mb-1">URL da Imagem</label>
|
| 501 |
+
<input type="text" class="w-full p-2 border rounded-md component-prop"
|
| 502 |
+
data-prop="src" value="${component.props.src}">
|
| 503 |
+
</div>
|
| 504 |
+
<div class="mb-4">
|
| 505 |
+
<label class="block text-gray-700 mb-1">Texto Alternativo</label>
|
| 506 |
+
<input type="text" class="w-full p-2 border rounded-md component-prop"
|
| 507 |
+
data-prop="alt" value="${component.props.alt}">
|
| 508 |
+
</div>
|
| 509 |
+
<div class="mb-4">
|
| 510 |
+
<label class="block text-gray-700 mb-1">Largura</label>
|
| 511 |
+
<select class="w-full p-2 border rounded-md component-prop" data-prop="width">
|
| 512 |
+
<option value="25%" ${component.props.width === '25%' ? 'selected' : ''}>25%</option>
|
| 513 |
+
<option value="50%" ${component.props.width === '50%' ? 'selected' : ''}>50%</option>
|
| 514 |
+
<option value="75%" ${component.props.width === '75%' ? 'selected' : ''}>75%</option>
|
| 515 |
+
<option value="100%" ${component.props.width === '100%' ? 'selected' : ''}>100%</option>
|
| 516 |
+
</select>
|
| 517 |
+
</div>
|
| 518 |
+
<div class="mb-4">
|
| 519 |
+
<label class="block text-gray-700 mb-1">Alinhamento</label>
|
| 520 |
+
<div class="flex space-x-2">
|
| 521 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'left' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 522 |
+
data-prop="alignment" data-value="left">
|
| 523 |
+
<i class="fas fa-align-left"></i>
|
| 524 |
+
</button>
|
| 525 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'center' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 526 |
+
data-prop="alignment" data-value="center">
|
| 527 |
+
<i class="fas fa-align-center"></i>
|
| 528 |
+
</button>
|
| 529 |
+
<button class="p-2 border rounded-md ${component.props.alignment === 'right' ? 'bg-blue-100 border-blue-300' : ''}"
|
| 530 |
+
data-prop="alignment" data-value="right">
|
| 531 |
+
<i class="fas fa-align-right"></i>
|
| 532 |
+
</button>
|
| 533 |
+
</div>
|
| 534 |
+
</div>
|
| 535 |
+
`;
|
| 536 |
+
break;
|
| 537 |
+
default:
|
| 538 |
+
propertiesHtml = `<div class="text-gray-500 italic">Nenhuma propriedade editável para este componente</div>`;
|
| 539 |
+
}
|
| 540 |
+
|
| 541 |
+
propertyPanel.innerHTML = `
|
| 542 |
+
<div class="mb-4 pb-2 border-b">
|
| 543 |
+
<h3 class="font-medium capitalize">${component.type}</h3>
|
| 544 |
+
</div>
|
| 545 |
+
${propertiesHtml}
|
| 546 |
+
`;
|
| 547 |
+
|
| 548 |
+
// Adicionar event listeners para as propriedades
|
| 549 |
+
propertyPanel.querySelectorAll('.component-prop').forEach(input => {
|
| 550 |
+
input.addEventListener('change', function() {
|
| 551 |
+
const prop = this.dataset.prop;
|
| 552 |
+
const value = this.type === 'checkbox' ? this.checked : this.value;
|
| 553 |
+
|
| 554 |
+
// Atualizar propriedade no objeto do componente
|
| 555 |
+
const component = components.find(c => c.id === selectedComponent);
|
| 556 |
+
if (component) {
|
| 557 |
+
component.props[prop] = value;
|
| 558 |
+
updateComponent(component);
|
| 559 |
+
}
|
| 560 |
+
});
|
| 561 |
+
});
|
| 562 |
+
|
| 563 |
+
// Event listeners para botões de alinhamento
|
| 564 |
+
propertyPanel.querySelectorAll('button[data-prop
|
| 565 |
+
</html>
|