class QuantumFile extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
`;
}
connectedCallback() {
const type = this.getAttribute('type') || 'file';
const icon = this.shadowRoot.getElementById('icon');
const sizeEl = this.shadowRoot.getElementById('size');
const dateEl = this.shadowRoot.getElementById('date');
if (type === 'directory') {
icon.classList.add('fa-folder', 'directory');
sizeEl.textContent = '';
} else {
icon.classList.add('fa-file');
sizeEl.textContent = this.getAttribute('size') || '';
}
dateEl.textContent = this.getAttribute('date') || '';
this.addEventListener('click', () => {
this.dispatchEvent(new CustomEvent('file-select', {
bubbles: true,
composed: true,
detail: {
path: this.getAttribute('path'),
type: type
}
}));
});
}
}
customElements.define('quantum-file', QuantumFile);