maille
Version:
Component library for MithrilJS
51 lines (50 loc) • 2.03 kB
JavaScript
;
// THIS FILE WAS AUTO-GENERATED FOR PACKAGING, DO NOT MODIFY
Object.defineProperty(exports, "__esModule", { value: true });
class ThreeRowLayout {
view(vnode) {
const classes = new Set(["maille", "maille-three-row-layout"]);
// Build list of classes
if (vnode.attrs.className) {
vnode.attrs.className.split(" ").forEach(c => classes.add(c));
}
const className = [...classes].join(" ");
const children = [
this.buildHeader(vnode),
this.buildBody(vnode),
this.buildFooter(vnode),
];
return m("div", { className }, children);
}
buildHeader(vnode) {
if (!vnode.attrs.header) {
return null;
}
const header = vnode.attrs.header;
// Build header content
const headerAttrs = Object.assign({}, header.container && header.container.attrs ? header.container.attrs : {});
const headerContent = header.content ? header.content : [];
return m(".maille-three-row-layout-header-container", headerAttrs, headerContent);
}
buildBody(vnode) {
if (!vnode.attrs.body) {
return null;
}
const body = vnode.attrs.body;
// Build body content
const bodyAttrs = Object.assign({}, body.container && body.container.attrs ? body.container.attrs : {});
const bodyContent = body.content ? body.content : [];
return m(".maille-three-row-layout-body-container", bodyAttrs, bodyContent);
}
buildFooter(vnode) {
if (!vnode.attrs.footer) {
return null;
}
const footer = vnode.attrs.footer;
// Build footer content
const footerAttrs = Object.assign({}, footer.container && footer.container.attrs ? footer.container.attrs : {});
const footerContent = footer.content ? footer.content : [];
return m(".maille-three-row-layout-footer-container", footerAttrs, footerContent);
}
}
exports.default = ThreeRowLayout;