@@ -18,8 +18,8 @@ import { TourItemMeasurement } from "../types";
1818import { useTourStepNavigation } from "../hooks/useTourStepNavigation" ;
1919
2020const TOOLTIP_MARGIN = 16 ;
21- const ARROW_SIZE = 8 ;
22- const TRANSPARENT = "transparent" ;
21+ const ARROW_SIZE = 10 ;
22+ const BORDER_RADIUS = 8 ;
2323
2424type Props = {
2525 itemMeasurement : TourItemMeasurement ;
@@ -53,8 +53,11 @@ export const TourTooltip = ({
5353 const showAbove = spaceAbove > spaceBelow ;
5454
5555 const tooltipTop = showAbove
56- ? itemMeasurement . y - tooltipHeight - ARROW_SIZE - TOOLTIP_MARGIN
57- : itemMeasurement . y + itemMeasurement . height + ARROW_SIZE + TOOLTIP_MARGIN ;
56+ ? itemMeasurement . y - tooltipHeight - ARROW_SIZE / 2 - TOOLTIP_MARGIN
57+ : itemMeasurement . y +
58+ itemMeasurement . height +
59+ ARROW_SIZE / 2 +
60+ TOOLTIP_MARGIN ;
5861
5962 const itemCenterX = itemMeasurement . x + itemMeasurement . width / 2 ;
6063 const tooltipWidth = screenWidth - TOOLTIP_MARGIN * 2 ;
@@ -69,8 +72,8 @@ export const TourTooltip = ({
6972 const arrowLeft = Math . max (
7073 TOOLTIP_MARGIN + ARROW_SIZE ,
7174 Math . min (
72- itemCenterX - tooltipLeft - ARROW_SIZE ,
73- tooltipWidth - ARROW_SIZE * 3
75+ itemCenterX - tooltipLeft - ARROW_SIZE / 2 ,
76+ tooltipWidth - ARROW_SIZE * 2
7477 )
7578 ) ;
7679
@@ -96,26 +99,18 @@ export const TourTooltip = ({
9699 onLayout = { e => setTooltipHeight ( e . nativeEvent . layout . height ) }
97100 pointerEvents = "box-none"
98101 >
99- { showAbove && (
100- < View
101- style = { [
102- styles . arrowDown ,
103- { left : arrowLeft , borderTopColor : tooltipBgColor }
104- ] }
105- />
106- ) }
107- { ! showAbove && (
108- < View
109- style = { [
110- styles . arrowUp ,
111- {
112- left : arrowLeft ,
113- top : - ARROW_SIZE ,
114- borderBottomColor : tooltipBgColor
115- }
116- ] }
117- />
118- ) }
102+ < View
103+ style = { [
104+ styles . arrow ,
105+ {
106+ backgroundColor : tooltipBgColor ,
107+ left : arrowLeft ,
108+ ...( showAbove
109+ ? { bottom : - ARROW_SIZE / 2 }
110+ : { top : - ARROW_SIZE / 2 } )
111+ }
112+ ] }
113+ />
119114 < View style = { [ styles . tooltip , { backgroundColor : tooltipBgColor } ] } >
120115 < H6 > { title } </ H6 >
121116 < VSpacer size = { 4 } />
@@ -165,10 +160,17 @@ const styles = StyleSheet.create({
165160 zIndex : 10000
166161 } ,
167162 tooltip : {
168- borderRadius : 8 ,
163+ borderRadius : BORDER_RADIUS ,
169164 borderCurve : "continuous" ,
170165 padding : 16
171166 } ,
167+ arrow : {
168+ position : "absolute" ,
169+ width : ARROW_SIZE ,
170+ height : ARROW_SIZE ,
171+ transform : [ { rotate : "45deg" } ] ,
172+ zIndex : - 1
173+ } ,
172174 buttonsRow : {
173175 flexDirection : "row" ,
174176 justifyContent : "space-between" ,
@@ -177,30 +179,5 @@ const styles = StyleSheet.create({
177179 rightButtons : {
178180 flexDirection : "row" ,
179181 alignItems : "center"
180- } ,
181- arrowUp : {
182- position : "absolute" ,
183- width : 0 ,
184- height : 0 ,
185- borderLeftWidth : ARROW_SIZE ,
186- borderRightWidth : ARROW_SIZE ,
187- borderBottomWidth : ARROW_SIZE ,
188- borderLeftColor : TRANSPARENT ,
189- borderRightColor : TRANSPARENT ,
190- borderBottomColor : TRANSPARENT ,
191- zIndex : 10001
192- } ,
193- arrowDown : {
194- position : "absolute" ,
195- bottom : - ARROW_SIZE ,
196- width : 0 ,
197- height : 0 ,
198- borderLeftWidth : ARROW_SIZE ,
199- borderRightWidth : ARROW_SIZE ,
200- borderTopWidth : ARROW_SIZE ,
201- borderLeftColor : TRANSPARENT ,
202- borderRightColor : TRANSPARENT ,
203- borderTopColor : TRANSPARENT ,
204- zIndex : 10001
205182 }
206183} ) ;
0 commit comments