sf-i-events
Version:
Superflows Navigation Component
60 lines (44 loc) • 1.3 kB
text/typescript
import { LitElement, html, css, PropertyValues } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { icons, IconName } from './icons';
('app-icon')
export class AppIcon extends LitElement {
({ type: String })
name: IconName = 'academicCap';
({ type: Number })
size = 16;
({ type: String })
color = '';
static override styles = css`
:host {
display: inline-flex;
align-items: center;
justify-content: center;
width: var(--app-icon-size, 20px);
height: var(--app-icon-size, 20px);
color: var(--app-icon-color, currentColor);
flex-shrink: 0;
line-height: 0;
}
svg {
width: 100%;
height: 100%;
display: block;
}
`;
protected override updated(_changed: PropertyValues) {
this.style.setProperty('--app-icon-size', `${this.size}px`);
if (this.color)
this.style.setProperty('--app-icon-color', this.color);
else
this.style.removeProperty('--app-icon-color');
}
override render() {
const icon = icons[this.name];
if (!icon) {
console.warn(`Unknown icon '${this.name}'`);
return html``;
}
return icon;
}
}