fiscalpass-mastermind / components /category-section.js
maralvic's picture
Alterar os thumbnails para outros que tenham relação com os temas; buscar as imagens em static.photos ; usar o padrão do site na url marcelovicente.prof
b532718 verified
class CategorySection extends HTMLElement {
static get observedAttributes() {
return ['title', 'category'];
}
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue !== newValue) {
this.render();
}
}
render() {
const title = this.getAttribute('title') || '';
const category = this.getAttribute('category') || '';
const id = this.getAttribute('id') || '';
this.shadowRoot.innerHTML = `
<style>
.category-section {
margin-bottom: 3rem;
}
.category-header {
display: flex;
align-items: center;
margin-bottom: 1.5rem;
padding-bottom: 0.5rem;
border-bottom: 2px solid #e2e8f0;
}
.category-title {
font-size: 1.5rem;
font-weight: 700;
color: #2d3748;
margin: 0;
}
.category-icon {
background: #4f46e5;
color: white;
width: 2.5rem;
height: 2.5rem;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
margin-right: 1rem;
}
.videos-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 1.5rem;
}
</style>
<section class="category-section" id="${id}">
<div class="category-header">
<div class="category-icon">
<i data-feather="${this.getIconForCategory(category)}"></i>
</div>
<h2 class="category-title">${title}</h2>
</div>
<div class="videos-grid">
<slot></slot>
</div>
</section>
<script>feather.replace();</script>
`;
}
getIconForCategory(category) {
const icons = {
'introducao': 'home',
'historico': 'clock',
'legislacao': 'book',
'modalidades': 'layers',
'pratica': 'activity',
'estrategia': 'target',
'comparacoes': 'columns',
'jurisprudencia': 'balance-scale'
};
return icons[category] || 'file-text';
}
}
customElements.define('category-section', CategorySection);