import React, { useCallback, useEffect, useId, useState } from 'react'; import { createPortal } from 'react-dom'; import { X } from 'lucide-react'; import { open as openUrl } from '@tauri-apps/plugin-shell'; import PsysonicLogo from '@/ui/PsysonicLogo'; const TAPS_TO_REVEAL_HINT = 10; const TARGET_CLICKS_IN_WINDOW = 100; const WINDOW_MS = 60_000; /** Hardcoded About lol copy — intentionally not in locale files. */ const MSG_HINT = 'To become a developer, you need to click the Psysonic logo 100 times within one minute.'; const MSG_CONGRATS_TITLE = 'Congratulations.'; const MSG_CONGRATS_SIGN_OFF = 'Sincerely, your maintainers.'; const MSG_CONGRATS_PS = "PS: Don't forget to star the repo! ★"; /** * About page brand row + Settings → System → About lol (logo taps + modal). * Modal copy is English and hardcoded by design. */ export function AboutPsysonicBrandHeader({ appVersion, aboutVersionLabel, }: { appVersion: string; aboutVersionLabel: string; }) { const modalWordmarkGradSuffix = useId().replace(/:/g, ''); const [phase, setPhase] = useState<'idle' | 'hint' | 'done'>('idle'); const [, setIdleTaps] = useState(0); const [, setHintTimestamps] = useState([]); const [overlayOpen, setOverlayOpen] = useState(false); const onLogoClick = useCallback(() => { if (phase === 'done') return; if (phase === 'idle') { setIdleTaps(prev => { const next = prev + 1; if (next >= TAPS_TO_REVEAL_HINT) queueMicrotask(() => setPhase('hint')); return next; }); return; } if (phase === 'hint') { const now = Date.now(); setHintTimestamps(prev => { const inWindow = prev.filter(t => t > now - WINDOW_MS); const nextTimes = [...inWindow, now]; if (nextTimes.length >= TARGET_CLICKS_IN_WINDOW) { queueMicrotask(() => { setPhase('done'); setOverlayOpen(true); }); } return nextTimes; }); } }, [phase]); const closeOverlay = useCallback(() => setOverlayOpen(false), []); useEffect(() => { if (!overlayOpen) return; const prevOverflow = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.body.style.overflow = prevOverflow; }; }, [overlayOpen]); return ( <>
Psysonic
{aboutVersionLabel} {appVersion}
{phase === 'hint' && !overlayOpen && (

{MSG_HINT}

)} {overlayOpen && createPortal(

{MSG_CONGRATS_TITLE}

{"We're very much looking forward to you as a developer — join us on "} {' and build great features!'}

{MSG_CONGRATS_SIGN_OFF}

{MSG_CONGRATS_PS}

, document.body, )} ); }