Here's a thinking process that leads to the suggested solution:
-
Analyze the Request:
- Goal: Build a prompt registry for AI features with approvals and metrics.
- Role: Natural UI/UX Artist (Biophilic Design, Wabi-Sabi).
- Tone: Organic shapes, earthy colors, textures, serif fonts, slow movements, glass-morphism but paper-like, interactive nature (Three.js/Shaders/Canvas).
- Tech Stack HTML/CSS/JS (Single file). Must include Three.js, Tailwind, Framer Motion/GSAP. (Note: I need to use CDN links since it's a single file).
- Constraint: No external frameworks (React/Vue), single HTML file, no native alerts, no heavy API calls (mock data), fully functional.
-
Conceptualization - The "Biophilic" Prompt Registry:
- Metaphor: A garden of ideas, where prompts are seeds or plants. Metrics are the growth (sunlight/water), and approvals are the care (pruning/nurturing).
- Visuals:
- Background: A soft, dynamic, flowing noise texture or a slow-moving gradient (like moss or sky).
- Colors: Sage green, terracotta, sand, off-white, soft charcoal.
- Shapes: Blobs, rounded tablets (border-radius-3xl), gentle curves.
- Typography: A classy serif (Playfair Display or Merriweather) for headings, a clean sans-serif (Lato or Inter) for data.
- Interactivity: Mouse movement influences a subtle background distortion (shader or canvas). Cards float slightly.
- Core Functionality:
- Dashboard: Overview of total prompts, approval rate, average success metric.
- Registry (List): A grid of prompt cards. Each card shows the prompt text, version, author, status (Draft, Pending, Approved, Rejected), and key metrics (Latency, Cost, Success Rate).
- Interactions: Filter by status, search by text.
- Detail View/Edit: Clicking a card opens a modal/form to edit the prompt or metrics (simulated). Approval buttons (Approve/Reject).
- Metrics Visualization: A simple chart (using canvas or SVG) showing trends.
-
Technical Implementation Strategy:
- Structure: HTML5
<header>, <main>, <dialog> (for modals), <footer>.
- Styling: Tailwind CSS via CDN. Custom config to add organic colors and fonts. Custom CSS for noise texture, blurring, and animations.
- 3D/Shaders: Three.js for the background. A simple plane with a vertex/fragment shader simulating "breathing" organic movement (perlin noise) and color mixing.
- Icons: Lucide (via SVG strings or script). Using an SVG icon helper function.
- Data: A JavaScript array of objects representing prompts. Initial mock data.
- State Management: Vanilla JS class
PromptRegistry to handle rendering, filtering, and CRUD operations (save state to localStorage to persist during session ideally, but memory is fine).
- Animations: Framer Motion is great, but it's heavy to include via standalone CDN without build steps sometimes. I'll stick to GSAP (GreenSock) for robust animations and scroll triggers, as it's very compatible with plain JS and CDN. It handles the "slow media" timing well.
-
Step-by-Step Build Plan:
- Step 1: Setup & Libraries: Tailwind CDN, Three.js CDN, GSAP CDN, Fonts (Google Fonts: Playfair Display, Inter).
- Step 2: CSS & Styling Base: Define custom Tailwind config inside the
<script> tag for the color palette. Add noise background CSS class.
- Step 3: Three.js Background: Create a canvas behind everything. Implement a GLSL shader that looks like slow-moving liquid smoke or soft pastel clouds.
- Step 4: Application Layout:
- Header: Title + Stats summary (3 cards).
- Controls: Search bar, Status filter, "New Prompt" button.
- Grid: Container for prompt cards.
- Step 5: Component Design (HTML/CSS Components):
- Card: Glassmorphism (white with opacity + backdrop-blur + border). Soft shadow. Rounded corners.
- Status Badges: Organic shapes (pills but very rounded).
- Metrics Bar: Miniature bars or circles.
- Step 6: JavaScript Logic - Data Model:
prompts array.
- Functions:
renderPrompts(), handleSearch(), handleFilter(), openModal(), savePrompt(), approvePrompt().
- Step 7: JavaScript Logic - Interactions & Animations:
- Use GSAP
from animations on card entry (stagger).
- Hover effects: scale up slightly, shadow deepening.
- Step 8: Refinement - The "Wabi-Sabi" Touch:
- Add random rotations? No, keep it cleaner, but maybe slight natural variations in border radius (some rounder than others?) using GSAP to morph border-radius subtly on hover.
- Ensure color palette is strictly earthy.
- Add grain overlay to the whole UI to give it a paper texture.
-
Drafting the Code (Mental & Scratchpad):
-
Addressing Specific Requirements:
- Approvals: Buttons on the card or in modal to change status.
- Metrics: Mock data (latency, token count, heuristic score).
- No Alerts: Use a custom "toast" notification for actions (like "Prompt Approved"). Create a
createToast() function that injects HTML and removes it after 3s with GSAP fade out.
-
Refining the Visuals (Self-Correction):
- Issue: Tailwind standard colors might be too saturated.
- Fix: Extend theme with specific hex codes:
#D4C5B0 (Sand), #8F9E8A (Sage), #BC6C25 (Clay), #F5F3EE (Off-white).
- Texture: I will add a fixed
div with a base64 noise image (or generate with CSS) covering the screen with mix-blend-mode: overlay and pointer-events: none.
-
Writing the Actual Code (Iterative assembly):
- HTML Head: Libraries, Google Fonts.
- Styles: Custom scrollbar, noise texture class, glass utility classes.
- Body:
#canvas-container for Three.js.
#noise-overlay.
<header> with logo and stats.
<main> with filters and grid.
<dialog id="prompt-modal">.
<div id="toast-container">.
- JS:
- Three.js setup: Scene, OrthographicCamera (since it's 2D), PlaneGeometry with ShaderMaterial. Uniforms:
u_time, u_resolution. Fragment shader: mix colors based on smooth noise derived from coordinates and time. Colors are pastel.
- Data:
const prompts = [...]. Status options: ['Draft', 'Pending Review', 'Approved', 'Rejected'].
- Render Logic:
- Clear grid.
- Loop through filtered prompts.
- Create DOM elements string or nodes.
- Assign IDs.
- GSAP animation:
gsap.from(".card", { y: 50, opacity: 0, stagger: 0.1, duration: 0.8, ease: "power2.out" }).
- Modal Logic: Open to create/edit. Populate fields on click.
- Approval Logic: Simple state change. Re-render.
- Toast Logic: Append fixed div, animate in, wait, animate out, remove.
-
Polishing the "Slow Media" Aspect:
- Hover states:
transition: all 1.5s cubic-bezier(...).
- Button clicks: Scale down slightly then back up.
- Modal open: Scale and fade in over 0.6s.
-
Final Review against constraints:
- Single file? Yes.
- No frameworks? Yes (Tailwind, Three, GSAP are libs, not frameworks like React).
- Biophilic? Yes (colors, shapes, noise, organic background).
- Functional? Yes (CRUD, filter, metrics).
-
Code Construction (Mental Check of the Shader):
- Need a noise function in GLSL. I'll include a standard Perlin noise function snippet inside the shader string to ensure organic movement.
- Colors:
vec3(0.8, 0.85, 0.78), vec3(0.5, 0.6, 0.55), vec3(0.7, 0.65, 0.55).
-
Final Output Generation: (Produce the code block). Ensure comments explain the Biophilic choices.
(Self-Correction during coding):
Make sure the text is readable against the Three.js background. I'll put a semi-transparent backing (the "paper" layer) behind the content or ensure the glass cards have enough opacity. Actually, I'll use a bg-stone-50/80 backing for the main content area to ensure contrast, creating a "sheet of paper" floating above the organic background.
Let's build it.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>The Prompt Grove | AI Registry</title>
<!-- Fonts: Playfair Display (Serif) & Inter (Sans) -->
<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=Playfair+Display:ital,wght@0,400;0,600;1,400&display=swap" rel="stylesheet">
<!-- Tailwind CSS -->
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
sans: ['Inter', 'sans-serif'],
serif: ['Playfair Display', 'serif'],
},
colors: {
// Biophilic / Wabi-Sabi Palette
clay: {
100: '#e8e0d5',
200: '#dccabf',
300: '#c4a98c',
400: '#b08c66',
},
sage: {
50: '#f4f8f4',
100: '#e3ebe3',
200: '#c7dcc7',
300: '#a8c5a8',
400: '#82a682',
},
night: {
200: '#4a5046', // Soft charcoal
300: '#2f3329',
},
paper: {
base: '#fdfcfa', // Warm white
overlay: '#f7f5f0'
}
},
boxShadow: {
'soft': '0 8px 32px 0 rgba(31, 38, 135, 0.07)',
'glow': '0 0 20px rgba(168, 197, 168, 0.3)',
},
animation: {
'float': 'float 6s ease-in-out infinite',
},
keyframes: {
float: {
'0%, 100%': { transform: 'translateY(0)' },
'50%': { transform: 'translateY(-8px)' },
}
}
}
}
}
</script>
<!-- GSAP -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.12.2/gsap.min.js"></script>
<!-- Three.js -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
<style>
/* Base Styles & Noise Texture */
body {
color: #2f3329;
overflow-x: hidden;
background-color: #fdfcfa;
}
.noise-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
pointer-events: none;
z-index: 50;
opacity: 0.07;
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.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
}
/* Glassmorphism but Paper-like */
.glass-panel {
background: rgba(255, 253, 250, 0.85);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.6);
box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.05);
}
.glass-panel-darker {
background: rgba(255, 255, 255, 0.65);
border: 1px solid rgba(255, 255, 255, 0.5);
}
/* Organic Radius */
.rounded-blob {
border-radius: 2rem 1.5rem 2.5rem 1.8rem;
}
.rounded-blob-hover:hover {
border-radius: 2.5rem 2rem 2rem 2.5rem;
transition: border-radius 1.5s ease-in-out;
}
/* Smooth Scrolling */
html { scroll-behavior: smooth; }
/* Custom scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4a98c; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #b08c66; }
/* Modal backdrop */
dialog::backdrop {
background: rgba(47, 51, 41, 0.3);
backdrop-filter: blur(4px);
}
</style>
</head>
<body class="antialiased min-h-screen flex flex-col">
<!-- Three.js Background -->
<div id="canvas-container" class="fixed inset-0 z-0 pointer-events-none"></div>
<!-- Noise Overlay -->
<div class="noise-overlay"></div>
<!-- Main Interface Layer -->
<div class="relative z-10 container mx-auto px-6 py-8 flex-1 max-w-7xl">
<!-- Header -->
<header class="mb-12 flex flex-col md:flex-row justify-between items-end md:items-center gap-6 animate-fade-in-up">
<div>
<div class="flex items-center gap-3 text-sage-500 mb-2 font-sans text-sm tracking-widest uppercase">
<span class="w-2 h-2 bg-sage-400 rounded-full animate-pulse"></span>
<span>Registry</span>
</div>
<h1 class="text-4xl md:text-5xl font-serif font-medium text-night-200 leading-tight">
The Prompt Grove
</h1>
<p class="mt-2 text-night-200/70 max-w-md leading-relaxed">
A sanctuary for nurturing AI prompts. Approve, refine, and watch your ideas grow.
</p>
</div>
<!-- Quick Stats (Organic Cards) -->
<div class="flex gap-4 w-full md:w-auto">
<div class="glass-panel rounded-blob p-4 flex-1 md:flex-none min-w-[120px] text-center md:text-right transform hover:scale-105 transition-transform duration-700 ease-out">
<div class="text-xs text-sage-500 uppercase tracking-wide">Total</div>
<div class="text-2xl font-serif font-medium text-night-200 mt-1" id="stat-total">0</div>
</div>
<div class="glass-panel rounded-blob p-4 flex-1 md:flex-none min-w-[120px] text-center md:text-right transform hover:scale-105 transition-transform duration-700 ease-out">
<div class="text-xs text-sage-500 uppercase tracking-wide">Live</div>
<div class="text-2xl font-serif font-medium text-clay-400 mt-1" id="stat-approved">0</div>
</div>
<div class="glass-panel rounded-blob p-4 flex-1 md:flex-none min-w-[120px] text-center md:text-right transform hover:scale-105 transition-transform duration-700 ease-out">
<div class="text-xs text-sage-500 uppercase tracking-wide">Avg. Success</div>
<div class="text-2xl font-serif font-medium text-clay-400 mt-1" id="stat-score">0%</div>
</div>
</div>
</header>
<!-- Controls -->
<section class="mb-10 flex flex-col md:flex-row gap-4 justify-between items-center">
<div class="relative w-full md:w-96 group">
<input type="text" id="search-input" placeholder="Search the grove..."
class="w-full bg-white/40 border border-sage-200/50 rounded-blob pl-10 pr-4 py-3 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300 focus:border-transparent transition-all duration-300 placeholder:text-gray-400 text-night-200/80">
<!-- Search Icon SVG -->
<svg class="w-4 h-4 text-gray-400 absolute left-4 top-4 group-focus-within:text-sage-500 transition-colors" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path></svg>
</div>
<div class="flex gap-3 w-full md:w-auto">
<select id="filter-status" class="bg-white/40 border border-sage-200/50 rounded-blob px-5 py-3 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300 cursor-pointer transition-all">
<option value="All">All Statuses</option>
<option value="Draft">Draft</option>
<option value="Pending Review">Pending</option>
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
</select>
<button onclick="modalManager.openCreate()"
class="bg-sage-500/90 hover:bg-sage-500 text-white rounded-blob px-6 py-3 font-serif italic flex items-center gap-2 shadow-soft hover:shadow-glow transition-all duration-500 transform active:scale-95">
<span>+ New Seed</span>
</button>
</div>
</section>
<!-- Prompt Grid -->
<main id="prompt-grid" class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6 pb-20">
<!-- Cards injected via JS -->
</main>
</div>
<!-- Modal (Editor) -->
<dialog id="prompt-modal" class="open:flex fixed inset-0 z-50 items-center justify-center p-4 opacity-0 pointer-events-none transition-opacity duration-500">
<div class="glass-panel-darker rounded-3xl p-8 w-full max-w-2xl relative shadow-soft transform scale-95 transition-transform duration-500" id="modal-content">
<button onclick="modalManager.close()" class="absolute top-6 right-6 text-night-200/50 hover:text-night-200 transition-colors">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path></svg>
</button>
<div class="flex items-start gap-4 mb-6">
<div class="p-3 bg-sage-100/50 rounded-full text-sage-500">
<svg class="w-6 h-6" 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.384-.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>
<div>
<h2 id="modal-title" class="text-2xl font-serif text-night-300 mb-1">Create New Prompt</h2>
<p class="text-sm text-night-200/60">Define the variables and track the performance.</p>
</div>
</div>
<form id="prompt-form" class="space-y-5">
<input type="hidden" id="prompt-id">
<div class="grid grid-cols-2 gap-6">
<div class="col-span-2 md:col-span-1">
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Name</label>
<input type="text" id="input-name" required class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-3 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300 transition-all">
</div>
<div class="col-span-2 md:col-span-1">
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Status</label>
<select id="input-status" class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-3 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300 cursor-pointer">
<option value="Draft">Draft</option>
<option value="Pending Review">Pending Review</option>
<option value="Approved">Approved</option>
<option value="Rejected">Rejected</option>
</select>
</div>
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Prompt Content</label>
<textarea id="input-content" required rows="4" class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-3 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300 resize-none transition-all" placeholder="The exact input given to the model..."></textarea>
</div>
<!-- Metrics Section -->
<div class="grid grid-cols-3 gap-4 pt-4 border-t border-sage-200/30">
<div>
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Latency (ms)</label>
<input type="number" id="input-latency" class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-2 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300">
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Tokens</label>
<input type="number" id="input-tokens" class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-2 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300">
</div>
<div>
<label class="block text-xs font-bold uppercase tracking-widest text-night-200/60 mb-2">Success Score (1-100)</label>
<input type="number" id="input-score" min="0" max="100" class="w-full bg-white/40 border border-sage-200/50 rounded-2xl px-4 py-2 font-sans text-sm focus:outline-none focus:ring-2 focus:ring-sage-300">
</div>
</div>
<!-- Actions -->
<div class="flex justify-end gap-4 pt-4">
<button type="button" onclick="modalManager.close()" class="px-6 py-3 rounded-full text-sm font-medium text-night-200/60 hover:text-night-200 transition-colors">Cancel</button>
<button type="submit" class="px-8 py-3 rounded-full bg-clay-300/20 text-clay-500 font-serif hover:bg-clay-300/30 transition-all duration-500 border border-clay-200/50 hover:border-clay-300 shadow-sm hover:shadow-md">
Save Changes
</button>
</div>
</form>
</div>
</dialog>
<!-- Toast Notification -->
<div id="toast-container" class="fixed bottom-8 right-8 z-50 flex flex-col gap-3"></div>
<!-- JavaScript Logic -->
<script>
// ==========================================
// 1. DATA & STATE MANAGEMENT
// ==========================================
// Initial mock data - The Grove
const initialPrompts = [
{
id: 'p1',
name: 'Welcome Bot',
status: 'Approved',
content: 'You are a friendly assistant for {client_name}. Welcome them warmly to the service and provide a brief summary of their current plan ({plan}).',
metrics: { latency: 340, tokens: 150, score: 98 },
lastUpdated: '2023-10-24'
},
{
id: 'p2',
name: 'Debugging Python',
status: 'Pending Review',
content: 'Analyze the following Python traceback and explain the root cause to a junior developer in simple terms: {traceback}.',
metrics: { latency: 540, tokens: 420, score: 85 },
lastUpdated: '2023-10-25'
},
{
id: 'p3',
name: 'Sentiment Analysis',
status: 'Draft',
content: 'Classify the sentiment of the user review into Positive, Neutral, or Negative. If Negative, suggest a empathetic response template. Review: {text}',
metrics: { latency: 120, tokens: 90, score: 0 },
lastUpdated: '2023-10-26'
},
{
id: 'p4',
name: 'Code Refactor',
status: 'Rejected',
content: 'Refactor this {language} code to be more efficient: {code}. But do not change the logic.',
metrics: { latency: 1200, tokens: 800, score: 45 },
lastUpdated: '2023-10-22'
},
{
id: 'p5',
name: 'Marketing Email',
status: 'Approved',
content: 'Write a catchy subject line and a 3-paragraph email body for the product launch of {product_name}. Target audience: {audience}.',
metrics: { latency: 850, tokens: 300, score: 92 },
lastUpdated: '2023-10-27'
},
{
id: 'p6',
name: 'Legal Clause Validity',
status: 'Draft',
content: 'Read the contract clause: {clause}. Determine if it is legally binding under common law. Highlight ambiguous terms.',
metrics: { latency: 2200, tokens: 1500, score: 0 },
lastUpdated: '2023-10-28'
}
];
class AppState {
constructor() {
this.prompts = [...initialPrompts];
this.filter = 'All';
this.search = '';
}
getFiltered() {
return this.prompts.filter(p => {
const matchesStatus = this.filter === 'All' || p.status === this.filter;
const matchesSearch = p.name.toLowerCase().includes(this.search.toLowerCase()) ||
p.content.toLowerCase().includes(this.search.toLowerCase());
return matchesStatus && matchesSearch;
});
}
add(prompt) {
prompt.id = 'p' + Date.now();
prompt.metrics = { latency: 0, tokens: 0, score: 0 }; // Default empty
this.prompts.unshift(prompt);
this.notify();
}
update(updatedPrompt) {
const index = this.prompts.findIndex(p => p.id === updatedPrompt.id);
if (index !== -1) {
this.prompts[index] = { ...this.prompts[index], ...updatedPrompt };
}
this.notify();
}
notify() {
render();
}
}
const appState = new AppState();
// ==========================================
// 2. UI RENDERING & ANIMATION
// ==========================================
const grid = document.getElementById('prompt-grid');
const statTotal = document.getElementById('stat-total');
const statApproved = document.getElementById('stat-approved');
const statScore = document.getElementById('stat-score');
function getStatusColor(status) {
switch (status) {
case 'Approved': return 'bg-green-100 text-green-800 border-green-200';
case 'Rejected': return 'bg-red-50 text-red-800 border-red-100';
case 'Pending Review': return 'bg-blue-50 text-blue-800 border-blue-100';
default: return 'bg-gray-100 text-gray-600 border-gray-200';
}
}
function createCardElement(prompt) {
const card = document.createElement('article');
card.className = 'glass-panel rounded-blob-hover p-6 flex flex-col gap-4 relative h-full transition-all duration-700 ease-out cursor-pointer group';
card.dataset.id = prompt.id;
// Add subtle random rotation only on load variation would be JS logic, keeping it flat for now per Wabi-sabi "imperfect but calm"
// Formatting metrics
const metricsColor = prompt.status === 'Approved' ? 'text-clay-500' : 'text-gray-400';
card.innerHTML = `
<div class="flex justify-between items-start">
<div class="flex-1 pr-2">
<h3 class="font-serif text-lg font-medium text-night-300 group-hover:text-sage-700 transition-colors">${prompt.name}</h3>
<div class="text-xs text-night-200/40 font-mono mt-1">ID: ${prompt.id}</div>
</div>
<span class="text-xs font-bold px-3 py-1 rounded-2xl border ${getStatusColor(prompt.status)} whitespace-nowrap">
${prompt.status}
</span>
</div>
<p class="text-night-200/80 font-sans text-sm leading-relaxed line-clamp-3 flex-1">
${prompt.content}
</p>
<div class="pt-3 border-t border-sage-100/50 mt-2">
<div class="flex justify-between items-center mb-2">
<span class="text-xs uppercase tracking-wider text-night-200/40">Performance</span>
<div class="text-xs font-mono text-night-200/60">
${prompt.metrics.score > 0 ? prompt.metrics.score + '%' : '--'}
</div>
</div>
<!-- Mini Metric Bar Visualization -->
<div class="flex items-center gap-4">
<div class="flex-1 h-1 bg-sage-100/50 rounded-full overflow-hidden">
<div class="h-full bg-sage-300 transition-all duration-1000" style="width: ${prompt.metrics.score}%"></div>
</div>
<div class="w-12 text-right font-mono text-xs text-night-200/50">
${prompt.metrics.latency > 0 ? prompt.metrics.latency + 'ms' : '--'}
</div>
</div>
</div>
<div class="flex justify-end gap-2 mt-2 opacity-0 group-hover:opacity-100 transition-opacity duration-500">
<button onclick="app.edit('${prompt.id}')" class="p-2 hover:bg-sage-100/50 rounded-lg text-night-200/60 hover:text-sage-700 transition-colors" title="Edit">
<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="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"></path></svg>
</button>
${prompt.status !== 'Approved' && prompt.status !== 'Rejected' ? `
<button onclick="app.approve('${prompt.id}')" class="p-2 hover:bg-green-100/50 rounded-lg text-night-200/60 hover:text-green-700 transition-colors" title="Approve">
<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="M5 13l4 4L19 7"></path></svg>
</button>` : ''}
</div>
<!-- Decorative organic blob on hover -->
<div class="absolute -inset-2 bg-sage-200/10 rounded-[2.5rem] -z-10 scale-0 group-hover:scale-100 transition-transform duration-700 ease-out origin-center"></div>
`;
return card;
}
function render() {
grid.innerHTML = '';
const filtered = appState.getFiltered();
// Update Stats
statTotal.textContent = filtered.length;
const approved = filtered.filter(p => p.status === 'Approved').length;
statApproved.textContent = approved;
const totalScore = filtered.reduce((sum, p) => sum + (p.metrics.score || 0), 0);
const avgScore = filtered.length ? Math.round(totalScore / filtered.length) : 0;
statScore.textContent = avgScore + '%';
if (filtered.length === 0) {
grid.innerHTML = `
<div class="col-span-full py-20 text-center text-night-200/40 font-serif text-xl italic">
The grove is quiet... no prompts match your search.
</div>
`;
return;
}
const fragment = document.createDocumentFragment();
filtered.forEach(prompt => {
fragment.appendChild(createCardElement(prompt));
});
grid.appendChild(fragment);
// Entry Animation
gsap.fromTo('.glass-panel',
{ y: 40, opacity: 0 },
{ y: 0, opacity: 1, duration: 0.8, stagger: 0.1, ease: 'power3.out' }
);
}
// ==========================================
// 3. INTERACTION HANDLERS
// ==========================================
// Toast System
function showToast(message, type = 'info') {
const container = document.getElementById('toast-container');
const toast = document.createElement('div');
const colors = type === 'success' ? 'bg-sage-500/90 text-white' : 'bg-night-200/90 text-white';
toast.className = `${colors} px-6 py-4 rounded-blob shadow-soft flex items-center gap-3 transform translate-y-10 opacity-0 transition-all duration-700 border border-white/20 backdrop-blur-sm`;
toast.innerHTML = `
<span>${message}</span>
`;
container.appendChild(toast);
// Animate in
requestAnimationFrame(() => {
gsap.to(toast, { y: 0, opacity: 1, duration: 0.5, ease: 'back.out(1.7)' });
});
// Remove after delay
setTimeout(() => {
gsap.to(toast, { y: 20, opacity: 0, duration: 0.4, ease: 'power2.in', onComplete: () => toast.remove() });
}, 3000);
}
// App Controller
const app = {
edit: (id) => {
const prompt = appState.prompts.find(p => p.id === id);
if (prompt) {
modalManager.openEdit(prompt);
}
},
approve: (id) => {
const prompt = appState.prompts.find(p => p.id === id);
if (prompt) {
prompt.status = 'Approved';
prompt.metrics.score = prompt.metrics.score || 80; // Simulate score if 0
appState.notify();
showToast(`'${prompt.name}' has been blessed with approval.`, 'success');
}
}
};
// Search & Filter
document.getElementById('search-input').addEventListener('input', (e) => {
appState.search = e.target.value;
render();
});
document.getElementById('filter-status').addEventListener('change', (e) => {
appState.filter = e.target.value;
render();
});
// ==========================================
// 4. MODAL LOGIC
// ==========================================
const modal = document.getElementById('prompt-modal');
const modalContent = document.getElementById('modal-content');
const form = document.getElementById('prompt-form');
const modalTitle = document.getElementById('modal-title');
const modalManager = {
openCreate: () => {
form.reset();
document.getElementById('prompt-id').value = '';
modalTitle.textContent = 'Plant a New Seed';
modal.showModal();
modalContent.classList.remove('scale-95');
modalContent.classList.add('scale-100');
gsap.from(modalContent, { scale: 0.95, duration: 0.5, ease: 'elastic.out(1, 0.7)' });
},
openEdit: (prompt) => {
document.getElementById('prompt-id').value = prompt.id;
document.getElementById('input-name').value = prompt.name;
document.getElementById('input-content').value = prompt.content;
document.getElementById('input-status').value = prompt.status;
document.getElementById('input-latency').value = prompt.metrics.latency || '';
document.getElementById('input-tokens').value = prompt.metrics.tokens || '';
document.getElementById('input-score').value = prompt.metrics.score || '';
modalTitle.textContent = 'Tend to Prompt';
modal.showModal();
modalContent.classList.remove('scale-95');
modalContent.classList.add('scale-100');
gsap.from(modalContent, { scale: 0.95, duration: 0.5, ease: 'elastic.out(1, 0.7)' });
},
close: () => {
const tl = gsap.timeline();
tl.to(modalContent, { scale: 0.95, duration: 0.3, ease: 'power2.in' });
tl.call(() => modal.close());
}
};
// Close modal on backdrop click
modal.addEventListener('click', (e) => {
if (e.target === modal) modalManager.close();
});
// Form Submit
form.addEventListener('submit', (e) => {
e.preventDefault();
const id = document.getElementById('prompt-id').value;
const data = {
name: document.getElementById('input-name').value,
content: document.getElementById('input-content').value,
status: document.getElementById('input-status').value,
metrics: {
latency: parseInt(document.getElementById('input-latency').value) || 0,
tokens: parseInt(document.getElementById('input-tokens').value) || 0,
score: parseInt(document.getElementById('input-score').value) || 0
}
};
if (id) {
// Edit
data.id = id;
appState.update(data);
showToast(`'${data.name}' has been updated.`);
} else {
// Create
appState.add(data);
showToast('A new seed has been planted.', 'success');
}
modalManager.close();
});
// ==========================================
// 5. THREE.JS ORGANIC BACKGROUND
// ==========================================
function 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);
// Shader Material
const vertexShader = `
varying vec2 vUv;
void main() {
vUv = uv;
gl_Position = vec4(position, 1.0);
}
`;
// Colors: Soft Sage / Sand mix
const color1 = new THREE.Color('#e3ebe3'); // Light sage
const color2 = new THREE.Color('#dccabf'); // Sand
const color3 = new THREE.Color('#c7dcc7'); // Green tint
const fragmentShader = `
uniform float u_time;
uniform vec2 u_resolution;
varying vec2 vUv;
// Simple noise function
vec3 hsb2rgb(in vec3 c){
vec3 rgb = clamp(abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),
6.0)-3.0)-1.0,
0.0,
1.0 );
rgb = rgb*rgb*(3.0-2.0*rgb);
return c.z * mix(vec3(1.0), rgb, c.y);
}
float random (in vec2 st) {
return fract(sin(dot(st.xy, vec2(12.9898,78.233))) * 43758.5453123);
}
float noise (in vec2 st) {
vec2 i = floor(st);
vec2 f = fract(st);
float a = random(i);
float b = random(i + vec2(1.0, 0.0));
float c = random(i + vec2(0.0, 1.0));
float d = random(i + vec2(1.0, 1.0));
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(a, b, u.x) + (c - a)* u.y * (1.0 - u.x) + (d - b) * u.x * u.y;
}
void main() {
vec2 st = vUv * 3.0; // Scale noise
float n = noise(st + u_time * 0.1);
float n2 = noise(st * 2.0 - u_time * 0.15);
float finalNoise = mix(n, n2, 0.5);
// Create organic color mixing
vec3 color1 = vec3(0.89, 0.92, 0.89); // #e3ebe3
vec3 color2 = vec3(0.86, 0.79, 0.75); // #dccabf
vec3 color3 = vec3(0.78, 0.86, 0.78); // #c7dcc7
vec3 color = mix(color1, color2, finalNoise);
color = mix(color, color3, n2 * 0.3);
// Vignette
float dist = distance(vUv, vec2(0.5));
color *= smoothstep(0.8, 0.2, dist);
gl_FragColor = vec4(color, 0.6);
}
`;
const uniforms = {
u_time: { value: 0.0 },
u_resolution: { value: new THREE.Vector2(window.innerWidth, window.innerHeight) }
};
const geometry = new THREE.PlaneGeometry(2, 2);
const material = new THREE.ShaderMaterial({
uniforms: uniforms,
vertexShader: vertexShader,
fragmentShader: fragmentShader
});
const plane = new THREE.Mesh(geometry, material);
scene.add(plane);
function animate() {
requestAnimationFrame(animate);
uniforms.u_time.value += 0.01;
renderer.render(scene, camera);
}
animate();
// Resize handler
window.addEventListener('resize', () => {
renderer.setSize(window.innerWidth, window.innerHeight);
uniforms.u_resolution.value.set(window.innerWidth, window.innerHeight);
});
}
// Initialize everything on load
window.addEventListener('DOMContentLoaded', () => {
initThreeJS();
render();
});
</script>
</body>
</html>