| class AlgorithmCard extends HTMLElement { |
| connectedCallback() { |
| const title = this.getAttribute('title') || 'Algorithm'; |
| const icon = this.getAttribute('icon') || 'cpu'; |
| const color = this.getAttribute('color') || 'bg-indigo-500'; |
| const href = this.getAttribute('href') || '#'; |
| const content = this.innerHTML.trim(); |
|
|
| this.attachShadow({ mode: 'open' }); |
| this.shadowRoot.innerHTML = ` |
| <style> |
| :host { |
| display: block; |
| cursor: pointer; |
| } |
| |
| .card { |
| background-color: white; |
| border-radius: 0.5rem; |
| box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); |
| overflow: hidden; |
| transition: transform 0.2s, box-shadow 0.2s; |
| height: 100%; |
| } |
| |
| .card:hover { |
| transform: translateY(-4px); |
| box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05); |
| } |
| |
| .card-header { |
| padding: 1.5rem; |
| display: flex; |
| align-items: center; |
| ${color} |
| } |
| |
| .card-icon { |
| width: 2.5rem; |
| height: 2.5rem; |
| display: flex; |
| align-items: center; |
| justify-content: center; |
| border-radius: 9999px; |
| background-color: rgba(255, 255, 255, 0.2); |
| margin-right: 1rem; |
| color: white; |
| } |
| |
| .card-title { |
| font-size: 1.25rem; |
| font-weight: 600; |
| color: white; |
| margin: 0; |
| } |
| |
| .card-body { |
| padding: 1.5rem; |
| } |
| |
| .card-content { |
| color: #4b5563; |
| line-height: 1.6; |
| } |
| </style> |
| |
| <a href="${href}" class="card"> |
| <div class="card-header"> |
| <div class="card-icon"> |
| <i data-feather="${icon}"></i> |
| </div> |
| <h3 class="card-title">${title}</h3> |
| </div> |
| <div class="card-body"> |
| <p class="card-content">${content}</p> |
| </div> |
| </a> |
| `; |
| } |
| } |
|
|
| customElements.define('algorithm-card', AlgorithmCard); |