UNPKG

@diondre27/smart-components

Version:

Smart Web Components

53 lines (52 loc) 1.59 kB
import { Host, h, getAssetPath } from "@stencil/core"; import { getSvgContent } from './util'; export class SmartIcons { connectedCallback() { this.loadIcon(); } loadIcon() { const svg = `svg/smart-${this.icon}.svg`; const url = getAssetPath(svg); if (this.icon) { getSvgContent(url).then(content => (this.svgContent = content)); } } render() { return (h(Host, { role: "img" }, this.svgContent ? (h("div", { innerHTML: this.svgContent })) : (h("div", null)))); } static get is() { return "smart-icon"; } static get encapsulation() { return "shadow"; } static get originalStyleUrls() { return { "$": ["icon.css"] }; } static get styleUrls() { return { "$": ["icon.css"] }; } static get assetsDirs() { return ["svg"]; } static get properties() { return { "icon": { "type": "string", "mutable": false, "complexType": { "original": "string", "resolved": "string", "references": {} }, "required": false, "optional": false, "docs": { "tags": [], "text": "" }, "attribute": "icon", "reflect": false } }; } static get states() { return { "svgContent": {} }; } static get watchers() { return [{ "propName": "icon", "methodName": "loadIcon" }]; } }