Skip to content

Commit

Permalink
PR
Browse files Browse the repository at this point in the history
  • Loading branch information
Manancode committed Oct 15, 2024
1 parent 8f3212d commit 156c405
Show file tree
Hide file tree
Showing 3 changed files with 485 additions and 4 deletions.
32 changes: 32 additions & 0 deletions library/src/components/ToolTipWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React, { ReactNode } from 'react';
import * as RadixTooltip from '@radix-ui/react-tooltip';

interface TooltipWrapperProps {
children: ReactNode;
description?: string;
}

export const TooltipWrapper: React.FC<TooltipWrapperProps> = ({ children, description }) => {
if (!description) {
return <>{children}</>;
}

return (
<RadixTooltip.Provider>
<RadixTooltip.Root>
<RadixTooltip.Trigger asChild>
<span>{children}</span>
</RadixTooltip.Trigger>
<RadixTooltip.Portal>
<RadixTooltip.Content
className="rounded-md bg-gray-800 px-4 py-2 text-sm text-white shadow-md"
sideOffset={5}
>
{description}
<RadixTooltip.Arrow className="fill-gray-800" />
</RadixTooltip.Content>
</RadixTooltip.Portal>
</RadixTooltip.Root>
</RadixTooltip.Provider>
);
};
Loading

0 comments on commit 156c405

Please sign in to comment.