codecraft-studio / components /project-card.js
Abmacode12's picture
<!doctype html>
6e8f694 verified
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);