diff --git a/custom_components/fontawesome/main.js b/custom_components/fontawesome/main.js index 053f90a..fccc976 100644 --- a/custom_components/fontawesome/main.js +++ b/custom_components/fontawesome/main.js @@ -1 +1 @@ -(()=>{const t={},o={"fa-primary":"primary","fa-secondary":"secondary",primary:"primary",secondary:"secondary"},e=(e,s)=>new Promise((async(n,a)=>{const r=`${e}:${s}`;t[r]&&n(t[r]),t[r]=(async(t,e)=>{const[s,n]=e.split("#"),a=await fetch(`/fontawesome/icons/${t}/${s}.svg`),r=await a.text(),c=(new DOMParser).parseFromString(r,"text/html");if(!c||!c.querySelector("svg"))return{};const i=c.querySelector("svg").getAttribute("viewBox"),l=c.querySelectorAll("path"),d={};let h="";for(const t of l){h+=t.getAttribute("d");const e=t.classList[0];o[e]&&(d[o[e]]=t.getAttribute("d"))}return{viewBox:i,path:h,paths:d,format:n}})(e,s),n(t[r])}));"customIconsets"in window||(window.customIconsets={}),window.customIconsets.fab=t=>e("brands",t),window.customIconsets.far=t=>e("regular",t),window.customIconsets.fas=t=>e("solid",t),window.customIconsets.fapro=t=>e("pro",t),window.customIconsets.facustom=t=>e("pro",t),customElements.whenDefined("ha-icon").then((()=>{customElements.get("ha-icon").prototype._setCustomPath=async function(t){const o=await t;this._path=o.path,this._viewBox=o.viewBox,await this.UpdateComplete;const e=this.shadowRoot.querySelector("ha-svg-icon");e&&e.setPaths&&(e.setPaths(o.paths),o.format&&e.classList.add(...o.format.split("-")))}})),customElements.whenDefined("ha-svg-icon").then((()=>{customElements.get("ha-svg-icon").prototype.setPaths=async function(t){if(await this.updateComplete,0===Object.keys(t).length)return;const o=this.shadowRoot.querySelector("style")||document.createElement("style");o.innerHTML="\n .secondary {\n opacity: 0.4;\n }\n :host(.invert) .secondary {\n opacity: 1;\n }\n :host(.invert) .primary {\n opacity: 0.4;\n }\n :host(.color) .primary {\n opacity: 1;\n }\n :host(.color) .secondary {\n opacity: 1;\n }\n :host(.color:not(.invert)) .secondary {\n fill: var(--icon-secondary-color, var(--disabled-text-color));\n }\n :host(.color.invert) .primary {\n fill: var(--icon-secondary-color, var(--disabled-text-color));\n }\n ",this.shadowRoot.appendChild(o);const e=this.shadowRoot.querySelector("g");console.log(t),e.firstElementChild&&(e.firstElementChild.style.display="none");for(const o in t){const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",t[o]),s.classList.add(o),e.appendChild(s)}}}))})(); \ No newline at end of file +(()=>{const t={},o={"fa-primary":"primary","fa-secondary":"secondary",primary:"primary",secondary:"secondary"},e=(e,s)=>new Promise((async(n,a)=>{const r=`${e}:${s}`;t[r]&&n(t[r]),t[r]=(async(t,e)=>{const[s,n]=e.split("#"),a=await fetch(`/fontawesome/icons/${t}/${s}.svg`),r=await a.text(),c=(new DOMParser).parseFromString(r,"text/html");if(!c||!c.querySelector("svg"))return{};const i=c.querySelector("svg").getAttribute("viewBox"),l=c.querySelectorAll("path"),d={};let h="";for(const t of l){h+=t.getAttribute("d");const e=t.classList[0];o[e]&&(d[o[e]]=t.getAttribute("d"))}return{viewBox:i,path:h,paths:d,format:n}})(e,s),n(t[r])}));"customIconsets"in window||(window.customIconsets={}),window.customIconsets.fab=t=>e("brands",t),window.customIconsets.far=t=>e("regular",t),window.customIconsets.fas=t=>e("solid",t),window.customIconsets.fapro=t=>e("pro",t),window.customIconsets.facustom=t=>e("pro",t),customElements.whenDefined("ha-icon").then((()=>{customElements.get("ha-icon").prototype._setCustomPath=async function(t){const o=await t;this._path=o.path,this._viewBox=o.viewBox,await this.UpdateComplete;const e=this.shadowRoot.querySelector("ha-svg-icon");e&&e.setPaths&&(e.setPaths(o.paths),o.format&&e.classList.add(...o.format.split("-")))}})),customElements.whenDefined("ha-svg-icon").then((()=>{customElements.get("ha-svg-icon").prototype.setPaths=async function(t){if(await this.updateComplete,null==t||0===Object.keys(t).length)return;const o=this.shadowRoot.querySelector("style")||document.createElement("style");o.innerHTML="\n .secondary {\n opacity: 0.4;\n }\n :host(.invert) .secondary {\n opacity: 1;\n }\n :host(.invert) .primary {\n opacity: 0.4;\n }\n :host(.color) .primary {\n opacity: 1;\n }\n :host(.color) .secondary {\n opacity: 1;\n }\n :host(.color:not(.invert)) .secondary {\n fill: var(--icon-secondary-color, var(--disabled-text-color));\n }\n :host(.color.invert) .primary {\n fill: var(--icon-secondary-color, var(--disabled-text-color));\n }\n ",this.shadowRoot.appendChild(o);const e=this.shadowRoot.querySelector("g");e.firstElementChild&&(e.firstElementChild.style.display="none");for(const o in t){const s=document.createElementNS("http://www.w3.org/2000/svg","path");s.setAttribute("d",t[o]),s.classList.add(o),e.appendChild(s)}}}))})(); \ No newline at end of file diff --git a/custom_components/fontawesome/manifest.json b/custom_components/fontawesome/manifest.json index a8c1acd..b4002fc 100644 --- a/custom_components/fontawesome/manifest.json +++ b/custom_components/fontawesome/manifest.json @@ -6,6 +6,6 @@ "codeowners": [], "requirements": [], "config_flow": true, - "version": "2.0.0", + "version": "2.0.1", "iot_class": "local_polling" } \ No newline at end of file diff --git a/js/main.js b/js/main.js index 27baf33..48b43ec 100644 --- a/js/main.js +++ b/js/main.js @@ -88,7 +88,7 @@ customElements.whenDefined("ha-svg-icon").then(() => { HaSvgIcon.prototype.setPaths = async function (paths) { await this.updateComplete; - if (Object.keys(paths).length === 0) return; + if (paths == undefined || Object.keys(paths).length === 0) return; const styleEl = this.shadowRoot.querySelector("style") || document.createElement("style"); styleEl.innerHTML = ` @@ -116,7 +116,6 @@ customElements.whenDefined("ha-svg-icon").then(() => { `; this.shadowRoot.appendChild(styleEl); const root = this.shadowRoot.querySelector("g"); - console.log(paths); if (root.firstElementChild) { root.firstElementChild.style.display = "none"; }