Skip to content

Commit

Permalink
fix(sdd): now supports using eds meta icon icon name
Browse files Browse the repository at this point in the history
  • Loading branch information
eikeland committed Jan 23, 2025
1 parent 43dda70 commit 19d60d3
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions packages/searchable-dropdown/src/dropdown/element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ export class SearchableDropdownElement
selectedItems: Set<SearchableDropdownResultItem['id']> = new Set([]);

updated(props: PropertyValues) {
console.log('props', props);
if (props.has('selectedId')) {
this.controller.updateSelectedByProp();
}
Expand Down Expand Up @@ -201,7 +200,7 @@ export class SearchableDropdownElement
>
<div slot="graphic" part="graphic">${this.renderItemGraphic(item)}</div>
${text}
<div slot="meta">${unsafeHTML(item.meta)}</div>
<div slot="meta">${this.renderItemMeta(item)}</div>
</fwc-list-item>`;
}

Expand All @@ -219,6 +218,20 @@ export class SearchableDropdownElement
}
}

protected renderItemMeta(item: SearchableDropdownResultItem): ReturnType<typeof unsafeHTML> | void {
const { meta, graphicType } = item;
switch (graphicType) {
case 'inline-html':
return unsafeHTML(meta);
case 'inline-svg':
return unsafeSVG(meta);
default:
if (meta) {
return html`<fwc-icon icon="${meta}" type="${IconType.EDS}"></fwc-icon>`;
}
}
}

/**
* Render the menu if state is open
* @returns HTMLTemplateResult
Expand Down

0 comments on commit 19d60d3

Please sign in to comment.