Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 | import { useRef, useEffect, useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; import concertImg from '@/assets/concert.png'; import LanguageSwitcher from '@/components/LanguageSwitcher'; import SemLogo from '@/components/SemLogo'; import { useTheme } from '@/contexts/ThemeContext'; import '@/styles/landing.css'; const DOT_COLORS_LIGHT = [ 'rgba(255,255,255,.30)', 'rgba(200,200,210,.35)', 'rgba(160,165,175,.30)', 'rgba(130,135,145,.25)', ]; const DOT_COLORS_DARK = [ 'rgba(255,255,255,.10)', 'rgba(200,200,210,.10)', 'rgba(160,165,175,.08)', 'rgba(130,135,145,.08)', ]; /* ── Interactive dot‑grid canvas ── */ function DotCanvas() { const canvasRef = useRef<HTMLCanvasElement>(null); const mouse = useRef({ x: -1000, y: -1000 }); const dots = useRef<{ baseX: number; baseY: number; x: number; y: number; r: number; color: string }[]>([]); const raf = useRef(0); const { theme } = useTheme(); const COLORS = theme === 'dark' ? DOT_COLORS_DARK : DOT_COLORS_LIGHT; const initDots = useCallback((w: number, h: number) => { const gap = 32; const arr: typeof dots.current = []; for (let x = gap / 2; x < w; x += gap) { for (let y = gap / 2; y < h; y += gap) { arr.push({ baseX: x, baseY: y, x, y, r: 3, color: COLORS[Math.floor(Math.random() * COLORS.length)], }); } } dots.current = arr; }, [COLORS]); useEffect(() => { const canvas = canvasRef.current; if (!canvas) return; const ctx = canvas.getContext('2d')!; const resize = () => { const parent = canvas.parentElement!; canvas.width = parent.clientWidth; canvas.height = parent.clientHeight; initDots(canvas.width, canvas.height); }; const onMove = (e: MouseEvent) => { const rect = canvas.getBoundingClientRect(); mouse.current = { x: e.clientX - rect.left, y: e.clientY - rect.top }; }; const onLeave = () => { mouse.current = { x: -1000, y: -1000 }; }; const draw = () => { ctx.clearRect(0, 0, canvas.width, canvas.height); const mx = mouse.current.x; const my = mouse.current.y; const radius = 180; const ease = 0.025; // slower easing for a gentle delay for (const dot of dots.current) { const dx = mx - dot.baseX; const dy = my - dot.baseY; const dist = Math.sqrt(dx * dx + dy * dy); let targetX = dot.baseX; let targetY = dot.baseY; let targetR = 3; if (dist < radius) { const force = (radius - dist) / radius; const angle = Math.atan2(dy, dx); targetX = dot.baseX - Math.cos(angle) * force * 30; targetY = dot.baseY - Math.sin(angle) * force * 30; targetR = 3 + force * 5; } dot.x += (targetX - dot.x) * ease; dot.y += (targetY - dot.y) * ease; dot.r += (targetR - dot.r) * ease; ctx.beginPath(); ctx.arc(dot.x, dot.y, dot.r, 0, Math.PI * 2); ctx.fillStyle = dot.color; ctx.fill(); } raf.current = requestAnimationFrame(draw); }; resize(); window.addEventListener('resize', resize); canvas.addEventListener('mousemove', onMove); canvas.addEventListener('mouseleave', onLeave); raf.current = requestAnimationFrame(draw); return () => { window.removeEventListener('resize', resize); canvas.removeEventListener('mousemove', onMove); canvas.removeEventListener('mouseleave', onLeave); cancelAnimationFrame(raf.current); }; }, [initDots]); return <canvas ref={canvasRef} className="dot-canvas" />; } /* ── Landing page ── */ export default function LandingPage() { const { t } = useTranslation(); const navigate = useNavigate(); return ( <div className="landing"> {/* Left — hero image */} <div className="landing-left"> <img src={concertImg} alt={t('auth.landing.hero_alt')} className="landing-hero-img" /> <div className="landing-img-overlay" /> </div> {/* Right — actions + dot animation */} <div className="landing-right"> <DotCanvas /> <div className="landing-language-switcher"> <LanguageSwitcher /> </div> <div className="landing-content"> <div className="landing-logo"> <SemLogo height={88} color="#ffffff" /> </div> <p className="landing-tagline"> {t('auth.landing.tagline')} </p> <div className="landing-actions"> <button className="landing-btn landing-btn--primary" onClick={() => navigate('/login')}> {t('auth.landing.sign_in')} </button> <button className="landing-btn landing-btn--outline" onClick={() => navigate('/register')}> {t('auth.landing.sign_up')} </button> <button className="landing-btn landing-btn--ghost" onClick={() => navigate('/discover')}> {t('auth.landing.continue_as_guest')} </button> </div> </div> </div> </div> ); } |