import { LitElement, html, property, customElement } from 'lit-element'; import * as domtools from '@designestate/dees-domtools'; import { icon, IconDefinition } from '@fortawesome/fontawesome-svg-core'; import { faFacebook, faGoogle, faLinkedin, faMedium, faSlackHash, faTwitter, } from '@fortawesome/free-brands-svg-icons'; import {} from '@fortawesome/free-regular-svg-icons'; import { faDesktop, faRss, faUsers } from '@fortawesome/free-solid-svg-icons'; type TFontAwesomeIcon = // normal | 'desktop' | 'rss' // brands | 'facebook' | 'google' | 'twitter' | 'linkedin' | 'medium' | 'slack' | 'users'; const faIcons: { [key: string]: IconDefinition } = { // normal desktop: faDesktop, rss: faRss, // brands facebook: faFacebook, google: faGoogle, linkedin: faLinkedin, medium: faMedium, slack: faSlackHash, twitter: faTwitter, users: faUsers, }; declare global { interface HTMLElementTagNameMap { 'dees-icon': DeesIcon; } } @customElement('dees-icon') export class DeesIcon extends LitElement { public static demo = () => html`
`; @property() public iconName: string; @property() public brandName: TFontAwesomeIcon; @property() public svgSize: number = 20; constructor() { super(); domtools.elementBasic.setup(); } public render() { return html` ${domtools.elementBasic.styles} ${this.iconName ? html`${this.iconName}` : html``} ${this.brandName ? html`
` : html``} `; } firstUpdated() { if (this.brandName && !this.iconName) { this.shadowRoot.querySelector('#iconContainer').innerHTML = icon( faIcons[this.brandName] ).html[0]; } } }