|
| 1 | +import { Button, Input } from '@/components/ui' |
| 2 | +import { useGSAP } from '@gsap/react' |
| 3 | +import gsap from 'gsap' |
| 4 | +import { ScrollTrigger } from 'gsap/all' |
| 5 | +import { useRef } from 'react' |
| 6 | +import { useTranslation } from 'react-i18next' |
| 7 | +gsap.registerPlugin(ScrollTrigger) |
| 8 | +export const JoinNewsletter = () => { |
| 9 | + const containerRef = useRef<HTMLDivElement | null>(null) |
| 10 | + const h2Ref = useRef<HTMLHeadingElement | null>(null) |
| 11 | + const pRef = useRef<HTMLParagraphElement | null>(null) |
| 12 | + const inputRef = useRef<HTMLDivElement | null>(null) |
| 13 | + const { t } = useTranslation(['landingPage', 'forms']) |
| 14 | + |
| 15 | + useGSAP(() => { |
| 16 | + const tl = gsap.timeline({ |
| 17 | + scrollTrigger: { |
| 18 | + trigger: containerRef.current, |
| 19 | + start: '-20% center', |
| 20 | + end: 'bottom bottom', |
| 21 | + scrub: 1, |
| 22 | + }, |
| 23 | + }) |
| 24 | + |
| 25 | + tl.from(h2Ref.current, { |
| 26 | + opacity: 0, |
| 27 | + y: 50, |
| 28 | + duration: 0.5, |
| 29 | + ease: 'power3.out', |
| 30 | + }) |
| 31 | + .from(pRef.current, { |
| 32 | + opacity: 0, |
| 33 | + y: 50, |
| 34 | + duration: 0.5, |
| 35 | + ease: 'power3.out', |
| 36 | + }) |
| 37 | + .from(inputRef.current, { |
| 38 | + opacity: 0, |
| 39 | + y: 50, |
| 40 | + duration: 0.5, |
| 41 | + ease: 'power3.out', |
| 42 | + }) |
| 43 | + }, []) |
| 44 | + |
| 45 | + return ( |
| 46 | + <div className='py-10 md:py-20 bg-white' ref={containerRef}> |
| 47 | + <div className='container'> |
| 48 | + <div className='flex items-center flex-col gap-10'> |
| 49 | + <div className='flex items-center justify-center flex-col gap-4'> |
| 50 | + <h2 |
| 51 | + className='text-3xl md:text-5xl font-bold text-center max-w-2xl' |
| 52 | + ref={h2Ref} |
| 53 | + > |
| 54 | + {t('join_out_newsletter')} |
| 55 | + </h2> |
| 56 | + <p |
| 57 | + className='text-center font-medium text-sm md:text-lg text-muted-foreground' |
| 58 | + ref={pRef} |
| 59 | + > |
| 60 | + {t('join_out_newsletter_subtitle')} |
| 61 | + </p> |
| 62 | + </div> |
| 63 | + <div |
| 64 | + className='flex items-center justify-center gap-3' |
| 65 | + ref={inputRef} |
| 66 | + > |
| 67 | + <Input |
| 68 | + placeholder={t('forms:email.placeholder')} |
| 69 | + className='w-96' |
| 70 | + type='email' |
| 71 | + /> |
| 72 | + <Button>{t('join_out_newsletter_button')}</Button> |
| 73 | + </div> |
| 74 | + </div> |
| 75 | + </div> |
| 76 | + </div> |
| 77 | + ) |
| 78 | +} |
| 79 | + |
| 80 | +export default JoinNewsletter |
0 commit comments