diff --git a/components/sections/ComoEmpezar.tsx b/components/sections/ComoEmpezar.tsx index 9597cf1..2faa62d 100644 --- a/components/sections/ComoEmpezar.tsx +++ b/components/sections/ComoEmpezar.tsx @@ -1,46 +1,41 @@ 'use client'; -import { motion } from 'framer-motion'; +import { motion, useScroll, useTransform } from 'framer-motion'; import Image from 'next/image'; import { Container } from '@/components/primitives/Container'; import { CTA } from '@/components/primitives/CTA'; import { Icono, type IconoNombre } from '@/components/primitives/Icono'; import { comoEmpezar, cierre } from '@/lib/content'; -import { fadeInUp, staggerContainer, viewportOnce, usePrefersReducedMotion, motionProps, useAutoStep } from '@/lib/motion'; +import { fadeInUp, staggerContainer, viewportOnce, usePrefersReducedMotion, motionProps } from '@/lib/motion'; const ICONOS: IconoNombre[] = ['escribeme', 'diagnostico', 'plan']; export function ComoEmpezar() { const reduced = usePrefersReducedMotion(); const waHref = `${cierre.contact.whatsapp.href}?text=${encodeURIComponent(comoEmpezar.whatsappText)}`; - const { active, setActive, hoverProps } = useAutoStep(comoEmpezar.steps.length, 3200); + // Page-level scroll (no target ref) keeps this to a single listener and + // avoids jsdom's "container has a static position" warning. + const { scrollYProgress } = useScroll(); + const desplazamiento = useTransform(scrollYProgress, [0, 1], [20, -20]); return (
{comoEmpezar.eyebrow} {comoEmpezar.title} - + {comoEmpezar.steps.map((step, i) => ( - - +

{step.desc}

+
))}
@@ -52,6 +47,7 @@ export function ComoEmpezar() { modificada (duotono) — créditos en el footer. "Tu siguiente movimiento empieza…": el amanecer como metáfora del comienzo. */}
{/* Foto: Golden Gate Bridge, Dietmar Rabich, CC BY-SA 4.0, modificada (duotono) — créditos en el footer */} - + {mecanismo.eyebrow} @@ -64,7 +72,7 @@ export function Mecanismo() { onClick={() => setActive(i)} aria-pressed={active === i} className={`w-full text-left border-t pt-6 transition-all duration-300 ease-out hover:-translate-y-1.5 motion-reduce:transform-none motion-reduce:transition-none ${ - active === i ? 'border-dorado md:-translate-y-1.5' : 'border-dorado/30 md:opacity-40' + active === i ? 'border-dorado md:-translate-y-1.5' : 'border-white/20' }`} >
diff --git a/components/sections/__tests__/ComoEmpezar.test.tsx b/components/sections/__tests__/ComoEmpezar.test.tsx index 315b4f0..3636a69 100644 --- a/components/sections/__tests__/ComoEmpezar.test.tsx +++ b/components/sections/__tests__/ComoEmpezar.test.tsx @@ -1,5 +1,5 @@ -import { render, screen, act } from '@testing-library/react'; -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { render, screen } from '@testing-library/react'; +import { describe, it, expect } from 'vitest'; import { ComoEmpezar } from '../ComoEmpezar'; describe('', () => { @@ -24,17 +24,17 @@ describe('', () => { expect(img).toHaveAttribute('alt', ''); }); - describe('auto-advancing step highlight', () => { - beforeEach(() => { vi.useFakeTimers(); }); - afterEach(() => { vi.useRealTimers(); }); + it('keeps all three steps readable without interaction', () => { + const { container } = render(); + // The steps used to sit at opacity-40 until the reader hovered or the + // autoplay reached them, which made two of every three illegible. + expect(container.innerHTML).not.toContain('opacity-40'); + }); - it('highlights the first step by default, then advances on its own', () => { - render(); - const first = screen.getByText('Escríbeme').closest('button'); - const second = screen.getByText('Sesión de diagnóstico').closest('button'); - expect(first).toHaveAttribute('aria-pressed', 'true'); - act(() => { vi.advanceTimersByTime(3300); }); - expect(second).toHaveAttribute('aria-pressed', 'true'); - }); + it('presents the steps as content, not as controls', () => { + render(); + // Without autoplay there is nothing to steer, so the steps stop being + // buttons and go back to being a plain ordered list. + expect(screen.queryAllByRole('button')).toHaveLength(0); }); });