mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Use the calendar color for state icon in event details (#14670)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
parent
66a22ae102
commit
ef7d839c0f
@ -32,6 +32,8 @@ export class StateBadge extends LitElement {
|
|||||||
|
|
||||||
@property({ type: Boolean }) public stateColor?: boolean;
|
@property({ type: Boolean }) public stateColor?: boolean;
|
||||||
|
|
||||||
|
@property() public color?: string;
|
||||||
|
|
||||||
@property({ type: Boolean, reflect: true, attribute: "icon" })
|
@property({ type: Boolean, reflect: true, attribute: "icon" })
|
||||||
private _showIcon = true;
|
private _showIcon = true;
|
||||||
|
|
||||||
@ -75,7 +77,8 @@ export class StateBadge extends LitElement {
|
|||||||
!changedProps.has("stateObj") &&
|
!changedProps.has("stateObj") &&
|
||||||
!changedProps.has("overrideImage") &&
|
!changedProps.has("overrideImage") &&
|
||||||
!changedProps.has("overrideIcon") &&
|
!changedProps.has("overrideIcon") &&
|
||||||
!changedProps.has("stateColor")
|
!changedProps.has("stateColor") &&
|
||||||
|
!changedProps.has("color")
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -106,6 +109,9 @@ export class StateBadge extends LitElement {
|
|||||||
}
|
}
|
||||||
hostStyle.backgroundImage = `url(${imageUrl})`;
|
hostStyle.backgroundImage = `url(${imageUrl})`;
|
||||||
this._showIcon = false;
|
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)) {
|
} else if (this._stateColor && stateActive(stateObj)) {
|
||||||
const color = stateColorCss(stateObj);
|
const color = stateColorCss(stateObj);
|
||||||
if (color) {
|
if (color) {
|
||||||
|
@ -19,6 +19,8 @@ class StateInfo extends LitElement {
|
|||||||
// property used only in CSS
|
// property used only in CSS
|
||||||
@property({ type: Boolean, reflect: true }) public rtl = false;
|
@property({ type: Boolean, reflect: true }) public rtl = false;
|
||||||
|
|
||||||
|
@property() public color?: string;
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
protected render(): TemplateResult {
|
||||||
if (!this.hass || !this.stateObj) {
|
if (!this.hass || !this.stateObj) {
|
||||||
return html``;
|
return html``;
|
||||||
@ -26,9 +28,10 @@ class StateInfo extends LitElement {
|
|||||||
|
|
||||||
const name = computeStateName(this.stateObj);
|
const name = computeStateName(this.stateObj);
|
||||||
|
|
||||||
return html`<state-badge
|
return html` <state-badge
|
||||||
.stateObj=${this.stateObj}
|
.stateObj=${this.stateObj}
|
||||||
.stateColor=${true}
|
.stateColor=${true}
|
||||||
|
.color=${this.color}
|
||||||
></state-badge>
|
></state-badge>
|
||||||
<div class="info">
|
<div class="info">
|
||||||
<div class="name" .title=${name} .inDialog=${this.inDialog}>
|
<div class="name" .title=${name} .inDialog=${this.inDialog}>
|
||||||
|
@ -101,6 +101,7 @@ class DialogCalendarEventDetail extends LitElement {
|
|||||||
<state-info
|
<state-info
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.stateObj=${stateObj}
|
.stateObj=${stateObj}
|
||||||
|
.color=${this._params.color}
|
||||||
inDialog
|
inDialog
|
||||||
></state-info>
|
></state-info>
|
||||||
</div>
|
</div>
|
||||||
|
@ -312,6 +312,7 @@ export class HAFullCalendar extends LitElement {
|
|||||||
calendars: this.calendars,
|
calendars: this.calendars,
|
||||||
calendarId: info.event.extendedProps.calendar,
|
calendarId: info.event.extendedProps.calendar,
|
||||||
entry: info.event.extendedProps.eventData,
|
entry: info.event.extendedProps.eventData,
|
||||||
|
color: info.event.backgroundColor,
|
||||||
updated: () => {
|
updated: () => {
|
||||||
this._fireViewChanged();
|
this._fireViewChanged();
|
||||||
},
|
},
|
||||||
|
@ -8,6 +8,7 @@ export interface CalendarEventDetailDialogParams {
|
|||||||
canDelete?: boolean;
|
canDelete?: boolean;
|
||||||
canEdit?: boolean;
|
canEdit?: boolean;
|
||||||
updated: () => void;
|
updated: () => void;
|
||||||
|
color?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const loadCalendarEventDetailDialog = () =>
|
export const loadCalendarEventDetailDialog = () =>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user