UNPKG

waibu-bootstrap

Version:

Bootstrap suport for Waibu Framework

41 lines (38 loc) 1.76 kB
async function appLauncherTrigger () { return class AppLauncherTrigger extends this.app.baseClass.MpaWidget { constructor (options) { super(options) const { isString } = this.app.lib._ this.params.attr.color = this.params.attr.color ?? 'color:body-emphasis' this.params.attr.text = this.params.attr.text ?? 'decoration:none' this.params.attr.display = 'type:block' this.params.attr.flex = 'justify-content:center align-items:center' this.params.attr.href = this.params.attr.href ?? '#' if (isString(this.params.attr.open)) { const [id, type = 'modal'] = this.params.attr.open.split(':') this.params.attr['data-bs-target'] = `#${id}` this.params.attr['data-bs-toggle'] = type === 'drawer' ? 'offcanvas' : type this.params.attr['aria-controls'] = id } this.params.attr.padding = this.params.attr.padding ?? 'all-0' this.params.attr.imgDimWidth = this.params.attr.imgDimWidth ?? 48 this.params.attr.imgDimHeight = this.params.attr.imgDimHeight ?? 48 } build = async () => { const { groupAttrs, stringifyAttribs } = this.app.waibuMpa const group = groupAttrs(this.params.attr, ['img']) this.params.attr = group._ let src = group.img.src if (!src) src = 'waibuMpa:/logo/main' this.params.tag = 'a' const sentence = [ `<c:img src="${src}"`, `width="${group.img.dimWidth}" height="${group.img.dimHeight}"` ] if (group.img.style) sentence.push(`style="${stringifyAttribs(group.img.style)}"`) sentence.push('/>') this.params.html = await this.component.buildSentence(sentence) } } } export default appLauncherTrigger