Fix state color in submenu items.
This commit is contained in:
+11
-10
@@ -1,12 +1,12 @@
|
|||||||
import type { Corner } from '@material/mwc-menu';
|
import type { Corner } from '@material/mwc-menu';
|
||||||
import { HomeAssistant } from 'custom-card-helpers';
|
import { HomeAssistant } from 'custom-card-helpers';
|
||||||
import {
|
import {
|
||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
TemplateResult,
|
TemplateResult,
|
||||||
unsafeCSS
|
unsafeCSS
|
||||||
} from 'lit';
|
} from 'lit';
|
||||||
import { customElement, property } from 'lit/decorators.js';
|
import { customElement, property } from 'lit/decorators.js';
|
||||||
import { ifDefined } from 'lit/directives/if-defined.js';
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
||||||
@@ -15,8 +15,8 @@ import { actionHandler } from '../action-handler-directive.js';
|
|||||||
import submenuStyle from '../scss/submenu.scss';
|
import submenuStyle from '../scss/submenu.scss';
|
||||||
import { MenuSubmenu, MenuSubmenuItem, MenuSubmenuSelect } from '../types.js';
|
import { MenuSubmenu, MenuSubmenuItem, MenuSubmenuSelect } from '../types.js';
|
||||||
import {
|
import {
|
||||||
frigateCardHasAction,
|
frigateCardHasAction,
|
||||||
stopEventFromActivatingCardWideActions
|
stopEventFromActivatingCardWideActions
|
||||||
} from '../utils/action.js';
|
} from '../utils/action.js';
|
||||||
import { isHassDifferent, refreshDynamicStateParameters } from '../utils/ha';
|
import { isHassDifferent, refreshDynamicStateParameters } from '../utils/ha';
|
||||||
import { domainIcon } from '../utils/icons/domain-icon.js';
|
import { domainIcon } from '../utils/icons/domain-icon.js';
|
||||||
@@ -138,8 +138,7 @@ export class FrigateCardSubmenuSelect extends LitElement {
|
|||||||
return (
|
return (
|
||||||
changedProps.size != 1 ||
|
changedProps.size != 1 ||
|
||||||
!this.submenuSelect ||
|
!this.submenuSelect ||
|
||||||
(!!oldHass &&
|
(!!oldHass && isHassDifferent(this.hass, oldHass, [this.submenuSelect.entity]))
|
||||||
isHassDifferent(this.hass, oldHass, [this.submenuSelect.entity]))
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,7 +186,9 @@ export class FrigateCardSubmenuSelect extends LitElement {
|
|||||||
)
|
)
|
||||||
: option;
|
: option;
|
||||||
submenu.items.push({
|
submenu.items.push({
|
||||||
|
state_color: true,
|
||||||
selected: stateObj.state === option,
|
selected: stateObj.state === option,
|
||||||
|
enabled: true,
|
||||||
title: title || option,
|
title: title || option,
|
||||||
...((entity.startsWith('select.') || entity.startsWith('input_select.')) && {
|
...((entity.startsWith('select.') || entity.startsWith('input_select.')) && {
|
||||||
tap_action: {
|
tap_action: {
|
||||||
|
|||||||
+3
-3
@@ -466,10 +466,10 @@ export type MenuStateIcon = z.infer<typeof menuStateIconSchema>;
|
|||||||
const menuSubmenuItemSchema = elementsBaseSchema.extend({
|
const menuSubmenuItemSchema = elementsBaseSchema.extend({
|
||||||
entity: z.string().optional(),
|
entity: z.string().optional(),
|
||||||
icon: z.string().optional(),
|
icon: z.string().optional(),
|
||||||
state_color: z.boolean().default(true).optional(),
|
state_color: z.boolean().default(true),
|
||||||
selected: z.boolean().default(false).optional(),
|
selected: z.boolean().default(false),
|
||||||
subtitle: z.string().optional(),
|
subtitle: z.string().optional(),
|
||||||
enabled: z.boolean().default(true).optional(),
|
enabled: z.boolean().default(true),
|
||||||
});
|
});
|
||||||
export type MenuSubmenuItem = z.infer<typeof menuSubmenuItemSchema>;
|
export type MenuSubmenuItem = z.infer<typeof menuSubmenuItemSchema>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user