Make control sizes configurable.

This commit is contained in:
Dermot Duffy
2021-10-30 20:14:46 -07:00
parent fcc40a926b
commit 17eb1d439d
8 changed files with 69 additions and 15 deletions
+5
View File
@@ -41,6 +41,11 @@ export class FrigateCardMenu extends LitElement {
@property({ attribute: false })
public buttons: MenuButton[] = [];
@property({ attribute: false })
set buttonSize(buttonSize: string) {
this.style.setProperty('--frigate-card-menu-button-size', buttonSize);
}
protected _interactionHandler(ev: CustomEvent, button: MenuButton): void {
if (this.menuMode.startsWith('hidden-')) {
if (button.type == 'internal-menu-icon' && button.tap_action === 'frigate') {
+18 -2
View File
@@ -17,6 +17,13 @@ export class FrigateCardMessage extends LitElement {
@property({ attribute: false })
protected thumbnail?: string;
@property({ attribute: false })
set controlSize(controlSize: string | undefined) {
if (controlSize) {
this.style.setProperty('--frigate-card-next-prev-size', controlSize);
}
}
protected render(): TemplateResult {
if (!this.controlStyle || this.controlStyle == 'none') {
return html``;
@@ -32,11 +39,20 @@ export class FrigateCardMessage extends LitElement {
};
if (this.controlStyle == 'chevrons') {
const icon = this.direction == 'previous' ? 'mdi:chevron-left' : 'mdi:chevron-right';
// TODO: Upon a safe distance from the release of HA 2021.11 these
// attributes can be removed from the <ha-icon-button>.
// - icon (replaced with the embedded <ha-icon>)
// - title (replaced with .label)
return html` <ha-icon-button
icon=${this.direction == 'previous' ? 'mdi:chevron-left' : 'mdi:chevron-right'}
icon=${icon}
class="${classMap(classes)}"
.label=${this.title}
title=${this.title}
></ha-icon-button>`;
>
<ha-icon icon=${icon}></ha-icon>
</ha-icon-button>`;
}
if (!this.thumbnail) {
+9
View File
@@ -55,6 +55,9 @@ export class FrigateCardViewer extends LitElement {
@property({ attribute: false })
protected nextPreviousControlStyle?: NextPreviousControlStyle;
@property({ attribute: false })
protected nextPreviousControlSize?: string;
@property({ attribute: false })
protected autoplayClip?: boolean;
@@ -142,6 +145,7 @@ export class FrigateCardViewer extends LitElement {
return html` <frigate-card-viewer-core
.view=${this.view}
.nextPreviousControlStyle=${this.nextPreviousControlStyle}
.nextPreviousControlSize=${this.nextPreviousControlSize}
.resolvedMediaCache=${this.resolvedMediaCache}
.autoplayClip=${autoplay}
.hass=${this.hass}
@@ -167,6 +171,9 @@ export class FrigateCardViewerCore extends LitElement {
@property({ attribute: false })
protected nextPreviousControlStyle?: NextPreviousControlStyle;
@property({ attribute: false })
protected nextPreviousControlSize?: string;
@property({ attribute: false })
protected resolvedMediaCache?: ResolvedMediaCache;
@@ -498,6 +505,7 @@ export class FrigateCardViewerCore extends LitElement {
? html`<frigate-card-next-previous-control
.direction=${'previous'}
.controlStyle=${this.nextPreviousControlStyle}
.controlSize=${this.nextPreviousControlSize}
.thumbnail=${neighbors.previous.thumbnail}
.title=${neighbors.previous.title}
@click=${() => this._nextPreviousHandler('previous')}
@@ -512,6 +520,7 @@ export class FrigateCardViewerCore extends LitElement {
? html`<frigate-card-next-previous-control
.direction=${'next'}
.controlStyle=${this.nextPreviousControlStyle}
.controlSize=${this.nextPreviousControlSize}
.thumbnail=${neighbors.next.thumbnail}
.title=${neighbors.next.title}
@click=${() => this._nextPreviousHandler('next')}