view src/VideoSection.ts @ 41:44bd161e4779

layout
author drewp@bigasterisk.com
date Thu, 05 Dec 2024 21:33:25 -0800
parents ff73b95fc72f
children df51269bcef4
line wrap: on
line source

import { LitElement, html, css } from "lit";
import { customElement, property } from "lit/decorators.js";
import "shaka-video-element";

@customElement("video-section")
export class VideoSection extends LitElement {
  @property({ type: String }) manifest: string | undefined;
  @property({ type: String }) thumbRelPath: string | undefined;
  @property({ type: String }) title: string = "(unknown)";
  @property({ type: String }) big: boolean = false;

  static styles = [
    css`
      :host {
        display: inline-block;
      }
      section {
        box-shadow: 4px 4px 2px #00000029;
        border-radius: 5px;
        background: #ffffff14;
        display: inline-block;
        padding: 10px;
        color: white;
        width: 255px;
      }
      .video-title {
        line-clamp: 2;
        height: 3.2em;
      }
      #imgCrop {
        overflow: hidden;
        width: 250px;
        height: 140px;
        background-repeat: no-repeat;
        background-position: center;
        background-size: contain;
        display: inline-block;
      }
    `,
  ];
  render() {
    return html`
      <section @click=${this.click}>
        <div class="video-title" title="${this.title}">${this.title}</div>
        <span id="imgCrop" style='background-image: url("${this.thumbRelPath}")'></span>
      </section>
    `;
  }
  click() {
    this.dispatchEvent(
      new CustomEvent("playVideo", {
        detail: {
          manifest: this.manifest,
          zoomFrom: "my location",
        },
      })
    );
  }
  updated() {
    // const  el=this.querySelector("#video")
    // console.log(el.clientWidth);
  }
}