pic.ts

570 B · typescript · 13 lines

1import { escape } from "./md.ts";23/* PAIRS */45export type Pair = { dark: string; light: string };67export const SHADE = "screen and (prefers-color-scheme: dark)";89export const halves = (pair: Pair, alt = "", cls = "", extra = "") =>10  `<source data-dark srcset="${pair.dark}" media="${SHADE}" type="image/webp">` +11  `<img${cls ? ` class="${escape(cls)}"` : ""} src="${pair.light}" alt="${escape(alt)}" width="1024" height="1024"${extra}>`;1213export const themed = (pair: Pair, alt = "", cls = "", extra = "") => `<picture>${halves(pair, alt, cls, extra)}</picture>`;