sujal777 commited on
Commit
0ebd4a6
·
1 Parent(s): b8b25ba

fix: tooltip UI

Browse files
Files changed (1) hide show
  1. 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 ToolTipProps {
6
- tooltip: string;
7
- children: ReactNode | ReactNode[];
8
  sideOffset?: number;
9
  className?: string;
10
  arrowClassName?: string;
11
- tooltipStyle?: any; //TODO better type
 
 
 
12
  }
13
 
14
  const WithTooltip = ({
@@ -18,18 +19,51 @@ const WithTooltip = ({
18
  className = '',
19
  arrowClassName = '',
20
  tooltipStyle = {},
21
- }: ToolTipProps) => {
 
 
 
22
  return (
23
- <Tooltip.Root>
24
  <Tooltip.Trigger asChild>{children}</Tooltip.Trigger>
25
  <Tooltip.Portal>
26
  <Tooltip.Content
27
- className={`bg-bolt-elements-tooltip-background text-bolt-elements-textPrimary px-3 py-2 rounded-lg text-sm shadow-lg ${className}`}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  sideOffset={sideOffset}
29
- style={{ zIndex: 2000, backgroundColor: 'white', ...tooltipStyle }}
 
 
 
30
  >
31
- {tooltip}
32
- <Tooltip.Arrow className={`fill-bolt-elements-tooltip-background ${arrowClassName}`} />
 
 
 
 
 
 
 
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>