Allow menu toggling from picture elements, update documentation.

This commit is contained in:
Dermot Duffy
2022-01-30 21:56:13 -08:00
parent 1fb3940699
commit 881e544591
3 changed files with 72 additions and 30 deletions
+6
View File
@@ -818,6 +818,12 @@ export class FrigateCard extends LitElement {
screenfull.toggle(this);
}
break;
case 'menu_toggle':
// This is a rare code path: this would only be used if someone has a
// menu toggle action configured outside of the menu itself (e.g.
// picture elements).
this._menu.toggleMenu();
break;
case 'camera_select':
const camera = frigateCardAction.camera;
if (this._cameras?.has(camera) && this._view) {
+9
View File
@@ -61,6 +61,15 @@ export class FrigateCardMenu extends LitElement {
return menuConfig?.mode.startsWith('hidden-') ?? false;
}
/**
* Toggle the menu. Has no action if menu is not hiding/expandable.
*/
public toggleMenu(): void {
if (this._isHidingMenu()) {
this.expanded = !this.expanded;
}
}
/**
* Determine if a given menu configuration is a hiding menu (internal version).
* @returns `true` if the menu is hiding, `false` otherwise.