import { useState, useEffect } from 'react';
export default function DemoSelector({ onDemoSelect, currentDemo }) {
const [demos, setDemos] = useState([]);
const [categories, setCategories] = useState([]);
const [loading, setLoading] = useState(true);
const [selectedCategory, setSelectedCategory] = useState('all');
useEffect(() => {
fetch('/demos.json')
.then(res => res.json())
.then(data => {
setDemos(data.demos);
setCategories(data.categories);
setLoading(false);
})
.catch(err => {
console.error('Failed to load demos:', err);
setLoading(false);
});
}, []);
const filteredDemos = selectedCategory === 'all'
? demos
: demos.filter(demo => demo.category === selectedCategory);
if (loading) {
return (
);
}
return (
Choose a Demo
{/* Category Filter */}
{categories.map(category => (
))}
{/* Demo Grid */}
{filteredDemos.map(demo => (
onDemoSelect(demo)}
>

{
e.target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAwIiBoZWlnaHQ9IjIwMCIgdmlld0JveD0iMCAwIDMwMCAyMDAiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHdpZHRoPSIzMDAiIGhlaWdodD0iMjAwIiBmaWxsPSIjRjNGNEY2Ii8+Cjx0ZXh0IHg9IjE1MCIgeT0iMTAwIiB0ZXh0LWFuY2hvcj0ibWlkZGxlIiBmaWxsPSIjOUI5QkEwIiBmb250LWZhbWlseT0iQXJpYWwiIGZvbnQtc2l6ZT0iMTQiPkltYWdlIE5vdCBGb3VuZDwvdGV4dD4KPC9zdmc+';
}}
/>
{demo.name}
{demo.description}
⏱️ {demo.estimatedTime}
📋 {demo.steps} steps
))}
{filteredDemos.length === 0 && (
No demos found in this category
)}
);
}