File size: 2,467 Bytes
41235a1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { useRef, useState } from 'react'

const SLIDES = [
  {
    serif: 'Reimagining wellness ',
    sans: 'for a new generation of patients and caregivers.',
  },
  {
    serif: 'Turning a hometown retailer ',
    sans: 'into a brand people genuinely love.',
  },
  {
    serif: 'Building diversity, inclusion, and social good ',
    sans: 'into the core of one of the largest tech companies.',
  },
  {
    serif: 'Designing a food system ',
    sans: 'that feeds people and regenerates the planet.',
  },
  {
    serif: 'Helping a global icon ',
    sans: 'rediscover what made it matter in the first place.',
  },
  {
    serif: 'Creating new rituals ',
    sans: 'for how the next generation experiences sport.',
  },
]

const FADE_MS = 280

export default function WorkCarousel() {
  const [index, setIndex] = useState(2) // matches "3 of 6" in the reference
  const [leaving, setLeaving] = useState(false)
  const timer = useRef(null)

  const next = () => {
    if (leaving) return
    setLeaving(true)
    timer.current = setTimeout(() => {
      setIndex((i) => (i + 1 >= SLIDES.length - 1 ? 0 : i + 1))
      setLeaving(false)
    }, FADE_MS)
  }

  const slide = SLIDES[index]

  return (
    <section className="work" aria-label="What we're working on">
      <div className="work-meta">
        <p className="eyebrow">
          What we&rsquo;re working on <span className="dash" aria-hidden="true" />
        </p>
        <p className="work-count" aria-live="polite">
          {index + 1} of {SLIDES.length}
        </p>
      </div>

      <div className={`work-copy${leaving ? ' is-leaving' : ''}`}>
        <h2 className="work-headline" key={index}>
          <em>{slide.serif}</em>
          {slide.sans}
        </h2>
      </div>

      <div className="work-actions">
        <button type="button" className="pill-button">
          How&rsquo;d you do that?
        </button>
        <button type="button" className="next-button" onClick={next}>
          Next
          <svg
            className="arrow"
            width="34"
            height="16"
            viewBox="0 0 34 16"
            fill="none"
            aria-hidden="true"
          >
            <path
              d="M1 8h31M25 1.5L32.5 8 25 14.5"
              stroke="currentColor"
              strokeWidth="1.6"
              strokeLinecap="round"
              strokeLinejoin="round"
            />
          </svg>
        </button>
      </div>
    </section>
  )
}