Skip to content

Commit e58ed4e

Browse files
committed
render collection icon for media tree item
1 parent 980f4c7 commit e58ed4e

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

src/packages/media/media/tree/tree-item/media-tree-item.element.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
1010
return html`
1111
<span id="icon-container" slot="icon">
1212
${this.item?.mediaType.icon
13-
? html` <umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon> `
13+
? html`
14+
<umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon>
15+
${this.#renderStateIcon()}
16+
`
1417
: nothing}
1518
</span>
1619
`;
@@ -20,6 +23,18 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
2023
return html`<span id="label" slot="label">${this._item?.variants[0].name}</span> `;
2124
}
2225

26+
#renderStateIcon() {
27+
if (this.item?.mediaType.collection) {
28+
return this.#renderIsCollectionIcon();
29+
}
30+
31+
return nothing;
32+
}
33+
34+
#renderIsCollectionIcon() {
35+
return html`<umb-icon id="state-icon" slot="icon" name="icon-grid" title="Collection"></umb-icon>`;
36+
}
37+
2338
static override styles = [
2439
UmbTextStyles,
2540
css`
@@ -36,6 +51,45 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
3651
overflow: hidden;
3752
text-overflow: ellipsis;
3853
}
54+
55+
#state-icon {
56+
position: absolute;
57+
bottom: -5px;
58+
right: -5px;
59+
font-size: 10px;
60+
background: var(--uui-color-surface);
61+
width: 14px;
62+
height: 14px;
63+
border-radius: 100%;
64+
line-height: 14px;
65+
}
66+
67+
:hover #state-icon {
68+
background: var(--uui-color-surface-emphasis);
69+
}
70+
71+
/** Active */
72+
[active] #state-icon {
73+
background: var(--uui-color-current);
74+
}
75+
76+
[active]:hover #state-icon {
77+
background: var(--uui-color-current-emphasis);
78+
}
79+
80+
/** Selected */
81+
[selected] #state-icon {
82+
background-color: var(--uui-color-selected);
83+
}
84+
85+
[selected]:hover #state-icon {
86+
background-color: var(--uui-color-selected-emphasis);
87+
}
88+
89+
/** Disabled */
90+
[disabled] #state-icon {
91+
background-color: var(--uui-color-disabled);
92+
}
3993
`,
4094
];
4195
}

0 commit comments

Comments
 (0)