// Library screen — subject filter sidebar + grid of materials. function Library({ initialSubject, initialLevel, onOpenMaterial }) { const { MATERIALS, SUBJECTS, KINDS, LEVELS } = window.ECC_DATA; const [level, setLevel] = React.useState(initialLevel || 'all'); const [subject, setSubject] = React.useState(initialSubject || 'all'); const [kind, setKind] = React.useState('all'); const [query, setQuery] = React.useState(''); const [sort, setSort] = React.useState('recent'); let items = MATERIALS.slice(); if (level !== 'all') items = items.filter(m => m.level === level); if (subject !== 'all') items = items.filter(m => m.subject === subject); if (kind !== 'all') items = items.filter(m => m.kind === kind); if (query) { const q = query.toLowerCase(); items = items.filter(m => m.title.toLowerCase().includes(q) || m.desc.toLowerCase().includes(q)); } if (sort === 'title') items.sort((a,b) => a.title.localeCompare(b.title)); // only show kinds that exist in the data const kinds = Object.keys(KINDS).filter(k => MATERIALS.some(m => m.kind === k)); return (

Todo el material

{MATERIALS.length} materiales · Matemáticas 4º ESO

{/* SIDEBAR */} {/* CONTENT */}
{/* Search + sort */}
setQuery(e.target.value)} placeholder="Buscar por título o descripción…" style={{ flex: 1, border: 0, outline: 0, background: 'transparent', font: 'var(--type-body-sm)', color: 'var(--ink)', }}/>
{/* Active filter chips */} {(level !== 'all' || subject !== 'all' || kind !== 'all') && (
Filtros: {level !== 'all' && ( setLevel('all')}> {LEVELS.find(l => l.id === level)?.label} × )} {subject !== 'all' && setSubject('all')} />} {kind !== 'all' && ( setKind('all')}> {KINDS[kind].label} × )}
)} {/* Grid */} {items.length === 0 ? ( ) : (
{items.map(m => onOpenMaterial(m.id)} />)}
)}
); } function SidebarItem({ active, onClick, children }) { return ( ); } function EmptyState() { return (

Sin resultados.

Prueba a quitar algún filtro o cambia la búsqueda.

); } window.Library = Library;