// ------------------------------------------------------------------------ // components/WeeklyNudge.js - Friendly weekly reminder for free users. // // Shown at most once every 7 days to non-subscribers (never on the very // first visit - the WelcomeModal owns that moment). Leads with a small // sun-themed fact so it reads as a bit of sunshine trivia rather than a // nag, then offers SunScope Extra. // // Reuses the .welcome-* overlay/card styling. Purely presentational - the // open/close state lives in useAppState (weeklyNudgeOpen). // // Props: // onClose - dismiss and stamp the "shown" date (7-day cooldown) // openRestore - opens the "Already subscribed?" restore modal // ------------------------------------------------------------------------ import { h } from '../../vendor/preact.js'; import { useEffect, useMemo } from '../../vendor/preact-hooks.js'; import htm from '../../vendor/htm.js'; import { Wordmark } from './Wordmark.js'; import { SUBSCRIBE_URL, SUBSCRIBE_URL_ONEOFF } from './SubscribeModal.js'; const html = htm.bind(h); // One of these is picked at random each time the nudge appears, so a // regular user gets a different bit of sun trivia week to week. const SUN_FACTS = [ { icon: 'โ˜€๏ธ', title: 'Sunlight is eight minutes old', body: html`Every ray that warms your face left the Sun eight and a half minutes ago and crossed 93 million miles to get here. The least you can do is dress for it.`, }, { icon: '๐ŸŒก๏ธ', title: 'Shade can feel 15ยฐC cooler', body: html`Air temperature barely changes when you step into shade โ€” but what your body feels can drop by ten or fifteen degrees. That gap is exactly what SunSoak measures.`, }, { icon: '๐Ÿงด', title: 'Clouds are not sunscreen', body: html`Up to 80% of UV sails straight through thin cloud, which is why overcast days catch people out. SunScope's UV and sunburn-time columns keep score for you.`, }, { icon: '๐Ÿš—', title: 'A parked car beats the desert', body: html`On a mild 22ยฐC afternoon a car's interior can pass 50ยฐC in under an hour โ€” hotter than the Sahara. SunScope can show you that number before you park.`, }, { icon: '๐Ÿ’จ', title: 'Wind steals your warmth', body: html`A brisk breeze can strip several degrees off how cold you feel without moving the thermometer at all. Wind chill is baked into every SunSoak reading.`, }, { icon: '๐ŸŒ…', title: 'The golden hour is real', body: html`Low sun travels through far more atmosphere, so early and late light is gentler on skin โ€” a good reason to check the hourly view before heading out.`, }, ]; export function WeeklyNudge({ onClose, openRestore }) { const fact = useMemo(() => SUN_FACTS[Math.floor(Math.random() * SUN_FACTS.length)], []); // Dismiss on Esc. useEffect(() => { const onKey = (e) => { if (e.key === 'Escape') onClose(); }; document.addEventListener('keydown', onKey); return () => document.removeEventListener('keydown', onKey); }, [onClose]); return html`
`; }