fix: tooltip UI
Browse files- app/components/ui/Tooltip.tsx +46 -12
app/components/ui/Tooltip.tsx
CHANGED
|
@@ -1,14 +1,15 @@
|
|
| 1 |
-
import React from 'react';
|
| 2 |
import * as Tooltip from '@radix-ui/react-tooltip';
|
| 3 |
-
import type { ReactNode } from 'react';
|
| 4 |
|
| 5 |
-
interface
|
| 6 |
-
tooltip:
|
| 7 |
-
children: ReactNode
|
| 8 |
sideOffset?: number;
|
| 9 |
className?: string;
|
| 10 |
arrowClassName?: string;
|
| 11 |
-
tooltipStyle?:
|
|
|
|
|
|
|
|
|
|
| 12 |
}
|
| 13 |
|
| 14 |
const WithTooltip = ({
|
|
@@ -18,18 +19,51 @@ const WithTooltip = ({
|
|
| 18 |
className = '',
|
| 19 |
arrowClassName = '',
|
| 20 |
tooltipStyle = {},
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
return (
|
| 23 |
-
<Tooltip.Root>
|
| 24 |
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
|
| 25 |
<Tooltip.Portal>
|
| 26 |
<Tooltip.Content
|
| 27 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
sideOffset={sideOffset}
|
| 29 |
-
style={{
|
|
|
|
|
|
|
|
|
|
| 30 |
>
|
| 31 |
-
{tooltip}
|
| 32 |
-
<Tooltip.Arrow
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
</Tooltip.Content>
|
| 34 |
</Tooltip.Portal>
|
| 35 |
</Tooltip.Root>
|
|
|
|
|
|
|
| 1 |
import * as Tooltip from '@radix-ui/react-tooltip';
|
|
|
|
| 2 |
|
| 3 |
+
interface TooltipProps {
|
| 4 |
+
tooltip: React.ReactNode;
|
| 5 |
+
children: React.ReactNode;
|
| 6 |
sideOffset?: number;
|
| 7 |
className?: string;
|
| 8 |
arrowClassName?: string;
|
| 9 |
+
tooltipStyle?: React.CSSProperties;
|
| 10 |
+
position?: 'top' | 'bottom' | 'left' | 'right';
|
| 11 |
+
maxWidth?: number;
|
| 12 |
+
delay?: number;
|
| 13 |
}
|
| 14 |
|
| 15 |
const WithTooltip = ({
|
|
|
|
| 19 |
className = '',
|
| 20 |
arrowClassName = '',
|
| 21 |
tooltipStyle = {},
|
| 22 |
+
position = 'top',
|
| 23 |
+
maxWidth = 250,
|
| 24 |
+
delay = 0,
|
| 25 |
+
}: TooltipProps) => {
|
| 26 |
return (
|
| 27 |
+
<Tooltip.Root delayDuration={delay}>
|
| 28 |
<Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
|
| 29 |
<Tooltip.Portal>
|
| 30 |
<Tooltip.Content
|
| 31 |
+
side={position}
|
| 32 |
+
className={`
|
| 33 |
+
z-[2000]
|
| 34 |
+
px-2.5
|
| 35 |
+
py-1.5
|
| 36 |
+
max-h-[300px]
|
| 37 |
+
select-none
|
| 38 |
+
rounded-md
|
| 39 |
+
bg-bolt-elements-background-depth-3
|
| 40 |
+
text-bolt-elements-textPrimary
|
| 41 |
+
text-sm
|
| 42 |
+
leading-tight
|
| 43 |
+
shadow-lg
|
| 44 |
+
animate-in
|
| 45 |
+
fade-in-0
|
| 46 |
+
zoom-in-95
|
| 47 |
+
data-[state=closed]:animate-out
|
| 48 |
+
data-[state=closed]:fade-out-0
|
| 49 |
+
data-[state=closed]:zoom-out-95
|
| 50 |
+
${className}
|
| 51 |
+
`}
|
| 52 |
sideOffset={sideOffset}
|
| 53 |
+
style={{
|
| 54 |
+
maxWidth,
|
| 55 |
+
...tooltipStyle,
|
| 56 |
+
}}
|
| 57 |
>
|
| 58 |
+
<div className="break-words">{tooltip}</div>
|
| 59 |
+
<Tooltip.Arrow
|
| 60 |
+
className={`
|
| 61 |
+
fill-bolt-elements-background-depth-3
|
| 62 |
+
${arrowClassName}
|
| 63 |
+
`}
|
| 64 |
+
width={12}
|
| 65 |
+
height={6}
|
| 66 |
+
/>
|
| 67 |
</Tooltip.Content>
|
| 68 |
</Tooltip.Portal>
|
| 69 |
</Tooltip.Root>
|