File size: 2,821 Bytes
1404c2a | 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 | 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); |