refactor: better tooltip

This commit is contained in:
MAZE 2023-10-29 18:42:20 +03:30
parent f5cdb8c06b
commit 5fecd383aa
2 changed files with 14 additions and 15 deletions

View File

@ -28,6 +28,8 @@ export function UnselectButton() {
variants={variants} variants={variants}
> >
<Tooltip <Tooltip
hideDelay={0}
showDelay={0}
content={ content={
hasHistory hasHistory
? 'Restore unselected sounds.' ? 'Restore unselected sounds.'

View File

@ -38,9 +38,6 @@ export function Tooltip({
floatingStyles, floatingStyles,
placement: computedPlacement, placement: computedPlacement,
refs, refs,
strategy,
x,
y,
} = useFloating({ } = useFloating({
middleware: [offset(12), flip(), shift()], middleware: [offset(12), flip(), shift()],
onOpenChange: setIsTooltipOpen, onOpenChange: setIsTooltipOpen,
@ -90,20 +87,20 @@ export function Tooltip({
<AnimatePresence> <AnimatePresence>
{isTooltipOpen && ( {isTooltipOpen && (
<motion.div <div
animate="show"
exit="hidden"
initial="hidden"
ref={refs.setFloating} ref={refs.setFloating}
style={floatingStyles} {...getFloatingProps({ style: floatingStyles })}
variants={variants}
{...getFloatingProps({
className: styles.tooltip,
style: { left: x ?? 0, position: strategy, top: y ?? 0 },
})}
> >
{content} <motion.div
</motion.div> animate="show"
className={styles.tooltip}
exit="hidden"
initial="hidden"
variants={variants}
>
{content}
</motion.div>
</div>
)} )}
</AnimatePresence> </AnimatePresence>
</> </>