Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
Mariusthvdb authored Nov 29, 2023
1 parent a59f3fd commit df5345d
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions custom-ui-icon-color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
const Name = "Custom-ui-icon-color";
const Version = "20231126";
const Description = "add icon_color to UI";
const Url = "https://github.com/Mariusthvdb/custom-ui-icon-color";
console.info(
`%c ${Name} \n%c Version ${Version} ${Description}`,
"color: gold; font-weight: bold; background: black",
"color: white; font-weight: bold; background: steelblue"
);
window.customUI = {
installStateBadge() {
customElements.whenDefined("state-badge").then(() => {
const stateBadge = customElements.get("state-badge");
if (!stateBadge) return;
if (stateBadge.prototype?.updated) {
const originalUpdated = stateBadge.prototype.updated;
stateBadge.prototype.updated = function customUpdated(changedProps) {
if (!changedProps.has("stateObj")) return;
const { stateObj } = this;
if (
stateObj.attributes.icon_color &&
!stateObj.attributes.entity_picture
) {
this.style.backgroundImage = "";
this._showIcon = true;
this._iconStyle = {
color: stateObj.attributes.icon_color
};
}
originalUpdated.call(this, changedProps);
};
}
});
},
installClassHooks() {
window.customUI.installStateBadge();
},
init() {
if (window.customUI.initDone) return;
window.customUI.installClassHooks();
window.CUSTOM_UI_LIST = window.CUSTOM_UI_LIST || [];
window.CUSTOM_UI_LIST.push({
name: Name,
version: `${Version} ${Description}`,
url: Url
});
},

};
window.customUI.init();

0 comments on commit df5345d

Please sign in to comment.