Skip to content

Commit 9b42ca4

Browse files
committed
Tooltip New Feature Added
1 parent 1140c18 commit 9b42ca4

24 files changed

+1482
-0
lines changed

src/components/tooltip/index.d.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import { FC } from 'react'
2+
3+
export enum Trigger {
4+
Hover = 'hover',
5+
Click = 'click',
6+
Touch = 'touch',
7+
}
8+
9+
export enum Position {
10+
Right = 'right',
11+
Below = 'below',
12+
Left = 'left',
13+
Above = 'above',
14+
Auto = 'auto',
15+
}
16+
17+
export interface ToolTipStyle extends React.CSSProperties {
18+
backgroundColor?: string
19+
color?: string
20+
fontSize?: string
21+
animationDuration?: string
22+
}
23+
24+
export type ToolTipContent =
25+
| string
26+
| {
27+
type: 'image' | 'list'
28+
src: string
29+
alt: string
30+
items: string[]
31+
}
32+
| React.ReactElement
33+
34+
interface ToolTipProps {
35+
position: Position
36+
show: boolean
37+
trigger: Trigger[]
38+
content: ToolTipContent
39+
delay: number
40+
style: ToolTipStyle
41+
forceCenter: boolean
42+
autoClose: boolean
43+
children: React.ReactNode
44+
}
45+
46+
interface ToolTipRef {
47+
showDynamicToolTip: (hoverRect: ClientRect) => void
48+
killDynamicToolTip: () => void
49+
getNode: () => HTMLElement | null
50+
}
51+
52+
/**
53+
* ToolTip
54+
*
55+
* A tooltip component that can be positioned relative to its parent element.
56+
*
57+
* @author Fahis <muhammadfahis.shareef@agilisium.com>
58+
* @version 1.0.0
59+
*
60+
* @example
61+
*
62+
* import ToolTip from './index'
63+
*
64+
* const Example = () => {
65+
* return (
66+
* <div>
67+
* <ToolTip
68+
* position="right"
69+
* show={true}
70+
* trigger="hover"
71+
* content="This is some information in the tooltip"
72+
* delay={1000}
73+
* ref={ref}
74+
* >
75+
* <div>Hover over me</div>
76+
* </ToolTip>
77+
* </div>
78+
* )
79+
* }
80+
*/
81+
declare const ToolTip: FC<ToolTipProps> & {
82+
forwardRef: (props: ToolTipProps, ref: ToolTipRef) => JSX.Element
83+
}
84+
85+
export default ToolTip

0 commit comments

Comments
 (0)