Skip to content

Commit

Permalink
feat: add tw merge (#1827)
Browse files Browse the repository at this point in the history
  • Loading branch information
keellyp authored Oct 25, 2024
1 parent 4172bbb commit 8b6ae92
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/components/designSystem/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { Tooltip as MuiTooltip, TooltipProps as MuiTooltipProps } from '@mui/material'
import { forwardRef, ReactNode, useState } from 'react'

import { tw } from '~/styles/utils'

interface TooltipProps
extends Pick<
MuiTooltipProps,
Expand All @@ -11,23 +13,25 @@ interface TooltipProps
maxWidth?: string
}

export const Tooltip = forwardRef(
(
{ children, disableHoverListener, className, maxWidth = '320px', ...props }: TooltipProps,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ref: any,
) => {
export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
({ children, disableHoverListener, className, maxWidth = '320px', ...props }, ref) => {
const [isOpen, setIsOpen] = useState(false)

return (
<div
className={className}
className={tw(className)}
ref={ref}
onMouseEnter={() => !disableHoverListener && setIsOpen(true)}
onMouseLeave={() => setIsOpen(false)}
>
<MuiTooltip
componentsProps={{ tooltip: { style: { maxWidth: maxWidth } } }}
componentsProps={{
tooltip: {
style: {
maxWidth: maxWidth,
},
},
}}
open={isOpen}
enterDelay={400}
leaveDelay={0}
Expand Down

0 comments on commit 8b6ae92

Please sign in to comment.