fonteva-design-guide
Version:
## Dev, Build and Test
62 lines (58 loc) • 1.93 kB
JavaScript
import { LightningElement, track, api } from 'lwc';
import PFM_Base from 'c/pfmBase';
export default class Card extends PFM_Base {
type;
classes;
header;
footer; // not supported
title;
hasFooter = true;
hasHeader = true;
hasBody = true;
collapsed;
show() {
const body = this.template.querySelector('.pfm-card__body');
body.classList.remove('js-hide');
body.style.height = body.scrollHeight + 'px';
setTimeout(() => {
body.style.overflow = 'inherit';
body.style.height = 'auto';
}, 250);
}
hide() {
const body = this.template.querySelector('.pfm-card__body');
body.style.height = body.scrollHeight + 'px';
setTimeout(() => {
body.classList.add('js-hide');
body.style.height = 0;
body.style.overflow = 'hidden';
}, 1);
}
showFooter() {
const footer = this.template.querySelector('.pfm-card__footer');
footer.classList.remove('slds-hide');
}
hideFooter() {
const footer = this.template.querySelector('.pfm-card__footer');
footer.classList.add('slds-hide');
}
resetHeight() {
const body = this.template.querySelector('.pfm-card__body');
body.style.height = body.scrollHeight + 'px';
}
connectedCallback() {
this.classes = 'pfm-card';
}
renderedCallback() {
this.hasFooter = super.hasSlot('footer');
this.hasHeader = super.hasSlot('header');
super.renderedCallback('pfm-card');
// for collapse animation
const body = this.template.querySelector('.pfm-card__body');
if (this.collapsed) {
this.hide();
} else {
this.show();
}
}
}