1- import { html , css , LitElement } from 'lit'
1+ import { html , css , LitElement , PropertyValues } from 'lit'
22import { property , state } from 'lit/decorators.js'
33import { TextboxConfiguration } from './definition-schema.js'
44
@@ -21,17 +21,25 @@ export class WidgetTextbox extends LitElement {
2121
2222 update ( changedProperties : Map < string , any > ) {
2323 if ( changedProperties . has ( 'theme' ) ) {
24- const cssTextColor = getComputedStyle ( this ) . getPropertyValue ( '--re-text-color' ) . trim ( )
25- const cssBgColor = getComputedStyle ( this ) . getPropertyValue ( '--re-background-color' ) . trim ( )
26- this . themeBgColor = cssBgColor || this . theme ?. theme_object ?. backgroundColor
27- this . themeTitleColor = cssTextColor || this . theme ?. theme_object ?. title ?. textStyle ?. color
28- this . themeSubtitleColor =
29- cssTextColor || this . theme ?. theme_object ?. title ?. subtextStyle ?. color || this . themeTitleColor
24+ this . registerTheme ( this . theme )
3025 }
3126
3227 super . update ( changedProperties )
3328 }
3429
30+ protected firstUpdated ( _changedProperties : PropertyValues ) : void {
31+ this . registerTheme ( this . theme )
32+ }
33+
34+ registerTheme ( theme ?: Theme ) {
35+ const cssTextColor = getComputedStyle ( this ) . getPropertyValue ( '--re-text-color' ) . trim ( )
36+ const cssBgColor = getComputedStyle ( this ) . getPropertyValue ( '--re-background-color' ) . trim ( )
37+ this . themeBgColor = cssBgColor || this . theme ?. theme_object ?. backgroundColor
38+ this . themeTitleColor = cssTextColor || this . theme ?. theme_object ?. title ?. textStyle ?. color
39+ this . themeSubtitleColor =
40+ cssTextColor || this . theme ?. theme_object ?. title ?. subtextStyle ?. color || this . themeTitleColor
41+ }
42+
3543 static styles = css `
3644 :host {
3745 display: block;
0 commit comments