import { animated, useSprings } from '@react-spring/web' import { HomeBlockCopy } from './HomeBlockCopy' import { useIsDarkTheme } from '~/hooks/useIsDarkTheme' import { pre } from '../Code/Pre.css' import clsx from 'clsx' import { homeBlockCode, list, listItem } from './HomeBlockMore.css' import { section } from './shared.css' const listItems = [ 'Animate any value – strings, numbers, css variables...', 'Shorthand transformation styles', 'Interpolate values inline', 'Easily react to animation events', 'Usable with any component library', ] const dataFixtures = [ `
import * as Dialog from '@radix-ui/react-dialog'
import { styled } from '@stitches/react'
import { animated, useSpring } from '@react-spring/web'
export const AnimatedDialog = ({ isOpen, onOpenCallback }) => {
const { x, backgroundColor, o } = useSpring({
x: isOpen ? '0%' : '-100%',
backgroundColor: isOpen
? 'var(--color-whiteblur)'
: 'var(--colors-white00)',
o: isOpen ? 1 : 0,
onRest: () => {
if (isOpen && onOpenCallback) {
onOpenCallback()
}
},
})
return (
<Dialog.Root>
<Overlay style={{ backgroundColor }} />
<Modal style={{ x, backgroundColor: o.to(o => 'rgba(255,255,255,' + o + ')'), }} />
</Dialog.Root>
)
}
`, `
import * as Dialog from '@radix-ui/react-dialog'
import { styled } from '@stitches/react'
import { animated, useSpring } from '@react-spring/web'
export const AnimatedDialog = ({ isOpen, onOpenCallback }) => {
const { x, backgroundColor, o } = useSpring({
x: isOpen ? '0%' : '-100%',
backgroundColor: isOpen
? 'var(--color-whiteblur)'
: 'var(--colors-white00)',
o: isOpen ? 1 : 0,
onRest: () => {
if (isOpen && onOpenCallback) {
onOpenCallback()
}
},
})
return (
<Dialog.Root>
<Overlay style={{ backgroundColor }} />
<Modal style={{ x, backgroundColor: o.to(o => 'rgba(255,255,255,' + o + ')'), }} />
</Dialog.Root>
)
}
`, `
import * as Dialog from '@radix-ui/react-dialog'
import { styled } from '@stitches/react'
import { animated, useSpring } from '@react-spring/web'
export const AnimatedDialog = ({ isOpen, onOpenCallback }) => {
const { x, backgroundColor, o } = useSpring({
x: isOpen ? '0%' : '-100%',
backgroundColor: isOpen
? 'var(--color-whiteblur)'
: 'var(--colors-white00)',
o: isOpen ? 1 : 0,
onRest: () => {
if (isOpen && onOpenCallback) {
onOpenCallback()
}
},
})
return (
<Dialog.Root>
<Overlay style={{ backgroundColor }} />
<Modal style={{ x, backgroundColor: o.to(o => 'rgba(255,255,255,' + o + ')'), }} />
</Dialog.Root>
)
}
`, `
import * as Dialog from '@radix-ui/react-dialog'
import { styled } from '@stitches/react'
import { animated, useSpring } from '@react-spring/web'
export const AnimatedDialog = ({ isOpen, onOpenCallback }) => {
const { x, backgroundColor, o } = useSpring({
x: isOpen ? '0%' : '-100%',
backgroundColor: isOpen
? 'var(--color-whiteblur)'
: 'var(--colors-white00)',
o: isOpen ? 1 : 0,
onRest: () => {
if (isOpen && onOpenCallback) {
onOpenCallback()
}
},
})
return (
<Dialog.Root>
<Overlay style={{ backgroundColor }} />
<Modal style={{ x, backgroundColor: o.to(o => 'rgba(255,255,255,' + o + ')'), }} />
</Dialog.Root>
)
}
`, `
import * as Dialog from '@radix-ui/react-dialog'
import { styled } from '@stitches/react'
import { animated, useSpring } from '@react-spring/web'
export const AnimatedDialog = ({ isOpen, onOpenCallback }) => {
const { x, backgroundColor, o } = useSpring({
x: isOpen ? '0%' : '-100%',
backgroundColor: isOpen
? 'var(--color-whiteblur)'
: 'var(--colors-white00)',
o: isOpen ? 1 : 0,
onRest: () => {
if (isOpen && onOpenCallback) {
onOpenCallback()
}
},
})
return (
<Dialog.Root>
<Overlay style={{ backgroundColor }} />
<Modal style={{ x, backgroundColor: o.to(o => 'rgba(255,255,255,' + o + ')'), }} />
</Dialog.Root>
)
}
`, ] export const HomeBlockMore = () => { const isDarkMode = useIsDarkTheme() const [springs, api] = useSprings( 5, i => ({ opacity: 0 === i ? 1 : 0, config: { precision: 0.0001, }, }), [] ) const handleMouseEnter = (i: number) => () => { api.start(j => ({ opacity: j === i ? 1 : 0, })) } return (
        
        {springs.map((style, i) => (
          
        ))}
      
) }