Spaces:
Running
Running
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>MidJourney Clone - AI Image Generator</title> | |
| <!-- Font Awesome for Icons --> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <!-- Google Fonts --> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;700&display=swap" rel="stylesheet"> | |
| <style> | |
| :root { | |
| --bg-color: #0f1115; | |
| --sidebar-bg: #16191e; | |
| --card-bg: #1e2229; | |
| --accent-color: #5865F2; /* Discord/Midjourney blue-ish */ | |
| --accent-hover: #4752C4; | |
| --text-primary: #ffffff; | |
| --text-secondary: #9ca3af; | |
| --border-color: #2b303b; | |
| --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | |
| --glass-bg: rgba(30, 34, 41, 0.7); | |
| --glass-border: rgba(255, 255, 255, 0.1); | |
| } | |
| * { | |
| margin: 0; | |
| padding: 0; | |
| box-sizing: border-box; | |
| font-family: 'Inter', sans-serif; | |
| } | |
| body { | |
| background-color: var(--bg-color); | |
| color: var(--text-primary); | |
| height: 100vh; | |
| display: flex; | |
| overflow: hidden; | |
| } | |
| /* Header / Top Bar */ | |
| .top-bar { | |
| position: fixed; | |
| top: 0; | |
| left: 0; | |
| right: 0; | |
| height: 60px; | |
| background: var(--glass-bg); | |
| backdrop-filter: blur(10px); | |
| border-bottom: 1px solid var(--border-color); | |
| display: flex; | |
| align-items: center; | |
| justify-content: space-between; | |
| padding: 0 20px; | |
| z-index: 100; | |
| } | |
| .logo { | |
| font-family: 'Space Grotesk', sans-serif; | |
| font-weight: 700; | |
| font-size: 1.2rem; | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| .logo i { | |
| font-size: 1.5rem; | |
| background: var(--gradient-1); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| } | |
| .anycoder-link { | |
| text-decoration: none; | |
| color: var(--text-secondary); | |
| font-size: 0.85rem; | |
| padding: 6px 12px; | |
| border-radius: 20px; | |
| background: rgba(255,255,255,0.05); | |
| transition: all 0.3s ease; | |
| } | |
| .anycoder-link:hover { | |
| background: rgba(255,255,255,0.1); | |
| color: var(--text-primary); | |
| } | |
| /* Sidebar */ | |
| .sidebar { | |
| width: 280px; | |
| background-color: var(--sidebar-bg); | |
| border-right: 1px solid var(--border-color); | |
| display: flex; | |
| flex-direction: column; | |
| padding-top: 80px; /* Space for header */ | |
| flex-shrink: 0; | |
| transition: transform 0.3s ease; | |
| } | |
| .nav-item { | |
| padding: 12px 20px; | |
| color: var(--text-secondary); | |
| cursor: pointer; | |
| display: flex; | |
| align-items: center; | |
| gap: 12px; | |
| transition: 0.2s; | |
| margin: 4px 10px; | |
| border-radius: 8px; | |
| } | |
| .nav-item:hover, .nav-item.active { | |
| background-color: rgba(88, 101, 242, 0.1); | |
| color: var(--text-primary); | |
| } | |
| .nav-item.active { | |
| border-left: 3px solid var(--accent-color); | |
| } | |
| .history-section { | |
| margin-top: 20px; | |
| padding: 0 20px; | |
| flex-grow: 1; | |
| overflow-y: auto; | |
| } | |
| .history-title { | |
| font-size: 0.75rem; | |
| text-transform: uppercase; | |
| color: var(--text-secondary); | |
| letter-spacing: 1px; | |
| margin-bottom: 10px; | |
| font-weight: 600; | |
| } | |
| .history-grid { | |
| display: grid; | |
| grid-template-columns: repeat(2, 1fr); | |
| gap: 10px; | |
| } | |
| .history-thumb { | |
| aspect-ratio: 1; | |
| background-color: var(--card-bg); | |
| border-radius: 6px; | |
| overflow: hidden; | |
| cursor: pointer; | |
| border: 1px solid transparent; | |
| transition: border-color 0.2s; | |
| } | |
| .history-thumb:hover { | |
| border-color: var(--accent-color); | |
| } | |
| .history-thumb img { | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| } | |
| /* Main Content */ | |
| .main-content { | |
| flex-grow: 1; | |
| padding-top: 60px; | |
| display: flex; | |
| flex-direction: column; | |
| position: relative; | |
| overflow: hidden; | |
| } | |
| /* Chat/Gallery Area */ | |
| .gallery-area { | |
| flex-grow: 1; | |
| overflow-y: auto; | |
| padding: 20px; | |
| display: flex; | |
| flex-direction: column; | |
| gap: 20px; | |
| scroll-behavior: smooth; | |
| } | |
| .welcome-screen { | |
| display: flex; | |
| flex-direction: column; | |
| align-items: center; | |
| justify-content: center; | |
| height: 100%; | |
| text-align: center; | |
| opacity: 1; | |
| transition: opacity 0.5s; | |
| } | |
| .welcome-screen h1 { | |
| font-size: 2.5rem; | |
| margin-bottom: 10px; | |
| background: linear-gradient(to right, #fff, #9ca3af); | |
| -webkit-background-clip: text; | |
| -webkit-text-fill-color: transparent; | |
| } | |
| .welcome-screen p { | |
| color: var(--text-secondary); | |
| max-width: 500px; | |
| line-height: 1.6; | |
| } | |
| /* Generated Item Card */ | |
| .generation-card { | |
| background-color: var(--card-bg); | |
| border-radius: 12px; | |
| padding: 16px; | |
| border: 1px solid var(--border-color); | |
| animation: slideUp 0.4s ease-out; | |
| } | |
| @keyframes slideUp { | |
| from { opacity: 0; transform: translateY(20px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .prompt-text { | |
| font-family: 'Space Grotesk', sans-serif; | |
| margin-bottom: 12px; | |
| font-size: 1.1rem; | |
| color: #e2e8f0; | |
| } | |
| .prompt-meta { | |
| font-size: 0.8rem; | |
| color: var(--text-secondary); | |
| margin-bottom: 15px; | |
| display: flex; | |
| gap: 10px; | |
| } | |
| .image-grid { | |
| display: grid; | |
| grid-template-columns: repeat(2, 1fr); | |
| gap: 10px; | |
| width: 100%; | |
| max-width: 600px; | |
| } | |
| .gen-image { | |
| width: 100%; | |
| aspect-ratio: 1; | |
| background-color: #111; | |
| border-radius: 8px; | |
| overflow: hidden; | |
| position: relative; | |
| } | |
| .gen-image img { | |
| width: 100%; | |
| height: 100%; | |
| object-fit: cover; | |
| transition: transform 0.3s; | |
| } | |
| .gen-image:hover img { | |
| transform: scale(1.05); | |
| } | |
| .actions-bar { | |
| margin-top: 15px; | |
| display: flex; | |
| gap: 10px; | |
| flex-wrap: wrap; | |
| } | |
| .action-btn { | |
| background: rgba(255,255,255,0.05); | |
| border: 1px solid var(--border-color); | |
| color: var(--text-secondary); | |
| padding: 8px 16px; | |
| border-radius: 6px; | |
| font-size: 0.85rem; | |
| cursor: pointer; | |
| transition: all 0.2s; | |
| } | |
| .action-btn:hover { | |
| background: rgba(255,255,255,0.1); | |
| color: white; | |
| } | |
| .action-btn.primary { | |
| background: var(--accent-color); | |
| color: white; | |
| border: none; | |
| } | |
| .action-btn.primary:hover { | |
| background: var(--accent-hover); | |
| } | |
| /* Loading State */ | |
| .loading-container { | |
| display: flex; | |
| align-items: center; | |
| justify-content: center; | |
| height: 300px; | |
| width: 100%; | |
| background: rgba(0,0,0,0.2); | |
| border-radius: 8px; | |
| flex-direction: column; | |
| gap: 15px; | |
| } | |
| .loader { | |
| width: 48px; | |
| height: 48px; | |
| border: 3px solid #FFF; | |
| border-radius: 50%; | |
| display: inline-block; | |
| position: relative; | |
| box-sizing: border-box; | |
| animation: rotation 1s linear infinite; | |
| } | |
| .loader::after { | |
| content: ''; | |
| box-sizing: border-box; | |
| position: absolute; | |
| left: 50%; | |
| top: 50%; | |
| transform: translate(-50%, -50%); | |
| width: 40px; | |
| height: 40px; | |
| border-radius: 50%; | |
| border: 3px solid transparent; | |
| border-bottom-color: var(--accent-color); | |
| } | |
| @keyframes rotation { | |
| 0% { transform: rotate(0deg); } | |
| 100% { transform: rotate(360deg); } | |
| } | |
| .loading-text { | |
| color: var(--text-secondary); | |
| font-size: 0.9rem; | |
| animation: pulse 1.5s infinite; | |
| } | |
| @keyframes pulse { | |
| 0% { opacity: 0.5; } | |
| 50% { opacity: 1; } | |
| 100% { opacity: 0.5; } | |
| } | |
| /* Input Area */ | |
| .input-area { | |
| padding: 20px; | |
| background: var(--bg-color); | |
| border-top: 1px solid var(--border-color); | |
| position: relative; | |
| z-index: 10; | |
| } | |
| .input-wrapper { | |
| background-color: var(--card-bg); | |
| border: 1px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 10px; | |
| display: flex; | |
| align-items: flex-start; /* allows multiline growth */ | |
| gap: 10px; | |
| box-shadow: 0 4px 20px rgba(0,0,0,0.3); | |
| transition: border-color 0.2s; | |
| } | |
| .input-wrapper:focus-within { | |
| border-color: var(--accent-color); | |
| } | |
| .prompt-input { | |
| flex-grow: 1; | |
| background: transparent; | |
| border: none; | |
| color: white; | |
| font-size: 1rem; | |
| resize: none; | |
| height: 50px; /* Default height */ | |
| outline: none; | |
| padding: 12px 0; | |
| } | |
| .settings-btn { | |
| color: var(--text-secondary); | |
| background: transparent; | |
| border: none; | |
| font-size: 1.2rem; | |
| padding: 10px; | |
| cursor: pointer; | |
| transition: color 0.2s; | |
| } | |
| .settings-btn:hover { | |
| color: white; | |
| } | |
| .generate-btn { | |
| background: var(--gradient-1); | |
| color: white; | |
| border: none; | |
| padding: 10px 24px; | |
| border-radius: 8px; | |
| font-weight: 600; | |
| cursor: pointer; | |
| transition: transform 0.2s, opacity 0.2s; | |
| height: 45px; | |
| align-self: center; | |
| } | |
| .generate-btn:hover { | |
| opacity: 0.9; | |
| transform: translateY(-1px); | |
| } | |
| .generate-btn:disabled { | |
| opacity: 0.5; | |
| cursor: not-allowed; | |
| } | |
| /* Settings Modal (Hidden by default) */ | |
| .settings-panel { | |
| position: absolute; | |
| bottom: 90px; | |
| right: 20px; | |
| width: 300px; | |
| background: var(--card-bg); | |
| border: 1px solid var(--border-color); | |
| border-radius: 12px; | |
| padding: 15px; | |
| display: none; | |
| box-shadow: 0 10px 30px rgba(0,0,0,0.5); | |
| z-index: 50; | |
| } | |
| .settings-panel.show { | |
| display: block; | |
| animation: fadeIn 0.2s; | |
| } | |
| @keyframes fadeIn { | |
| from { opacity: 0; transform: translateY(10px); } | |
| to { opacity: 1; transform: translateY(0); } | |
| } | |
| .setting-group { | |
| margin-bottom: 15px; | |
| } | |
| .setting-label { | |
| display: block; | |
| font-size: 0.8rem; | |
| color: var(--text-secondary); | |
| margin-bottom: 5px; | |
| } | |
| .slider-container { | |
| display: flex; | |
| align-items: center; | |
| gap: 10px; | |
| } | |
| input[type="range"] { | |
| width: 100%; | |
| accent-color: var(--accent-color); | |
| } | |
| select { | |
| width: 100%; | |
| background: #111; | |
| border: 1px solid var(--border-color); | |
| color: white; | |
| padding: 8px; | |
| border-radius: 6px; | |
| } | |
| /* Mobile Responsiveness */ | |
| .menu-toggle { | |
| display: none; | |
| color: white; | |
| font-size: 1.5rem; | |
| cursor: pointer; | |
| } | |
| @media (max-width: 768px) { | |
| .sidebar { | |
| position: fixed; | |
| left: -280px; | |
| height: 100%; | |
| z-index: 90; | |
| background: var(--bg-color); | |
| } | |
| .sidebar.open { | |
| transform: translateX(280px); | |
| } | |
| .menu-toggle { | |
| display: block; | |
| } | |
| .input-area { | |
| padding: 10px; | |
| } | |
| .generate-btn { | |
| padding: 10px 16px; | |
| } | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <!-- Top Header --> | |
| <header class="top-bar"> | |
| <div class="logo"> | |
| <div class="menu-toggle" id="menuToggle"> | |
| <i class="fas fa-bars"></i> | |
| </div> | |
| <i class="fas fa-robot"></i> | |
| <span>MidClone AI</span> | |
| </div> | |
| <a href="https://huggingface.co/spaces/akhaliq/anycoder" target="_blank" class="anycoder-link"> | |
| Built with anycoder | |
| </a> | |
| </header> | |
| <!-- Sidebar Navigation --> | |
| <nav class="sidebar" id="sidebar"> | |
| <div class="nav-item active"> | |
| <i class="fas fa-magic"></i> | |
| <span>Generate</span> | |
| </div> | |
| <div class="nav-item"> | |
| <i class="fas fa-compass"></i> | |
| <span>Explore</span> | |
| </div> | |
| <div class="nav-item"> | |
| <i class="fas fa-user"></i> | |
| <span>My Profile</span> | |
| </div> | |
| <div class="nav-item"> | |
| <i class="fas fa-cog"></i> | |
| <span>Settings</span> | |
| </div> | |
| <div class="history-section"> | |
| <div class="history-title">Recent Creations</div> | |
| <div class="history-grid" id="historyGrid"> | |
| <!-- History items injected via JS --> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Main Application Area --> | |
| <main class="main-content"> | |
| <!-- Gallery / Chat Feed --> | |
| <div class="gallery-area" id="galleryArea"> | |
| <div class="welcome-screen" id="welcomeScreen"> | |
| <h1>Imagine Anything</h1> | |
| <p>Enter a prompt below to start generating amazing AI art. Try "Cyberpunk city in rain" or "Oil painting of a cat astronaut".</p> | |
| </div> | |
| <!-- Generated content will appear here --> | |
| </div> | |
| <!-- Settings Panel (Popup) --> | |
| <div class="settings-panel" id="settingsPanel"> | |
| <div class="setting-group"> | |
| <label class="setting-label">Aspect Ratio</label> | |
| <select id="aspectRatio"> | |
| <option value="1:1">Square (1:1)</option> | |
| <option value="16:9">Landscape (16:9)</option> | |
| <option value="9:16">Portrait (9:16)</option> | |
| </select> | |
| </div> | |
| <div class="setting-group"> | |
| <label class="setting-label">Stylize (<span id="stylizeVal">50</span>)</label> | |
| <div class="slider-container"> | |
| <input type="range" min="0" max="100" value="50" id="stylizeRange"> | |
| </div> | |
| </div> | |
| <div class="setting-group"> | |
| <label class="setting-label">Model Version</label> | |
| <select> | |
| <option>MidClone v5.2</option> | |
| <option>MidClone v5.1</option> | |
| <option>Niji v5 (Anime)</option> | |
| </select> | |
| </div> | |
| </div> | |
| <!-- Input Section --> | |
| <div class="input-area"> | |
| <div class="input-wrapper"> | |
| <button class="settings-btn" id="settingsToggle" title="Generation Settings"> | |
| <i class="fas fa-sliders-h"></i> | |
| </button> | |
| <textarea | |
| class="prompt-input" | |
| id="promptInput" | |
| placeholder="Describe what you want to see..." | |
| rows="1"></textarea> | |
| <button class="generate-btn" id="generateBtn"> | |
| Generate | |
| </button> | |
| </div> | |
| </div> | |
| </main> | |
| <script> | |
| // --- Data & Config --- | |
| // Using placeholder images from Unsplash to simulate generation results | |
| const placeholderImages = [ | |
| "https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?q=80&w=600&auto=format&fit=crop", // Abstract | |
| "https://images.unsplash.com/photo-1534528741775-53994a69daeb?q=80&w=600&auto=format&fit=crop", // Portrait | |
| "https://images.unsplash.com/photo-1518709268805-4e9042af9f23?q=80&w=600&auto=format&fit=crop", // Space | |
| "https://images.unsplash.com/photo-1635322966219-b75ed372eb01?q=80&w=600&auto=format&fit=crop", // Cyberpunk | |
| "https://images.unsplash.com/photo-1550684848-fac1c5b4e853?q=80&w=600&auto=format&fit=crop", // Sci-fi | |
| "https://images.unsplash.com/photo-1579783902614-a3fb39279c23?q=80&w=600&auto=format&fit=crop" // Art | |
| ]; | |
| // --- DOM Elements --- | |
| const promptInput = document.getElementById('promptInput'); | |
| const generateBtn = document.getElementById('generateBtn'); | |
| const galleryArea = document.getElementById('galleryArea'); | |
| const welcomeScreen = document.getElementById('welcomeScreen'); | |
| const historyGrid = document.getElementById('historyGrid'); | |
| const settingsToggle = document.getElementById('settingsToggle'); | |
| const settingsPanel = document.getElementById('settingsPanel'); | |
| const stylizeRange = document.getElementById('stylizeRange'); | |
| const stylizeVal = document.getElementById('stylizeVal'); | |
| const menuToggle = document.getElementById('menuToggle'); | |
| const sidebar = document.getElementById('sidebar'); | |
| // --- Logic --- | |
| // 1. Handle Generate Click | |
| generateBtn.addEventListener('click', startGeneration); | |
| // Allow Enter key to submit (Shift+Enter for new line) | |
| promptInput.addEventListener('keydown', (e) => { | |
| if (e.key === 'Enter' && !e.shiftKey) { | |
| e.preventDefault(); | |
| startGeneration(); | |
| } | |
| }); | |
| function startGeneration() { | |
| const prompt = promptInput.value.trim(); | |
| if (!prompt) return; | |
| // Disable UI | |
| promptInput.disabled = true; | |
| generateBtn.disabled = true; | |
| generateBtn.innerText = "Dreaming..."; | |
| // Hide welcome screen if first time | |
| if (welcomeScreen) { | |
| welcomeScreen.style.display = 'none'; | |
| } | |
| // Create Loading Card | |
| const loadingId = Date.now(); | |
| const loadingCard = createLoadingCard(prompt, loadingId); | |
| galleryArea.appendChild(loadingCard); | |
| galleryArea.scrollTop = galleryArea.scrollHeight; | |
| // Simulate API Latency (3 seconds) | |
| setTimeout(() => { | |
| // Remove loading card | |
| const cardToRemove = document.getElementById(`loading-${loadingId}`); | |
| if(cardToRemove) cardToRemove.remove(); | |
| // Add Final Result Card | |
| const resultCard = createResultCard(prompt); | |
| galleryArea.appendChild(resultCard); | |
| galleryArea.scrollTop = galleryArea.scrollHeight; | |
| // Add to sidebar history | |
| addToHistory(prompt); | |
| // Reset UI | |
| promptInput.value = ''; | |
| promptInput.disabled = false; | |
| generateBtn.disabled = false; | |
| generateBtn.innerText = "Generate"; | |
| promptInput.focus(); | |
| }, 3000); | |
| } | |
| function createLoadingCard(prompt, id) { | |
| const div = document.createElement('div'); | |
| div.className = 'generation-card'; | |
| div.id = `loading-${id}`; | |
| div.innerHTML = ` | |
| <div class="prompt-text">${prompt}</div> | |
| <div class="prompt-meta"><i class="fas fa-clock"></i> Waiting to start...</div> | |
| <div class="loading-container"> | |
| <span class="loader"></span> | |
| <span class="loading-text">Synthesizing pixels...</span> | |
| </div> | |
| `; | |
| return div; | |
| } | |
| function createResultCard(prompt) { | |
| // Pick 4 random images from placeholder array to simulate variations | |
| const shuffled = [...placeholderImages].sort(() => 0.5 - Math.random()); | |
| const selectedImages = shuffled.slice(0, 4); | |
| const div = document.createElement('div'); | |
| div.className = 'generation-card'; | |
| div.innerHTML = ` | |
| <div class="prompt-text">${prompt}</div> | |
| <div class="prompt-meta"> | |
| <span><i class="fas fa-user-circle"></i> User</span> | |
| <span>•</span> | |
| <span>MidClone v5.2</span> | |
| <span>•</span> | |
| <span>Fast</span> | |
| </div> | |
| <div class="image-grid"> | |
| ${selectedImages.map(src => ` | |
| <div class="gen-image"> | |
| <img src="${src}" alt="AI Generated Art"> | |
| </div> | |
| `).join('')} | |
| </div> | |
| <div class="actions-bar"> | |
| <button class="action-btn primary">U1</button> | |
| <button class="action-btn primary">U2</button> | |
| <button class="action-btn primary">U3</button> | |
| <button class="action-btn primary">U4</button> | |
| <button class="action-btn"><i class="fas fa-redo"></i> Re-roll</button> | |
| <button class="action-btn"><i class="fas fa-heart"></i> Like</button> | |
| </div> | |
| `; | |
| return div; | |
| } | |
| function addToHistory(prompt) { | |
| // Just grab a random image for the thumbnail | |
| const randomThumb = placeholderImages[Math.floor(Math.random() * placeholderImages.length)]; | |
| const thumbDiv = document.createElement('div'); | |
| thumbDiv.className = 'history-thumb'; | |
| thumbDiv.title = prompt; | |
| thumbDiv.innerHTML = `<img src="${randomThumb}" alt="History">`; | |
| // Insert at the beginning | |
| historyGrid.insertBefore(thumbDiv, historyGrid.firstChild); | |
| } | |
| // 2. Settings Logic | |
| settingsToggle.addEventListener('click', (e) => { | |
| e.stopPropagation(); | |
| settingsPanel.classList.toggle('show'); | |
| }); | |
| document.addEventListener('click', (e) => { | |
| if (!settingsPanel.contains(e.target) && e.target !== settingsToggle) { | |
| settingsPanel.classList.remove('show'); | |
| } | |
| }); | |
| stylizeRange.addEventListener('input', (e) => { | |
| stylizeVal.innerText = e.target.value; | |
| }); | |
| // 3. Mobile Menu | |
| menuToggle.addEventListener('click', () => { | |
| sidebar.classList.toggle('open'); | |
| }); | |
| // Close sidebar when clicking outside on mobile | |
| document.addEventListener('click', (e) => { | |
| if(window.innerWidth <= 768) { | |
| if (!sidebar.contains(e.target) && !menuToggle.contains(e.target)) { | |
| sidebar.classList.remove('open'); | |
| } | |
| } | |
| }); | |
| // 4. Auto-resize textarea | |
| promptInput.addEventListener('input', function() { | |
| this.style.height = 'auto'; | |
| this.style.height = (this.scrollHeight) + 'px'; | |
| if(this.value === '') this.style.height = '50px'; | |
| }); | |
| // Initialize some fake history | |
| window.onload = () => { | |
| for(let i=0; i<4; i++) { | |
| addToHistory("Previous generation #" + i); | |
| } | |
| }; | |
| </script> | |
| </body> | |
| </html> |