@@ -8,7 +8,7 @@ import styles from './styles.module.css'
8
8
9
9
function WithProviderMinimal ( ) {
10
10
return (
11
- < section style = { { marginTop : '100px ' } } >
11
+ < section style = { { marginTop : '50px ' } } >
12
12
< p >
13
13
< TooltipWrapper place = "bottom" content = "Shared Global Tooltip" >
14
14
< button > Minimal 1</ button >
@@ -24,7 +24,7 @@ function WithProviderMinimal() {
24
24
25
25
function WithProviderMultiple ( ) {
26
26
return (
27
- < section style = { { marginTop : '100px ' } } >
27
+ < section style = { { marginTop : '50px ' } } >
28
28
< p >
29
29
< TooltipWrapper tooltipId = "tooltip-1" place = "bottom" >
30
30
< button > Multiple 1</ button >
@@ -43,27 +43,10 @@ function App() {
43
43
const [ anchorId , setAnchorId ] = useState ( 'button' )
44
44
const [ isDarkOpen , setIsDarkOpen ] = useState ( false )
45
45
const [ position , setPosition ] = useState < IPosition > ( { } )
46
- const [ tooltipEffect , setTooltipEffect ] = useState ( 'float' )
47
-
48
- const handlePositionClick = ( event : MouseEvent ) => {
49
- if ( tooltipEffect === 'float' ) {
50
- return
51
- }
52
46
47
+ const handlePositionClick : React . MouseEventHandler < HTMLDivElement > = ( event ) => {
53
48
const x = event . clientX
54
49
const y = event . clientY
55
-
56
- setPosition ( { x, y } )
57
- }
58
-
59
- const handleMouseMove = ( event : MouseEvent ) => {
60
- if ( tooltipEffect !== 'float' ) {
61
- return
62
- }
63
-
64
- const x = event . clientX
65
- const y = event . clientY
66
-
67
50
setPosition ( { x, y } )
68
51
}
69
52
@@ -139,31 +122,18 @@ function App() {
139
122
< TooltipProvider >
140
123
< WithProviderMultiple />
141
124
</ TooltipProvider >
142
-
143
- < button
144
- onClick = { ( ) => {
145
- if ( tooltipEffect === 'float' ) {
146
- setTooltipEffect ( 'coordinates' )
147
- } else if ( tooltipEffect === 'coordinates' ) {
148
- setTooltipEffect ( 'float' )
149
- }
150
- } }
151
- >
152
- Switch tooltip effect
153
- </ button >
154
125
< div
155
- id = "freeTooltipAnchor"
156
- className = { styles . freeAnchor }
157
- onClick = { ( event : any ) => {
158
- handlePositionClick ( event as MouseEvent )
159
- } }
160
- onMouseMove = { ( event : any ) => {
161
- handleMouseMove ( event as MouseEvent )
126
+ id = "onClickAnchor"
127
+ className = { styles [ 'on-click-anchor' ] }
128
+ onClick = { ( event ) => {
129
+ handlePositionClick ( event )
162
130
} }
163
- />
131
+ >
132
+ Click me!
133
+ </ div >
164
134
< Tooltip
165
- anchorId = "freeTooltipAnchor "
166
- content = " This is a free tooltip"
135
+ anchorId = "onClickAnchor "
136
+ content = { ` This is an on click tooltip (x: ${ position . x } ,y: ${ position . y } )` }
167
137
events = { [ 'click' ] }
168
138
position = { position }
169
139
/>
0 commit comments