File tree 6 files changed +46
-5
lines changed
playground/_stories/main/Tree
6 files changed +46
-5
lines changed Original file line number Diff line number Diff line change @@ -257,6 +257,19 @@ abstract class ListItem extends ListItemBase {
257
257
@slot ( )
258
258
deleteButton ! : Array < HTMLElement > ;
259
259
260
+ /**
261
+ * Defines the icon, displayed in the beginning or end of the list item.
262
+ * If a custom icon is set, it will be rendered in place of the standard icon defined in the <code>icon</code> property.
263
+ * <br><br>
264
+ * @type {sap.ui.webc.main.IIcon }
265
+ * @name sap.ui.webc.main.ListItem.prototype.customIcon
266
+ * @since 1.18.0
267
+ * @slot
268
+ * @public
269
+ */
270
+ @slot ( )
271
+ customIcon ! : Array < HTMLElement > ;
272
+
260
273
deactivateByKey : ( e : KeyboardEvent ) => void ;
261
274
deactivate : ( ) => void ;
262
275
_ontouchstart : PassiveEventListenerObject ;
@@ -498,6 +511,10 @@ abstract class ListItem extends ListItemBase {
498
511
return ! ! this . deleteButton . length ;
499
512
}
500
513
514
+ get hasCustomIconSlot ( ) {
515
+ return ! ! this . customIcon . length ;
516
+ }
517
+
501
518
get _accessibleNameRef ( ) : string {
502
519
if ( ( this as IAccessibleListItem ) . accessibleName ) {
503
520
// accessibleName is set - return labels excluding content
Original file line number Diff line number Diff line change 39
39
40
40
{{ #*inline " iconBegin" }}
41
41
{{ #if displayIconBegin }}
42
- <ui5-icon part =" icon" name =" {{ icon }} " class =" ui5-li-icon" accessible-role =" presentation" aria-hidden =" true" ></ui5-icon >
42
+ {{ #if hasCustomIconSlot }}
43
+ <slot name =" customIcon" ></slot >
44
+ {{ else }}
45
+ <ui5-icon part =" icon" name =" {{ icon }} " class =" ui5-li-icon" accessible-role =" presentation" aria-hidden =" true" ></ui5-icon >
46
+ {{ /if }}
43
47
{{ /if }}
44
48
{{ /inline }}
45
49
46
50
{{ #*inline " iconEnd" }}
47
51
{{ #if displayIconEnd }}
48
- <ui5-icon part =" icon" name =" {{ icon }} " class =" ui5-li-icon" accessible-role =" presentation" aria-hidden =" true" ></ui5-icon >
52
+ {{ #if hasCustomIconSlot }}
53
+ <slot name =" customIcon" ></slot >
54
+ {{ else }}
55
+ <ui5-icon part =" icon" name =" {{ icon }} " class =" ui5-li-icon" accessible-role =" presentation" aria-hidden =" true" ></ui5-icon >
56
+ {{ /if }}
49
57
{{ /if }}
50
58
{{ /inline }}
Original file line number Diff line number Diff line change 28
28
{{ #*inline " imageBegin" }} {{ /inline }}
29
29
30
30
{{ #*inline " iconBegin" }}
31
- {{ #if icon }}
31
+ {{ #if hasCustomIconSlot }}
32
+ <slot name =" customIcon" ></slot >
33
+ {{ else if icon}}
32
34
<ui5-icon part =" icon" name =" {{ icon }} " class =" ui5-li-icon" ></ui5-icon >
33
35
{{ /if }}
34
36
{{ /inline }}
Original file line number Diff line number Diff line change 171
171
object-fit : contain;
172
172
}
173
173
174
+ ::slotted ([ui5-icon ][slot = "customIcon" ]),
174
175
.ui5-li-icon {
175
176
min-width : var (--_ui5_list_item_icon_size );
176
177
min-height : var (--_ui5_list_item_icon_size );
Original file line number Diff line number Diff line change 9
9
min-width : 0 ;
10
10
}
11
11
12
+ : host ([_minimal ]) ::slotted ([ui5-icon ][slot = "customIcon" ]),
12
13
: host ([_minimal ]) .ui5-li-icon {
13
14
padding : 0 ;
14
15
}
Original file line number Diff line number Diff line change @@ -96,8 +96,8 @@ export const DynamicContent: StoryFn = () => html`
96
96
</ script >
97
97
` ;
98
98
99
- export const TreeWithCustomItems = Template . bind ( { } ) ;
100
- TreeWithCustomItems . args = {
99
+ export const WithCustomItems = Template . bind ( { } ) ;
100
+ WithCustomItems . args = {
101
101
header : `
102
102
<div slot="header">
103
103
<ui5-title>Tree with custom items</ui5-title>
@@ -132,3 +132,15 @@ TreeWithCustomItems.args = {
132
132
</ui5-tree-item-custom>
133
133
</ui5-tree-item-custom>` ,
134
134
} ;
135
+
136
+
137
+ export const WithCustomIcon = Template . bind ( { } ) ;
138
+ WithCustomIcon . args = {
139
+ default : `
140
+ <ui5-tree-item text="Tree 1" expanded>
141
+ <ui5-icon slot="customIcon" name="paste" accessible-name="Paste" show-tooltip></ui5-icon>
142
+ <ui5-tree-item text="Tree 1.2">
143
+ <ui5-icon slot="customIcon" name="paste" accessible-name="Paste" show-tooltip></ui5-icon>
144
+ </ui5-tree-item>
145
+ </ui5-tree-item>`
146
+ } ;
You can’t perform that action at this time.
0 commit comments