File size: 17,664 Bytes
499a14d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | <!DOCTYPE html>
<html lang="en" class="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ComponentForge - AI Scope Generation</title>
<link rel="icon" type="image/x-icon" href="/static/favicon.ico">
<link rel="stylesheet" href="style.css">
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
<script src="https://unpkg.com/feather-icons"></script>
</head>
<body class="bg-gray-900 text-white min-h-screen">
<custom-header></custom-header>
<main class="container mx-auto px-4 py-8">
<div class="max-w-6xl mx-auto">
<!-- Progress Bar -->
<div class="mb-8">
<div class="flex items-center justify-between mb-2">
<span class="text-sm text-gray-400">Step 2 of 3</span>
<span class="text-sm text-purple-400">AI Scope Generation</span>
</div>
<div class="w-full bg-gray-700 rounded-full h-2">
<div class="bg-gradient-to-r from-purple-500 to-pink-500 h-2 rounded-full w-2/3"></div>
</div>
<!-- Project Info -->
<div class="bg-gray-800 rounded-xl p-6 mb-6 border border-gray-700">
<div class="flex items-center justify-between">
<div>
<h2 class="text-xl font-bold" id="projectTitle">Project: Loading...</h2>
<p class="text-gray-400 mt-1" id="projectDesc"></p>
</div>
<button onclick="window.location.href = 'index.html'" class="text-gray-400 hover:text-white transition-colors">
<i data-feather="edit" class="w-5 h-5"></i>
</button>
</div>
</div>
<!-- AI Scope Generator -->
<div class="grid lg:grid-cols-2 gap-8">
<!-- Left Column - Input -->
<div class="space-y-6">
<!-- Component Type Selection -->
<div class="bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="grid" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Component Type</h3>
</div>
<div class="grid grid-cols-2 gap-3">
<button class="component-type-btn bg-gray-700 hover:bg-purple-600 p-4 rounded-lg border border-gray-600 hover:border-purple-500 transition-all duration-200" data-type="button">
<i data-feather="mouse-pointer" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Button</span>
</button>
<button class="component-type-btn bg-gray-700 hover:bg-pink-600 p-4 rounded-lg border border-gray-600 hover:border-pink-500 transition-all duration-200" data-type="input">
<i data-feather="edit" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Input</span>
</button>
<button class="component-type-btn bg-gray-700 hover:bg-blue-600 p-4 rounded-lg border border-gray-600 hover:border-blue-500 transition-all duration-200" data-type="select">
<i data-feather="chevron-down" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Select</span>
</button>
<button class="component-type-btn bg-gray-700 hover:bg-green-600 p-4 rounded-lg border border-gray-600 hover:border-green-500 transition-all duration-200" data-type="modal">
<i data-feather="square" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Modal</span>
</button>
<button class="component-type-btn bg-gray-700 hover:bg-yellow-600 p-4 rounded-lg border border-gray-600 hover:border-yellow-500 transition-all duration-200" data-type="menu">
<i data-feather="menu" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Menu</span>
</button>
<button class="component-type-btn bg-gray-700 hover:bg-indigo-600 p-4 rounded-lg border border-gray-600 hover:border-indigo-500 transition-all duration-200" data-type="tabs">
<i data-feather="folder" class="w-6 h-6 mb-2 mx-auto"></i>
<span class="text-sm font-medium">Tabs</span>
</button>
</div>
<!-- Additional Requirements -->
<div class="bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="list" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Additional Requirements</h3>
</div>
<textarea
id="additionalReqs"
class="w-full px-4 py-3 bg-gray-700 border border-gray-600 rounded-lg focus:ring-2 focus:ring-purple-500 focus:border-transparent text-white placeholder-gray-400 resize-none transition-all duration-200"
rows="3"
placeholder="Any specific behaviors, accessibility requirements, or custom features?"
></textarea>
</div>
<!-- Generate Button -->
<button
id="generateScopeBtn"
class="w-full px-6 py-4 bg-gradient-to-r from-purple-600 to-pink-600 hover:from-purple-700 hover:to-pink-700 text-white font-semibold rounded-lg transition-all duration-200 transform hover:scale-105 focus:ring-4 focus:ring-purple-500 focus:ring-opacity-50 flex items-center justify-center"
>
<i data-feather="zap" class="w-5 h-5 mr-2"></i>
Generate AI Scope
</button>
</div>
<!-- Right Column - AI Output -->
<div class="space-y-6">
<!-- Loading State -->
<div id="loadingState" class="hidden bg-gray-800 rounded-xl p-8 border border-gray-700 text-center">
<div class="animate-spin rounded-full h-12 w-12 border-b-2 border-purple-500 mx-auto mb-4"></div>
<p class="text-gray-300">AI is analyzing your requirements and generating optimal component scope...</p>
</div>
<!-- Framework Selection -->
<div id="frameworkSection" class="hidden bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="smartphone" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Target Framework</h3>
</div>
<div class="grid grid-cols-2 gap-4">
<button class="framework-btn bg-gray-700 hover:bg-purple-600 p-4 rounded-lg border border-gray-600 transition-all duration-200" data-framework="react-web">
<i data-feather="globe" class="w-8 h-8 mb-3 mx-auto"></i>
<span class="text-sm font-medium">React Web</span>
<p class="text-xs text-gray-400 mt-1">With react-aria hooks</p>
</button>
<button class="framework-btn bg-gray-700 hover:bg-pink-600 p-4 rounded-lg border border-gray-600 transition-all duration-200" data-framework="react-native">
<i data-feather="smartphone" class="w-8 h-8 mb-3 mx-auto"></i>
<span class="text-sm font-medium">React Native</span>
<p class="text-xs text-gray-400 mt-1">With native APIs</p>
</button>
</div>
</div>
<!-- Hooks & Behaviors -->
<div id="hooksSection" class="hidden bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="anchor" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Suggested Hooks & Behaviors</h3>
</div>
<div id="hooksList" class="space-y-2">
<!-- Hooks will be populated here -->
</div>
</div>
<!-- Data Attributes -->
<div id="attributesSection" class="hidden bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="database" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Data Attributes</h3>
</div>
<div id="attributesList" class="space-y-2">
<!-- Attributes will be populated here -->
</div>
</div>
<!-- Code Structure -->
<div id="structureSection" class="hidden bg-gray-800 rounded-xl p-6 border border-gray-700">
<div class="flex items-center mb-4">
<i data-feather="code" class="w-6 h-6 text-purple-500 mr-3"></i>
<h3 class="text-lg font-semibold">Code Structure</h3>
</div>
<div class="grid grid-cols-2 gap-4">
<button class="structure-btn bg-gray-700 hover:bg-purple-600 p-4 rounded-lg border border-gray-600 transition-all duration-200" data-structure="typed-primitives">
<i data-feather="type" class="w-8 h-8 mb-3 mx-auto"></i>
<span class="text-sm font-medium">Typed Primitives</span>
<p class="text-xs text-gray-400 mt-1">Combined approach</p>
</button>
<button class="structure-btn bg-gray-700 hover:bg-pink-600 p-4 rounded-lg border border-gray-600 transition-all duration-200" data-structure="adapter-pattern">
<i data-feather="layers" class="w-8 h-8 mb-3 mx-auto"></i>
<span class="text-sm font-medium">Adapter Pattern</span>
<p class="text-xs text-gray-400 mt-1">Separated behaviors</p>
</button>
</div>
</div>
<!-- Continue Button -->
<div id="continueSection" class="hidden">
<button
id="continueBtn"
class="w-full px-6 py-4 bg-gradient-to-r from-green-600 to-emerald-600 hover:from-green-700 hover:to-emerald-700 text-white font-semibold rounded-lg transition-all duration-200 transform hover:scale-105 focus:ring-4 focus:ring-green-500 focus:ring-opacity-50 flex items-center justify-center"
>
<i data-feather="arrow-right" class="w-5 h-5 mr-2"></i>
Continue to Code Generation
</button>
</div>
</div>
</div>
</main>
<custom-footer></custom-footer>
<script src="components/header.js"></script>
<script src="components/footer.js"></script>
<script src="script.js"></script>
<script>
feather.replace();
// Load project data
document.addEventListener('DOMContentLoaded', function() {
const projectData = StorageManager.getProjectData();
document.getElementById('projectTitle').textContent = `Project: ${projectData.name}`;
document.getElementById('projectDesc').textContent = projectData.description;
// Component type selection
document.querySelectorAll('.component-type-btn').forEach(btn => {
btn.addEventListener('click', function() {
document.querySelectorAll('.component-type-btn').forEach(b => b.classList.remove('bg-purple-600', 'bg-pink-600', 'bg-blue-600', 'bg-green-600', 'bg-yellow-600', 'bg-indigo-600'));
this.classList.add(this.classList.contains('hover:bg-purple-600') ? 'bg-purple-600' :
this.classList.contains('hover:bg-pink-600') ? 'bg-pink-600' :
this.classList.contains('hover:bg-blue-600') ? 'bg-blue-600' :
this.classList.contains('hover:bg-green-600') ? 'bg-green-600' :
this.classList.contains('hover:bg-yellow-600') ? 'bg-yellow-600' : 'bg-indigo-600');
});
});
// Generate scope
document.getElementById('generateScopeBtn').addEventListener('click', async function() {
const selectedType = document.querySelector('.component-type-btn.bg-purple-600, .component-type-btn.bg-pink-600, .component-type-btn.bg-blue-600, .component-type-btn.bg-green-600, .component-type-btn.bg-yellow-600, .component-type-btn.bg-indigo-600')?.dataset.type || 'button';
const additionalReqs = document.getElementById('additionalReqs').value;
// Show loading
document.getElementById('loadingState').classList.remove('hidden');
try {
const scope = await AIService.generateComponentScope(projectData.description, selectedType);
// Store scope
localStorage.setItem('projectScope', JSON.stringify(scope));
// Hide loading, show results
document.getElementById('loadingState').classList.add('hidden');
document.getElementById('frameworkSection').classList.remove('hidden');
document.getElementById('hooksSection').classList.remove('hidden');
document.getElementById('attributesSection').classList.remove('hidden');
document.getElementById('structureSection').classList.remove('hidden');
// Populate hooks
const hooksList = document.getElementById('hooksList');
hooksList.innerHTML = scope.suggestedHooks.map(hook => `
<div class="flex items-center p-3 bg-gray-700 rounded-lg border border-gray-600">
<i data-feather="check-circle" class="w-4 h-4 text-green-500 mr-3"></i>
<span class="text-sm font-mono">${hook}</span>
`).join('');
// Populate attributes
const attributesList = document.getElementById('attributesList');
attributesList.innerHTML = scope.dataAttributes.map(attr => `
<div class="flex items-center p-3 bg-gray-700 rounded-lg border border-gray-600">
<i data-feather="tag" class="w-4 h-4 text-blue-500 mr-3"></i>
<span class="text-sm font-mono">${attr}</span>
</div>
`).join('');
} catch (error) {
console.error('Error generating scope:', error);
document.getElementById('loadingState').classList.add('hidden');
alert('Error generating scope. Please try again.');
}
});
// Framework selection
document.querySelectorAll('.framework-btn').forEach(btn => {
btn.addEventListener('click', function() {
document.querySelectorAll('.framework-btn').forEach(b => b.classList.remove('bg-purple-600', 'bg-pink-600'));
this.classList.add(this.classList.contains('hover:bg-purple-600') ? 'bg-purple-600' : 'bg-pink-600');
localStorage.setItem('selectedFramework', this.dataset.framework);
document.getElementById('continueSection').classList.remove('hidden');
});
// Structure selection
document.querySelectorAll('.structure-btn').forEach(btn => {
btn.addEventListener('click', function() {
document.querySelectorAll('.structure-btn').forEach(b => b.classList.remove('bg-purple-600', 'bg-pink-600'));
this.classList.add(this.classList.contains('hover:bg-purple-600') ? 'bg-purple-600' : 'bg-pink-600');
localStorage.setItem('selectedCodeStructure', this.dataset.structure);
});
// Continue to next page
document.getElementById('continueBtn').addEventListener('click', function() {
window.location.href = 'code.html';
});
});
</script>
</body>
</html> |