Here's a thinking process that leads to the suggested HTML solution:
-
Analyze the Request:
- Role: Top-tier creative front-end engineer and UI/UX designer.
- Style: Minimalism, Swiss Design, avant-garde digital interaction. Deep typography, negative space, 60-30-10 color rule, parallax, narrative scrolling.
- Goal: Engineer a "preview deployment stack generating temporary URLs, seeded datasets, and teardown policies."
Interpretation: The user wants a web-based UI that simulates or is a dashboard/control panel for a deployment stack (like Vercel, Netlify, or a custom CI/CD tool) that generates temporary preview URLs, manages seeded data, and handles cleanup (teardown). It needs to be functional (in terms of interaction), professional, and visually stunning following the design principles (GSAP, Tailwind, shaders/particles if appropriate).
Constraints: Single HTML file, no external build steps, no paid APIs. Use Tailwind CSS, GSAP. High visual impact is mandatory.
-
Conceptualization & Design Strategy:
- Theme: "Deployment Engine" - feels futuristic, precise, fast.
- Visual Language: Dark mode (deep #0a0a0a background), Swiss typography (Inter/Montserrat), but with a "cyber" twist using mesh gradients (meshes representing data flow). High contrast neon accents (Cyan/Purple) for active states.
- Core Features:
- Preview URL Generator: Input form (Git branch/commit hash) -> "Deploy" button -> Simulation of build process -> Result: Temporary URL card.
- Seeded Datasets: Section to select/configure a seed for the database (e.g., "Load Demo E-commerce Data").
- Teardown Policy: Controls to set auto-delete timers (TTL) or manual destroy buttons for active previews.
- Interactions:
- Micro-interactions: Magnetic buttons, smooth focus states, custom cursor maybe?
- Animation: GSAP ScrollTrigger for sections fading in/elements arranging.
- Background: Dynamic mesh gradient (using a shader or a complex CSS gradient with animation) to look like "living data".
- Structure:
- Header: Logo/Brand (e.g., "FluxDeploy").
- Hero: Brief value prop.
- Main Dashboard Split:
- Left: Controls (Inputs).
- Right: Live Preview List (Cards with status, URL, actions).
- Footer: Simple stats.
-
Technical Stack (Single File):
- HTML: Semantic structure.
- CSS: Tailwind CSS (via CDN). Custom CSS for specific effects (glassmorphism, grain, animations).
- JS: Vanilla JS + GSAP (via CDN). Logic for simulating deployment, state management, DOM manipulation.
- Visuals: I'll use a Canvas-based fluid gradient or a Three.js shader to meet the "Shader/3D" requirement to make it visually stunning. Let's go with a custom WebGL fluid shader background using Three.js, as it's high-impact and fits the "avante-garde" brief.
-
Step-by-Step Implementation Plan:
- Step 1: Setup: HTML skeleton, import Tailwind, Three.js, GSAP, and a nice font (Google Fonts: Space Grotesk for headers, Inter for body - fits Swiss-tech).
- Step 2: The Three.js Background: A WebGL shader material that renders a subtle but moving, color-rich mesh in the background. It should be performant and not distract too much from the UI (lower opacity).
- Step 3: UI Layout (Tailwind):
- Container: Glassmorphism effect (backdrop-blur, semi-transparent bg).
- Typography hierarchy: Large H1, descriptive text.
- Input fields: Styled with glow effects on focus.
- Step 4: JavaScript Logic (The "Engine"):
- State: Array of active deployments.
- Deploy Simulation: When "Create Preview" is clicked -> Show loading bar/spinner -> Wait 2-3 seconds -> Add a new object to state -> Render new card.
- Teardown: Click "Destroy" -> Animate removal -> Delete from state.
- Seeding: A toggle or select that adds a specific flag to the new deployment's metadata.
- Step 5: Animations (GSAP):
- Intro: Staggered fade-in of UI elements.
- New Card: Slide in from bottom, height expansion.
- Destroy: Shrink/fade out.
- Parallax effect on scroll inside the container (if content overflows).
- Step 6: Polish:
- Ensure high contrast (text white/light gray on dark).
- Add tooltips or status indicators (Online, Building, Offline).
- Add "Noise" grain overlay for texture.
-
Refining the "Wow" Factor (Self-Correction during thought process):
- Initial thought: Just standard HTML inputs. Correction: Needs to look "designed". Use floating labels or underlines that expand.
- Initial thought: Simple spinner. Correction: Use a glowing progress bar that fills up, or a terminal-like text effect. Let's go with a terminal-style status log updating the card during "build".
- Requirement check: "Seeded datasets". I'll add a switch: "Seed withmock data (Products, Users, Orders)". When enabled, it shows a tag on the card.
- Requirement check: "Teardown policies". I'll add a column/input for "TTL (Minutes)". Default 15. Auto-destroy logic that runs every second to expire previews.
-
Drafting the Code (Mental or Scratchpad):
- Three.js Shader: Need a plane filling the screen. Fragment shader: Simplex noise mixing colors (cyan/purple). Uniforms: time, resolution, mouse.
- Tailwind Config: Use arbitrary values for colors to keep the single-file constraint without a build step (e.g.,
bg-[#0a0a0a]).
- GSAP:
gsap.from(".card", {y: 50, opacity: 0, stagger: 0.1}).
-
Writing the Actual Code (incorporating into final output):
- HTML Structure:
<canvas id="bg-canvas"></canvas> at back. <main class="relative z-10"> for content.
- UI: A split layout. Left panel: Configuration (Form). Right panel: Active Preview Grid.
- JS Logic:
deployments array.
renderDeployments() function.
setInterval to check TTLs.
simulateDeployment(id) function that updates status text.
-
Final Polish & Review against Rules:
- Single file? Yes.
- Tailwind? Yes (via CDN).
- Three.js? Yes, custom shader background.
- GSAP? Yes, used for transitions.
- No external keys? Yes.
- High visual impact? Yes, dark theme, neon accents, 3D background, glass cards.
- Interactive? Yes, forms work, buttons working, timeouts.
-
Output Generation: (Proceeding to generate the HTML string).
(Self-Correction during coding specific parts):
- Make sure the text is readable against the 3D background. I will add a
bg-black/70 or bg-gray-900/80 backdrop to the main container to ensure contrast.
- The "Seeded Dataset" option needs to be distinct. A switch/checkbox with a sliding thumb style using Tailwind form plugins or custom CSS. Custom CSS is easier for a single file without loading the extra plugin script.
- The "Teardown Policy" is essentially TTL. I'll put a numeric input for minutes.
- Final Code Structure:
<!DOCTYPE html>
<head> with CDNs (Tailwind script, Three.js, GSAP, Google Fonts).
<style> for custom scrollbars, glass effect, noise.
<body> with Canvas and Main content.
<script>: Shader code, Three.js init, App logic, GSAP animations.
Let's write it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FluxDeploy | Preview & Teardown Engine</title>
<!-- Tailwind CSS (via CDN for standalone) -->
<script src="https://cdn.tailwindcss.com"></script>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Space+Grotesk:wght@300;400;500;600;700&display=swap" rel="stylesheet">
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/ScrollTrigger.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<!-- Tailwind Config -->
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
display: ['Space Grotesk', 'sans-serif'],
},
colors: {
'flux-black': '#050505',
'flux-gray': '#121212',
'flux-glass': 'rgba(255, 255, 255, 0.03)',
'flux-border': 'rgba(255, 255, 255, 0.08)',
'accent-blue': '#00f0ff',
'accent-pink': '#ff00ff',
'accent-yellow': '#f2ff00',
},
backgroundImage: {
'gradient-radial': 'radial-gradient(var(--tw-gradient-stops))',
}
}
}
}
</script>
<style>
/* Custom Styles & Polish */
body, html {
margin: 0;
padding: 0;
overflow-x: hidden;
background-color: #050505;
color: #ffffff;
font-family: 'Inter', sans-serif;
}
/* Noise Texture Overlay */
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.05;
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Glassmorphism Utility */
.glass-panel {
background: rgba(20, 20, 20, 0.6);
backdrop-filter: blur(20px);
-webkit-backdrop-filter: blur(20px);
border: 1px solid rgba(255, 255, 255, 0.08);
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}
/* Custom Range Slider */
input[type=range] {
-webkit-appearance: none;
background: transparent;
}
input[type=range]::-webkit-slider-thumb {
-webkit-appearance: none;
height: 16px;
width: 16px;
border-radius: 50%;
background: #00f0ff;
cursor: pointer;
margin-top: -6px;
box-shadow: 0 0 10px #00f0ff;
}
input[type=range]::-webkit-slider-runnable-track {
width: 100%;
height: 4px;
cursor: pointer;
background: rgba(255,255,255,0.2);
border-radius: 2px;
}
/* Magnetic Button Hover Effect Handle via JS, but base styles here */
.magnetic-btn {
transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}
/* Text Glow */
.text-glow {
text-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
}
/* Loader */
.spinner {
width: 16px;
height: 16px;
border: 2px solid rgba(255,255,255,0.3);
border-top: 2px solid #00f0ff;
border-radius: 50%;
animation: spin 1s linear infinite;
display: none;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
/* Scrollbar */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: #0a0a0a;
}
::-webkit-scrollbar-thumb {
background: #333;
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: #555;
}
</style>
</head>
<body class="antialiased selection:bg-accent-blue selection:text-flux-black">
<!-- Noise Layer -->
<div class="noise-overlay"></div>
<!-- Three.js Background -->
<div id="canvas-container" class="fixed top-0 left-0 w-full h-full -z-10"></div>
<!-- Main Content Wrapper -->
<div class="relative w-full min-h-screen flex flex-col p-6 md:p-12 max-w-7xl mx-auto z-10">
<!-- Header -->
<header class="flex justify-between items-center mb-16">
<div class="flex items-center gap-3">
<div class="w-8 h-8 bg-gradient-to-br from-accent-blue to-accent-pink rounded-lg flex items-center justify-center shadow-lg shadow-accent-blue/20">
<span class="font-display font-bold text-sm">F</span>
</div>
<h1 class="font-display font-bold text-2xl tracking-tight text-white">Flux<span class="text-accent-blue">Deploy</span></h1>
</div>
<div class="hidden md:flex items-center gap-6 text-sm text-gray-400 font-medium">
<a href="#" class="hover:text-white transition-colors">Documentation</a>
<a href="#" class="hover:text-white transition-colors">API</a>
<a href="#" class="hover:text-white transition-colors">Status</a>
<div class="w-2 h-2 rounded-full bg-green-500 shadow-[0_0_8px_rgba(34,197,94,0.6)]"></div>
<span class="text-green-400">System Operational</span>
</div>
</header>
<!-- Hero Section -->
<section class="mb-16">
<h2 class="font-display font-bold text-5xl md:text-7xl leading-tight mb-6 text-transparent bg-clip-text bg-gradient-to-r from-white via-gray-200 to-gray-500">
Deploy Previews.<br>
<span class="text-glow text-accent-blue">Instant Reality.</span>
</h2>
<p class="text-gray-400 text-lg md:text-xl max-w-2xl leading-relaxed font-light">
Generate ephemeral preview URLs with seeded datasets. Define automatic teardown policies
for efficient resource management. The ultimate deployment stack for modern frontend teams.
</p>
</section>
<!-- Main Interface Grid -->
<main class="grid grid-cols-1 lg:grid-cols-12 gap-8 pb-32">
<!-- Left Column: Configuration (4 cols) -->
<div class="lg:col-span-4 flex flex-col gap-8">
<!-- Control Panel Card -->
<div class="glass-panel p-8 rounded-2xl relative overflow-hidden">
<div class="absolute top-0 right-0 w-32 h-32 bg-accent-blue/10 blur-[50px] pointer-events-none"></div>
<h3 class="font-display font-semibold text-xl mb-6 flex items-center gap-2">
<svg class="w-5 h-5 text-accent-blue" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"></path></svg>
Configuration
</h3>
<form id="deploy-form" onsubmit="handleDeploy(event)" class="space-y-6">
<!-- Branch/Commit Input -->
<div>
<label class="block text-xs uppercase tracking-widest text-gray-500 mb-2 font-mono">Source Reference</label>
<div class="relative">
<span class="absolute left-3 top-1/2 -translate-y-1/2 text-gray-500 font-mono text-sm">refs/heads/</span>
<input type="text" id="branch-input" placeholder="feature/new-ui" required
class="w-full bg-flux-black/50 border border-flux-border rounded-lg py-3 pl-20 pr-4 text-white focus:outline-none focus:border-accent-blue focus:ring-1 focus:ring-accent-blue transition-all font-mono text-sm">
</div>
</div>
<!-- Seeded Datasets Toggle -->
<div class="flex items-center justify-between p-4 bg-flux-gray/30 rounded-lg border border-flux-border/50 relative overflow-hidden group">
<div class="absolute inset-0 bg-gradient-to-r from-accent-blue/5 to-transparent opacity-0 group-hover:opacity-100 transition-opacity"></div>
<div>
<div class="text-sm font-medium">Seeded Datasets</div>
<div class="text-xs text-gray-500 font-mono mt-1">load: products, users, orders</div>
</div>
<button type="button" id="seed-toggle" class="relative w-12 h-6 rounded-full bg-gray-700 transition-colors duration-300 border border-gray-600 focus:outline-none focus:ring-2 focus:ring-accent-blue/50" onclick="toggleSeed()">
<div id="seed-thumb" class="absolute top-1 left-1 w-4 h-4 rounded-full bg-white shadow-md transform transition-transform duration-300"></div>
</button>
</div>
<input type="hidden" id="seed-enabled" value="false">
<!-- Teardown Policy -->
<div>
<label class="flex justify-between text-xs uppercase tracking-widest text-gray-500 mb-3 font-mono">
<span>Auto-Teardown (TTL)</span>
<span id="ttl-display" class="text-accent-blue">30 min</span>
</label>
<input type="range" id="ttl-range" min="5" max="120" step="5" value="30"
class="w-full mb-2" oninput="updateTTL(this.value)">
<div class="flex justify-between text-[10px] text-gray-600 font-mono mt-1">
<span>5 min</span>
<span>2 hrs</span>
</div>
</div>
<!-- CTA Button -->
<button type="submit" id="deploy-btn" class="magnetic-btn w-full bg-white text-flux-black font-bold py-4 rounded-lg flex items-center justify-center gap-3 hover:bg-accent-blue hover:scale-[1.02] hover:shadow-[0_0_20px_rgba(0,240,255,0.4)] transition-all duration-300 group">
<span class="spinner" id="btn-spinner"></span>
<span id="btn-text">Initialize Deployment</span>
<svg class="w-5 h-5 group-hover:translate-x-1 transition-transform" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 7l5 5m0 0l-5 5m5-5H6"></path></svg>
</button>
</form>
</div>
<!-- Info Panel -->
<div class="glass-panel p-6 rounded-xl border-l-4 border-accent-pink">
<h4 class="font-display font-bold text-sm mb-2 text-accent-pink">Limits & Quotas</h4>
<ul class="text-xs text-gray-400 space-y-2 font-mono">
<li class="flex justify-between"><span>Active Previews</span> <span class="text-white"><span id="active-count">0</span>/10</span></li>
<li class="flex justify-between"><span>Bandwidth</span> <span class="text-green-400">∞ TB</span></li>
<li class="flex justify-between"><span>Compute Nodes</span> <span class="text-white">Edge Ready</span></li>
</ul>
</div>
</div>
<!-- Right Column: Preview List (8 cols) -->
<div class="lg:col-span-8 flex flex-col relative">
<!-- Empty State / Header Message -->
<div id="empty-state" class="flex flex-col items-center justify-center py-20 text-center opacity-60">
<div class="w-16 h-16 mb-4 rounded-full border border-gray-700 flex items-center justify-center">
<svg class="w-8 h-8 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z"></path></svg>
</div>
<h3 class="font-display text-xl text-gray-300">No Active Previews</h3>
<p class="text-gray-500 max-w-xs mt-2">Generate a temporary URL to inspect your changes in a live environment before merging.</p>
</div>
<!-- Grid Container -->
<div id="deployments-grid" class="grid grid-cols-1 gap-4 hidden">
<!-- Cards will be injected here via JS -->
</div>
</div>
</main>
<footer class="mt-auto pt-8 border-t border-white/10 flex justify-between text-xs text-gray-600 font-mono">
<span>© 2023 FluxDeploy Inc.</span>
<span>FRAME RENDER: 60 FPS</span>
</footer>
</div>
<!-- Application Logic -->
<script>
// --- 1. THREE.JS BACKGROUND SHADER (The "Wow" Factor) ---
const initThreeJS = () => {
const container = document.getElementById('canvas-container');
const scene = new THREE.Scene();
const camera = new THREE.OrthographicCamera(-1, 1, 1, -1, 0, 1);
const renderer = new THREE.WebGLRenderer({ alpha: true });
renderer.setSize(window.innerWidth, window.innerHeight);
container.appendChild(renderer.domElement);
// Custom Shader Material
const geometry = new THREE.PlaneGeometry(2, 2);
const vertexShader = `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position, 1.0);
}
`;
const fragmentShader = `
uniform float u_time;
uniform vec2 u_resolution;
uniform vec2 u_mouse;
varying vec2 vUv;
// Simplex noise function (simplified)
vec3 permute(vec3 x) { return mod(((x*34.0)+1.0)*x, 289.0); }
float snoise(vec2 v){
const vec4 C = vec4(0.211324865405187, 0.366025403784439, -0.577350269189626, 0.024390243902439);
vec2 i = floor(v + dot(v, C.yy) );
vec2 x0 = v - i + dot(i, C.xx);
vec2 i1;
i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
vec4 x12 = x0.xyxy + C.xxzz;
x12.xy -= i1;
i = mod(i, 289.0);
vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 )) + i.x + vec3(0.0, i1.x, 1.0 ));
vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
m = m*m ;
m = m*m ;
vec3 x = 2.0 * fract(p * C.www) - 1.0;
vec3 h = abs(x) - 0.5;
vec3 ox = floor(x + 0.5);
vec3 a0 = x - ox;
m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
vec3 g;
g.x = a0.x * x0.x + h.x * x0.y;
g.yz = a0.yz * x12.xz + h.yz * x12.yw;
return 130.0 * dot(m, g);
}
void main() {
vec2 st = gl_FragCoord.xy / u_resolution.xy;
float noiseVal = snoise(st * 3.0 + u_time * 0.1);
float noiseVal2 = snoise(st * 6.0 - u_time * 0.15);
// Color Palette: Deep Blue/Purple
vec3 colorA = vec3(0.02, 0.02, 0.05); // Near black
vec3 colorB = vec3(0.0, 0.2, 0.4); // Dark Blue
vec3 colorC = vec3(0.5, 0.0, 0.4); // Purple hint
float mixVal = (noiseVal + 1.0) * 0.5;
vec3 finalColor = mix(colorA, colorB, mixVal);
finalColor = mix(finalColor, colorC, (noiseVal2 + 1.0) * 0.2);
// Add a subtle glow at center
float dist = distance(vUv, vec2(0.5));
finalColor += vec3(0.0, 0.8, 1.0) * (0.05 / (dist * 5.0 + 0.1));
gl_FragColor = vec4(finalColor, 1.0);
}
`;
const uniforms = {
u_time: { value: 0 },
u_resolution: { value: new THREE.Vector2(window.innerWidth, window.innerHeight) },
u_mouse: { value: new THREE.Vector2(0, 0) }
};
const material = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader
});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
// Animation Loop
const animate = (time) => {
requestAnimationFrame(animate);
uniforms.u_time.value = time * 0.001;
renderer.render(scene, camera);
};
animate(0);
// Resize Handler
window.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
uniforms.u_resolution.value.set(window.innerWidth, window.innerHeight);
});
window.addEventListener('mousemove', (e) => {
uniforms.u_mouse.value.x = e.clientX / window.innerWidth;
uniforms.u_mouse.value.y = 1.0 - e.clientY / window.innerHeight;
});
};
// --- 2. APPLICATION STATE MANAGEMENT ---
const state = {
deployments: [],
isSeeding: false,
ttl: 30,
maxActive: 10
};
const deployForm = document.getElementById('deploy-form');
const grid = document.getElementById('deployments-grid');
const emptyState = document.getElementById('empty-state');
const activeCountEl = document.getElementById('active-count');
// --- UTILS ---
const generateId = () => Math.random().toString(36).substr(2, 9);
const formatTime = (minutes) => {
if (minutes >= 60) return `${Math.floor(minutes / 60)}h ${minutes % 60}m`;
return `${minutes}m`;
};
// --- UI CONTROLLERS ---
const toggleSeed = () => {
const btn = document.getElementById('seed-toggle');
const thumb = document.getElementById('seed-thumb');
const input = document.getElementById('seed-enabled');
state.isSeeding = !state.isSeeding;
if (state.isSeeding) {
btn.classList.remove('bg-gray-700');
btn.classList.add('bg-accent-blue');
thumb.classList.transform = 'translateX(24px)';
input.value = 'true';
} else {
btn.classList.remove('bg-accent-blue');
btn.classList.add('bg-gray-700');
thumb.style.transform = 'translateX(0)';
input.value = 'false';
}
};
const updateTTL = (val) => {
state.ttl = parseInt(val);
document.getElementById('ttl-display').textContent = formatTime(state.ttl);
};
const handleDeploy = async (e) => {
e.preventDefault();
const branch = document.getElementById('branch-input').value.trim();
if (!branch) return;
const btn = document.getElementById('deploy-btn');
const spinner = document.getElementById('btn-spinner');
const text = document.getElementById('btn-text');
// UI Loading State
btn.classList.add('pointer-events-none', 'opacity-80');
spinner.style.display = 'block';
text.textContent = 'Building...';
// Simulate Build Process (Network delay)
await new Promise(resolve => setTimeout(resolve, 2500));
// Create Deployment Object
const newDeploy = {
id: generateId(),
branch: branch,
seed: state.isSeeding,
ttl: state.ttl,
status: 'building', // building, ready, expired
url: `https://preview.fluxdeploy.io/${branch}-${generateId()}`,
endsAt: new Date(Date.now() + state.ttl * 60000),
logs: [
"Cloning repository...",
"Applying environment patches...",
state.isSeeding ? "Seeding database with mock data..." : "Skipping dataset seeding.",
"Optimizing build assets...",
"Deploying to edge network..."
]
};
state.deployments.unshift(newDeploy);
renderDeploymentCard(newDeploy);
// Reset Form UI
spinner.style.display = 'none';
text.textContent = 'Initialize Deployment';
btn.classList.remove('pointer-events-none', 'opacity-80');
document.getElementById('branch-input').value = '';
// Show Grid if hidden
grid.classList.remove('hidden');
emptyState.style.display = 'none';
updateCounts();
triggerEntryAnimation(newDeploy.id);
};
const destroyDeployment = (id) => {
const el = document.getElementById(`card-${id}`);
// GSAP Exit
gsap.to(el, {
height: 0,
opacity: 0,
duration: 0.5,
ease: "power2.in",
onComplete: () => {
state.deployments = state.deployments.filter(d => d.id !== id);
el.remove();
updateCounts();
if (state.deployments.length === 0) {
emptyState.style.display = 'flex';
grid.classList.add('hidden');
}
}
});
};
const updateCounts = () => {
const count = state.deployments.filter(d => d.status !== 'expired').length;
activeCountEl.textContent = count;
};
// --- RENDERING ---
const renderDeploymentCard = (deploy) => {
const card = document.createElement('div');
card.id = `card-${deploy.id}`;
card.className = `glass-panel p-6 rounded-xl border border-white/5 hover:border-accent-blue/30 transition-colors duration-300 relative overflow-hidden group`;
// Build Log Status (hidden mostly, visible on hover maybe)
const buildLogHtml = deploy.logs.map(l => `<div class="text-xs font-mono text-gray-500 mb-1">> ${l}</div>`).join('');
card.innerHTML = `
<div class="absolute top-0 left-0 w-1 h-full bg-gradient-to-b from-transparent via-accent-blue/50 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-500"></div>
<div class="flex flex-col h-full">
<!-- Header -->
<div class="flex justify-between items-start mb-4">
<div>
<div class="text-xs font-mono text-accent-blue mb-1 flex items-center gap-2">
${deploy.seed ? `<span class="bg-accent-blue/20 px-1 rounded text-accent-blue">SEEDED</span>` : ''}
<span>REF: ${deploy.branch}</span>
</div>
<h4 class="font-display font-bold text-lg text-white">
${deploy.url}
</h4>
</div>
<div class="flex flex-col items-end gap-2">
<span id="timer-${deploy.id}" class="text-xs font-mono text-gray-400">
${formatTime(state.ttl)} left
</span>
<button onclick="destroyDeployment('${deploy.id}')" class="destroy-btn p-2 bg-red-500/10 hover:bg-red-500/20 text-red-500 rounded-lg transition-all border border-transparent hover:border-red-500/30">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"></path></svg>
</button>
</div>
</div>
<!-- Status Bar -->
<div class="mt-auto pt-4 border-t border-white/5">
<div class="flex items-center justify-between text-xs text-gray-400 mb-2">
<span class="font-mono">STATUS: <span id="status-${deploy.id}" class="text-accent-yellow uppercase font-bold">Building</span></span>
<span class="font-mono">TTL: ${formatTime(state.ttl)}</span>
</div>
<!-- Progress Container -->
<div class="h-1 w-full bg-gray-800 rounded-full overflow-hidden">
<div id="progress-${deploy.id}" class="h-full bg-accent-blue transition-all duration-1000 ease-out" style="width: 0%"></div>
</div>
</div>
<!-- Debug Logs (Collapsible/Inline) -->
<div class="mt-4 font-mono text-xs text-gray-600 opacity-0 group-hover:opacity-100 transition-opacity duration-300">
${buildLogHtml}
</div>
</div>
`;
grid.appendChild(card);
// Simulate Build Progress (GSAP)
setTimeout(() => {
const el = document.getElementById(`card-${deploy.id}`);
if(!el) return;
// Build Complete
gsap.to(`#progress-${deploy.id}`, { width: '100%', duration: 2, ease: "power2.inOut" });
setTimeout(() => {
const statusEl = document.getElementById(`status-${deploy.id}`);
if(statusEl) {
statusEl.textContent = "Ready";
statusEl.className = "text-green-400 uppercase font-bold";
}
// Update visual state if needed
el.classList.add('border-accent-green/20'); // subtle green tint? maybe too much
}, 2000);
}, 100);
};
const triggerEntryAnimation = (id) => {
const card = document.getElementById(`card-${id}`);
if(!card) return;
gsap.fromTo(card,
{ y: 100, opacity: 0, scale: 0.95 },
{ y: 0, opacity: 1, scale: 1, duration: 0.6, ease: "back.out(1.7)" }
);
};
// --- TICKER FOR TEARDOWN ---
setInterval(() => {
const now = new Date();
let changed = false;
state.deployments.forEach(d => {
if (now > d.endsAt && d.status !== 'expired') {
// Mark expired
d.status = 'expired';
// Find card and animate removal
const el = document.getElementById(`card-${d.id}`);
if(el) {
// Optional: Flash red then disappear
gsap.to(el, { backgroundColor: 'rgba(255,0,0,0.1)', duration: 0.3, yoyo: true, repeat: 1 });
destroyDeployment(d.id);
changed = true;
}
} else if (d.status !== 'expired') {
// Update Timer Text
const timerEl = document.getElementById(`timer-${d.id}`);
if (timerEl) {
const diff = Math.max(0, d.endsAt - now);
const mins = Math.floor(diff / 60000);
timerEl.textContent = `${mins}m`;
// Visual urgency if < 5m
if (mins < 5) timerEl.classList.add('text-yellow-500');
}
}
});
if (changed) updateCounts();
}, 1000);
// --- INITIALIZATION ---
window.addEventListener('DOMContentLoaded', () => {
initThreeJS();
// Intro Animations
gsap.from('header', { y: -50, opacity: 0, duration: 1, ease: "power3.out" });
gsap.from('h2', { y: 50, opacity: 0, duration: 1, delay: 0.2, ease: "power3.out" });
gsap.from('p', { y: 30, opacity: 0, duration: 1, delay: 0.4, ease: "power3.out" });
gsap.from('.glass-panel', { y: 50, opacity: 0, duration: 0.8, stagger: 0.2, delay: 0.6, ease: "power3.out" });
// Setup Magnetic Buttons
initMagneticButtons();
});
// --- MAGNETIC BUTTON EFFECT ---
function initMagneticButtons() {
const buttons = document.querySelectorAll('.magnetic-btn');
buttons.forEach(btn => {
btn.addEventListener('mousemove', (e) => {
const rect = btn.getBoundingClientRect();
const x = e.clientX - rect.left - rect.width / 2;
const y = e.clientY - rect.top - rect.height / 2;
gsap.to(btn, {
x: x * 0.3,
y: y * 0.3,
duration: 0.2,
ease: "power2.out"
});
});
btn.addEventListener('mouseleave', () => {
gsap.to(btn, {
x: 0,
y: 0,
duration: 0.4,
ease: "elastic.out(1, 0.3)"
});
});
});
}
</script>
</body>
</html>