MCHAVEZP102's picture
✅ Context for Designing a Product Activation Dashboard for “CaseFlow”
bc2f68f verified
Raw History Blame Contribute Delete
2.28 kB
class ProgressItem extends HTMLElement {
static get observedAttributes() {
return ['label', 'value', 'progress'];
}
attributeChangedCallback(name, oldValue, newValue) {
if (this.shadowRoot) {
this.render();
}
}
connectedCallback() {
this.attachShadow({ mode: 'open' });
this.render();
}
render() {
const label = this.getAttribute('label') || '';
const value = this.getAttribute('value') || '0%';
const progress = parseInt(this.getAttribute('progress') || '0');
this.shadowRoot.innerHTML = `
<style>
.progress-item {
display: flex;
flex-direction: column;
}
.progress-header {
display: flex;
justify-content: space-between;
margin-bottom: 0.5rem;
}
.progress-label {
font-size: 0.875rem;
color: #64748B;
}
.progress-value {
font-size: 0.875rem;
font-weight: 600;
color: #1E293B;
}
.progress-bar {
height: 6px;
background-color: #E2E8F0;
border-radius: 3px;
overflow: hidden;
}
.progress-fill {
height: 100%;
border-radius: 3px;
background-color: #4F46E5;
transition: width 0.5s ease-out;
}
</style>
<div class="progress-item fade-in">
<div class="progress-header">
<span class="progress-label">${label}</span>
<span class="progress-value">${value}</span>
</div>
<div class="progress-bar">
<div class="progress-fill" style="width: ${progress}%"></div>
</div>
</div>
`;
}
}
customElements.define('progress-item', ProgressItem);