@@ -8,7 +8,7 @@ import styles from './styles.module.css'
88
99function WithProviderMinimal ( ) {
1010 return (
11- < section style = { { marginTop : '100px ' } } >
11+ < section style = { { marginTop : '50px ' } } >
1212 < p >
1313 < TooltipWrapper place = "bottom" content = "Shared Global Tooltip" >
1414 < button > Minimal 1</ button >
@@ -24,7 +24,7 @@ function WithProviderMinimal() {
2424
2525function WithProviderMultiple ( ) {
2626 return (
27- < section style = { { marginTop : '100px ' } } >
27+ < section style = { { marginTop : '50px ' } } >
2828 < p >
2929 < TooltipWrapper tooltipId = "tooltip-1" place = "bottom" >
3030 < button > Multiple 1</ button >
@@ -43,27 +43,10 @@ function App() {
4343 const [ anchorId , setAnchorId ] = useState ( 'button' )
4444 const [ isDarkOpen , setIsDarkOpen ] = useState ( false )
4545 const [ position , setPosition ] = useState < IPosition > ( { } )
46- const [ tooltipEffect , setTooltipEffect ] = useState ( 'float' )
47-
48- const handlePositionClick = ( event : MouseEvent ) => {
49- if ( tooltipEffect === 'float' ) {
50- return
51- }
5246
47+ const handlePositionClick : React . MouseEventHandler < HTMLDivElement > = ( event ) => {
5348 const x = event . clientX
5449 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-
6750 setPosition ( { x, y } )
6851 }
6952
@@ -139,31 +122,18 @@ function App() {
139122 < TooltipProvider >
140123 < WithProviderMultiple />
141124 </ 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 >
154125 < 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 )
162130 } }
163- />
131+ >
132+ Click me!
133+ </ div >
164134 < 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 } )` }
167137 events = { [ 'click' ] }
168138 position = { position }
169139 />
0 commit comments