import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; dayjs.extend(relativeTime); type SensorReading = { val: number; unit: string; when: dayjs.Dayjs; title: string; }; const mockSensorReadings: SensorReading[] = [ { title: "Temperature", val: 22.5, unit: "°C", when: dayjs().subtract(2, "minute"), }, { title: "Humidity", val: 45.3, unit: "%", when: dayjs().subtract(1, "minute"), }, { title: "Pressure", val: 1013.25, unit: "hPa", when: dayjs() }, { title: "PM 1.0", val: 8.2, unit: "µg/m³", when: dayjs().subtract(30, "second"), }, { title: "PM 2.5", val: 12.7, unit: "µg/m³", when: dayjs().subtract(30, "second"), }, { title: "PM 10", val: 24.1, unit: "µg/m³", when: dayjs().subtract(45, "second"), }, ]; function SensorReadingCard({ reading }: { reading: SensorReading }) { const fontSize = reading.unit.length > 2 ? "text-4xl" : "text-6xl"; return (
updated: {reading.when.fromNow()}