File size: 1,158 Bytes
a8aec61 |
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 |
'use client'
import type React from 'react'
import { motion, AnimatePresence } from 'framer-motion'
import { useStickToBottomContext } from 'use-stick-to-bottom'
import { Button } from '@/components/ui/button'
import Icon from '@/components/ui/icon'
const ScrollToBottom: React.FC = () => {
const { isAtBottom, scrollToBottom } = useStickToBottomContext()
return (
<AnimatePresence>
{!isAtBottom && (
<motion.div
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
transition={{ duration: 0.3, ease: 'easeInOut' }}
className="absolute bottom-4 left-1/2 -translate-x-1/2"
>
<Button
onClick={() => scrollToBottom()}
type="button"
size="icon"
variant="secondary"
className="border border-border bg-background text-primary shadow-md transition-shadow duration-300 hover:bg-background-secondary"
>
<Icon type="arrow-down" size="xs" />
</Button>
</motion.div>
)}
</AnimatePresence>
)
}
export default ScrollToBottom
|