Skip to content

Commit

Permalink
Merge pull request #2069 from umbraco/v14/bugfix/document-media-tree-…
Browse files Browse the repository at this point in the history
…item-collection-icon

Bugfix: Render collection icon for document/media tree items
  • Loading branch information
leekelleher authored Jul 2, 2024
2 parents aedc0a8 + 5f4125e commit dc27f58
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { UmbDocumentTreeItemModel, UmbDocumentTreeItemVariantModel } from '../types.js';
import { css, html, nothing, customElement, state, classMap } from '@umbraco-cms/backoffice/external/lit';
import type { UmbAppLanguageContext } from '@umbraco-cms/backoffice/language';
import { UMB_APP_LANGUAGE_CONTEXT } from '@umbraco-cms/backoffice/language';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbTreeItemElementBase } from '@umbraco-cms/backoffice/tree';
import type { UmbDocumentTreeItemModel, UmbDocumentTreeItemVariantModel } from '../types.js';

@customElement('umb-document-tree-item')
export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocumentTreeItemModel> {
Expand Down Expand Up @@ -74,11 +74,7 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
${this.item?.documentType.icon
? html`
<umb-icon id="icon" slot="icon" name="${this.item.documentType.icon}"></umb-icon>
${this.item.isProtected ? this.#renderIsProtectedIcon() : nothing}
<!--
// TODO: implement correct status symbol
<span id="status-symbol"></span>
-->
${this.#renderStateIcon()}
`
: nothing}
</span>
Expand All @@ -91,8 +87,24 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
> `;
}

#renderStateIcon() {
if (this.item?.isProtected) {
return this.#renderIsProtectedIcon();
}

if (this.item?.documentType.collection) {
return this.#renderIsCollectionIcon();
}

return nothing;
}

#renderIsCollectionIcon() {
return html`<umb-icon id="state-icon" slot="icon" name="icon-grid" title="Collection"></umb-icon>`;
}

#renderIsProtectedIcon() {
return html`<umb-icon id="icon-lock" slot="icon" name="icon-lock" title="Protected"></umb-icon>`;
return html`<umb-icon id="state-icon" slot="icon" name="icon-lock" title="Protected"></umb-icon>`;
}

static override styles = [
Expand All @@ -106,19 +118,13 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
vertical-align: middle;
}
#status-symbol {
width: 5px;
height: 5px;
border: 1px solid white;
background-color: blue;
display: block;
position: absolute;
bottom: 0;
right: 0;
border-radius: 100%;
#label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#icon-lock {
#state-icon {
position: absolute;
bottom: -5px;
right: -5px;
Expand All @@ -130,36 +136,30 @@ export class UmbDocumentTreeItemElement extends UmbTreeItemElementBase<UmbDocume
line-height: 14px;
}
#label {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
:hover #icon-lock {
:hover #state-icon {
background: var(--uui-color-surface-emphasis);
}
/** Active */
[active] #icon-lock {
[active] #state-icon {
background: var(--uui-color-current);
}
[active]:hover #icon-lock {
[active]:hover #state-icon {
background: var(--uui-color-current-emphasis);
}
/** Selected */
[selected] #icon-lock {
[selected] #state-icon {
background-color: var(--uui-color-selected);
}
[selected]:hover #icon-lock {
[selected]:hover #state-icon {
background-color: var(--uui-color-selected-emphasis);
}
/** Disabled */
[disabled] #icon-lock {
[disabled] #state-icon {
background-color: var(--uui-color-disabled);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
return html`
<span id="icon-container" slot="icon">
${this.item?.mediaType.icon
? html` <umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon> `
? html`
<umb-icon id="icon" slot="icon" name="${this.item.mediaType.icon}"></umb-icon>
${this.#renderStateIcon()}
`
: nothing}
</span>
`;
Expand All @@ -20,6 +23,18 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
return html`<span id="label" slot="label">${this._item?.variants[0].name}</span> `;
}

#renderStateIcon() {
if (this.item?.mediaType.collection) {
return this.#renderIsCollectionIcon();
}

return nothing;
}

#renderIsCollectionIcon() {
return html`<umb-icon id="state-icon" slot="icon" name="icon-grid" title="Collection"></umb-icon>`;
}

static override styles = [
UmbTextStyles,
css`
Expand All @@ -36,6 +51,45 @@ export class UmbMediaTreeItemElement extends UmbTreeItemElementBase<UmbMediaTree
overflow: hidden;
text-overflow: ellipsis;
}
#state-icon {
position: absolute;
bottom: -5px;
right: -5px;
font-size: 10px;
background: var(--uui-color-surface);
width: 14px;
height: 14px;
border-radius: 100%;
line-height: 14px;
}
:hover #state-icon {
background: var(--uui-color-surface-emphasis);
}
/** Active */
[active] #state-icon {
background: var(--uui-color-current);
}
[active]:hover #state-icon {
background: var(--uui-color-current-emphasis);
}
/** Selected */
[selected] #state-icon {
background-color: var(--uui-color-selected);
}
[selected]:hover #state-icon {
background-color: var(--uui-color-selected-emphasis);
}
/** Disabled */
[disabled] #state-icon {
background-color: var(--uui-color-disabled);
}
`,
];
}
Expand Down

0 comments on commit dc27f58

Please sign in to comment.