🔧 refactor(ShadTooltipComponent): destructure props and add types
The ShadTooltipComponent has been refactored to destructure the props and add types to improve readability and maintainability. The ShadTooltipProps type has been added to the types/components/index.ts file to define the expected props for the ShadTooltipComponent. The delayDuration, side, content, and children props are now destructured from the props object and have their respective types defined.
This commit is contained in:
parent
1880484a6c
commit
e10d271e22
2 changed files with 20 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { ShadTooltipProps } from "../../types/components";
|
||||
import {
|
||||
Tooltip,
|
||||
TooltipContent,
|
||||
|
|
@ -5,18 +6,19 @@ import {
|
|||
TooltipTrigger,
|
||||
} from "../ui/tooltip";
|
||||
|
||||
const ShadTooltip = (props) => {
|
||||
const ShadTooltip = ({
|
||||
delayDuration = 500,
|
||||
side,
|
||||
content,
|
||||
children,
|
||||
}: ShadTooltipProps) => {
|
||||
return (
|
||||
<TooltipProvider>
|
||||
<Tooltip delayDuration={props.delayDuration}>
|
||||
<TooltipTrigger asChild>{props.children}</TooltipTrigger>
|
||||
<Tooltip delayDuration={delayDuration}>
|
||||
<TooltipTrigger asChild>{children}</TooltipTrigger>
|
||||
|
||||
<TooltipContent
|
||||
side={props.side}
|
||||
avoidCollisions={false}
|
||||
sticky="always"
|
||||
>
|
||||
{props.content}
|
||||
<TooltipContent side={side} avoidCollisions={false} sticky="always">
|
||||
{content}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
</TooltipProvider>
|
||||
|
|
|
|||
|
|
@ -110,3 +110,12 @@ export type RadialProgressType = {
|
|||
value?: number;
|
||||
color?: string;
|
||||
};
|
||||
|
||||
export type Side = "top" | "right" | "bottom" | "left";
|
||||
|
||||
export type ShadTooltipProps = {
|
||||
delayDuration?: number;
|
||||
side?: Side;
|
||||
content: ReactNode;
|
||||
children: ReactNode;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue