Skip to content

Commit 303bc5c

Browse files
committed
feat(component): Enhance IconLink with label support (#9173)
- Add label_ config (reactive). - Update _vdom to include a span for the label. - Implement afterSetLabel to toggle visibility and update text.
1 parent a78de98 commit 303bc5c

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/component/IconLink.mjs

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ class IconLink extends Component {
2626
* @reactive
2727
*/
2828
iconCls_: null,
29+
/**
30+
* @member {String|null} label_=null
31+
* @reactive
32+
*/
33+
label_: null,
2934
/**
3035
* @member {String} tag='a'
3136
*/
@@ -45,7 +50,8 @@ class IconLink extends Component {
4550
*/
4651
_vdom:
4752
{cn: [
48-
{tag: 'i', cls: []}
53+
{tag: 'i', cls: []},
54+
{tag: 'span', cls: ['neo-link-label'], style: {visibility: 'hidden'}}
4955
]}
5056
}
5157

@@ -65,6 +71,25 @@ class IconLink extends Component {
6571
me.update()
6672
}
6773

74+
/**
75+
* Triggered after the label config got changed
76+
* @param {String|null} value
77+
* @param {String|null} oldValue
78+
*/
79+
afterSetLabel(value, oldValue) {
80+
let me = this,
81+
node = me.vdom.cn[1];
82+
83+
if (value) {
84+
node.html = value;
85+
delete node.style
86+
} else {
87+
node.style = {visibility: 'hidden'}
88+
}
89+
90+
me.update()
91+
}
92+
6893
/**
6994
* Triggered after the target config got changed
7095
* @param {String} value

0 commit comments

Comments
 (0)