Download index.html from Examups/Cards: direct link, hf CLI and curl.
- Browser
- Download file 125 kB
-
https://huggingface.co/spaces/Examups/Cards/resolve/main/index.html
- Command line
-
hf download hf://spaces/Examups/Cards/index.html
-
curl -L -o index.html https://huggingface.co/spaces/Examups/Cards/resolve/main/index.html
125 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Component Builder</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<style>
:root {
--primary-color: #3b82f6;
--primary-hover-color: #2563eb;
--secondary-color: #10b981;
--secondary-hover-color: #059669;
--text-color: #374151;
--heading-color: #111827;
--font-family: 'Inter', sans-serif;
}
body {
font-family: var(--font-family);
color: var(--text-color);
background-color: var(--background-color);
}
h1, h2, h3, h4, h5, h6 {
color: var(--heading-color);
}
/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
.preview-iframe {
width: 100%;
height: 100%;
border: 0;
transition: all 0.3s ease-in-out;
}
#preview-container.preview-desktop .preview-iframe { width: 100%; }
#preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; }
#preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; }
.toast {
visibility: hidden;
min-width: 250px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 8px;
padding: 16px;
position: fixed;
z-index: 100;
left: 50%;
bottom: 30px;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.3s, visibility 0.3s;
}
.toast.show {
visibility: visible;
opacity: 1;
}
#controls-layout { display: flex; height: 100%; }
#controls-nav { width: 180px; flex-shrink: 0; background-color: #f8fafc; border-right: 1px solid #e5e7eb; padding: 0.5rem; overflow-y: auto; }
.control-nav-button { display: flex; align-items: center; width: 100%; padding: 0.75rem; border-radius: 0.375rem; font-weight: 500; color: var(--text-color); transition: background-color 0.2s, color 0.2s; text-align: left; }
.control-nav-button:hover { background-color: #e5e7eb; }
.control-nav-button.active { background-color: var(--primary-color); color: white; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
.control-nav-button i { margin-right: 0.75rem; width: 20px; text-align: center; }
#controls-panels { flex-grow: 1; padding: 1.5rem; overflow-y: auto; }
.control-panel { display: none; }
.control-panel.active { display: block; }
.control-panel h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.75rem; }
.control-panel h4 { font-size: 0.875rem; font-weight: 600; color: #4b5563; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1.5rem; margin-bottom: 1rem; }
.layout-item, .carousel-card-item { cursor: move; }
.code-modal-pre { background-color: #2d3748; color: #e2e8f0; padding: 1rem; border-radius: 0.375rem; max-height: 200px; overflow-y: auto; position: relative; }
#controls-sidebar { flex-shrink: 0; }
#main-container.sidebar-collapsed #controls-sidebar { width: 0; padding: 0; overflow: hidden; }
#main-container.sidebar-collapsed #preview-main { width: 100%; }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.input-group input, .input-group select, .input-group textarea { width: 100%; padding: 0.5rem; border-radius: 0.375rem; border: 1px solid #d1d5db; }
.carousel-card-item { background-color: #f9fafb; border: 1px solid #e5e7eb; padding: 1rem; border-radius: 0.5rem; }
</style>
</head>
<body class="text-gray-800">
<div id="app" class="flex flex-col h-screen">
<header class="bg-white shadow-md p-4 flex justify-between items-center z-20">
<div class="flex items-center space-x-3">
<h1 class="text-xl font-bold text-gray-700">Component Builder</h1>
<button id="toggle-sidebar-btn" class="p-2 rounded-md hover:bg-gray-200 text-gray-600" title="Hide Controls">
<i class="fas fa-chevron-left"></i>
</button>
</div>
<div class="flex items-center space-x-4">
<button id="import-btn" class="flex items-center space-x-2 bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition"><span>Import</span></button>
<input type="file" id="import-file-input" class="hidden" accept=".html">
<div id="export-menu-container" class="relative">
<button id="export-menu-btn" class="flex items-center space-x-2 bg-green-600 text-white font-bold py-2 px-4 rounded-md hover:bg-green-700 transition"><span>Export Page</span></button>
<div id="export-dropdown" class="hidden absolute right-0 mt-2 w-64 rounded-md shadow-lg bg-white ring-1 ring-black ring-opacity-5 z-30">
<div class="py-1" role="menu">
<a href="#" id="copy-combined-code" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"><span>Copy Combined Code</span></a>
<a href="#" id="copy-html" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"><span>Copy Page HTML</span></a>
<a href="#" id="copy-css" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"><span>Copy Page CSS</span></a>
<a href="#" id="copy-js" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"><span>Copy Page JS</span></a>
<div class="border-t border-gray-100"></div>
<a href="#" id="download-zip-btn" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem"><span>Download Page .zip</span></a>
</div>
</div>
</div>
<div class="flex items-center space-x-2">
<span class="text-sm font-medium text-gray-500">Preview:</span>
<button id="desktop-btn" class="p-2 rounded-md bg-blue-500 text-white shadow" title="Desktop View"><i class="fas fa-desktop"></i></button>
<button id="tablet-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Tablet View"><i class="fas fa-tablet-alt"></i></button>
<button id="mobile-btn" class="p-2 rounded-md bg-gray-200 text-gray-700" title="Mobile View"><i class="fas fa-mobile-alt"></i></button>
</div>
</div>
</header>
<div class="flex flex-1 overflow-hidden" id="main-container">
<aside id="controls-sidebar" class="w-1/3 bg-white shadow-lg overflow-hidden transition-all duration-300 ease-in-out">
<div id="controls-layout">
<nav id="controls-nav" class="space-y-2">
<button class="control-nav-button" data-target="#panel-global-settings"><i class="fas fa-cog"></i>Global</button>
<button class="control-nav-button" data-target="#panel-layout"><i class="fas fa-layer-group"></i>Layout</button>
<button class="control-nav-button" data-target="#panel-featured-categories"><i class="fas fa-star"></i>Featured Cats</button>
<button class="control-nav-button" data-target="#panel-category-grid"><i class="fas fa-th-large"></i>Category Grid</button>
<button class="control-nav-button" data-target="#panel-feature-grid"><i class="fas fa-image"></i>Feature Grid</button>
<button class="control-nav-button" data-target="#panel-info-cards"><i class="fas fa-id-card-alt"></i>Info Cards</button>
<button class="control-nav-button" data-target="#panel-steps-display"><i class="fas fa-stream"></i>Steps Display</button>
<button class="control-nav-button" data-target="#panel-timeline-list"><i class="fas fa-bars"></i>Timeline List</button>
<button class="control-nav-button" data-target="#panel-project-cards"><i class="fas fa-tasks"></i>Project Cards</button>
<button class="control-nav-button" data-target="#panel-genres-carousel"><i class="fas fa-film"></i>Genres Carousel</button>
<button class="control-nav-button" data-target="#panel-custom-html"><i class="fas fa-code"></i>Custom HTML</button>
</nav>
<div id="controls-panels">
<div id="panel-global-settings" class="control-panel">
<h3>⚙️ Global Settings</h3>
<div class="space-y-4">
<div class="space-y-2">
<label class="font-medium text-sm">Color Palette</label>
<div class="grid grid-cols-2 gap-2 text-xs">
<div><label for="global-color-primary">Primary</label><input type="color" id="global-color-primary" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label for="global-color-secondary">Secondary</label><input type="color" id="global-color-secondary" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label for="global-color-text">Text</label><input type="color" id="global-color-text" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label for="global-color-heading">Heading</label><input type="color" id="global-color-heading" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
</div>
<div class="space-y-2"><label class="font-medium text-sm">Typography</label>
<div><label for="global-font-family" class="text-xs">Font Family</label>
<select id="global-font-family" class="w-full p-1 border rounded-md text-sm">
<option value="'Inter', sans-serif">Inter</option><option value="'Roboto', sans-serif">Roboto</option><option value="'Open Sans', sans-serif">Open Sans</option>
<option value="'Lato', sans-serif">Lato</option><option value="'Montserrat', sans-serif">Montserrat</option><option value="'Poppins', sans-serif">Poppins</option>
</select>
</div>
</div>
<button id="apply-global-settings" class="w-full bg-blue-600 text-white font-bold py-2 px-4 rounded-md hover:bg-blue-700 transition">Apply Global Styles</button>
</div>
</div>
<div id="panel-layout" class="control-panel">
<h3>↕️ Component Layout</h3>
<div id="layout-builder-container" class="space-y-2"></div>
</div>
<div id="panel-featured-categories" class="control-panel space-y-6">
<h3><i class="fas fa-star mr-2"></i>Featured Categories</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="featured-categories-toggle" class="h-4 w-4 rounded"><label for="featured-categories-toggle" class="font-medium">Enable Component</label></div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="featured-categories-desktop-cols">Desktop</label><input type="number" id="featured-categories-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="featured-categories-tablet-cols">Tablet</label><input type="number" id="featured-categories-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="featured-categories-mobile-cols">Mobile</label><input type="number" id="featured-categories-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="featured-categories-hscroll-toggle" class="h-4 w-4 rounded"><label for="featured-categories-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Category Cards</h4>
<div id="featured-categories-cards-builder" class="space-y-3"></div>
<button id="add-featured-category-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
</div>
<div id="panel-category-grid" class="control-panel space-y-6">
<h3><i class="fas fa-th-large mr-2"></i>Category Grid</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="category-grid-toggle" class="h-4 w-4 rounded"><label for="category-grid-toggle" class="font-medium">Enable Grid</label></div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="category-grid-desktop-cols">Desktop</label><input type="number" id="category-grid-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="category-grid-tablet-cols">Tablet</label><input type="number" id="category-grid-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="category-grid-mobile-cols">Mobile</label><input type="number" id="category-grid-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="category-grid-hscroll-toggle" class="h-4 w-4 rounded"><label for="category-grid-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Grid Cards</h4>
<div id="category-grid-cards-builder" class="space-y-3"></div>
<button id="add-category-card-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
<h4>"View All" Link</h4>
<div class="space-y-4">
<div class="flex items-center space-x-2"><input type="checkbox" id="category-grid-viewall-toggle"><label for="category-grid-viewall-toggle">Show "View All" Link</label></div>
<div id="category-grid-viewall-controls" class="space-y-4">
<div class="input-group"><label for="category-grid-viewall-text">Link Text</label><input type="text" id="category-grid-viewall-text"></div>
<div class="input-group"><label for="category-grid-viewall-url">Link URL</label><input type="text" id="category-grid-viewall-url"></div>
</div>
</div>
</div>
<div id="panel-feature-grid" class="control-panel space-y-6">
<h3><i class="fas fa-image mr-2"></i>Feature Grid</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="feature-grid-toggle" class="h-4 w-4 rounded"><label for="feature-grid-toggle" class="font-medium">Enable Component</label></div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="feature-grid-desktop-cols">Desktop</label><input type="number" id="feature-grid-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="feature-grid-tablet-cols">Tablet</label><input type="number" id="feature-grid-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="feature-grid-mobile-cols">Mobile</label><input type="number" id="feature-grid-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="feature-grid-hscroll-toggle" class="h-4 w-4 rounded"><label for="feature-grid-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Feature Cards</h4>
<div id="feature-grid-cards-builder" class="space-y-3"></div>
<button id="add-feature-card-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
</div>
<div id="panel-info-cards" class="control-panel space-y-6">
<h3><i class="fas fa-id-card-alt mr-2"></i>Info Cards</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="info-cards-toggle" class="h-4 w-4 rounded"><label for="info-cards-toggle" class="font-medium">Enable Component</label></div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="info-cards-desktop-cols">Desktop</label><input type="number" id="info-cards-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="info-cards-tablet-cols">Tablet</label><input type="number" id="info-cards-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="info-cards-mobile-cols">Mobile</label><input type="number" id="info-cards-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="info-cards-hscroll-toggle" class="h-4 w-4 rounded"><label for="info-cards-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Info Cards</h4>
<div id="info-cards-builder" class="space-y-3"></div>
<button id="add-info-card-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
</div>
<div id="panel-steps-display" class="control-panel space-y-6">
<h3><i class="fas fa-stream mr-2"></i>Steps Display</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="steps-display-toggle" class="h-4 w-4 rounded"><label for="steps-display-toggle" class="font-medium">Enable Component</label></div>
<div class="input-group">
<label for="steps-display-style">Card Style</label>
<select id="steps-display-style">
<option value="ribbon">Ribbon Base</option>
<option value="banner">Text in Banner</option>
<option value="circle">Icon in Circle</option>
</select>
</div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="steps-display-desktop-cols">Desktop</label><input type="number" id="steps-display-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="steps-display-tablet-cols">Tablet</label><input type="number" id="steps-display-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="steps-display-mobile-cols">Mobile</label><input type="number" id="steps-display-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="steps-display-hscroll-toggle" class="h-4 w-4 rounded"><label for="steps-display-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Steps</h4>
<div id="steps-display-builder" class="space-y-3"></div>
<button id="add-step-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Step</button>
</div>
<div id="panel-timeline-list" class="control-panel space-y-6">
<h3><i class="fas fa-bars mr-2"></i>Timeline List</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="timeline-list-toggle" class="h-4 w-4 rounded"><label for="timeline-list-toggle" class="font-medium">Enable Component</label></div>
<div class="input-group">
<label for="timeline-list-style">Item Style</label>
<select id="timeline-list-style">
<option value="arrow">Arrow Pointer</option>
<option value="rounded">Rounded Tab</option>
</select>
</div>
<div class="input-group">
<label for="timeline-list-gap">Vertical Gap (px)</label>
<input type="number" id="timeline-list-gap" min="0" max="100" step="1">
</div>
<div id="timeline-rounded-options" class="space-y-2">
<h4>Style Options (Rounded Tab Only)</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="timeline-glossy-toggle" class="h-4 w-4 rounded"><label for="timeline-glossy-toggle">Enable Glossy Effect</label></div>
<div class="flex items-center space-x-2"><input type="checkbox" id="timeline-hover-toggle" class="h-4 w-4 rounded"><label for="timeline-hover-toggle">Enable Hover Effect</label></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="timeline-list-hscroll-toggle" class="h-4 w-4 rounded"><label for="timeline-list-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>List Items</h4>
<div id="timeline-list-builder" class="space-y-3"></div>
<button id="add-timeline-item-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Item</button>
</div>
<div id="panel-project-cards" class="control-panel space-y-6">
<h3><i class="fas fa-tasks mr-2"></i>Project Cards</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="project-cards-toggle" class="h-4 w-4 rounded"><label for="project-cards-toggle" class="font-medium">Enable Component</label></div>
<h4>Grid Layout</h4>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="project-cards-desktop-cols">Desktop</label><input type="number" id="project-cards-desktop-cols" min="1" max="12" step="1"></div>
<div><label for="project-cards-tablet-cols">Tablet</label><input type="number" id="project-cards-tablet-cols" min="1" max="8" step="1"></div>
<div><label for="project-cards-mobile-cols">Mobile</label><input type="number" id="project-cards-mobile-cols" min="1" max="4" step="1"></div>
</div>
<h4>Mobile Behavior</h4>
<div class="flex items-center space-x-2"><input type="checkbox" id="project-cards-hscroll-toggle" class="h-4 w-4 rounded"><label for="project-cards-hscroll-toggle" class="font-medium">Enable Horizontal Scrolling</label></div>
<h4>Project Cards</h4>
<div id="project-cards-builder" class="space-y-3"></div>
<button id="add-project-card-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
</div>
<div id="panel-genres-carousel" class="control-panel space-y-6">
<h3>🎬 Genres and Collections</h3>
<div class="flex items-center space-x-2"><input type="checkbox" id="genres-carousel-toggle" class="h-4 w-4 rounded"><label for="genres-carousel-toggle" class="font-medium">Enable Carousel</label></div>
<h4>Header</h4>
<div class="space-y-4">
<div class="input-group"><label for="genres-carousel-title">Title</label><input type="text" id="genres-carousel-title"></div>
<div class="flex items-center space-x-2"><input type="checkbox" id="genres-carousel-seemore-toggle"><label for="genres-carousel-seemore-toggle">Show "See More" Link</label></div>
<div id="genres-carousel-seemore-controls" class="space-y-4">
<div class="input-group"><label for="genres-carousel-seemore-text">Link Text</label><input type="text" id="genres-carousel-seemore-text"></div>
<div class="input-group"><label for="genres-carousel-seemore-url">Link URL</label><input type="text" id="genres-carousel-seemore-url"></div>
</div>
</div>
<h4>Carousel Cards</h4>
<div id="genres-carousel-cards-builder" class="space-y-3"></div>
<button id="add-genre-card-btn" class="w-full text-sm bg-gray-200 hover:bg-gray-300 py-2 rounded-md"><i class="fas fa-plus mr-2"></i>Add Card</button>
<h4>Behavior</h4>
<div class="space-y-4">
<div class="flex items-center space-x-2"><input type="checkbox" id="genres-carousel-arrows-toggle"><label for="genres-carousel-arrows-toggle">Show Navigation Arrows</label></div>
<div class="grid grid-cols-3 gap-2 input-group">
<div><label for="genres-carousel-desktop-items">Desktop</label><input type="number" id="genres-carousel-desktop-items" min="1" max="10" step="1"></div>
<div><label for="genres-carousel-tablet-items">Tablet</label><input type="number" id="genres-carousel-tablet-items" min="1" max="8" step="1"></div>
<div><label for="genres-carousel-mobile-items">Mobile</label><input type="number" id="genres-carousel-mobile-items" min="1" max="5" step="1"></div>
</div>
</div>
</div>
<div id="panel-custom-html" class="control-panel">
<h3 class="border-b-0"> </> Custom HTML</h3>
<div class="space-y-4">
<div class="flex items-center space-x-2"><input type="checkbox" id="custom-html-toggle" class="h-4 w-4 rounded"><label for="custom-html-toggle">Enable Custom HTML</label></div>
<div id="custom-html-builder">
<textarea id="custom-html-content" rows="10" class="w-full p-2 border rounded-md font-mono text-sm"></textarea>
</div>
</div>
</div>
</div>
</div>
</aside>
<main id="preview-main" class="w-2/3 bg-gray-200 p-4 flex flex-col items-center justify-center overflow-hidden transition-all duration-300 ease-in-out">
<div id="preview-container" class="bg-white shadow-lg rounded-lg w-full h-full overflow-hidden">
<iframe id="preview-iframe" class="preview-iframe"></iframe>
</div>
</main>
</div>
</div>
<div id="toast-notification" class="toast"></div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// --- STATE & CONFIGURATION ---
const config = {
globalSettings: {
colors: { primary: '#3b82f6', secondary: '#10b981', text: '#374151', heading: '#111827' },
typography: { fontFamily: "'Inter', sans-serif" }
},
componentOrder: ['featuredCategories', 'categoryGrid', 'featureGrid', 'infoCards', 'stepsDisplay', 'timelineList', 'projectCards', 'genresCarousel', 'customHtml'],
featuredCategories: {
enabled: true,
layout: { desktop: 6, tablet: 3, mobile: 2 },
horizontalScrollMobile: false,
cards: [
{ id: Date.now() + 20, text: 'Card', url: '#', color: '#6d28d9', iconClass: 'fas fa-clone' },
{ id: Date.now() + 21, text: 'Action', url: '#', color: '#f59e0b', iconClass: 'fas fa-trophy' },
{ id: Date.now() + 22, text: 'Arcade', url: '#', color: '#ec4899', iconClass: 'fas fa-gamepad' },
{ id: Date.now() + 23, text: 'Sports', url: '#', color: '#0ea5e9', iconClass: 'fas fa-futbol' },
{ id: Date.now() + 24, text: 'Simulation', url: '#', color: '#f59e0b', iconClass: 'fas fa-car-alt' },
{ id: Date.now() + 25, text: 'Adventure', url: '#', color: '#22c55e', iconClass: 'fas fa-shield-alt' }
]
},
categoryGrid: {
enabled: true,
viewAllLink: { enabled: true, text: 'View All 100+ Categories →', url: '#' },
layout: { desktop: 4, tablet: 2, mobile: 1 },
horizontalScrollMobile: true,
cards: [
{ id: Date.now() + 10, icon: 'fas fa-swatchbook', title: 'Fiction', description: 'Novels, stories & literature', url: '#', iconColor: '#2dd4bf' },
{ id: Date.now() + 11, icon: 'fas fa-book-open', title: 'Non-Fiction', description: 'Learn something new', url: '#', iconColor: '#a78bfa' },
{ id: Date.now() + 12, icon: 'fas fa-briefcase', title: 'Business', description: 'Grow your career', url: '#', iconColor: '#a3a3a3' },
{ id: Date.now() + 13, icon: 'fas fa-heart', title: 'Romance', description: 'Love stories & passion', url: '#', iconColor: '#f472b6' },
]
},
featureGrid: {
enabled: true,
layout: { desktop: 2, tablet: 2, mobile: 1 },
horizontalScrollMobile: false,
cards: [
{ id: Date.now() + 50, title: 'Gamification', subtitle: 'Marketing', linkText: 'LEARN MORE', linkUrl: '#', imageUrl: 'https://i.ibb.co/tBSm9Vj/bowling.png', bgColor: '#F87171' },
{ id: Date.now() + 51, title: 'Graphic', subtitle: 'Design', linkText: 'LEARN MORE', linkUrl: '#', imageUrl: 'https://i.ibb.co/MfZg4v5/paint.png', bgColor: '#FFFFFF' },
{ id: Date.now() + 52, title: 'Analytics and', subtitle: 'Tracking', linkText: 'LEARN MORE', linkUrl: '#', imageUrl: 'https://i.ibb.co/gZ7pCDP/megaphone.png', bgColor: '#FFFFFF' },
{ id: Date.now() + 53, title: 'Content', subtitle: 'Creation', linkText: 'LEARN MORE', linkUrl: '#', imageUrl: 'https://i.ibb.co/hK7dYgC/notebook.png', bgColor: '#60A5FA' }
]
},
infoCards: {
enabled: true,
layout: { desktop: 4, tablet: 2, mobile: 1 },
horizontalScrollMobile: false,
cards: [
{ id: Date.now() + 60, title: 'Shopping', subtitle: 'Trendy', linkUrl: '#', imageUrl: 'https://i.ibb.co/THYvLg4/shopping-bag.png', bgColor: '#a78bfa' },
{ id: Date.now() + 61, title: 'Cloud', subtitle: 'Sunny', linkUrl: '#', imageUrl: 'https://i.ibb.co/pwnxLzW/cloud-weather.png', bgColor: '#93c5fd' },
{ id: Date.now() + 62, title: 'Notes', subtitle: 'Regular', linkUrl: '#', imageUrl: 'https://i.ibb.co/3W6qWqX/calendar-task.png', bgColor: '#f87171' },
{ id: Date.now() + 63, title: 'Premium', subtitle: '$2/Month', linkUrl: '#', imageUrl: 'https://i.ibb.co/B2z921q/crown.png', bgColor: '#4ade80' }
]
},
stepsDisplay: {
enabled: true,
style: 'ribbon', // 'ribbon', 'banner', 'circle'
layout: { desktop: 3, tablet: 2, mobile: 1 },
horizontalScrollMobile: false,
steps: [
{ id: Date.now() + 70, title: 'STEP 01', description: 'Lorem ipsum dolor sitam et con sectetuer adip isci ng utiaoreet di lore mag.', iconClass: 'fas fa-user', color: '#f59e0b' },
{ id: Date.now() + 71, title: 'STEP 02', description: 'Lorem ipsum dolor sitam et con sectetuer adip isci ng utiaoreet di lore mag.', iconClass: 'fas fa-comments', color: '#10b981' },
{ id: Date.now() + 72, title: 'STEP 03', description: 'Lorem ipsum dolor sitam et con sectetuer adip isci ng utiaoreet di lore mag.', iconClass: 'fas fa-bullhorn', color: '#785549' }
]
},
timelineList: {
enabled: true,
style: 'rounded', // 'arrow', 'rounded'
gap: 16,
enableGlossyEffect: true,
enableHoverEffect: true,
horizontalScrollMobile: false,
items: [
{ id: Date.now() + 80, leftTitle: 'STEP 01', leftSubtitle: 'DATA', mainTitle: 'Infographics Headline', description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.', iconClass: 'fas fa-comments', tabColor: '#f59e0b', titleBarColor: '#f59e0b', iconColor: '#f59e0b' },
{ id: Date.now() + 81, leftTitle: 'STEP 02', leftSubtitle: 'DATA', mainTitle: 'Infographics Headline', description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.', iconClass: 'fas fa-laptop-code', tabColor: '#ef4444', titleBarColor: '#ef4444', iconColor: '#ef4444' },
{ id: Date.now() + 82, leftTitle: 'STEP 03', leftSubtitle: 'DATA', mainTitle: 'Infographics Headline', description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod.', iconClass: 'fas fa-chart-line', tabColor: '#ec4899', titleBarColor: '#ec4899', iconColor: '#ec4899' }
]
},
projectCards: {
enabled: true,
layout: { desktop: 3, tablet: 2, mobile: 1 },
horizontalScrollMobile: false,
cards: [
{ id: Date.now() + 30, title: 'Financial App', date: '25 Apr 2030', bgColor: '#FEEBCF', avatars: 'https://randomuser.me/api/portraits/men/32.jpg', moreCount: '3+' },
{ id: Date.now() + 31, title: 'Graphic Design', date: '18 May 2030', bgColor: '#D9F9E6', avatars: 'https://randomuser.me/api/portraits/women/44.jpg', moreCount: '2+' },
{ id: Date.now() + 32, title: 'Artifact Model', date: '17 Nov 2030', bgColor: '#F4DFF6', avatars: 'https://randomuser.me/api/portraits/men/33.jpg', moreCount: '3+' },
{ id: Date.now() + 33, title: 'Operating System', date: '20 Apr 2030', bgColor: '#E9D8FD', avatars: 'https://randomuser.me/api/portraits/women/45.jpg', moreCount: '2+' },
{ id: Date.now() + 34, title: 'Business card', date: '15 Oct 2030', bgColor: '#D1ECF9', avatars: 'https://randomuser.me/api/portraits/men/34.jpg', moreCount: '3+' },
{ id: Date.now() + 35, title: 'Centered Design', date: '20 Apr 2030', bgColor: '#FBD2D3', avatars: 'https://randomuser.me/api/portraits/women/46.jpg', moreCount: '2+' }
]
},
genresCarousel: {
enabled: true,
title: 'Genres and Collections',
seeMore: { enabled: true, text: 'See More', url: '#' },
behavior: { showArrows: true, desktop: 4, tablet: 3, mobile: 2 },
cards: [
{ id: Date.now() + 1, text: 'Romance', url: '#', color1: '#3b82f6', color2: '#1d4ed8' },
{ id: Date.now() + 2, text: 'Mystery', url: '#', color1: '#8b5cf6', color2: '#6d28d9' },
{ id: Date.now() + 3, text: 'Fantasy', url: '#', color1: '#10b981', color2: '#047857' },
{ id: Date.now() + 4, text: 'Thriller', url: '#', color1: '#ef4444', color2: '#b91c1c' },
]
},
customHtml: { enabled: false, content: '' }
};
const componentNames = {
featuredCategories: 'Featured Categories',
categoryGrid: 'Category Grid',
featureGrid: 'Feature Grid',
infoCards: 'Info Cards',
stepsDisplay: 'Steps Display',
timelineList: 'Timeline List',
projectCards: 'Project Cards',
genresCarousel: 'Genres & Collections',
customHtml: 'Custom HTML'
};
const ui = {
previewIframe: document.getElementById('preview-iframe'),
mainContainer: document.getElementById('main-container'),
toggleSidebarBtn: document.getElementById('toggle-sidebar-btn'),
controls: { nav: document.getElementById('controls-nav'), panels: document.getElementById('controls-panels') },
globalSettings: {
primaryColor: document.getElementById('global-color-primary'),
secondaryColor: document.getElementById('global-color-secondary'),
textColor: document.getElementById('global-color-text'),
headingColor: document.getElementById('global-color-heading'),
fontFamily: document.getElementById('global-font-family'),
applyBtn: document.getElementById('apply-global-settings'),
},
layout: { container: document.getElementById('layout-builder-container') },
featuredCategories: {
toggle: document.getElementById('featured-categories-toggle'),
desktopCols: document.getElementById('featured-categories-desktop-cols'),
tabletCols: document.getElementById('featured-categories-tablet-cols'),
mobileCols: document.getElementById('featured-categories-mobile-cols'),
hScrollToggle: document.getElementById('featured-categories-hscroll-toggle'),
cardsBuilder: document.getElementById('featured-categories-cards-builder'),
addCardBtn: document.getElementById('add-featured-category-btn'),
},
categoryGrid: {
toggle: document.getElementById('category-grid-toggle'),
desktopCols: document.getElementById('category-grid-desktop-cols'),
tabletCols: document.getElementById('category-grid-tablet-cols'),
mobileCols: document.getElementById('category-grid-mobile-cols'),
hScrollToggle: document.getElementById('category-grid-hscroll-toggle'),
cardsBuilder: document.getElementById('category-grid-cards-builder'),
addCardBtn: document.getElementById('add-category-card-btn'),
viewAllToggle: document.getElementById('category-grid-viewall-toggle'),
viewAllControls: document.getElementById('category-grid-viewall-controls'),
viewAllText: document.getElementById('category-grid-viewall-text'),
viewAllUrl: document.getElementById('category-grid-viewall-url'),
},
featureGrid: {
toggle: document.getElementById('feature-grid-toggle'),
desktopCols: document.getElementById('feature-grid-desktop-cols'),
tabletCols: document.getElementById('feature-grid-tablet-cols'),
mobileCols: document.getElementById('feature-grid-mobile-cols'),
hScrollToggle: document.getElementById('feature-grid-hscroll-toggle'),
cardsBuilder: document.getElementById('feature-grid-cards-builder'),
addCardBtn: document.getElementById('add-feature-card-btn'),
},
infoCards: {
toggle: document.getElementById('info-cards-toggle'),
desktopCols: document.getElementById('info-cards-desktop-cols'),
tabletCols: document.getElementById('info-cards-tablet-cols'),
mobileCols: document.getElementById('info-cards-mobile-cols'),
hScrollToggle: document.getElementById('info-cards-hscroll-toggle'),
cardsBuilder: document.getElementById('info-cards-builder'),
addCardBtn: document.getElementById('add-info-card-btn'),
},
stepsDisplay: {
toggle: document.getElementById('steps-display-toggle'),
style: document.getElementById('steps-display-style'),
desktopCols: document.getElementById('steps-display-desktop-cols'),
tabletCols: document.getElementById('steps-display-tablet-cols'),
mobileCols: document.getElementById('steps-display-mobile-cols'),
hScrollToggle: document.getElementById('steps-display-hscroll-toggle'),
builder: document.getElementById('steps-display-builder'),
addBtn: document.getElementById('add-step-btn'),
},
timelineList: {
toggle: document.getElementById('timeline-list-toggle'),
style: document.getElementById('timeline-list-style'),
gap: document.getElementById('timeline-list-gap'),
roundedOptions: document.getElementById('timeline-rounded-options'),
glossyToggle: document.getElementById('timeline-glossy-toggle'),
hoverToggle: document.getElementById('timeline-hover-toggle'),
hScrollToggle: document.getElementById('timeline-list-hscroll-toggle'),
builder: document.getElementById('timeline-list-builder'),
addBtn: document.getElementById('add-timeline-item-btn'),
},
projectCards: {
toggle: document.getElementById('project-cards-toggle'),
desktopCols: document.getElementById('project-cards-desktop-cols'),
tabletCols: document.getElementById('project-cards-tablet-cols'),
mobileCols: document.getElementById('project-cards-mobile-cols'),
hScrollToggle: document.getElementById('project-cards-hscroll-toggle'),
cardsBuilder: document.getElementById('project-cards-builder'),
addCardBtn: document.getElementById('add-project-card-btn'),
},
genresCarousel: {
toggle: document.getElementById('genres-carousel-toggle'),
title: document.getElementById('genres-carousel-title'),
seeMoreToggle: document.getElementById('genres-carousel-seemore-toggle'),
seeMoreControls: document.getElementById('genres-carousel-seemore-controls'),
seeMoreText: document.getElementById('genres-carousel-seemore-text'),
seeMoreUrl: document.getElementById('genres-carousel-seemore-url'),
cardsBuilder: document.getElementById('genres-carousel-cards-builder'),
addCardBtn: document.getElementById('add-genre-card-btn'),
arrowsToggle: document.getElementById('genres-carousel-arrows-toggle'),
desktopItems: document.getElementById('genres-carousel-desktop-items'),
tabletItems: document.getElementById('genres-carousel-tablet-items'),
mobileItems: document.getElementById('genres-carousel-mobile-items'),
},
customHtml: { toggle: document.getElementById('custom-html-toggle'), content: document.getElementById('custom-html-content') },
buttons: { desktop: document.getElementById('desktop-btn'), tablet: document.getElementById('tablet-btn'), mobile: document.getElementById('mobile-btn') },
};
// --- EVENT LISTENERS ---
function setupEventListeners() {
// Main Navigation
ui.controls.nav.addEventListener('click', (e) => {
const button = e.target.closest('.control-nav-button');
if (!button) return;
ui.controls.nav.querySelectorAll('.control-nav-button').forEach(btn => btn.classList.remove('active'));
button.classList.add('active');
ui.controls.panels.querySelectorAll('.control-panel').forEach(panel => panel.classList.toggle('active', `#${panel.id}` === button.dataset.target));
});
// Global Settings
ui.globalSettings.applyBtn.addEventListener('click', () => {
config.globalSettings.colors.primary = ui.globalSettings.primaryColor.value;
config.globalSettings.colors.secondary = ui.globalSettings.secondaryColor.value;
config.globalSettings.colors.text = ui.globalSettings.textColor.value;
config.globalSettings.colors.heading = ui.globalSettings.headingColor.value;
config.globalSettings.typography.fontFamily = ui.globalSettings.fontFamily.value;
renderAll();
showToast('Global styles applied!');
});
// Featured Categories Listeners
const fc = ui.featuredCategories;
fc.toggle.addEventListener('change', e => { config.featuredCategories.enabled = e.target.checked; renderAll(); });
fc.desktopCols.addEventListener('input', e => { config.featuredCategories.layout.desktop = parseInt(e.target.value, 10) || 6; renderAll(); });
fc.tabletCols.addEventListener('input', e => { config.featuredCategories.layout.tablet = parseInt(e.target.value, 10) || 3; renderAll(); });
fc.mobileCols.addEventListener('input', e => { config.featuredCategories.layout.mobile = parseInt(e.target.value, 10) || 2; renderAll(); });
fc.hScrollToggle.addEventListener('change', e => { config.featuredCategories.horizontalScrollMobile = e.target.checked; renderAll(); });
fc.addCardBtn.addEventListener('click', () => {
config.featuredCategories.cards.push({ id: Date.now(), text: 'New', url: '#', color: '#6b7280', iconClass: 'fas fa-plus' });
renderFeaturedCategoriesCardControls();
renderAll();
});
fc.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.featuredCategories.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
fc.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.featuredCategories.cards = config.featuredCategories.cards.filter(c => c.id !== cardId);
renderFeaturedCategoriesCardControls();
renderAll();
}
});
// Category Grid Panel Listeners
const cg = ui.categoryGrid;
cg.toggle.addEventListener('change', e => { config.categoryGrid.enabled = e.target.checked; renderAll(); });
cg.desktopCols.addEventListener('input', e => { config.categoryGrid.layout.desktop = parseInt(e.target.value, 10) || 4; renderAll(); });
cg.tabletCols.addEventListener('input', e => { config.categoryGrid.layout.tablet = parseInt(e.target.value, 10) || 2; renderAll(); });
cg.mobileCols.addEventListener('input', e => { config.categoryGrid.layout.mobile = parseInt(e.target.value, 10) || 1; renderAll(); });
cg.hScrollToggle.addEventListener('change', e => { config.categoryGrid.horizontalScrollMobile = e.target.checked; renderAll(); });
cg.viewAllToggle.addEventListener('change', e => {
config.categoryGrid.viewAllLink.enabled = e.target.checked;
cg.viewAllControls.style.display = e.target.checked ? 'block' : 'none';
renderAll();
});
cg.viewAllText.addEventListener('input', e => { config.categoryGrid.viewAllLink.text = e.target.value; renderAll(); });
cg.viewAllUrl.addEventListener('input', e => { config.categoryGrid.viewAllLink.url = e.target.value; renderAll(); });
cg.addCardBtn.addEventListener('click', () => {
config.categoryGrid.cards.push({ id: Date.now(), icon: 'fas fa-plus-circle', title: 'New Category', description: 'Description', url: '#', iconColor: '#808080' });
renderCategoryGridCardControls();
renderAll();
});
cg.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.categoryGrid.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
cg.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.categoryGrid.cards = config.categoryGrid.cards.filter(c => c.id !== cardId);
renderCategoryGridCardControls();
renderAll();
}
});
// Feature Grid Panel Listeners
const fg = ui.featureGrid;
fg.toggle.addEventListener('change', e => { config.featureGrid.enabled = e.target.checked; renderAll(); });
fg.desktopCols.addEventListener('input', e => { config.featureGrid.layout.desktop = parseInt(e.target.value, 10) || 2; renderAll(); });
fg.tabletCols.addEventListener('input', e => { config.featureGrid.layout.tablet = parseInt(e.target.value, 10) || 2; renderAll(); });
fg.mobileCols.addEventListener('input', e => { config.featureGrid.layout.mobile = parseInt(e.target.value, 10) || 1; renderAll(); });
fg.hScrollToggle.addEventListener('change', e => { config.featureGrid.horizontalScrollMobile = e.target.checked; renderAll(); });
fg.addCardBtn.addEventListener('click', () => {
config.featureGrid.cards.push({ id: Date.now(), title: 'New Feature', subtitle: 'Subtitle', linkText: 'LEARN MORE', linkUrl: '#', imageUrl: '', bgColor: '#E5E7EB' });
renderFeatureGridCardControls();
renderAll();
});
fg.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.featureGrid.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
fg.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.featureGrid.cards = config.featureGrid.cards.filter(c => c.id !== cardId);
renderFeatureGridCardControls();
renderAll();
}
});
// Info Cards Panel Listeners
const ic = ui.infoCards;
ic.toggle.addEventListener('change', e => { config.infoCards.enabled = e.target.checked; renderAll(); });
ic.desktopCols.addEventListener('input', e => { config.infoCards.layout.desktop = parseInt(e.target.value, 10) || 4; renderAll(); });
ic.tabletCols.addEventListener('input', e => { config.infoCards.layout.tablet = parseInt(e.target.value, 10) || 2; renderAll(); });
ic.mobileCols.addEventListener('input', e => { config.infoCards.layout.mobile = parseInt(e.target.value, 10) || 1; renderAll(); });
ic.hScrollToggle.addEventListener('change', e => { config.infoCards.horizontalScrollMobile = e.target.checked; renderAll(); });
ic.addCardBtn.addEventListener('click', () => {
config.infoCards.cards.push({ id: Date.now(), title: 'New Card', subtitle: 'Subtitle', linkUrl: '#', imageUrl: '', bgColor: '#BDBDBD' });
renderInfoCardsControls();
renderAll();
});
ic.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.infoCards.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
ic.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.infoCards.cards = config.infoCards.cards.filter(c => c.id !== cardId);
renderInfoCardsControls();
renderAll();
}
});
// Steps Display Panel Listeners
const sd = ui.stepsDisplay;
sd.toggle.addEventListener('change', e => { config.stepsDisplay.enabled = e.target.checked; renderAll(); });
sd.style.addEventListener('change', e => { config.stepsDisplay.style = e.target.value; renderAll(); });
sd.desktopCols.addEventListener('input', e => { config.stepsDisplay.layout.desktop = parseInt(e.target.value, 10) || 3; renderAll(); });
sd.tabletCols.addEventListener('input', e => { config.stepsDisplay.layout.tablet = parseInt(e.target.value, 10) || 2; renderAll(); });
sd.mobileCols.addEventListener('input', e => { config.stepsDisplay.layout.mobile = parseInt(e.target.value, 10) || 1; renderAll(); });
sd.hScrollToggle.addEventListener('change', e => { config.stepsDisplay.horizontalScrollMobile = e.target.checked; renderAll(); });
sd.addBtn.addEventListener('click', () => {
config.stepsDisplay.steps.push({ id: Date.now(), title: 'NEW STEP', description: 'New step description.', iconClass: 'fas fa-plus', color: '#9E9E9E' });
renderStepsDisplayControls();
renderAll();
});
sd.builder.addEventListener('input', e => {
const target = e.target;
const stepItem = target.closest('.carousel-card-item');
if (!stepItem) return;
const stepId = parseInt(stepItem.dataset.id, 10);
const step = config.stepsDisplay.steps.find(s => s.id === stepId);
if (!step) return;
const property = target.dataset.property;
step[property] = target.value;
renderAll();
});
sd.builder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const stepItem = e.target.closest('.carousel-card-item');
const stepId = parseInt(stepItem.dataset.id, 10);
config.stepsDisplay.steps = config.stepsDisplay.steps.filter(s => s.id !== stepId);
renderStepsDisplayControls();
renderAll();
}
});
// Timeline List Panel Listeners
const tl = ui.timelineList;
tl.toggle.addEventListener('change', e => { config.timelineList.enabled = e.target.checked; renderAll(); });
tl.style.addEventListener('change', e => {
config.timelineList.style = e.target.value;
tl.roundedOptions.style.display = e.target.value === 'rounded' ? 'block' : 'none';
renderAll();
});
tl.gap.addEventListener('input', e => { config.timelineList.gap = parseInt(e.target.value, 10) || 16; renderAll(); });
tl.glossyToggle.addEventListener('change', e => { config.timelineList.enableGlossyEffect = e.target.checked; renderAll(); });
tl.hoverToggle.addEventListener('change', e => { config.timelineList.enableHoverEffect = e.target.checked; renderAll(); });
tl.hScrollToggle.addEventListener('change', e => { config.timelineList.horizontalScrollMobile = e.target.checked; renderAll(); });
tl.addBtn.addEventListener('click', () => {
const newColor = '#9E9E9E';
config.timelineList.items.push({ id: Date.now(), leftTitle: '00', leftSubtitle: 'NEW', mainTitle: 'New Item', description: 'New item description.', iconClass: 'fas fa-plus', tabColor: newColor, titleBarColor: newColor, iconColor: newColor });
renderTimelineListControls();
renderAll();
});
tl.builder.addEventListener('input', e => {
const target = e.target;
const item = target.closest('.carousel-card-item');
if (!item) return;
const itemId = parseInt(item.dataset.id, 10);
const tlItem = config.timelineList.items.find(i => i.id === itemId);
if (!tlItem) return;
const property = target.dataset.property;
tlItem[property] = target.value;
renderAll();
});
tl.builder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const item = e.target.closest('.carousel-card-item');
const itemId = parseInt(item.dataset.id, 10);
config.timelineList.items = config.timelineList.items.filter(i => i.id !== itemId);
renderTimelineListControls();
renderAll();
}
});
// Project Cards Panel Listeners
const pc = ui.projectCards;
pc.toggle.addEventListener('change', e => { config.projectCards.enabled = e.target.checked; renderAll(); });
pc.desktopCols.addEventListener('input', e => { config.projectCards.layout.desktop = parseInt(e.target.value, 10) || 3; renderAll(); });
pc.tabletCols.addEventListener('input', e => { config.projectCards.layout.tablet = parseInt(e.target.value, 10) || 2; renderAll(); });
pc.mobileCols.addEventListener('input', e => { config.projectCards.layout.mobile = parseInt(e.target.value, 10) || 1; renderAll(); });
pc.hScrollToggle.addEventListener('change', e => { config.projectCards.horizontalScrollMobile = e.target.checked; renderAll(); });
pc.addCardBtn.addEventListener('click', () => {
config.projectCards.cards.push({ id: Date.now(), title: 'New Project', date: '01 Jan 2030', bgColor: '#E5E7EB', avatars: '', moreCount: '' });
renderProjectCardsControls();
renderAll();
});
pc.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.projectCards.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
pc.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.projectCards.cards = config.projectCards.cards.filter(c => c.id !== cardId);
renderProjectCardsControls();
renderAll();
}
});
// Genres Carousel Panel Listeners
const gc = ui.genresCarousel;
gc.toggle.addEventListener('change', e => { config.genresCarousel.enabled = e.target.checked; renderAll(); });
gc.title.addEventListener('input', e => { config.genresCarousel.title = e.target.value; renderAll(); });
gc.seeMoreToggle.addEventListener('change', e => {
config.genresCarousel.seeMore.enabled = e.target.checked;
gc.seeMoreControls.style.display = e.target.checked ? 'block' : 'none';
renderAll();
});
gc.seeMoreText.addEventListener('input', e => { config.genresCarousel.seeMore.text = e.target.value; renderAll(); });
gc.seeMoreUrl.addEventListener('input', e => { config.genresCarousel.seeMore.url = e.target.value; renderAll(); });
gc.arrowsToggle.addEventListener('change', e => { config.genresCarousel.behavior.showArrows = e.target.checked; renderAll(); });
gc.desktopItems.addEventListener('input', e => { config.genresCarousel.behavior.desktop = parseInt(e.target.value, 10); renderAll(); });
gc.tabletItems.addEventListener('input', e => { config.genresCarousel.behavior.tablet = parseInt(e.target.value, 10); renderAll(); });
gc.mobileItems.addEventListener('input', e => { config.genresCarousel.behavior.mobile = parseInt(e.target.value, 10); renderAll(); });
gc.addCardBtn.addEventListener('click', () => {
config.genresCarousel.cards.push({ id: Date.now(), text: 'New Card', url: '#', color1: '#6b7280', color2: '#374151' });
renderCarouselCardControls();
renderAll();
});
// Event delegation for dynamic carousel card controls
gc.cardsBuilder.addEventListener('input', e => {
const target = e.target;
const cardItem = target.closest('.carousel-card-item');
if (!cardItem) return;
const cardId = parseInt(cardItem.dataset.id, 10);
const card = config.genresCarousel.cards.find(c => c.id === cardId);
if (!card) return;
const property = target.dataset.property;
card[property] = target.value;
renderAll();
});
gc.cardsBuilder.addEventListener('click', e => {
if (e.target.closest('.delete-card-btn')) {
const cardItem = e.target.closest('.carousel-card-item');
const cardId = parseInt(cardItem.dataset.id, 10);
config.genresCarousel.cards = config.genresCarousel.cards.filter(c => c.id !== cardId);
renderCarouselCardControls();
renderAll();
}
});
// Custom HTML Panel
ui.customHtml.toggle.addEventListener('change', e => { config.customHtml.enabled = e.target.checked; renderAll(); });
ui.customHtml.content.addEventListener('input', e => { config.customHtml.content = e.target.value; renderAll(); });
// Preview Buttons
document.getElementById('desktop-btn').addEventListener('click', () => setPreviewMode('desktop'));
document.getElementById('tablet-btn').addEventListener('click', () => setPreviewMode('tablet'));
document.getElementById('mobile-btn').addEventListener('click', () => setPreviewMode('mobile'));
// --- Import/Export Listeners ---
const importBtn = document.getElementById('import-btn');
const importFileInput = document.getElementById('import-file-input');
const exportMenuBtn = document.getElementById('export-menu-btn');
const exportDropdown = document.getElementById('export-dropdown');
const copyCombinedCodeBtn = document.getElementById('copy-combined-code');
const copyHtmlBtn = document.getElementById('copy-html');
const copyCssBtn = document.getElementById('copy-css');
const copyJsBtn = document.getElementById('copy-js');
const downloadZipBtn = document.getElementById('download-zip-btn');
// --- Import ---
importBtn.addEventListener('click', () => importFileInput.click());
importFileInput.addEventListener('change', (event) => {
const file = event.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = (e) => {
const fileContent = e.target.result;
try {
const parser = new DOMParser();
const doc = parser.parseFromString(fileContent, 'text/html');
const configScript = doc.getElementById('app-config');
if (!configScript) {
throw new Error('Not a valid page file. Configuration data not found.');
}
const importedConfig = JSON.parse(configScript.textContent);
if (!importedConfig || typeof importedConfig.componentOrder === 'undefined') {
throw new Error('Invalid configuration format.');
}
// The 'config' object is a const, so we can't reassign it.
// Instead, we clear it and then copy properties from the imported config.
Object.keys(config).forEach(key => delete config[key]);
Object.assign(config, importedConfig);
showToast('Page imported successfully!');
init(); // Re-initialize the app with the new state
} catch (error) {
console.error('Import failed:', error);
showToast(`Import failed: ${error.message}`);
} finally {
importFileInput.value = ''; // Reset for re-uploading the same file
}
};
reader.onerror = () => {
showToast('Error reading the file.');
importFileInput.value = '';
};
reader.readAsText(file);
});
// --- Export ---
exportMenuBtn.addEventListener('click', () => {
exportDropdown.classList.toggle('hidden');
});
document.addEventListener('click', (e) => {
if (!exportMenuBtn.contains(e.target) && !exportDropdown.contains(e.target)) {
exportDropdown.classList.add('hidden');
}
});
function copyToClipboard(text, successMessage) {
navigator.clipboard.writeText(text).then(() => {
showToast(successMessage);
}, (err) => {
showToast('Failed to copy!');
console.error('Could not copy text: ', err);
});
exportDropdown.classList.add('hidden');
}
copyCombinedCodeBtn.addEventListener('click', (e) => {
e.preventDefault();
copyToClipboard(getCombinedCode(), 'Combined code copied!');
});
copyHtmlBtn.addEventListener('click', (e) => {
e.preventDefault();
copyToClipboard(getAllHtml(), 'HTML copied!');
});
copyCssBtn.addEventListener('click', (e) => {
e.preventDefault();
copyToClipboard(getFullCSS(), 'CSS copied!');
});
copyJsBtn.addEventListener('click', (e) => {
e.preventDefault();
copyToClipboard(getFullJS(), 'JavaScript copied!');
});
downloadZipBtn.addEventListener('click', (e) => {
e.preventDefault();
const zip = new JSZip();
zip.file("index.html", getCombinedCode());
zip.file("style.css", getFullCSS());
zip.file("script.js", getFullJS());
zip.generateAsync({type:"blob"}).then(function(content) {
saveAs(content, "exported-page.zip");
});
exportDropdown.classList.add('hidden');
showToast('Downloading .zip file...');
});
// --- Sidebar Toggle ---
ui.toggleSidebarBtn.addEventListener('click', () => {
ui.mainContainer.classList.toggle('sidebar-collapsed');
const icon = ui.toggleSidebarBtn.querySelector('i');
icon.classList.toggle('fa-chevron-left');
icon.classList.toggle('fa-chevron-right');
ui.toggleSidebarBtn.title = ui.mainContainer.classList.contains('sidebar-collapsed') ? 'Show Controls' : 'Hide Controls';
});
}
// --- DYNAMIC UI RENDERING ---
function renderFeaturedCategoriesCardControls() {
const builder = ui.featuredCategories.cardsBuilder;
builder.innerHTML = config.featuredCategories.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="text" value="${card.text}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>URL</label><input type="text" data-property="url" value="${card.url}"></div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Icon Class (e.g., fas fa-gamepad)</label><input type="text" data-property="iconClass" value="${card.iconClass}"></div>
<div><label>Background Color</label><input type="color" data-property="color" value="${card.color}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
</div>
`).join('');
}
function renderCategoryGridCardControls() {
const builder = ui.categoryGrid.cardsBuilder;
builder.innerHTML = config.categoryGrid.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="title" value="${card.title}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>Description</label><input type="text" data-property="description" value="${card.description}"></div>
<div class="input-group text-xs"><label>URL</label><input type="text" data-property="url" value="${card.url}"></div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Icon Class (e.g., fas fa-book)</label><input type="text" data-property="icon" value="${card.icon}"></div>
<div><label>Icon Color</label><input type="color" data-property="iconColor" value="${card.iconColor}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
</div>
`).join('');
}
function renderFeatureGridCardControls() {
const builder = ui.featureGrid.cardsBuilder;
builder.innerHTML = config.featureGrid.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="title" value="${card.title}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>Subtitle</label><input type="text" data-property="subtitle" value="${card.subtitle}"></div>
<div class="input-group text-xs"><label>Link Text</label><input type="text" data-property="linkText" value="${card.linkText}"></div>
<div class="input-group text-xs"><label>Link URL</label><input type="text" data-property="linkUrl" value="${card.linkUrl}"></div>
<div class="input-group text-xs"><label>Image URL</label><input type="text" data-property="imageUrl" value="${card.imageUrl}"></div>
<div class="input-group text-xs"><label>BG Color</label><input type="color" data-property="bgColor" value="${card.bgColor}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
`).join('');
}
function renderInfoCardsControls() {
const builder = ui.infoCards.cardsBuilder;
builder.innerHTML = config.infoCards.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="title" value="${card.title}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>Subtitle</label><input type="text" data-property="subtitle" value="${card.subtitle}"></div>
<div class="input-group text-xs"><label>Link URL</label><input type="text" data-property="linkUrl" value="${card.linkUrl}"></div>
<div class="input-group text-xs"><label>Image URL</label><input type="text" data-property="imageUrl" value="${card.imageUrl}"></div>
<div class="input-group text-xs"><label>BG Color</label><input type="color" data-property="bgColor" value="${card.bgColor}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
`).join('');
}
function renderStepsDisplayControls() {
const builder = ui.stepsDisplay.builder;
builder.innerHTML = config.stepsDisplay.steps.map(step => `
<div class="carousel-card-item space-y-2" data-id="${step.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="title" value="${step.title}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>Description</label><textarea data-property="description" rows="3">${step.description}</textarea></div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Icon Class</label><input type="text" data-property="iconClass" value="${step.iconClass}"></div>
<div><label>Color</label><input type="color" data-property="color" value="${step.color}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
</div>
`).join('');
}
function renderTimelineListControls() {
const builder = ui.timelineList.builder;
const isArrowStyle = config.timelineList.style === 'arrow';
builder.innerHTML = config.timelineList.items.map(item => `
<div class="carousel-card-item space-y-2" data-id="${item.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="mainTitle" value="${item.mainTitle}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Left Title (e.g. STEP 01)</label><input type="text" data-property="leftTitle" value="${item.leftTitle}"></div>
<div style="display: ${isArrowStyle ? 'block' : 'none'}"><label>Left Subtitle (e.g. DATA)</label><input type="text" data-property="leftSubtitle" value="${item.leftSubtitle}"></div>
</div>
<div class="input-group text-xs"><label>Description</label><textarea data-property="description" rows="2">${item.description}</textarea></div>
<div class="input-group text-xs"><label>Icon Class</label><input type="text" data-property="iconClass" value="${item.iconClass}"></div>
${isArrowStyle
? `<div class="input-group text-xs"><label>Color</label><input type="color" data-property="color" value="${item.color || '#000000'}" class="w-full p-0 h-8 border-none rounded-md"></div>`
: `<div class="grid grid-cols-3 gap-2 input-group text-xs">
<div><label>Tab Color</label><input type="color" data-property="tabColor" value="${item.tabColor || '#000000'}" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label>Title BG</label><input type="color" data-property="titleBarColor" value="${item.titleBarColor || '#000000'}" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label>Icon Color</label><input type="color" data-property="iconColor" value="${item.iconColor || '#000000'}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>`
}
</div>
`).join('');
}
function renderProjectCardsControls() {
const builder = ui.projectCards.cardsBuilder;
builder.innerHTML = config.projectCards.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="title" value="${card.title}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Date</label><input type="text" data-property="date" value="${card.date}"></div>
<div><label>Background Color</label><input type="color" data-property="bgColor" value="${card.bgColor}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
<div class="input-group text-xs">
<label>Avatar URLs (comma-separated)</label>
<textarea data-property="avatars" rows="2">${card.avatars}</textarea>
</div>
<div class="input-group text-xs">
<label>More Count (e.g., 2+)</label>
<input type="text" data-property="moreCount" value="${card.moreCount}">
</div>
</div>
`).join('');
}
function renderCarouselCardControls() {
const builder = ui.genresCarousel.cardsBuilder;
builder.innerHTML = config.genresCarousel.cards.map(card => `
<div class="carousel-card-item space-y-2" data-id="${card.id}">
<div class="flex justify-between items-center">
<i class="fas fa-grip-vertical text-gray-400 cursor-move"></i>
<input type="text" data-property="text" value="${card.text}" class="font-semibold border-none bg-transparent p-0 w-full focus:ring-0">
<button class="delete-card-btn text-red-500 hover:text-red-700 p-1"><i class="fas fa-trash"></i></button>
</div>
<div class="input-group text-xs"><label>URL</label><input type="text" data-property="url" value="${card.url}"></div>
<div class="grid grid-cols-2 gap-2 input-group text-xs">
<div><label>Color 1</label><input type="color" data-property="color1" value="${card.color1}" class="w-full p-0 h-8 border-none rounded-md"></div>
<div><label>Color 2</label><input type="color" data-property="color2" value="${card.color2}" class="w-full p-0 h-8 border-none rounded-md"></div>
</div>
</div>
`).join('');
}
// --- HTML, CSS, JS GENERATORS ---
function generateFeaturedCategoriesHTML() {
if (!config.featuredCategories.enabled) return '';
const { layout, cards, horizontalScrollMobile } = config.featuredCategories;
const gridClasses = `grid gap-4 grid-cols-${layout.mobile || 2} md:grid-cols-${layout.tablet || 3} lg:grid-cols-${layout.desktop || 6}`;
const cardsEl = cards.map(card => `
<a href="${card.url || '#'}" class="featured-category-card relative block rounded-xl p-5 text-white font-bold text-lg overflow-hidden transition-transform transform hover:scale-105" style="background-color: ${card.color}; min-height: 100px;">
<div class="relative z-10">
<span>${card.text}</span>
<div class="w-6 h-0.5 bg-white opacity-75 mt-1 rounded-full"></div>
</div>
<i class="${card.iconClass} absolute text-white text-7xl opacity-20 z-0" style="right: -15px; bottom: 50%; transform: translateY(50%) rotate(15deg);"></i>
</a>
`).join('');
return `
<section class="featured-categories-section py-12 bg-gray-100 ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
</div>
</section>`;
}
function generateCategoryGridHTML() {
if (!config.categoryGrid.enabled) return '';
const { layout, cards, viewAllLink, horizontalScrollMobile } = config.categoryGrid;
const desktopCols = layout.desktop || 4;
const tabletCols = layout.tablet || 2;
const mobileCols = layout.mobile || 1;
const gridClasses = `grid gap-4 grid-cols-${mobileCols} md:grid-cols-${tabletCols} lg:grid-cols-${desktopCols}`;
const cardsEl = cards.map(card => `
<a href="${card.url || '#'}" class="category-item-link group block">
<div class="bg-white rounded-lg p-4 flex items-center space-x-4 border border-gray-200 hover:shadow-lg hover:border-blue-500 transition-all duration-300 h-full">
<div class="flex-shrink-0">
<i class="${card.icon} text-2xl w-8 text-center" style="color: ${card.iconColor};"></i>
</div>
<div>
<h3 class="font-bold text-gray-900 group-hover:text-blue-600 transition-colors">${card.title}</h3>
<p class="text-sm text-gray-500">${card.description}</p>
</div>
</div>
</a>
`).join('');
const viewAllEl = viewAllLink.enabled
? `<div class="text-center mt-8">
<a href="${viewAllLink.url || '#'}" class="text-blue-600 font-semibold hover:underline">${viewAllLink.text}</a>
</div>`
: '';
return `
<section class="category-grid-section py-12 bg-gray-50 ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
${viewAllEl}
</div>
</section>`;
}
function generateFeatureGridHTML() {
if (!config.featureGrid.enabled) return '';
const { layout, cards, horizontalScrollMobile } = config.featureGrid;
const gridClasses = `grid gap-6 grid-cols-${layout.mobile || 1} sm:grid-cols-${layout.tablet || 2} lg:grid-cols-${layout.desktop || 2}`;
const cardsEl = cards.map(card => {
const isLightBg = ((parseInt(card.bgColor.substring(1), 16) > 0xffffff / 2) || card.bgColor === '#FFFFFF');
const titleColor = isLightBg ? '#111827' : '#FFFFFF';
const linkColor = isLightBg ? '#374151' : '#FFFFFF';
return `
<a href="${card.linkUrl || '#'}" class="feature-card-link block" style="--card-bg-color: ${card.bgColor}; --card-text-color: ${titleColor};">
<div class="feature-card relative flex flex-col justify-between p-6 rounded-2xl overflow-hidden h-full">
<div class="relative z-10">
<h3 class="text-2xl font-bold">${card.title}</h3>
<p class="text-xl opacity-90">${card.subtitle}</p>
<div class="feature-card-learn-more mt-4 flex items-center space-x-2 font-semibold">
<span>${card.linkText}</span>
<i class="fas fa-arrow-right"></i>
</div>
</div>
<img src="${card.imageUrl}" alt="${card.title}" class="feature-card-img absolute z-0 pointer-events-none">
</div>
</a>`;
}).join('');
return `
<section class="feature-grid-section py-12 bg-white ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
</div>
</section>`;
}
function generateInfoCardsHTML() {
if (!config.infoCards.enabled) return '';
const { layout, cards, horizontalScrollMobile } = config.infoCards;
const gridClasses = `grid gap-6 grid-cols-${layout.mobile || 1} sm:grid-cols-${layout.tablet || 2} lg:grid-cols-${layout.desktop || 4}`;
const cardsEl = cards.map(card => `
<a href="${card.linkUrl || '#'}" class="info-card-link block">
<div class="info-card relative rounded-2xl p-6 text-white h-48 flex flex-col justify-between" style="background-color: ${card.bgColor};">
<div class="relative z-10">
<h3 class="text-2xl font-bold">${card.title}</h3>
<p class="opacity-80">${card.subtitle}</p>
</div>
<img src="${card.imageUrl}" alt="${card.title}" class="card-image absolute w-28 h-28 bottom-2 right-2 z-10">
</div>
</a>
`).join('');
return `
<section class="info-cards-section py-12 bg-gray-50 ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
</div>
</section>`;
}
function generateStepsDisplayHTML() {
if (!config.stepsDisplay.enabled) return '';
const { layout, steps, style, horizontalScrollMobile } = config.stepsDisplay;
const gridClasses = `grid gap-x-6 gap-y-12 grid-cols-${layout.mobile || 1} sm:grid-cols-${layout.tablet || 2} lg:grid-cols-${layout.desktop || 3}`;
const cardsEl = steps.map(step => {
let cardContent = '';
if (style === 'ribbon') {
cardContent = `
<div class="step-card-main">
<div class="step-card-body">
<i class="${step.iconClass} step-icon"></i>
<h3 class="step-title">${step.title}</h3>
<p class="step-description">${step.description}</p>
</div>
<div class="step-card-ribbon" style="--step-color: ${step.color};"></div>
</div>`;
} else if (style === 'banner') {
cardContent = `
<div class="step-card-main text-center">
<div class="step-card-body">
<i class="${step.iconClass} step-icon"></i>
<p class="step-description">${step.description}</p>
</div>
<div class="step-card-banner-text" style="background-color: ${step.color};">
<h3 class="step-title-banner">${step.title}</h3>
</div>
</div>`;
} else { // style === 'circle'
cardContent = `
<div class="step-card-main text-center">
<div class="step-card-body">
<h3 class="step-title">${step.title}</h3>
<p class="step-description">${step.description}</p>
</div>
<div class="step-card-footer" style="background-color: ${step.color};">
<div class="step-icon-circle-wrapper">
<div class="step-icon-circle"><i class="${step.iconClass} step-icon-inner" style="color: ${step.color};"></i></div>
</div>
</div>
</div>`;
}
return `<div class="step-item-wrapper">${cardContent}</div>`;
}).join('');
return `
<section class="steps-display-section py-16 bg-white ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
</div>
</section>`;
}
function generateTimelineListHTML() {
if (!config.timelineList.enabled) return '';
const { style, items, gap, enableGlossyEffect, enableHoverEffect, horizontalScrollMobile } = config.timelineList;
const itemsEl = items.map(item => {
let itemHtml = '';
if (style === 'arrow') {
itemHtml = `
<div class="timeline-item-arrow" style="--item-color: ${item.color};">
<div class="arrow-left-tab">
<span class="left-title">${item.leftTitle}</span>
<span class="left-subtitle">${item.leftSubtitle}</span>
</div>
<div class="arrow-main-content">
<div class="main-text">
<h4 class="main-title">${item.mainTitle}</h4>
<p class="main-description">${item.description}</p>
</div>
<div class="main-icon">
<i class="${item.iconClass}"></i>
</div>
</div>
<div class="arrow-pointer"></div>
</div>`;
} else { // style === 'rounded'
itemHtml = `
<div class="timeline-item-rounded ${enableGlossyEffect ? 'glossy' : ''} ${enableHoverEffect ? 'hoverable' : ''}">
<div class="rounded-left-tab" style="background-color: ${item.tabColor};">
<span class="left-title">${item.leftTitle}</span>
</div>
<div class="rounded-main-content">
<div class="main-text">
<div class="main-title-bar" style="background-color: ${item.titleBarColor};">
<h4>${item.mainTitle}</h4>
</div>
<p class="main-description">${item.description}</p>
</div>
<div class="main-icon-rounded">
<i class="${item.iconClass}" style="color: ${item.iconColor};"></i>
</div>
</div>
</div>`;
}
return `<div class="timeline-item-wrapper">${itemHtml}</div>`
}).join('');
return `
<section class="timeline-list-section py-12 bg-gray-100 ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper flex flex-col" style="gap: ${gap}px;">
${itemsEl}
</div>
</div>
</section>`;
}
function generateProjectCardsHTML() {
if (!config.projectCards.enabled) return '';
const { layout, cards, horizontalScrollMobile } = config.projectCards;
const gridClasses = `grid gap-6 grid-cols-${layout.mobile || 1} md:grid-cols-${layout.tablet || 2} lg:grid-cols-${layout.desktop || 3}`;
const cardsEl = cards.map(card => {
const avatarUrls = card.avatars.split(',').map(url => url.trim()).filter(Boolean);
const avatarsHtml = avatarUrls.map(url => `<img src="${url}" alt="avatar" class="avatar-img">`).join('');
const moreCountHtml = card.moreCount ? `<div class="more-count">${card.moreCount}</div>` : '';
return `
<div class="project-card flex flex-col justify-between rounded-2xl p-6 shadow-sm h-full" style="background-color: ${card.bgColor};">
<div>
<h3 class="text-2xl font-bold text-gray-800">${card.title}</h3>
<p class="text-gray-500 mt-1">${card.date}</p>
</div>
<div class="project-card-avatars mt-6">
${avatarsHtml}
${moreCountHtml}
</div>
</div>`;
}).join('');
return `
<section class="project-cards-section py-12 bg-white ${horizontalScrollMobile ? 'mobile-h-scroll' : ''}">
<div class="container mx-auto px-4">
<div class="cards-wrapper ${gridClasses}">
${cardsEl}
</div>
</div>
</section>`;
}
function generateGenresCarouselHTML() {
if (!config.genresCarousel.enabled) return '';
const { title, seeMore, behavior, cards } = config.genresCarousel;
const seeMoreEl = seeMore.enabled ? `<a href="${seeMore.url}" class="text-blue-600 font-semibold hover:underline mr-6">${seeMore.text}</a>` : '';
const arrowsEl = behavior.showArrows ? `
<div class="carousel-nav flex space-x-2">
<button class="prev-btn p-2 rounded-full bg-gray-200 hover:bg-gray-300 text-gray-700 transition duration-300" disabled><i class="fas fa-chevron-left"></i></button>
<button class="next-btn p-2 rounded-full bg-gray-200 hover:bg-gray-300 text-gray-700 transition duration-300"><i class="fas fa-chevron-right"></i></button>
</div>` : '';
const cardsEl = cards.map(card => `
<div class="carousel-item p-2">
<a href="${card.url}" class="category-card block rounded-lg shadow-md hover:shadow-lg transform hover:scale-105 transition-all duration-300 p-8 text-center text-white" style="background-image: linear-gradient(to right, ${card.color1}, ${card.color2})">
<h3 class="text-xl font-bold">${card.text}</h3>
</a>
</div>`).join('');
return `
<section class="genres-and-collections py-12 bg-white" data-desktop="${behavior.desktop}" data-tablet="${behavior.tablet}" data-mobile="${behavior.mobile}">
<div class="container mx-auto px-4">
<div class="flex justify-between items-center mb-6 responsive-header">
<h2 class="text-3xl font-bold text-gray-800">${title}</h2>
<div class="flex items-center">${seeMoreEl}${arrowsEl}</div>
</div>
<div class="carousel-container overflow-hidden relative">
<div class="carousel-track flex">${cardsEl}</div>
</div>
</div>
</section>`;
}
function generateCustomHtmlHTML() {
if (!config.customHtml.enabled) return '';
return `<div class="custom-html-section">${config.customHtml.content}</div>`;
}
function getAllHtml() {
return config.componentOrder.map(key => {
if (key === 'featuredCategories') return generateFeaturedCategoriesHTML();
if (key === 'categoryGrid') return generateCategoryGridHTML();
if (key === 'featureGrid') return generateFeatureGridHTML();
if (key === 'infoCards') return generateInfoCardsHTML();
if (key === 'stepsDisplay') return generateStepsDisplayHTML();
if (key === 'timelineList') return generateTimelineListHTML();
if (key === 'projectCards') return generateProjectCardsHTML();
if (key === 'genresCarousel') return generateGenresCarouselHTML();
if (key === 'customHtml') return generateCustomHtmlHTML();
return '';
}).filter(Boolean).join('\n\n');
}
function getFullCSS() {
const { colors, typography } = config.globalSettings;
let css = `
:root { --primary-color: ${colors.primary}; --secondary-color: ${colors.secondary}; --text-color: ${colors.text}; --heading-color: ${colors.heading}; --font-family: ${typography.fontFamily}; }
body { font-family: var(--font-family); color: var(--text-color); margin: 0; background-color: #f0f2f5; }
.container { max-width: 1280px; }
.featured-categories-section .featured-category-card { text-decoration: none; }
.category-grid-section .category-item-link { text-decoration: none; }
/* Feature Grid Styles */
.feature-grid-section .feature-card-link { text-decoration: none; transition: transform 0.3s ease; display: block; }
.feature-grid-section .feature-card-link:hover { transform: translateY(-5px); }
.feature-grid-section .feature-card { background-color: var(--card-bg-color); color: var(--card-text-color); min-height: 200px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06); }
.feature-grid-section .feature-card * { color: inherit; }
.feature-grid-section .feature-card .feature-card-learn-more { color: var(--card-text-color); }
.feature-grid-section .feature-card .feature-card-img { right: -20px; bottom: -20px; width: auto; height: 90%; max-height: 160px; object-fit: contain; transition: transform 0.4s ease; transform-origin: bottom right; }
.feature-grid-section .feature-card-link:hover .feature-card-img { transform: scale(1.1) rotate(3deg); }
/* Info Cards Styles */
.info-cards-section .info-card-link { text-decoration: none; display: block; transition: all 0.3s ease; border-radius: 1rem; }
.info-cards-section .info-card-link:hover { transform: translateY(-6px); box-shadow: 0 10px 20px -5px rgba(0,0,0,0.15); }
.info-cards-section .info-card { overflow: hidden; }
.info-cards-section .info-card::after { content: ''; position: absolute; bottom: -50px; right: -50px; width: 150px; height: 150px; background: rgba(255, 255, 255, 0.15); border-radius: 50%; z-index: 0; transition: all 0.4s ease; }
.info-cards-section .info-card-link:hover .info-card::after { transform: scale(1.3); background: rgba(255, 255, 255, 0.25); }
.info-cards-section .info-card .card-image { transition: transform 0.4s ease; }
.info-cards-section .info-card-link:hover .info-card .card-image { transform: rotate(10deg) scale(1.1); }
/* Steps Display Styles */
.steps-display-section .step-card-main { background: #f8fafc; border-radius: 0.5rem; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1); height: 100%; }
.steps-display-section .step-card-body { padding: 1.5rem; text-align: center; }
.steps-display-section .step-icon { font-size: 2.5rem; color: #9ca3af; margin-bottom: 1rem; display: inline-block; }
.steps-display-section .step-title { font-size: 1.125rem; font-weight: 700; color: var(--heading-color); margin-bottom: 0.5rem; text-transform: uppercase; }
.steps-display-section .step-description { font-size: 0.875rem; color: var(--text-color); line-height: 1.5; }
.steps-display-section .step-card-ribbon { position: relative; height: 3rem; background-color: var(--step-color); margin: 0 1rem; }
.steps-display-section .step-card-ribbon::before, .steps-display-section .step-card-ribbon::after { content: ''; position: absolute; top: 0; width: 0; height: 0; border-style: solid; border-color: transparent; filter: brightness(0.7); }
.steps-display-section .step-card-ribbon::before { left: -1rem; border-width: 1.5rem 0.5rem; border-right-color: var(--step-color); border-top-color: var(--step-color); }
.steps-display-section .step-card-ribbon::after { right: -1rem; border-width: 1.5rem 0.5rem; border-left-color: var(--step-color); border-top-color: var(--step-color); }
.steps-display-section .step-card-banner-text { padding: 1rem; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem; }
.steps-display-section .step-title-banner { color: white; font-weight: 700; text-transform: uppercase; }
.steps-display-section .step-card-footer { padding: 0.75rem; border-bottom-left-radius: 0.5rem; border-bottom-right-radius: 0.5rem; margin-top: 1rem; position: relative; height: 2.5rem; }
.steps-display-section .step-icon-circle-wrapper { position: absolute; left: 50%; top: 0; transform: translate(-50%, -50%); }
.steps-display-section .step-icon-circle { background-color: white; width: 4rem; height: 4rem; border-radius: 9999px; display: flex; align-items: center; justify-content: center; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1); }
.steps-display-section .step-icon-inner { font-size: 1.75rem; }
/* Timeline List Styles */
.timeline-list-section .timeline-item-wrapper { width: 100%; }
.timeline-item-arrow { display: flex; align-items: stretch; background-color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.05); transition: all 0.2s ease-in-out; }
.timeline-item-arrow:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); transform: translateY(-2px); }
.timeline-item-arrow .arrow-left-tab { background-color: var(--item-color); color: white; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 0.5rem 1rem; flex-shrink: 0; }
.timeline-item-arrow .left-title { font-size: 1.5rem; font-weight: 700; }
.timeline-item-arrow .left-subtitle { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.timeline-item-arrow .arrow-main-content { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.5rem; border-left: 1px solid #e5e7eb; border-right: 1px solid #e5e7eb; flex-grow: 1; }
.timeline-item-arrow .main-title { font-weight: 600; color: var(--heading-color); }
.timeline-item-arrow .main-description { font-size: 0.875rem; color: var(--text-color); }
.timeline-item-arrow .main-icon { font-size: 1.75rem; color: var(--item-color); padding-left: 1.5rem; border-left: 1px solid #e5e7eb; margin-left: 1.5rem; }
.timeline-item-arrow .arrow-pointer { background-color: var(--item-color); width: 3rem; flex-shrink: 0; clip-path: polygon(0 0, 100% 50%, 0 100%); }
.timeline-item-rounded { display: flex; align-items: stretch; background-color: white; box-shadow: 0 2px 4px rgba(0,0,0,0.05); border-radius: 0.5rem; overflow: hidden; position: relative; transition: all 0.2s ease-in-out; }
.timeline-item-rounded.hoverable:hover { box-shadow: 0 5px 15px rgba(0,0,0,0.1); transform: scale(1.02); }
.timeline-item-rounded.glossy::before { content:''; position: absolute; top: 0; left: 0; right: 0; height: 60%; background: linear-gradient(to bottom, rgba(255,255,255,0.5), transparent); pointer-events: none; z-index: 10; }
.timeline-item-rounded .rounded-left-tab { color: white; display: flex; justify-content: center; align-items: center; padding: 1rem 1.5rem; font-size: 1.25rem; font-weight: 700; }
.timeline-item-rounded .rounded-main-content { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1.5rem; flex-grow: 1; }
.timeline-item-rounded .main-text { flex-grow: 1; }
.timeline-item-rounded .main-title-bar { color: white; padding: 0.25rem 0.75rem; border-radius: 0.25rem; display: inline-block; margin-bottom: 0.5rem; }
.timeline-item-rounded .main-title-bar h4 { font-size: 0.875rem; font-weight: 600; }
.timeline-item-rounded .main-description { font-size: 0.875rem; color: var(--text-color); }
.timeline-item-rounded .main-icon-rounded { font-size: 1.75rem; padding-left: 1.5rem; opacity: 0.5; }
.project-cards-section .project-card { min-height: 160px; }
.project-card-avatars { display: flex; align-items: center; justify-content: flex-end; }
.project-card-avatars .avatar-img { width: 32px; height: 32px; border-radius: 50%; border: 2px solid white; margin-left: -12px; object-fit: cover; background-color: #CBD5E1; }
.project-card-avatars .more-count { width: 32px; height: 32px; border-radius: 50%; background-color: #1F2937; color: white; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 600; border: 2px solid white; margin-left: -12px; }
.genres-and-collections .carousel-container { cursor: grab; }
.genres-and-collections .carousel-track { user-select: none; }
.genres-and-collections .carousel-item { flex-shrink: 0; }
.genres-and-collections .carousel-nav button:disabled { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 768px) { .genres-and-collections .responsive-header { flex-direction: column; align-items: flex-start; gap: 1rem; } }
/* Styles for Mobile Horizontal Scrolling */
@media (max-width: 767px) {
.mobile-h-scroll .cards-wrapper {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
gap: 1rem;
padding-left: 1rem;
padding-right: 1rem;
/* reset grid styles */
grid-template-columns: none;
-ms-overflow-style: none;
scrollbar-width: none;
}
.mobile-h-scroll .cards-wrapper::-webkit-scrollbar { display: none; }
.mobile-h-scroll .cards-wrapper > * {
width: 80%;
flex-shrink: 0;
scroll-snap-align: start;
}
.timeline-list-section.mobile-h-scroll .cards-wrapper {
flex-direction: row;
}
.timeline-list-section.mobile-h-scroll .timeline-item-wrapper {
width: 85%; /* slightly wider for better look */
}
}`;
return css;
}
function getFullJS() {
let js = '';
if (config.genresCarousel.enabled) {
js += `
const setupGenresCarousel = () => {
const carousel = document.querySelector('.genres-and-collections');
if (!carousel) return;
const track = carousel.querySelector('.carousel-track');
const items = Array.from(track.children);
const nextButton = carousel.querySelector('.next-btn');
const prevButton = carousel.querySelector('.prev-btn');
const container = carousel.querySelector('.carousel-container');
if (!items.length) return;
let currentIndex = 0;
const calculateDimensions = () => {
let visibleCards = parseInt(carousel.dataset.desktop, 10);
if (window.innerWidth <= 768) visibleCards = parseInt(carousel.dataset.mobile, 10);
else if (window.innerWidth <= 1024) visibleCards = parseInt(carousel.dataset.tablet, 10);
const itemWidth = container.clientWidth / visibleCards;
items.forEach(item => { item.style.width = \`\${itemWidth}px\`; });
updateCarousel(false, visibleCards);
};
const updateCarousel = (animate = true, visibleCards) => {
if(!visibleCards) {
visibleCards = parseInt(carousel.dataset.desktop, 10);
if (window.innerWidth <= 768) visibleCards = parseInt(carousel.dataset.mobile, 10);
else if (window.innerWidth <= 1024) visibleCards = parseInt(carousel.dataset.tablet, 10);
}
const itemWidth = container.clientWidth / visibleCards;
track.style.transition = animate ? 'transform 0.5s ease-in-out' : 'none';
track.style.transform = \`translateX(-\${currentIndex * itemWidth}px)\`;
if (prevButton) prevButton.disabled = currentIndex === 0;
if (nextButton) nextButton.disabled = currentIndex >= items.length - visibleCards;
};
if (nextButton) nextButton.addEventListener('click', () => { currentIndex++; updateCarousel(); });
if (prevButton) prevButton.addEventListener('click', () => { currentIndex--; updateCarousel(); });
window.addEventListener('resize', calculateDimensions);
setTimeout(calculateDimensions, 100);
};
setupGenresCarousel();`;
}
return js;
}
function getCombinedCode() {
let js = getFullJS();
if (js.trim()) js = `<script>document.addEventListener('DOMContentLoaded', () => { ${js} });<\/script>`;
// Embed the config object as a JSON script for easy re-importing
const configScript = `<script id="app-config" type="application/json">${JSON.stringify(config)}<\/script>`;
return `<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Exported Page</title><script src="https://cdn.tailwindcss.com"><\/script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"><style>${getFullCSS()}</style></head><body>${configScript}${getAllHtml()}${js}</body></html>`;
}
// --- PREVIEW & RENDER ---
function renderAll() {
const fullJs = getFullJS();
const previewContent = `<!DOCTYPE html><html><head><title>Preview</title><script src="https://cdn.tailwindcss.com"><\/script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css"><style>${getFullCSS()}</style></head><body>
<div class="site-wrapper">${getAllHtml()}</div>
<script>document.addEventListener('DOMContentLoaded', () => { ${fullJs} });<\/script></body></html>`;
ui.previewIframe.srcdoc = previewContent;
}
function setPreviewMode(mode) {
ui.mainContainer.querySelector('#preview-container').className = `bg-white shadow-lg rounded-lg w-full h-full overflow-hidden transition-all duration-300 preview-${mode}`;
['desktop', 'tablet', 'mobile'].forEach(m => {
const btn = document.getElementById(`${m}-btn`);
btn.classList.toggle('bg-blue-500', m === mode);
btn.classList.toggle('text-white', m === mode);
btn.classList.toggle('bg-gray-200', m !== mode);
btn.classList.toggle('text-gray-700', m !== mode);
});
}
function showToast(message) {
const toast = document.getElementById('toast-notification');
toast.textContent = message;
toast.classList.add('show');
setTimeout(() => { toast.classList.remove('show'); }, 3000);
}
// --- INITIALIZATION ---
function init() {
// Populate Global Settings
ui.globalSettings.primaryColor.value = config.globalSettings.colors.primary;
ui.globalSettings.secondaryColor.value = config.globalSettings.colors.secondary;
ui.globalSettings.textColor.value = config.globalSettings.colors.text;
ui.globalSettings.headingColor.value = config.globalSettings.colors.heading;
ui.globalSettings.fontFamily.value = config.globalSettings.typography.fontFamily;
// Populate Featured Categories Controls
const fc = ui.featuredCategories;
const fcConfig = config.featuredCategories;
fc.toggle.checked = fcConfig.enabled;
fc.desktopCols.value = fcConfig.layout.desktop;
fc.tabletCols.value = fcConfig.layout.tablet;
fc.mobileCols.value = fcConfig.layout.mobile;
fc.hScrollToggle.checked = fcConfig.horizontalScrollMobile;
renderFeaturedCategoriesCardControls();
// Populate Category Grid Controls
const cg = ui.categoryGrid;
const cgConfig = config.categoryGrid;
cg.toggle.checked = cgConfig.enabled;
cg.desktopCols.value = cgConfig.layout.desktop;
cg.tabletCols.value = cgConfig.layout.tablet;
cg.mobileCols.value = cgConfig.layout.mobile;
cg.hScrollToggle.checked = cgConfig.horizontalScrollMobile;
cg.viewAllToggle.checked = cgConfig.viewAllLink.enabled;
cg.viewAllControls.style.display = cgConfig.viewAllLink.enabled ? 'block' : 'none';
cg.viewAllText.value = cgConfig.viewAllLink.text;
cg.viewAllUrl.value = cgConfig.viewAllLink.url;
renderCategoryGridCardControls();
// Populate Feature Grid Controls
const fg = ui.featureGrid;
const fgConfig = config.featureGrid;
fg.toggle.checked = fgConfig.enabled;
fg.desktopCols.value = fgConfig.layout.desktop;
fg.tabletCols.value = fgConfig.layout.tablet;
fg.mobileCols.value = fgConfig.layout.mobile;
fg.hScrollToggle.checked = fgConfig.horizontalScrollMobile;
renderFeatureGridCardControls();
// Populate Info Cards Controls
const ic = ui.infoCards;
const icConfig = config.infoCards;
ic.toggle.checked = icConfig.enabled;
ic.desktopCols.value = icConfig.layout.desktop;
ic.tabletCols.value = icConfig.layout.tablet;
ic.mobileCols.value = icConfig.layout.mobile;
ic.hScrollToggle.checked = icConfig.horizontalScrollMobile;
renderInfoCardsControls();
// Populate Steps Display Controls
const sd = ui.stepsDisplay;
const sdConfig = config.stepsDisplay;
sd.toggle.checked = sdConfig.enabled;
sd.style.value = sdConfig.style;
sd.desktopCols.value = sdConfig.layout.desktop;
sd.tabletCols.value = sdConfig.layout.tablet;
sd.mobileCols.value = sdConfig.layout.mobile;
sd.hScrollToggle.checked = sdConfig.horizontalScrollMobile;
renderStepsDisplayControls();
// Populate Timeline List Controls
const tl = ui.timelineList;
const tlConfig = config.timelineList;
tl.toggle.checked = tlConfig.enabled;
tl.style.value = tlConfig.style;
tl.gap.value = tlConfig.gap;
tl.glossyToggle.checked = tlConfig.enableGlossyEffect;
tl.hoverToggle.checked = tlConfig.enableHoverEffect;
tl.hScrollToggle.checked = tlConfig.horizontalScrollMobile;
tl.roundedOptions.style.display = tlConfig.style === 'rounded' ? 'block' : 'none';
renderTimelineListControls();
// Populate Project Cards Controls
const pc = ui.projectCards;
const pcConfig = config.projectCards;
pc.toggle.checked = pcConfig.enabled;
pc.desktopCols.value = pcConfig.layout.desktop;
pc.tabletCols.value = pcConfig.layout.tablet;
pc.mobileCols.value = pcConfig.layout.mobile;
pc.hScrollToggle.checked = pcConfig.horizontalScrollMobile;
renderProjectCardsControls();
// Populate Carousel Controls
const gc = ui.genresCarousel;
const gcConfig = config.genresCarousel;
gc.toggle.checked = gcConfig.enabled;
gc.title.value = gcConfig.title;
gc.seeMoreToggle.checked = gcConfig.seeMore.enabled;
gc.seeMoreControls.style.display = gcConfig.seeMore.enabled ? 'block' : 'none';
gc.seeMoreText.value = gcConfig.seeMore.text;
gc.seeMoreUrl.value = gcConfig.seeMore.url;
gc.arrowsToggle.checked = gcConfig.behavior.showArrows;
gc.desktopItems.value = gcConfig.behavior.desktop;
gc.tabletItems.value = gcConfig.behavior.tablet;
gc.mobileItems.value = gcConfig.behavior.mobile;
renderCarouselCardControls();
// Populate Custom HTML
ui.customHtml.toggle.checked = config.customHtml.enabled;
ui.customHtml.content.value = config.customHtml.content;
setupEventListeners();
renderAll();
ui.controls.nav.querySelector('.control-nav-button').click();
}
init();
});
</script>
</body>
</html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Advanced Component Builder</title>
<script src="https://cdn.tailwindcss.com"></script>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Open+Sans:wght@400;700&family=Lato:wght@400;700&family=Montserrat:wght@400;700&family=Poppins:wght@400;500;600;700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.0/FileSaver.min.js"></script>
<style>
:root {
--primary-color: #3b82f6;
--primary-hover-color: #2563eb;
--secondary-color: #10b981;
--secondary-hover-color: #059669;
--text-color: #374151;
--heading-color: #111827;
--font-family: 'Inter', sans-serif;
}
body {
font-family: var(--font-family);
color: var(--text-color);
background-color: var(--background-color);
}
h1, h2, h3, h4, h5, h6 {
color: var(--heading-color);
}
/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}
::-webkit-scrollbar-track {
background: #f1f1f1;
}
::-webkit-scrollbar-thumb {
background: #888;
border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
.preview-iframe {
width: 100%;
height: 100%;
border: 0;
transition: all 0.3s ease-in-out;
}
#preview-container.preview-desktop .preview-iframe { width: 100%; }
#preview-container.preview-tablet .preview-iframe { width: 768px; margin: 0 auto; }
#preview-container.preview-mobile .preview-iframe { width: 375px; margin: 0 auto; }
.toast {
visibility: hidden;
min-width: 250px;
background-color: #333;
color: #fff;
text-align: center;
border-radius: 8px;
padding: 16px;
position: fixed;
z-index: 100;
left: 50%;
bottom: 30px;
transform: translateX(-50%);
opacity: 0;
transition: opacity 0.3s, visibility 0.3s;
}
.toast.show {
visibility: visible;
opacity: 1;
}
#controls-layout { display: flex; height: 100%; }
#controls-nav { width: 180px; flex-shrink: 0; background-color: #f8fafc; border-right: 1px solid #e5e7eb; padding: 0.5rem; overflow-y: auto; }
.control-nav-button { display: flex; align-items: center; width: 100%; padding: 0.75rem; border-radius: 0.375rem; font-weight: 500; color: var(--text-color); transition: background-color 0.2s, color 0.2s; text-align: left; }
.control-nav-button:hover { background-color: #e5e7eb; }
.control-nav-button.active { background-color: var(--primary-color); color: white; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06); }
.control-nav-button i { margin-right: 0.75rem; width: 20px; text-align: center; }
#controls-panels { flex-grow: 1; padding: 1.5rem; overflow-y: auto; }
.control-panel { display: none; }
.control-panel.active { display: block; }
.control-panel h3 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1.5rem; border-bottom: 1px solid #e5e7eb; padding-bottom: 0.75rem; }
.control-panel h4 { font-size: 0.875rem; font-weight: 600; color: #4b5563; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 1.5rem; margin-bottom: 1rem; }
.layout-item, .carousel-card-item { cursor: move; }
.code-modal-pre { background-color: #2d3748; color: #e2e8f0; padding: 1rem; border-radius: 0.375rem; max-height: 200px; overflow-y: auto; position: relative; }
#controls-sidebar { flex-shrink: 0; }
#main-container.sidebar-collapsed #controls-sidebar { width: 0; padding: 0; overflow: hidden; }
#main-container.sidebar-collapsed #preview-main { width: 100%; }
.input-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.25rem; }
.input-group input, .input-group select, .input-group textarea { width: 100%; padding: 0.5rem; border-radius: 0.375rem; border: 1px solid #d1d5db; }
.carousel-card-item { background-color: #f9fafb; border: 1px solid #e5e7eb; padding: 1rem; border-radius: 0.5rem; }
</style>
</head>
<body class="text-gray-800">