Changed around line 1
+ document.addEventListener('DOMContentLoaded', () => {
+ const heroGrid = document.querySelector('.hero-grid');
+ const heroSearch = document.getElementById('hero-search');
+ const filterButtons = document.querySelectorAll('.filter-buttons button');
+ const heroSlots = document.querySelectorAll('.hero-slot');
+
+ // Sample hero data (would be fetched from API in production)
+ const heroes = [
+ { id: 1, name: 'Anti-Mage', role: 'carry' },
+ { id: 2, name: 'Shadow Fiend', role: 'mid' },
+ { id: 3, name: 'Tidehunter', role: 'offlane' },
+ // Add more heroes...
+ ];
+
+ function renderHeroes(filteredHeroes = heroes) {
+ heroGrid.innerHTML = '';
+ filteredHeroes.forEach(hero => {
+ const heroElement = document.createElement('div');
+ heroElement.classList.add('hero-portrait');
+ heroElement.dataset.role = hero.role;
+ heroElement.textContent = hero.name;
+ heroElement.addEventListener('click', () => selectHero(hero));
+ heroGrid.appendChild(heroElement);
+ });
+ }
+
+ function selectHero(hero) {
+ const emptySlot = Array.from(heroSlots).find(slot => !slot.dataset.hero);
+ if (emptySlot) {
+ emptySlot.dataset.hero = hero.id;
+ emptySlot.textContent = hero.name;
+ updateCounterPicks();
+ }
+ }
+
+ function updateCounterPicks() {
+ // Would calculate counter picks based on selected heroes
+ // and update the suggestions section
+ }
+
+ heroSearch.addEventListener('input', (e) => {
+ const searchTerm = e.target.value.toLowerCase();
+ const filteredHeroes = heroes.filter(hero =>
+ hero.name.toLowerCase().includes(searchTerm)
+ );
+ renderHeroes(filteredHeroes);
+ });
+
+ filterButtons.forEach(button => {
+ button.addEventListener('click', () => {
+ const role = button.dataset.role;
+ const filteredHeroes = heroes.filter(hero => hero.role === role);
+ renderHeroes(filteredHeroes);
+ });
+ });
+
+ // Initialize
+ renderHeroes();
+ });