You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.7 KiB
66 lines
1.7 KiB
import { Icon } from "../icon/icon"; |
|
import { DefaultLayout, CenterAdaptLayout, shortcut, createWidget, isNumber, isNull, pixFormat } from "@/core"; |
|
import { Single } from "../0.single"; |
|
|
|
/** |
|
* @class IconLabel |
|
* @extends Single |
|
* 图标标签 |
|
*/ |
|
|
|
@shortcut() |
|
export class IconLabel extends Single { |
|
static xtype = "bi.icon_label"; |
|
|
|
props = { |
|
baseCls: "bi-icon-label horizon-center", |
|
hgap: 0, |
|
vgap: 0, |
|
tgap: 0, |
|
bgap: 0, |
|
lgap: 0, |
|
rgap: 0, |
|
iconWidth: null, |
|
iconHeight: null, |
|
lineHeight: null, |
|
}; |
|
|
|
render() { |
|
const { iconWidth, iconHeight, height, lineHeight, hgap, vgap, lgap, rgap, tgap, bgap } = this.options; |
|
this.element.css({ |
|
textAlign: "center", |
|
}); |
|
this.icon = createWidget({ |
|
type: Icon.xtype, |
|
width: iconWidth, |
|
height: iconHeight, |
|
}); |
|
if (isNumber(height) && height > 0 && isNull(iconWidth) && isNull(iconHeight)) { |
|
this.element.css("lineHeight", pixFormat(lineHeight || height)); |
|
createWidget({ |
|
type: DefaultLayout.xtype, |
|
element: this, |
|
hgap, |
|
vgap, |
|
lgap, |
|
rgap, |
|
tgap, |
|
bgap, |
|
items: [this.icon], |
|
}); |
|
} else { |
|
this.element.css("lineHeight", "1"); |
|
createWidget({ |
|
element: this, |
|
type: CenterAdaptLayout.xtype, |
|
hgap, |
|
vgap, |
|
lgap, |
|
rgap, |
|
tgap, |
|
bgap, |
|
items: [this.icon], |
|
}); |
|
} |
|
} |
|
}
|
|
|