Use the calendar color for state icon in event details (#14670)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Philip Allgaier 2022-12-14 12:15:36 +01:00 committed by GitHub
parent 66a22ae102
commit ef7d839c0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 14 additions and 2 deletions

View File

@ -32,6 +32,8 @@ export class StateBadge extends LitElement {
@property({ type: Boolean }) public stateColor?: boolean;
@property() public color?: string;
@property({ type: Boolean, reflect: true, attribute: "icon" })
private _showIcon = true;
@ -75,7 +77,8 @@ export class StateBadge extends LitElement {
!changedProps.has("stateObj") &&
!changedProps.has("overrideImage") &&
!changedProps.has("overrideIcon") &&
!changedProps.has("stateColor")
!changedProps.has("stateColor") &&
!changedProps.has("color")
) {
return;
}
@ -106,6 +109,9 @@ export class StateBadge extends LitElement {
}
hostStyle.backgroundImage = `url(${imageUrl})`;
this._showIcon = false;
} else if (this.color) {
// Externally provided overriding color wins over state color
iconStyle.color = this.color;
} else if (this._stateColor && stateActive(stateObj)) {
const color = stateColorCss(stateObj);
if (color) {

View File

@ -19,6 +19,8 @@ class StateInfo extends LitElement {
// property used only in CSS
@property({ type: Boolean, reflect: true }) public rtl = false;
@property() public color?: string;
protected render(): TemplateResult {
if (!this.hass || !this.stateObj) {
return html``;
@ -26,9 +28,10 @@ class StateInfo extends LitElement {
const name = computeStateName(this.stateObj);
return html`<state-badge
return html` <state-badge
.stateObj=${this.stateObj}
.stateColor=${true}
.color=${this.color}
></state-badge>
<div class="info">
<div class="name" .title=${name} .inDialog=${this.inDialog}>

View File

@ -101,6 +101,7 @@ class DialogCalendarEventDetail extends LitElement {
<state-info
.hass=${this.hass}
.stateObj=${stateObj}
.color=${this._params.color}
inDialog
></state-info>
</div>

View File

@ -312,6 +312,7 @@ export class HAFullCalendar extends LitElement {
calendars: this.calendars,
calendarId: info.event.extendedProps.calendar,
entry: info.event.extendedProps.eventData,
color: info.event.backgroundColor,
updated: () => {
this._fireViewChanged();
},

View File

@ -8,6 +8,7 @@ export interface CalendarEventDetailDialogParams {
canDelete?: boolean;
canEdit?: boolean;
updated: () => void;
color?: string;
}
export const loadCalendarEventDetailDialog = () =>