Skip to content

Commit

Permalink
feat(ui/icon): svg property
Browse files Browse the repository at this point in the history
  • Loading branch information
MM25Zamanian authored and alimd committed Apr 5, 2023
1 parent ac607f6 commit 7815917
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion ui/icon/src/icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,19 @@ export class AlwatrIcon extends DirectionMixin(SignalMixin(AlwatrBaseElement)) {
@property()
name?: string;

@property({attribute: false})
svg?: string;

@state()
protected _svg?: HTMLTemplateResult | null;

override render(): unknown {
this._logger.logMethod('render');

if (this.svg != null) {
return html`${unsafeSVG(this.svg)}`;
}

return this._svg ?? nothing;
}

Expand All @@ -86,7 +94,7 @@ export class AlwatrIcon extends DirectionMixin(SignalMixin(AlwatrBaseElement)) {
}

protected override shouldUpdate(changedProperties: PropertyValues<this>): boolean {
return super.shouldUpdate(changedProperties) && this._svg !== undefined;
return super.shouldUpdate(changedProperties) && (this._svg !== undefined || this.svg != null);
}

protected async _fetchIcon(): Promise<void> {
Expand Down

0 comments on commit 7815917

Please sign in to comment.