fix: stop treating rainfall total as current rain

This commit is contained in:
zv
2026-06-02 15:10:37 +02:00
parent ce2e1176fa
commit 352287bc38
8 changed files with 11 additions and 39 deletions

View File

@@ -3,15 +3,6 @@
import { motion, useReducedMotion } from "framer-motion";
import type { SynopStation, WeatherMood } from "@/types/imgw";
const rainDrops = Array.from({ length: 58 }, (_, index) => ({
left: `${(index * 29 + 7) % 100}%`,
delay: (index % 11) * 0.13,
duration: 0.72 + (index % 6) * 0.1,
height: 15 + (index % 5) * 5,
opacity: 0.48 + (index % 4) * 0.1,
width: index % 5 === 0 ? 2 : 1,
}));
const windLines = Array.from({ length: 7 }, (_, index) => ({
top: `${18 + index * 11}%`,
delay: index * 0.22,
@@ -26,14 +17,11 @@ const stars = Array.from({ length: 16 }, (_, index) => ({
export function WeatherEffects({ station, mood }: { station: SynopStation; mood: WeatherMood }) {
const reduceMotion = useReducedMotion();
const rainfall = station.rainfall ?? 0;
const isRaining = rainfall >= 0.1;
const visibleDrops = rainfall >= 5 ? rainDrops : rainfall >= 1 ? rainDrops.slice(0, 44) : rainDrops.slice(0, 30);
const isWindy = (station.windSpeed ?? 0) >= 8;
return (
<div aria-hidden="true" className="pointer-events-none absolute inset-0 z-[1] overflow-hidden">
{(mood === "cloudy" || mood === "rain") && (
{mood === "cloudy" && (
<>
<motion.div
animate={reduceMotion ? undefined : { x: ["-4%", "5%", "-4%"], y: [0, 8, 0], scale: [1, 1.05, 1] }}
@@ -75,16 +63,6 @@ export function WeatherEffects({ station, mood }: { station: SynopStation; mood:
style={{ top: line.top, width: line.width }}
/>
))}
{isRaining && !reduceMotion && visibleDrops.map((drop, index) => (
<motion.span
key={index}
initial={{ y: "-8vh", opacity: 0 }}
animate={{ y: ["-8vh", "85vh"], x: [0, -16], opacity: [0, drop.opacity, 0.18] }}
transition={{ duration: drop.duration, delay: drop.delay, repeat: Infinity, ease: "linear" }}
className="absolute -top-10 rounded-full bg-slate-100/90 shadow-[0_0_6px_rgba(226,232,240,0.7)] blur-[0.25px]"
style={{ height: drop.height, left: drop.left, width: drop.width, transform: "rotate(14deg)" }}
/>
))}
{mood === "cold" && (
<div className="absolute inset-x-0 bottom-0 h-28 bg-gradient-to-t from-cyan-100/20 to-transparent" />
)}

View File

@@ -26,7 +26,7 @@ export function WeatherHero({ station, locationName, distanceKm }: { station: Sy
const metrics = [
{ icon: Droplets, label: t("weather.humidity"), value: formatHumidity(station.humidity, language) },
{ icon: Wind, label: t("weather.wind"), value: formatWind(station.windSpeed, null, language) },
{ icon: Umbrella, label: t("weather.rainfall"), value: formatRainfall(station.rainfall, language) },
{ icon: Umbrella, label: t("weather.rainfallTotal"), value: formatRainfall(station.rainfall, language) },
{ icon: Gauge, label: t("weather.pressure"), value: formatPressure(station.pressure, language) },
];

View File

@@ -1,11 +1,10 @@
import { Cloud, CloudRain, CloudSun, MoonStar, Snowflake, ThermometerSun, Wind } from "lucide-react";
import { Cloud, CloudSun, MoonStar, Snowflake, ThermometerSun, Wind } from "lucide-react";
import type { WeatherMood } from "@/types/imgw";
export function WeatherIcon({ mood, className = "" }: { mood: WeatherMood; className?: string }) {
const Icon = {
warm: ThermometerSun,
cloudy: Cloud,
rain: CloudRain,
wind: Wind,
cold: Snowflake,
night: MoonStar,