Datasets:
Download tasks/c11/repo/src/components/WorkCarousel.jsx from Roy-DOU/Webdev-Bench: direct link, hf CLI and curl.
- Browser
- Download file 2.47 kB
-
https://huggingface.co/datasets/Roy-DOU/Webdev-Bench/resolve/main/tasks/c11/repo/src/components/WorkCarousel.jsx
- Command line
-
hf download hf://datasets/Roy-DOU/Webdev-Bench/tasks/c11/repo/src/components/WorkCarousel.jsx
-
curl -L -o WorkCarousel.jsx https://huggingface.co/datasets/Roy-DOU/Webdev-Bench/resolve/main/tasks/c11/repo/src/components/WorkCarousel.jsx
2.47 kB
| 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’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’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> | |
| ) | |
| } | |