Spaces:
Running
Running
File size: 3,269 Bytes
1ca197b f180d5e 1ca197b f180d5e 1ca197b f180d5e 1ca197b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 | class AuthModal extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.shadowRoot.innerHTML = `
<style>
.modal {
position: fixed;
inset: 0;
background-color: rgba(0, 0, 0, 0.5);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
}
.modal-content {
background-color: white;
padding: 2rem;
border-radius: 0.5rem;
width: 100%;
max-width: 400px;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
animation: modalFadeIn 0.3s ease-out forwards;
}
.tabs {
display: flex;
margin-bottom: 1.5rem;
border-bottom: 1px solid #e5e7eb;
}
.tab {
padding: 0.75rem 1rem;
cursor: pointer;
font-weight: 500;
color: #6b7280;
border-bottom: 2px solid transparent;
}
.tab.active {
color: #3b82f6;
border-bottom-color: #3b82f6;
}
.tab-content {
display: none;
}
.tab-content.active {
display: block;
}
.form-group {
margin-bottom: 1rem;
}
label {
display: block;
margin-bottom: 0.5rem;
font-weight: 500;
}
input {
width: 100%;
padding: 0.5rem 0.75rem;
border: 1px solid #d1d5db;
border-radius: 0.375rem;
}
button {
width: 100%;
padding: 0.75rem;
background-color: #3b82f6;
color: white;
border: none;
border-radius: 0.375rem;
font-weight: 500;
cursor: pointer;
}
button:hover {
background-color: #2563eb;
}
@keyframes modalFadeIn {
from {
opacity: 0;
transform: translateY(-20px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
</style>
<div id="login-modal" class="modal">
<div class="modal-content">
<div class="tabs">
<div class="tab active">Login</div>
</div>
<form id="login-form" class="tab-content active">
<div class="form-group">
<label for="email">Email</label>
<input type="email" id="email" required>
</div>
<div class="form-group">
<label for="password">Password</label>
<input type="password" id="password" required>
</div>
<button type="submit">Sign In</button>
<div id="error-message" class="text-red-500 mt-2 text-sm hidden"></div>
</form>
</div>
</div>
`;
// Initialize Feather Icons in shadow DOM
const featherScript = document.createElement('script');
featherScript.src = 'https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js';
this.shadowRoot.appendChild(featherScript);
featherScript.onload = () => {
if (window.feather) {
window.feather.replace();
}
};
}
}
customElements.define('auth-modal', AuthModal); |