eduGHoSt / components /email-viewer.js
dropkickJesus999's picture
Don't just use 4 or 5 different domains. Have a variety of legit domains from community colleges as well as ivy League colleges. It needs to look legit and be in full working order. Don't just give me a mockup. I need functionality.
3676820 verified
class CustomEmailViewer extends HTMLElement {
static get observedAttributes() {
return ['email-id'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
this.classList.add('hidden');
}
attributeChangedCallback(name, oldValue, newValue) {
if (name === 'email-id' && newValue) {
this.renderEmail(newValue);
}
}
async renderEmail(emailId) {
// In a real app, this would be an API call
const email = demoEmails.find(e => e.id === emailId);
if (email) {
this.shadowRoot.innerHTML = `
<style>
.email-container {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.9);
z-index: 1000;
padding: 2rem;
overflow-y: auto;
}
.email-content {
max-width: 800px;
margin: 0 auto;
background-color: rgba(0, 0, 0, 0.8);
border: 2px solid rgba(255, 0, 0, 0.7);
padding: 2rem;
border-radius: 0.5rem;
}
.close-btn {
position: absolute;
top: 1rem;
right: 1rem;
cursor: pointer;
}
</style>
<div class="email-container">
<div class="email-content">
<i class="close-btn" data-feather="x"></i>
<div class="flex justify-between items-center mb-6">
<h2 class="text-2xl font-bold">${email.subject}</h2>
<div class="text-sm">${email.date}</div>
</div>
<div class="mb-6">
<strong>From:</strong> ${email.from}
</div>
<div class="mb-6">
<div class="whitespace-pre-line">${email.body}</div>
</div>
<div class="flex space-x-4">
<button class="btn-neon px-4 py-2 rounded">
<i data-feather="reply"></i> Reply
</button>
<button class="btn-neon px-4 py-2 rounded">
<i data-feather="trash-2"></i> Delete
</button>
</div>
</div>
</div>
`;
feather.replace();
this.shadowRoot.querySelector('.close-btn').addEventListener('click', () => {
this.classList.add('hidden');
});
this.classList.remove('hidden');
}
}
}
customElements.define('custom-email-viewer', CustomEmailViewer);