Merge pull request #64 from dermotduffy/scrollbars-and-css-messy

Refactor CSS to force aspect ratio and avoid scrollbars
This commit is contained in:
Dermot Duffy
2021-09-07 21:23:00 -07:00
committed by GitHub
2 changed files with 40 additions and 45 deletions
+15 -19
View File
@@ -512,7 +512,7 @@ export class FrigateCard extends LitElement {
icon: string, icon: string,
message: string | TemplateResult | null = null, message: string | TemplateResult | null = null,
): TemplateResult { ): TemplateResult {
return html` <div class="frigate-card-attention"> return html` <div class="attention">
<span> <span>
<ha-icon icon="${icon}"> </ha-icon> <ha-icon icon="${icon}"> </ha-icon>
${message ? html`&nbsp;${message}` : ''} ${message ? html`&nbsp;${message}` : ''}
@@ -737,12 +737,12 @@ export class FrigateCard extends LitElement {
'frigate-media-controls': true, 'frigate-media-controls': true,
previous: previous, previous: previous,
next: !previous, next: !previous,
thumbnails: ( thumbnails:
!this.config.controls?.nextprev || !this.config.controls?.nextprev ||
this.config.controls?.nextprev === "thumbnails"), this.config.controls?.nextprev === 'thumbnails',
chevrons: this.config.controls?.nextprev === "chevrons", chevrons: this.config.controls?.nextprev === 'chevrons',
button: this.config.controls?.nextprev === "chevrons", button: this.config.controls?.nextprev === 'chevrons',
} };
const clickChangeView = () => { const clickChangeView = () => {
this._view = new View({ this._view = new View({
@@ -751,7 +751,7 @@ export class FrigateCard extends LitElement {
childIndex: targetChildIndex, childIndex: targetChildIndex,
previous: this._view, previous: this._view,
}); });
} };
if (this.config.controls?.nextprev == 'chevrons') { if (this.config.controls?.nextprev == 'chevrons') {
return html` <ha-icon-button return html` <ha-icon-button
@@ -827,9 +827,9 @@ export class FrigateCard extends LitElement {
${this._view.is('clip') ${this._view.is('clip')
? resolvedMedia?.mime_type.toLowerCase() == 'application/x-mpegurl' ? resolvedMedia?.mime_type.toLowerCase() == 'application/x-mpegurl'
? html`<ha-hls-player ? html`<ha-hls-player
class="media"
.hass=${this._hass} .hass=${this._hass}
.url=${resolvedMedia.url} .url=${resolvedMedia.url}
class="frigate-card-viewer"
title="${mediaToRender.title}" title="${mediaToRender.title}"
muted muted
controls controls
@@ -839,7 +839,7 @@ export class FrigateCard extends LitElement {
> >
</ha-hls-player>` </ha-hls-player>`
: html`<video : html`<video
class="frigate-card-viewer" class="media"
title="${mediaToRender.title}" title="${mediaToRender.title}"
muted muted
controls controls
@@ -856,7 +856,7 @@ export class FrigateCard extends LitElement {
</video>` </video>`
: html`<img : html`<img
src=${resolvedMedia.url} src=${resolvedMedia.url}
class="frigate-card-viewer" class="media"
title="${mediaToRender.title}" title="${mediaToRender.title}"
@click=${() => { @click=${() => {
// Get clips potentially related to this snapshot. // Get clips potentially related to this snapshot.
@@ -998,20 +998,16 @@ export class FrigateCard extends LitElement {
} }
return html` <ha-card @click=${this._interactionHandler}> return html` <ha-card @click=${this._interactionHandler}>
${this.config.menu_mode != 'below' ? this._renderMenu() : ''} ${this.config.menu_mode != 'below' ? this._renderMenu() : ''}
<div class="container_16_9">
<div class="frigate-card-contents"> <div class="frigate-card-contents">
${this._view.is('clips') || this._view.is('snapshots') ${this._view.is('clips') || this._view.is('snapshots')
? html`<div class="frigate-card-gallery"> ? until(this._renderEvents(), this._renderProgressIndicator())
${until(this._renderEvents(), this._renderProgressIndicator())}
</div>`
: ``} : ``}
${this._view.is('clip') || this._view.is('snapshot') ${this._view.is('clip') || this._view.is('snapshot')
? html`<div class="frigate-card-viewer"> ? until(this._renderViewer(), this._renderProgressIndicator())
${until(this._renderViewer(), this._renderProgressIndicator())}
</div>`
: ``}
${this._view.is('live')
? html`<div class="frigate-card-viewer">${this._renderLiveViewer()}</div>`
: ``} : ``}
${this._view.is('live') ? this._renderLiveViewer() : ``}
</div>
</div> </div>
${this.config.menu_mode == 'below' ? this._renderMenu() : ''} ${this.config.menu_mode == 'below' ? this._renderMenu() : ''}
</ha-card>`; </ha-card>`;
+20 -21
View File
@@ -2,43 +2,42 @@
@use "@material/image-list"; @use "@material/image-list";
@use './common.scss'; @use './common.scss';
.container_16_9 {
/* 16:9 Aspect Ratio. When Safari supports 'aspect-ratio' this should not be
necessary */
position: relative;
padding-top: 56.25%; // 9 / 16 == 0.5625
}
.frigate-card-contents { .frigate-card-contents {
position: absolute;
top: 0px;
right: 0px;
bottom: 0px;
left: 0px;
width: 100%; width: 100%;
max-height: 277px; /* Max Lovelace 16/9 video height */
height: 100%; height: 100%;
aspect-ratio: 16 / 9;
overflow: auto;
}
.frigate-card-viewer {
width: 100%;
height: 100%;
aspect-ratio: 16 / 9;
}
.frigate-card-gallery {
overflow: auto; overflow: auto;
-ms-overflow-style: none; /* Hide scrollbar: IE and Edge */ -ms-overflow-style: none; /* Hide scrollbar: IE and Edge */
scrollbar-width: none; /* Hide scrollbar: Firefox */ scrollbar-width: none; /* Hide scrollbar: Firefox */
}
height: 100%; .frigate-card-contents img.media,video.media {
aspect-ratio: 16 / 9; width: 100%;
} }
/* Hide scrollbar for Chrome, Safari and Opera */ /* Hide scrollbar for Chrome, Safari and Opera */
.frigate-card-gallery::-webkit-scrollbar { .frigate-card-contents::-webkit-scrollbar {
display: none; display: none;
} }
.frigate-card-attention { .frigate-card-contents .attention {
height: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
padding: 0% 5% 0% 5%; box-sizing: border-box;
padding: 5%;
height: 100%;
} }
.frigate-card-image-list { .frigate-card-image-list {