class TopPanel extends HTMLElement { connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; this.initializeEventListeners(); } initializeEventListeners() { const menuButton = this.shadowRoot.getElementById('menu-button'); const terminalButton = this.shadowRoot.querySelector('[title="Terminal"]'); const browserButton = this.shadowRoot.querySelector('[title="Navegador Web"]'); const fileBrowserButton = this.shadowRoot.querySelector('[title="Navegador de Arquivos"]'); menuButton.addEventListener('click', (e) => { e.stopPropagation(); this.showAppMenu(); }); terminalButton.addEventListener('click', () => { this.createTerminal(); }); browserButton.addEventListener('click', () => { this.createBrowser(); }); fileBrowserButton.addEventListener('click', () => { this.createFileBrowser(); }); } showAppMenu() { const appMenu = document.getElementById('app-menu'); const rect = this.shadowRoot.getElementById('menu-button').getBoundingClientRect(); appMenu.style.top = '32px'; appMenu.style.left = `${rect.left}px`; appMenu.classList.remove('hidden'); appMenu.classList.add('menu-enter'); setTimeout(() => { const menuRect = appMenu.getBoundingClientRect(); if (menuRect.right > window.innerWidth) { appMenu.style.left = `${window.innerWidth - menuRect.width - 5}px`; } }, 0); } createTerminal() { const content = `
mate@mate-desktop:~$ clear
mate@mate-desktop:~$ ls -la
total 48
drwxr-xr-x 12 mate mate 4096 Dez 15 10:30 .
drwxr-xr-x 3 root root 4096 Dez 14 09:00 ..
-rw------- 1 mate mate 421 Dez 15 10:30 .bash_history
-rw-r--r-- 1 mate mate 220 Dez 14 09:00 .bash_logout
-rw-r--r-- 1 mate mate 3771 Dez 14 09:00 .bashrc
drwx------ 7 mate mate 4096 Dez 14 09:15 .cache
mate@mate-desktop:~$ _
`; createNewWindow('Terminal', 'terminal', 650, 450, content, 100, 150); } createBrowser() { const content = `
`; createNewWindow('Navegador Web', 'globe', 800, 600, content, 200, 100); } createFileBrowser() { const content = `
/home/mate
${this.generateFolderIcons()}
`; createNewWindow('Navegador de Arquivos', 'folder', 700, 500, content, 150, 120); } generateFolderIcons() { const folders = ['Documentos', 'Imagens', 'Música', 'Vídeos', 'Downloads', 'Desktop', 'Modelos', 'Público', 'Projetos', 'Backup']; const colors = ['text-blue-400', 'text-green-400', 'text-purple-400', 'text-red-400', 'text-yellow-400', 'text-cyan-400', 'text-pink-400', 'text-orange-400', 'text-indigo-400', 'text-teal-400']; return folders.map((folder, index) => `
${folder}
`).join(''); } } customElements.define('top-panel', TopPanel);