mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: add tooltip to scroll button
This commit is contained in:
parent
262bb1a9c6
commit
d4401faaff
@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';
|
|||||||
import { BiUpArrowAlt } from 'react-icons/bi/index';
|
import { BiUpArrowAlt } from 'react-icons/bi/index';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
|
|
||||||
|
import { Tooltip } from '@/components/tooltip';
|
||||||
import { mix, fade, slideY } from '@/lib/motion';
|
import { mix, fade, slideY } from '@/lib/motion';
|
||||||
|
|
||||||
import styles from './scroll-to-top.module.css';
|
import styles from './scroll-to-top.module.css';
|
||||||
@ -32,17 +33,19 @@ export function ScrollToTop() {
|
|||||||
return (
|
return (
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{isVisible && (
|
{isVisible && (
|
||||||
<motion.button
|
<Tooltip content="Scroll to top" hideDelay={0} showDelay={0}>
|
||||||
animate="show"
|
<motion.button
|
||||||
aria-label="Scroll to top"
|
animate="show"
|
||||||
className={styles.button}
|
aria-label="Scroll to top"
|
||||||
exit="hidden"
|
className={styles.button}
|
||||||
initial="hidden"
|
exit="hidden"
|
||||||
variants={variants}
|
initial="hidden"
|
||||||
onClick={scrollToTop}
|
variants={variants}
|
||||||
>
|
onClick={scrollToTop}
|
||||||
<BiUpArrowAlt />
|
>
|
||||||
</motion.button>
|
<BiUpArrowAlt />
|
||||||
|
</motion.button>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
);
|
);
|
||||||
|
@ -41,7 +41,7 @@ export function Tooltip({
|
|||||||
placement: computedPlacement,
|
placement: computedPlacement,
|
||||||
refs,
|
refs,
|
||||||
} = useFloating({
|
} = useFloating({
|
||||||
middleware: [offset(12), flip(), shift()],
|
middleware: [offset(12), flip(), shift({ padding: 8 })],
|
||||||
onOpenChange: setIsTooltipOpen,
|
onOpenChange: setIsTooltipOpen,
|
||||||
open: isTooltipOpen,
|
open: isTooltipOpen,
|
||||||
placement: placement,
|
placement: placement,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user