Merge pull request #45 from dermotduffy/hide-menu

Allow the menu to be entirely removed
This commit is contained in:
Dermot Duffy
2021-09-04 13:19:07 -07:00
committed by GitHub
6 changed files with 21 additions and 10 deletions
+2 -2
View File
@@ -196,11 +196,11 @@ This card supports several menu configurations.
| Key | Description | Screenshot | | Key | Description | Screenshot |
| ------------- | --------------------------------------------- | - | | ------------- | --------------------------------------------- | - |
|`hidden-{top,bottom,right,left}` (default)| Hide the menu by default, expandable upon clicking the 'F' button. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-hidden.png" alt="Menu hidden" width="400px"> | |`hidden-{top,bottom,right,left}` [default: `hidden-top`]| Hide the menu by default, expandable upon clicking the 'F' button. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-hidden.png" alt="Menu hidden" width="400px"> |
|`overlay-{top,bottom,right,left}`| Overlay the menu on top of the card contents. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-overlay.png" alt="Menu overlaid" width="400px"> | |`overlay-{top,bottom,right,left}`| Overlay the menu on top of the card contents. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-overlay.png" alt="Menu overlaid" width="400px"> |
|`above`| Render the menu above the card. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-above.png" alt="Menu above" width="400px"> | |`above`| Render the menu above the card. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-above.png" alt="Menu above" width="400px"> |
|`below`| Render the menu below the card. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-below.png" alt="Menu below" width="400px"> | |`below`| Render the menu below the card. The 'F' button shows the default view. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-below.png" alt="Menu below" width="400px"> |
|`none`| No menu is shown. | <img src="https://raw.githubusercontent.com/dermotduffy/frigate-hass-card/main/images/menu-mode-none.png" alt="No Menu" width="400px"> |
<a name="yaml-examples"></a> <a name="yaml-examples"></a>
Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

+1
View File
@@ -114,6 +114,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
const menuModes = { const menuModes = {
'': '', '': '',
'none': localize('menu_mode.none'),
'hidden-top': localize('menu_mode.hidden-top'), 'hidden-top': localize('menu_mode.hidden-top'),
'hidden-left': localize('menu_mode.hidden-left'), 'hidden-left': localize('menu_mode.hidden-left'),
'hidden-bottom': localize('menu_mode.hidden-bottom'), 'hidden-bottom': localize('menu_mode.hidden-bottom'),
+16 -8
View File
@@ -164,6 +164,15 @@ export class FrigateCardMenu extends LitElement {
// Render the menu. // Render the menu.
protected render(): TemplateResult | void | ((part: NodePart) => Promise<void>) { protected render(): TemplateResult | void | ((part: NodePart) => Promise<void>) {
// 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 = { const classes = {
'frigate-card-menu': true, 'frigate-card-menu': true,
'overlay-hidden': 'overlay-hidden':
@@ -181,12 +190,6 @@ export class FrigateCardMenu extends LitElement {
bottom: this.menuMode.endsWith('-bottom'), 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` return html`
<div class=${classMap(classes)}> <div class=${classMap(classes)}>
${Array.from(this.buttons.keys()).map((name) => { ${Array.from(this.buttons.keys()).map((name) => {
@@ -775,7 +778,9 @@ export class FrigateCard extends LitElement {
if (!parent || !parent.children || childIndex == null) { if (!parent || !parent.children || childIndex == null) {
return this._renderAttentionIcon( return this._renderAttentionIcon(
this._view.is('clip') ? 'mdi:filmstrip-off' : 'mdi:camera-off', 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]; mediaToRender = parent.children[childIndex];
@@ -926,7 +931,10 @@ export class FrigateCard extends LitElement {
// is always rendered (but sometimes hidden). // is always rendered (but sometimes hidden).
protected _renderLiveViewer(): TemplateResult { protected _renderLiveViewer(): TemplateResult {
if (!this._hass || !(this.config.camera_entity in this._hass.states)) { 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) { if (this._webrtcElement) {
return html`${this._webrtcElement}`; return html`${this._webrtcElement}`;
+1
View File
@@ -44,6 +44,7 @@
"frigate_ui": "Frigate User Interface" "frigate_ui": "Frigate User Interface"
}, },
"menu_mode": { "menu_mode": {
"none": "No menu",
"hidden-top": "Hidden Top", "hidden-top": "Hidden Top",
"hidden-left": "Hidden Left", "hidden-left": "Hidden Left",
"hidden-bottom": "Hidden Bottom", "hidden-bottom": "Hidden Bottom",
+1
View File
@@ -25,6 +25,7 @@ export const FRIGATE_CARD_VIEWS = [
export type FrigateCardView = typeof FRIGATE_CARD_VIEWS[number]; export type FrigateCardView = typeof FRIGATE_CARD_VIEWS[number];
export const FRIGATE_MENU_MODES = [ export const FRIGATE_MENU_MODES = [
'none',
'hidden-top', 'hidden-top',
'hidden-left', 'hidden-left',
'hidden-bottom', 'hidden-bottom',