view src/WeekGuide.ts @ 21:a90cb6927c7d default tip

fix countdown queries. Display "now" instead of "In -0.4 hours"
author drewp@bigasterisk.com
date Sat, 07 Sep 2024 17:47:36 -0700
parents 472003015880
children
line wrap: on
line source

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

@customElement("fd-week-guide")
export class WeekGuide extends LitElement {
  constructor() {
    super();
    setInterval(this.requestUpdate.bind(this), 5 * 60 * 1000);
  }
  static styles = [
    shared,
    css`
      span {
        display: inline-block;
        background: #282a36;
        padding: 2px;
        border: 2px outset #333;
        text-align: center;
        vertical-align: middle;
        border-radius: 10px;
      }
      span.today {
        background: #282a36;
        border-color: #ff79c6;
        color: #ff79c6;
        text-shadow: 0 0 8px #ff79c6;
      }
    `,
  ];
  render() {
    const day = format(new Date(), "EEE").toLowerCase();

    return html`
      <span class="wday-sun ${day == "sun" ? "today" : ""}">Sunday</span>
      <span class="wday-mon ${day == "mon" ? "today" : ""}">Monday</span>
      <span class="wday-tue ${day == "tue" ? "today" : ""}">Tuesday</span>
      <span class="wday-wed ${day == "wed" ? "today" : ""}">Wednesday</span>
      <span class="wday-thu ${day == "thu" ? "today" : ""}">Thursday</span>
      <span class="wday-fri ${day == "fri" ? "today" : ""}">Friday</span>
      <span class="wday-sat ${day == "sat" ? "today" : ""}">Saturday</span>
    `;
  }
}