aiaas-visualizer-pro / components /infographic-card.js
rtik007's picture
Goal: Create a visually engaging and logically organized infographic that summarizes and enhances understanding of the provided content.
0398dc6 verified
class InfographicCard extends HTMLElement {
static get observedAttributes() {
return ['icon', 'title', 'content', 'color'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
attributeChangedCallback() {
this.render();
}
render() {
const icon = this.getAttribute('icon') || 'box';
const title = this.getAttribute('title') || 'Untitled';
const content = this.getAttribute('content') || 'No content provided';
const color = this.getAttribute('color') || 'bg-gray-100';
this.shadowRoot.innerHTML = `
<style>
.card {
border-radius: 0.75rem;
padding: 1.5rem;
transition: all 0.3s ease;
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
height: 100%;
display: flex;
flex-direction: column;
}
.card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}
.icon-container {
width: 3rem;
height: 3rem;
border-radius: 0.5rem;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 1rem;
}
.card-title {
font-size: 1.125rem;
font-weight: 600;
margin-bottom: 0.5rem;
color: #1f2937;
}
.card-content {
color: #4b5563;
font-size: 0.875rem;
line-height: 1.5;
}
</style>
<div class="card ${color}">
<div class="icon-container bg-white">
<i data-feather="${icon}"></i>
</div>
<h3 class="card-title">${title}</h3>
<p class="card-content">${content}</p>
</div>
`;
feather.replace();
}
}
customElements.define('infographic-card', InfographicCard);