import { Badge, Box, Group, Progress, Stack, Text } from "@mantine/core"; import { useScopedI18n } from "@homarr/translation/client"; import type { TimeOfDayPhase } from "./world-clock"; interface TimeOfDayBarProps { minuteOfDay: number; phase: TimeOfDayPhase; showLegend?: boolean; showTicks?: boolean; label: string; } const phaseSections = [ { key: "nightStart", value: 20.833, color: "indigo.8" }, { key: "dawn", value: 12.5, color: "orange.6" }, { key: "day", value: 41.667, color: "cyan.6" }, { key: "dusk", value: 12.5, color: "grape.6" }, { key: "nightEnd", value: 12.5, color: "indigo.8" }, ] as const; const phaseLegend = [ { key: "night", color: "indigo.8" }, { key: "dawn", color: "orange.6" }, { key: "day", color: "cyan.6" }, { key: "dusk", color: "grape.6" }, ] as const; const timeTicks = ["midnight", "morning", "noon", "evening", "end"] as const; export const TimeOfDayBar = ({ minuteOfDay, phase, showLegend = false, showTicks = false, label, }: TimeOfDayBarProps) => { const t = useScopedI18n("widget.clock"); const progress = Math.max(0, Math.min(100, (minuteOfDay / 1440) * 100)); const remainingMinutes = Math.max(0, 1440 - Math.floor(minuteOfDay)); const remainingHours = Math.floor(remainingMinutes / 60); const remainder = remainingMinutes % 60; return ( {t(`worldClock.phase.${phase}`)} {t("worldClock.dayProgress", { percent: Math.round(progress), hours: remainingHours, minutes: remainder.toString().padStart(2, "0"), })} {phaseSections.map((section) => ( ))} {showTicks && ( {timeTicks.map((tick) => ( {t(`worldClock.tick.${tick}`)} ))} )} {showLegend && ( {t("worldClock.phaseLegend")} {phaseLegend.map((item) => ( {t(`worldClock.phase.${item.key}`)} ยท {t(`worldClock.phaseRange.${item.key}`)} ))} )} ); }; const getPhaseColor = (phase: TimeOfDayPhase) => { if (phase === "night") return "indigo"; if (phase === "dawn") return "orange"; if (phase === "day") return "cyan"; return "grape"; };