view src/FdClock.ts @ 15:20d1fa4250c0

refactor
author drewp@bigasterisk.com
date Thu, 06 Jun 2024 17:52:28 -0700
parents deb0c25655eb
children 472003015880
line wrap: on
line source

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

@customElement("fd-clock")
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> `;
  }
}