From 93443a8241e901c98693bf4a7af4a3785474e022 Mon Sep 17 00:00:00 2001 From: Dermot Duffy Date: Fri, 13 Aug 2021 22:24:31 -0700 Subject: [PATCH] Go with a cleaner menu bar. --- src/frigate-card.scss | 29 +++++---- src/frigate-card.ts | 140 ++++++++++++++++++++++++------------------ 2 files changed, 95 insertions(+), 74 deletions(-) diff --git a/src/frigate-card.scss b/src/frigate-card.scss index 1dd8cb9f..c231d51d 100644 --- a/src/frigate-card.scss +++ b/src/frigate-card.scss @@ -11,8 +11,9 @@ overflow: auto; position: absolute; - left: 55px; + left: 0px; right: 0px; + top: 0px; height: 100%; -ms-overflow-style: none; // Hide scrollbar: IE and Edge @@ -32,7 +33,7 @@ } .frigate-card-image-list { - @include image-list.standard-columns(4); + @include image-list.standard-columns(5); @include image-list.shape-radius(5px); } @@ -54,28 +55,26 @@ border-color: var(--primary-color); } -.frigate-card-navbar { +.frigate-card-menubar { position: absolute; top: 0px; - width: 50px; z-index: 1; + height: 56px; + width: 50px; } -.frigate-card-statusbar { - @extend .frigate-card-navbar; - right: 3px; -} - -.frigate-card-statusbar-webrtc { - @extend .frigate-card-navbar; - left: 53px; +.frigate-card-menubar-full { + @extend .frigate-card-menubar; + width: 100%; + background-color: rgba(0, 0, 0, 0.6); } ha-icon-button.button { position: relative; - z-index: 2; - opacity: 50%; - background-color: rgba(0, 0, 0, 0.3); + z-index: 10; + color: white; + opacity: 0.8; + background-color: rgba(0, 0, 0, 0.6); border-radius: 50%; padding: 0px; margin: 3px; diff --git a/src/frigate-card.ts b/src/frigate-card.ts index ae28af49..dff61311 100644 --- a/src/frigate-card.ts +++ b/src/frigate-card.ts @@ -1,6 +1,5 @@ // TODO Make editor work. // TODO Add title to clips / snapshots playing/viewing -// TODO Try new navbar idea // TODO Add gallery item to take to media browser // TODO Add documentation & screenshots. // TODO Sometimes webrtc component shows up as not found in browser (maybe after fresh build?) @@ -77,6 +76,7 @@ export class FrigateCard extends LitElement { this._interactionTimerID = null; this._webrtcElement = null; this._hass = null; + this._showMenu = false; } // Get the configuration element. @@ -107,6 +107,9 @@ export class FrigateCard extends LitElement { @property({ attribute: false }) protected _viewEvent: FrigateEvent | null; + @property({ attribute: false }) + protected _showMenu: boolean; + protected _interactionTimerID: number | null; protected _webrtcElement: any | null; @@ -380,39 +383,83 @@ export class FrigateCard extends LitElement { } } - // Render the main navbar (live, clips, snapshots). - protected _renderNavigationBar(): TemplateResult { + // Render the Frigate menu button. + protected _renderFrigateButton(): TemplateResult { return html` -
- { - this._controlVideos({stop: true, control_clip: true}); - this._controlVideos({stop: false, control_live: true}); - this._viewMode = FrigateCardView.LIVE - }} - > - { - this._controlVideos({stop: true, control_live: true}); - this._viewMode = FrigateCardView.CLIPS - }} - > - { - this._controlVideos({stop: true, control_clip: true, control_live: true}); - this._viewMode = FrigateCardView.SNAPSHOTS - }} - > -
` + { + this._showMenu = !this._showMenu; + }} + >`; + } + + + // Render the menu bar. + protected _renderMenuBar(): TemplateResult { + if (!this._showMenu) { + return html` +
+ ${this._renderFrigateButton()} +
`; + } + + let motionIcon: string | null = null; + const motionEntity = this.config.motion_entity ? this.config.motion_entity : null; + if (motionEntity && this._hass && motionEntity in this._hass.states) { + motionIcon = (this._hass.states[motionEntity].state == "on" ? + "mdi:motion-sensor" : "mdi:walk"); + } + + return html` +
+ ${this._renderFrigateButton()} + { + this._controlVideos({stop: true, control_clip: true}); + this._controlVideos({stop: false, control_live: true}); + this._viewMode = FrigateCardView.LIVE; + this._showMenu = false; + }} + > + { + this._controlVideos({stop: true, control_live: true}); + this._viewMode = FrigateCardView.CLIPS; + this._showMenu = false; + }} + > + { + this._controlVideos({stop: true, control_clip: true, control_live: true}); + this._viewMode = FrigateCardView.SNAPSHOTS; + this._showMenu = false; + }} + > + ${!motionIcon ? html`` : html` + { + fireEvent(this, "hass-more-info", {entityId: motionEntity}); + this._showMenu = false; + }} + >` + } +
+ `; } // Render the player for a saved clip. @@ -465,30 +512,6 @@ export class FrigateCard extends LitElement { return html`` } - // Render the status bar (motion icon). - protected _renderStatusBar(): TemplateResult { - const motionEntity = this.config.motion_entity - if (!motionEntity || !this._hass || !(motionEntity in this._hass.states)) { - return html``; - } - const icon = this._hass.states[motionEntity].state == "on" ? - "mdi:motion-sensor" : "mdi:walk"; - return html` -
- { - fireEvent(this, "hass-more-info", {entityId: motionEntity}); - }} - > -
` - } - // Render the live viewer. // Note: The live viewer is the main element used to size the overall card. It // is always rendered (but sometimes hidden). @@ -539,7 +562,7 @@ export class FrigateCard extends LitElement { } return html` - ${this._renderNavigationBar()} + ${this._renderMenuBar()} ${this._viewMode == FrigateCardView.CLIPS ? html`` : `` } - ${this._renderStatusBar()} ${this._renderLiveViewer()} `; }