11import React , { useState , useRef , useEffect } from 'react' ;
2- import { Box , Button , Grid , Typography } from '@material-ui/core' ;
2+ import {
3+ Box , Button , Grid , Typography ,
4+ } from '@material-ui/core' ;
35import {
46 primaryColor , secondaryColor , bgLight , bgDark , primaryTextColor , secondaryTextColor , fontColor ,
57} from '../../theme' ;
68
79const rectMargin = 4 ;
810
911const TutorialBubble = ( {
10- requestedTourStep, steps, lastCheckRender, stopTutorial, incrementTutorialStep, validateTutorialStep, currentTourStep
12+ requestedTourStep, steps, lastCheckRender, stopTutorial, incrementTutorialStep, validateTutorialStep, currentTourStep,
1113} ) => {
12- const tutorialTarget = useRef ( null )
14+ const tutorialTarget = useRef ( null ) ;
1315
14- useEffect ( ( ) => {
15- return ( ) => {
16- tutorialTarget . current = null ;
17- }
18- } , [ ] )
16+ useEffect ( ( ) => ( ) => {
17+ tutorialTarget . current = null ;
18+ } , [ ] ) ;
1919
2020 const getDOMTarget = ( target , config ) => {
2121 // We query the DOM with the selector
@@ -37,7 +37,7 @@ const TutorialBubble = ({
3737 return DOMtargets [ config ?. collectionIndex || 0 ] ;
3838 } ;
3939
40- function calculateVisiblePosition ( rect1 , width2 , height2 ) {
40+ function calculateVisiblePosition ( rect1 , width2 , height2 ) {
4141 const windowHeight = window . innerHeight ;
4242 const windowWidth = window . innerWidth ;
4343
@@ -68,11 +68,10 @@ const TutorialBubble = ({
6868 }
6969
7070 const nextTourStep = steps [ requestedTourStep ] ;
71- const { target : nextTarget } = nextTourStep ? nextTourStep : { target : undefined } ;
71+ const { target : nextTarget } = nextTourStep || { target : undefined } ;
7272
7373 const { target, title, content } = tourStep ;
7474
75-
7675 const DOMtarget = getDOMTarget ( target , tourStep ) ;
7776 const nextDOMtarget = getDOMTarget ( nextTarget , nextTourStep ) ;
7877 const visible = DOMtarget ?. checkVisibility ( ) ;
@@ -91,7 +90,7 @@ const TutorialBubble = ({
9190 return false ;
9291 }
9392 return el . parentNode . isContentEditable ;
94- }
93+ } ;
9594
9695 const isAnyEditable = ( element ) => {
9796 if ( isEditable ( element ) ) {
@@ -104,27 +103,27 @@ const TutorialBubble = ({
104103 }
105104 }
106105 return false ;
107- }
106+ } ;
108107
109108 const listen = ( event ) => {
110109 tutorialTarget . current = null ;
111110 incrementTutorialStep ( ) ;
112- }
111+ } ;
113112
114113 const stop = ( event ) => {
115114 stopTutorial ( event ) ;
116115 tutorialTarget . current = null ;
117- }
116+ } ;
118117
119118 if ( currentTourStep === requestedTourStep ) {
120119 tutorialTarget . current = null ;
121120 }
122121
123122 if ( ! tutorialTarget . current && currentTourStep !== requestedTourStep ) {
124123 tutorialTarget . current = DOMtarget ;
125- let waitFor = tourStep . waitFor ;
124+ let { waitFor } = tourStep ;
126125 if ( ! waitFor ) {
127- waitFor = isAnyEditable ( DOMtarget ) ? 'fieldEdition' : 'click'
126+ waitFor = isAnyEditable ( DOMtarget ) ? 'fieldEdition' : 'click' ;
128127 }
129128 switch ( waitFor ) {
130129 case 'click' :
@@ -148,9 +147,9 @@ const TutorialBubble = ({
148147 const nextIsVisible = nextDOMtarget ?. checkVisibility ( ) ;
149148
150149 return (
151- < Box className = ' tutorials' >
150+ < Box className = " tutorials" >
152151 < Box
153- className = ' tutorials_highlight'
152+ className = " tutorials_highlight"
154153 id = "tutorialTargetRectangle"
155154 style = { {
156155 top : targetRect . top - rectMargin ,
@@ -162,25 +161,28 @@ const TutorialBubble = ({
162161 } }
163162 />
164163
165- < Box className = 'tutorials_wrapper' id = "tutorialBubble" >
166- { lastCheckRender }
167-
168- < Box className = 'tutorials_content' style = { {
169- top : y ,
170- left : x ,
171- } } >
172- < Typography component = 'h3' >
164+ < Box className = "tutorials_wrapper" id = "tutorialBubble" >
165+ < Box
166+ className = "tutorials_content"
167+ style = { {
168+ top : y ,
169+ left : x ,
170+ } }
171+ >
172+ < Typography component = "h3" >
173173 { title }
174174 </ Typography >
175175
176176 { content }
177177
178- < Box pt = { 2.5 } display = ' flex' alignItems = ' center' justifyContent = ' space-between' >
178+ < Box pt = { 2.5 } display = " flex" alignItems = " center" justifyContent = " space-between" >
179179 < Typography >
180- { requestedTourStep } /{ steps . length }
180+ { requestedTourStep }
181+ /
182+ { steps . length }
181183 </ Typography >
182184
183- < Box display = ' flex' alignItems = ' center' >
185+ < Box display = " flex" alignItems = " center" >
184186 < Button
185187 onClick = { stop }
186188 color = "primary"
@@ -190,7 +192,7 @@ const TutorialBubble = ({
190192
191193 { hasOtherSteps && (
192194 < Button
193- variant = ' contained'
195+ variant = " contained"
194196 color = "primary"
195197 onClick = { listen }
196198 disabled = { ! nextIsVisible }
0 commit comments