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}
>
<Tooltip
hideDelay={0}
showDelay={0}
content={
hasHistory
? 'Restore unselected sounds.'

View File

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