mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-08 01:46:35 +00:00
Set theme variables on html element (#1023)
* set theme on html element * style toggle buttons with primary color * Fix lint
This commit is contained in:
parent
d87d845dbc
commit
38542e1f0c
@ -244,11 +244,21 @@ class HomeAssistant extends Polymer.Element {
|
|||||||
|
|
||||||
this.hass.callApi('get', 'themes').then((themes) => {
|
this.hass.callApi('get', 'themes').then((themes) => {
|
||||||
this._updateHass({ themes: themes });
|
this._updateHass({ themes: themes });
|
||||||
window.hassUtil.applyThemesOnElement(this, themes, this.hass.selectedTheme, true);
|
window.hassUtil.applyThemesOnElement(
|
||||||
|
document.documentElement,
|
||||||
|
themes,
|
||||||
|
this.hass.selectedTheme,
|
||||||
|
true
|
||||||
|
);
|
||||||
});
|
});
|
||||||
conn.subscribeEvents((event) => {
|
conn.subscribeEvents((event) => {
|
||||||
this._updateHass({ themes: event.data });
|
this._updateHass({ themes: event.data });
|
||||||
window.hassUtil.applyThemesOnElement(this, event.data, this.hass.selectedTheme, true);
|
window.hassUtil.applyThemesOnElement(
|
||||||
|
document.documentElement,
|
||||||
|
event.data,
|
||||||
|
this.hass.selectedTheme,
|
||||||
|
true
|
||||||
|
);
|
||||||
}, 'themes_updated').then(function (unsub) {
|
}, 'themes_updated').then(function (unsub) {
|
||||||
unsubThemes = unsub;
|
unsubThemes = unsub;
|
||||||
});
|
});
|
||||||
@ -314,7 +324,12 @@ class HomeAssistant extends Polymer.Element {
|
|||||||
|
|
||||||
setTheme(event) {
|
setTheme(event) {
|
||||||
this._updateHass({ selectedTheme: event.detail });
|
this._updateHass({ selectedTheme: event.detail });
|
||||||
window.hassUtil.applyThemesOnElement(this, this.hass.themes, this.hass.selectedTheme, true);
|
window.hassUtil.applyThemesOnElement(
|
||||||
|
document.documentElement,
|
||||||
|
this.hass.themes,
|
||||||
|
this.hass.selectedTheme,
|
||||||
|
true
|
||||||
|
);
|
||||||
this.$.storage.storeState();
|
this.$.storage.storeState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@
|
|||||||
--table-row-background-color: transparent;
|
--table-row-background-color: transparent;
|
||||||
--table-row-alternative-background-color: #eee;
|
--table-row-alternative-background-color: #eee;
|
||||||
|
|
||||||
--paper-toggle-button-checked-ink-color: #039be5;
|
--paper-toggle-button-checked-ink-color: var(--primary-color);
|
||||||
--paper-toggle-button-checked-button-color: #039be5;
|
--paper-toggle-button-checked-button-color: var(--primary-color);
|
||||||
--paper-toggle-button-checked-bar-color: #039be5;
|
--paper-toggle-button-checked-bar-color: var(--primary-color);
|
||||||
|
|
||||||
--paper-slider-knob-color: var(--primary-color);
|
--paper-slider-knob-color: var(--primary-color);
|
||||||
--paper-slider-knob-start-color: var(--primary-color);
|
--paper-slider-knob-start-color: var(--primary-color);
|
||||||
|
@ -365,7 +365,10 @@ window.hassUtil.applyThemesOnElement = function (element, themes, localTheme, up
|
|||||||
styles[prefixedKey] = theme[key];
|
styles[prefixedKey] = theme[key];
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
element.updateStyles(styles);
|
// implement updateStyles() method of Polemer elements
|
||||||
|
if (window.ShadyCSS) {
|
||||||
|
window.ShadyCSS.styleSubtree(/** @type {!HTMLElement} */(element), styles);
|
||||||
|
}
|
||||||
|
|
||||||
if (!updateMeta) return;
|
if (!updateMeta) return;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user