diff --git a/web/src/lib/useParallax.ts b/web/src/lib/useParallax.ts new file mode 100644 index 0000000..e5e2358 --- /dev/null +++ b/web/src/lib/useParallax.ts @@ -0,0 +1,43 @@ +import { useEffect, type RefObject } from 'react'; + +/** + * Tło z paralaksą — elementy `data-parallax` przesuwają się względem środka + * widoku o przeskalowany współczynnik. W reduced-motion statycznie. + */ +export function useParallax(rootRef: RefObject) { + useEffect(() => { + const root = rootRef.current; + if (!root) return; + if ( + typeof window.matchMedia === 'function' && + window.matchMedia('(prefers-reduced-motion: reduce)').matches + ) + return; + + const layers = Array.from(root.querySelectorAll('[data-parallax]')); + if (!layers.length) return; + + let raf = 0; + const update = () => { + const rect = root.getBoundingClientRect(); + for (const layer of layers) { + const speed = Number(layer.dataset.parallax) || 0; + const offset = (rect.top + rect.height / 2 - window.innerHeight / 2) * speed; + layer.style.transform = `translate3d(0, ${offset.toFixed(1)}px, 0)`; + } + }; + const onScroll = () => { + cancelAnimationFrame(raf); + raf = requestAnimationFrame(update); + }; + + update(); + window.addEventListener('scroll', onScroll, { passive: true }); + window.addEventListener('resize', onScroll); + return () => { + cancelAnimationFrame(raf); + window.removeEventListener('scroll', onScroll); + window.removeEventListener('resize', onScroll); + }; + }, [rootRef]); +} diff --git a/web/src/sections/Cta.tsx b/web/src/sections/Cta.tsx index 701dff0..e359b5a 100644 --- a/web/src/sections/Cta.tsx +++ b/web/src/sections/Cta.tsx @@ -1,34 +1,74 @@ +import { useRef } from 'react'; import { ArrowRight, ShieldCheck } from 'lucide-react'; import { Reveal } from '../components/Reveal'; import { adminUrl, appUrl } from '../lib/links'; +import { useParallax } from '../lib/useParallax'; import { Section } from './shared'; -/** CTA końcowa: „uruchom system”. */ +const LINES_A = [ + 'gotowe: trening · coaching · siłownie', + 'błędy krytyczne: brak', + 'dane: Twoja infrastruktura', + 'start gotowy — wybieraj modul', +]; + +const LINES_B = ['$ fitos --run', 'port 9002 · self-hosted', '$ ./start --wybierz-modul']; + +/** CTA końcowa: „uruchom system” — czarne tło z paralaksą logu startowego. */ export function Cta() { + const rootRef = useRef(null); + useParallax(rootRef); + return ( -
- -

$ fitos --run

-

System gotowy.

-

- Włącz moduł, którego potrzebujesz: trening swój albo trening podopiecznych. -

- -
-
+
+ + + ); } diff --git a/web/src/sections/Manifest.tsx b/web/src/sections/Manifest.tsx index b8be7b0..abf56e1 100644 --- a/web/src/sections/Manifest.tsx +++ b/web/src/sections/Manifest.tsx @@ -1,47 +1,6 @@ -import { useEffect, useRef } from 'react'; +import { useRef } from 'react'; import { Reveal } from '../components/Reveal'; - -/** - * Tło z paralaksą — elementy przesuwają się względem widoku inną prędkością - * (dane `data-parallax` = przeskalowany współczynnik). W reduced-motion statycznie. - */ -function useParallax(rootRef: React.RefObject) { - useEffect(() => { - const root = rootRef.current; - if (!root) return; - if ( - typeof window.matchMedia === 'function' && - window.matchMedia('(prefers-reduced-motion: reduce)').matches - ) - return; - - const layers = Array.from(root.querySelectorAll('[data-parallax]')); - if (!layers.length) return; - - let raf = 0; - const update = () => { - const rect = root.getBoundingClientRect(); - for (const layer of layers) { - const speed = Number(layer.dataset.parallax) || 0; - const offset = (rect.top + rect.height / 2 - window.innerHeight / 2) * speed; - layer.style.transform = `translate3d(0, ${offset.toFixed(1)}px, 0)`; - } - }; - const onScroll = () => { - cancelAnimationFrame(raf); - raf = requestAnimationFrame(update); - }; - - update(); - window.addEventListener('scroll', onScroll, { passive: true }); - window.addEventListener('resize', onScroll); - return () => { - cancelAnimationFrame(raf); - window.removeEventListener('scroll', onScroll); - window.removeEventListener('resize', onScroll); - }; - }, [rootRef]); -} +import { useParallax } from '../lib/useParallax'; const LINES_A = [ '$ fitos --run',