Skip to content

Commit

Permalink
Add tooltip changes (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
vineethasok authored Sep 26, 2023
1 parent f869eab commit a13fd34
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 1 addition & 3 deletions src/components/Tooltip/Tooltip.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ const TooltipExample = ({ showArrow, side, ...props }: Props) => {
}}
>
<Tooltip {...props}>
<Tooltip.Trigger>
<div>Tooltip Trigger(Hover)</div>
</Tooltip.Trigger>
<Tooltip.Trigger>Tooltip Trigger(Hover)</Tooltip.Trigger>
<Tooltip.Content
showArrow={showArrow}
side={side}
Expand Down
4 changes: 1 addition & 3 deletions src/components/Tooltip/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ describe("Tooltip", () => {
const renderTooltip = (props: TooltipProps) =>
renderCUI(
<Tooltip {...props}>
<Tooltip.Trigger>
<div>Hover Here</div>
</Tooltip.Trigger>
<Tooltip.Trigger>Hover Here</Tooltip.Trigger>
<Tooltip.Content data-testid="tooltip-content">Tooltip content</Tooltip.Content>
</Tooltip>
);
Expand Down
22 changes: 15 additions & 7 deletions src/components/Tooltip/Tooltip.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as RadixTooltip from "@radix-ui/react-tooltip";
import { HTMLAttributes } from "react";
import styled from "styled-components";

export const Tooltip = ({ children, ...props }: RadixTooltip.TooltipProps) => {
return <RadixTooltip.Root {...props}>{children}</RadixTooltip.Root>;
};

const TooltipTrigger = (props: RadixTooltip.TooltipTriggerProps) => {
const TooltipTrigger = (props: HTMLAttributes<HTMLDivElement>) => {
return (
<RadixTooltip.Trigger
asChild
{...props}
/>
<RadixTooltip.Trigger asChild>
<div {...props} />
</RadixTooltip.Trigger>
);
};
TooltipTrigger.displayName = "TooltipTrigger";
Expand All @@ -37,10 +37,18 @@ const Arrow = styled.svg`
`};
`;

const TooltipContent = ({ showArrow, children, ...props }: TooltipContentProps) => {
const TooltipContent = ({
showArrow,
children,
sideOffset = 6,
...props
}: TooltipContentProps) => {
return (
<RadixTooltip.Portal>
<RadixTooltipContent {...props}>
<RadixTooltipContent
sideOffset={sideOffset}
{...props}
>
{showArrow && (
<Arrow
as={RadixTooltip.Arrow}
Expand Down

1 comment on commit a13fd34

@vercel
Copy link

@vercel vercel bot commented on a13fd34 Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

click-ui – ./

click-ui.vercel.app
click-ui-clickhouse.vercel.app
click-ui-git-main-clickhouse.vercel.app

Please sign in to comment.