Spaces:
Running
Running
File size: 2,924 Bytes
6e8f694 | 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 | class ProjectCard extends HTMLElement {
static get observedAttributes() {
return ['title', 'description', 'tech', 'image'];
}
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.render();
}
attributeChangedCallback() {
this.render();
}
render() {
const title = this.getAttribute('title') || 'Project';
const description = this.getAttribute('description') || 'No description provided';
const tech = this.getAttribute('tech') || 'Various technologies';
const image = this.getAttribute('image') || 'http://static.photos/abstract/640x360/4';
this.shadowRoot.innerHTML = `
<style>
.card {
border-radius: 1rem;
overflow: hidden;
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
transform: translateY(-5px);
}
.card-image {
height: 200px;
background-size: cover;
background-position: center;
}
.card-content {
padding: 1.5rem;
background: rgba(30, 41, 59, 0.7);
}
.tech-badge {
display: inline-block;
padding: 0.25rem 0.5rem;
background: var(--primary);
color: white;
border-radius: 0.25rem;
font-size: 0.75rem;
margin-top: 0.5rem;
}
.animate-fade-in {
opacity: 0;
animation: fadeIn 0.5s ease forwards;
}
@keyframes fadeIn {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
</style>
<div class="card glass-effect hover-glow">
<div class="card-image" style="background-image: url('${image}')"></div>
<div class="card-content">
<h3 class="text-xl font-bold mb-2">${title}</h3>
<p class="text-gray-300 mb-4">${description}</p>
<span class="tech-badge">${tech}</span>
<div class="mt-4 flex justify-end">
<a href="#" class="text-primary-400 hover:text-primary-300 flex items-center">
View Project <i data-feather="arrow-right" class="ml-2" width="16"></i>
</a>
</div>
</div>
</div>
`;
}
}
customElements.define('project-card', ProjectCard); |