import { prefersReducedMotion, spring } from '@remix-run/ui/animation' import { css, on } from 'remix/component' import type { Handle } from 'remix/component' export default function ExampleSpring(handle: Handle) { let active = 0 let position = 0 let frame = 0 handle.signal.addEventListener('abort', () => cancelAnimationFrame(frame), { once: true }) function goTo(index: number) { cancelAnimationFrame(frame) active = index let from = position let to = active * 100 if (prefersReducedMotion()) { position = to handle.update() return } let samples = spring('smooth') function tick() { let sample = samples.next() position = sample.done ? to : from + (to - from) * sample.value handle.update() if (!sample.done) frame = requestAnimationFrame(tick) } handle.update() frame = requestAnimationFrame(tick) } return () => (
Highlights
{active + 1} / {slides.length}
{slides.map((slide, index) => (
{slide.title}

{slide.description}

))}
) } const mutedStyle = css({ color: 'light-dark(#62626c, #b0b0bb)', margin: 0, fontSize: '12px', }) const buttonStyle = css({ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', padding: '8px', border: '1px solid light-dark(#d8d8df, #44444c)', borderRadius: '8px', background: 'var(--surface)', color: 'inherit', font: 'inherit', fontWeight: 600, cursor: 'pointer', transition: 'background-color 160ms ease, color 160ms ease', '&:disabled': { opacity: 0.4, cursor: 'not-allowed', }, '&:hover:not(:disabled)': { background: 'light-dark(#f0f0f5, #303038)', }, '&:focus-visible': { outline: '2px solid light-dark(#70707c, #a0a0ac)', outlineOffset: '3px', }, '@media (prefers-reduced-motion: reduce)': { transition: 'none', }, }) function Arrow(handle: Handle<{ back?: boolean }>) { return () => ( ) } const slides = [ { title: 'A place for every project', description: 'Keep designs, feedback and decisions together.', }, { title: 'Stay in the loop', description: 'Follow updates from the people you work with.', }, { title: 'Make room for good work', description: 'Turn your next idea into something worth sharing.', }, ]