Skip to content

Commit

Permalink
fix(tooltip): add childrenClassName
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinWijnant committed Jan 31, 2021
1 parent 149a79f commit 29831c3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,23 @@ interface Props {
content?: React.ReactNode;
children?: React.ReactNode;
placement?: Placement;
className?: string;
contentClassName?: string;
childrenClassName?: string;
}

const Popover: React.FC<Props> = ({ content, children, placement = 'top', className }: Props) => {
const Popover: React.FC<Props> = ({
content,
children,
placement = 'top',
contentClassName,
childrenClassName,
}: Props) => {
const [isShown, setIsShown] = useState(false);
const divRef = useRef<HTMLDivElement>(null);
const contentRef = useRef<HTMLDivElement>(null);
const [arrowRef, setArrowRef] = useState<HTMLDivElement | null>(null);
const contentClassNames = classnames(styles.content, className);
const contentClassNames = classnames(styles.content, contentClassName);
const childrenClassNames = classnames(styles.triggerContainer, childrenClassName);

const hide = () => setIsShown(false);
const show = () => setIsShown(true);
Expand All @@ -43,7 +51,7 @@ const Popover: React.FC<Props> = ({ content, children, placement = 'top', classN

return (
<>
<div className={styles.triggerContainer} ref={divRef} onMouseEnter={show} onMouseLeave={hide}>
<div className={childrenClassNames} ref={divRef} onMouseEnter={show} onMouseLeave={hide}>
{children}
</div>

Expand Down

0 comments on commit 29831c3

Please sign in to comment.