diff --git a/src/editor.ts b/src/editor.ts index f15b6a7f..debd2c51 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -114,6 +114,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor const menuModes = { '': '', + 'none': localize('menu_mode.none'), 'hidden-top': localize('menu_mode.hidden-top'), 'hidden-left': localize('menu_mode.hidden-left'), 'hidden-bottom': localize('menu_mode.hidden-bottom'), diff --git a/src/frigate-hass-card.ts b/src/frigate-hass-card.ts index eff84ada..11b2acd8 100644 --- a/src/frigate-hass-card.ts +++ b/src/frigate-hass-card.ts @@ -164,6 +164,15 @@ export class FrigateCardMenu extends LitElement { // Render the menu. protected render(): TemplateResult | void | ((part: NodePart) => Promise) { + // If the menu is off, or if it's in hidden mode but there's no button to + // unhide it, just show nothing. + if ( + this.menuMode == 'none' || + (this.menuMode.startsWith('hidden-') && !this.buttons.get('frigate')) + ) { + return html``; + } + const classes = { 'frigate-card-menu': true, 'overlay-hidden': @@ -181,12 +190,6 @@ export class FrigateCardMenu extends LitElement { bottom: this.menuMode.endsWith('-bottom'), }; - // If the menu is in hidden mode and there's no button to unhide it, just - // show nothing. - if (this.menuMode.startsWith('hidden-') && !this.buttons.get('frigate')) { - return html``; - } - return html`
${Array.from(this.buttons.keys()).map((name) => { @@ -775,7 +778,9 @@ export class FrigateCard extends LitElement { if (!parent || !parent.children || childIndex == null) { return this._renderAttentionIcon( this._view.is('clip') ? 'mdi:filmstrip-off' : 'mdi:camera-off', - this._view.is('clip') ? localize('common.no_clip') : localize('common.no_snapshot'), + this._view.is('clip') + ? localize('common.no_clip') + : localize('common.no_snapshot'), ); } mediaToRender = parent.children[childIndex]; @@ -926,7 +931,10 @@ export class FrigateCard extends LitElement { // is always rendered (but sometimes hidden). protected _renderLiveViewer(): TemplateResult { if (!this._hass || !(this.config.camera_entity in this._hass.states)) { - return this._renderAttentionIcon('mdi:camera-off', localize('error.no_live_camera')); + return this._renderAttentionIcon( + 'mdi:camera-off', + localize('error.no_live_camera'), + ); } if (this._webrtcElement) { return html`${this._webrtcElement}`; diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index ce97eff8..a667512a 100644 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -44,6 +44,7 @@ "frigate_ui": "Frigate User Interface" }, "menu_mode": { + "none": "No menu", "hidden-top": "Hidden Top", "hidden-left": "Hidden Left", "hidden-bottom": "Hidden Bottom", diff --git a/src/types.ts b/src/types.ts index e3f01d19..2363b00e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -25,6 +25,7 @@ export const FRIGATE_CARD_VIEWS = [ export type FrigateCardView = typeof FRIGATE_CARD_VIEWS[number]; export const FRIGATE_MENU_MODES = [ + 'none', 'hidden-top', 'hidden-left', 'hidden-bottom',