Skip to content

Commit

Permalink
refactor: better tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
remvze committed Oct 29, 2023
1 parent f5cdb8c commit 5fecd38
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/components/buttons/unselect/unselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ export function UnselectButton() {
variants={variants}
>
<Tooltip
hideDelay={0}
showDelay={0}
content={
hasHistory
? 'Restore unselected sounds.'
Expand Down
27 changes: 12 additions & 15 deletions src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,6 @@ export function Tooltip({
floatingStyles,
placement: computedPlacement,
refs,
strategy,
x,
y,
} = useFloating({
middleware: [offset(12), flip(), shift()],
onOpenChange: setIsTooltipOpen,
Expand Down Expand Up @@ -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>
</>
Expand Down

0 comments on commit 5fecd38

Please sign in to comment.