waibu-bootstrap
Version:
Bootstrap suport for Waibu Framework
26 lines (24 loc) • 1.02 kB
JavaScript
async function heading () {
return class Heading extends this.app.baseClass.MpaWidget {
constructor (options) {
super(options)
this.params.attr.type = this.params.attr.type ?? '1'
let [type, display] = this.params.attr.type.split('-')
if (display && display !== 'display') display = undefined
const tag = display ? 'h1' : ('h' + type)
this.component.normalizeAttr(this.params, { tag })
if (this.params.attr.tag && !display) {
this.params.attr.class.push('h' + type)
this.params.tag = this.params.attr.tag
}
if (display) this.params.attr.class.push(`display-${type}`)
delete this.params.attr.type
if (this.params.attr.href) {
this.params.prepend = `<a class="link-offset-2 link-underline link-underline-opacity-0 link-underline-opacity-75-hover" href="${this.params.attr.href}">`
this.params.append = '</a>'
delete this.params.attr.href
}
}
}
}
export default heading