view src/FdClock.ts @ 13:deb0c25655eb

cleanup, add FdClock and Countdown
author drewp@bigasterisk.com
date Thu, 06 Jun 2024 16:39:51 -0700
parents
children 20d1fa4250c0
line wrap: on
line source

import { css, html, LitElement } from "lit";
import { shared } from "./shared";


export class FdClock extends LitElement {
  constructor() {
    super();
    setInterval(() => {
      this.requestUpdate();
    }, 1000);
  }
  static styles = [
    shared,
    css`
      :host {
        display: inline block;
      }
    `,
  ];
  render() {
    const t = new Date();
    const h = t.getHours().toString().padStart(2, "0");
    const m = t.getMinutes().toString().padStart(2, "0");
    const s = t.getSeconds().toString().padStart(2, "0");
    return html` <span class="t">${h}:${m.slice(0, 2)}:${s.slice(0, 2)}</span> `;
  }
}
customElements.define("fd-clock", FdClock);