From 6346a3cda90cc7496ea86dc578d32acd376f327b Mon Sep 17 00:00:00 2001 From: zv Date: Mon, 1 Jun 2026 19:15:12 +0200 Subject: [PATCH] feat: add dynamic weather hero effects --- components/weather/weather-effects.tsx | 75 ++++++++++++++++++++++++++ components/weather/weather-hero.tsx | 4 +- components/weather/weather-icon.tsx | 4 +- lib/weather-utils.ts | 14 ++--- types/imgw.ts | 2 +- 5 files changed, 88 insertions(+), 11 deletions(-) create mode 100644 components/weather/weather-effects.tsx diff --git a/components/weather/weather-effects.tsx b/components/weather/weather-effects.tsx new file mode 100644 index 0000000..d40cbf5 --- /dev/null +++ b/components/weather/weather-effects.tsx @@ -0,0 +1,75 @@ +"use client"; + +import { motion, useReducedMotion } from "framer-motion"; +import type { SynopStation, WeatherMood } from "@/types/imgw"; + +const rainDrops = Array.from({ length: 32 }, (_, index) => ({ + left: `${(index * 29 + 7) % 100}%`, + delay: (index % 11) * 0.13, + duration: 0.72 + (index % 5) * 0.12, + height: 12 + (index % 4) * 4, +})); + +const windLines = Array.from({ length: 7 }, (_, index) => ({ + top: `${18 + index * 11}%`, + delay: index * 0.22, + width: 70 + (index % 3) * 34, +})); + +const stars = Array.from({ length: 16 }, (_, index) => ({ + left: `${(index * 37 + 11) % 96}%`, + top: `${(index * 23 + 8) % 72}%`, + delay: (index % 6) * 0.35, +})); + +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 : rainDrops.slice(0, 18); + const isWindy = (station.windSpeed ?? 0) >= 8; + + return ( +