Spaces:
Running
Running
| class PatientCard extends HTMLElement { | |
| static get observedAttributes() { | |
| return ['name', 'status', 'last-visit']; | |
| } | |
| connectedCallback() { | |
| this.render(); | |
| } | |
| attributeChangedCallback(name, oldValue, newValue) { | |
| this.render(); | |
| } | |
| render() { | |
| const name = this.getAttribute('name') || 'Unknown Patient'; | |
| const status = this.getAttribute('status') || 'Active'; | |
| const lastVisit = this.getAttribute('last-visit') || 'Never'; | |
| this.attachShadow({ mode: 'open' }); | |
| this.shadowRoot.innerHTML = ` | |
| <style> | |
| :host { | |
| display: block; | |
| margin-bottom: 1rem; | |
| } | |
| .card { | |
| background-color: #1e1e1e; | |
| border: 1px solid #333; | |
| border-radius: 0.5rem; | |
| overflow: hidden; | |
| transition: transform 0.2s; | |
| } | |
| .card:hover { | |
| transform: translateY(-3px); | |
| box-shadow: 0 4px 8px rgba(0,0,0,0.3); | |
| } | |
| .card-header { | |
| background-color: #2d2d2d; | |
| padding: 1rem; | |
| border-bottom: 1px solid #333; | |
| } | |
| .card-body { | |
| padding: 1rem; | |
| } | |
| .patient-name { | |
| font-size: 1.25rem; | |
| font-weight: 500; | |
| margin: 0 0 0.5rem 0; | |
| color: #f0f0f0; | |
| } | |
| .status-badge { | |
| display: inline-block; | |
| padding: 0.25rem 0.5rem; | |
| border-radius: 9999px; | |
| font-size: 0.75rem; | |
| font-weight: 500; | |
| } | |
| .status-active { | |
| background-color: #10b981; | |
| color: white; | |
| } | |
| .status-inactive { | |
| background-color: #6b7280; | |
| color: white; | |
| } | |
| .last-visit { | |
| color: #9ca3af; | |
| font-size: 0.875rem; | |
| } | |
| .action-btn { | |
| background-color: transparent; | |
| border: 1px solid #4b5563; | |
| color: #f0f0f0; | |
| padding: 0.25rem 0.5rem; | |
| border-radius: 0.25rem; | |
| cursor: pointer; | |
| font-size: 0.875rem; | |
| } | |
| .action-btn:hover { | |
| background-color: #2d2d2d; | |
| } | |
| </style> | |
| <div class="card"> | |
| <div class="card-header"> | |
| <h4 class="patient-name">${name}</h4> | |
| <span class="status-badge ${status === 'Active' ? 'status-active' : 'status-inactive'}">${status}</span> | |
| </div> | |
| <div class="card-body"> | |
| <p class="last-visit">Last visit: ${lastVisit}</p> | |
| <button class="action-btn">View Details</button> | |
| </div> | |
| </div> | |
| `; | |
| } | |
| } | |
| customElements.define('patient-card', PatientCard); |