diff 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 diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/FdClock.ts	Thu Jun 06 16:39:51 2024 -0700
@@ -0,0 +1,28 @@
+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);