Skip to content

Commit

Permalink
🏷️ Allow ReactNode as title in Tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
magnh committed May 23, 2024
1 parent af36ebd commit f41a5f7
Showing 1 changed file with 24 additions and 23 deletions.
47 changes: 24 additions & 23 deletions packages/eds-core-react/src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import {
forwardRef,
useRef,
useState,
HTMLAttributes,
SVGProps,
cloneElement,
useMemo,
useEffect,
} from 'react'
import styled from 'styled-components'
import {
spacingsTemplate,
typographyTemplate,
bordersTemplate,
mergeRefs,
spacingsTemplate,
typographyTemplate,
useIsInDialog,
} from '@equinor/eds-utils'
import { tooltip as tokens } from './Tooltip.tokens'
import {
FloatingPortal,
Placement,
offset,
flip,
shift,
arrow,
autoUpdate,
flip,
offset,
shift,
useDismiss,
useFloating,
useInteractions,
useHover,
useFocus,
useHover,
useInteractions,
useRole,
useDismiss,
FloatingPortal,
} from '@floating-ui/react'
import {
HTMLAttributes,
ReactNode,
SVGProps,
cloneElement,
forwardRef,
useEffect,
useMemo,
useRef,
useState,
} from 'react'
import styled from 'styled-components'
import { tooltip as tokens } from './Tooltip.tokens'

const StyledTooltip = styled.div`
${typographyTemplate(tokens.typography)}
Expand Down Expand Up @@ -76,7 +77,7 @@ export type TooltipProps = {
/** Tooltip placement relative to anchor */
placement?: Placement
/** Tooltip title */
title?: string
title?: string | ReactNode
/** Tooltip anchor element */
children: React.ReactElement & React.RefAttributes<HTMLElement>
/** Delay in ms, default 100 */
Expand All @@ -90,7 +91,7 @@ export const Tooltip = forwardRef<HTMLDivElement, TooltipProps>(
) {
const arrowRef = useRef<HTMLDivElement>(null)
const [open, setOpen] = useState(false)
const shouldOpen = title !== ''
const shouldOpen = Boolean(title)

const {
x,
Expand Down

0 comments on commit f41a5f7

Please sign in to comment.