import Link from "next/link";
import { SIGNS } from "@/lib/astro";
import { SIGN_IN, withArticle } from "@/lib/skyText";
import type { SkyNow } from "@/lib/types";
/** The Moon as it is lit now: the lit part on the right while waxing, on the left while waning. */
export function MoonPhaseIcon({
illumination,
waxing,
}: {
illumination: number;
waxing: boolean;
}) {
const r = 8.5;
const k = Math.min(1, Math.max(0, illumination));
const rx = Math.abs(1 - 2 * k) * r;
// The outer edge on the lit side, then the terminator back.
const outer = waxing ? 1 : 0;
const terminator = waxing ? (k > 0.5 ? 1 : 0) : k > 0.5 ? 0 : 1;
const d = `M12 ${12 - r}A${r} ${r} 0 0 ${outer} 12 ${12 + r}A${rx} ${r} 0 0 ${terminator} 12 ${12 - r}Z`;
return (
);
}
/**
* "Ma: Hold a ♉ Bikában" in the header (the moon calendar behind it). Narrow
* screens show the phase and the sign's glyph only.
*/
export function MoonChip({ sky }: { sky: SkyNow }) {
const moon = sky.moon;
const sign = moon.position.sign;
const where = withArticle(SIGN_IN[sign] ?? sign);
return (
Ma: Hold {where.split(" ")[0]}{" "}
{SIGNS[sign]?.glyph}
{"︎"}
{" "}
{SIGN_IN[sign]}
);
}