1
1
<template >
2
2
<div class =" tour" >
3
3
<v-tour
4
- name =" nimiq-tour"
5
- :steps =" steps.map((s) => s.tooltip) "
6
- :options =" tourOptions"
4
+ name =" nimiq-tour"
5
+ :steps =" vTourSteps "
6
+ :options =" tourOptions"
7
7
>
8
8
<template v-slot =" tour " >
9
9
<transition name =" fade" >
92
92
{{ tour.steps[tour.currentStep].button.text }}
93
93
</button >
94
94
<button
95
- v-else-if =" isLargeScreen && !isLoading"
95
+ v-else-if =" isLargeScreen && !disableNextStep && ! isLoading"
96
96
class =" right"
97
97
@click =" goToNextStep()"
98
98
tabindex =" 0"
@@ -212,20 +212,13 @@ export default defineComponent({
212
212
useKeyboardNavigation: false , // handled by us
213
213
};
214
214
215
- // `getTour` function returns an object like:
216
- // { "1": { /** First step */}, "10": { /** Step */}, "2": { /** Second step */}, ... }
217
- // where the key is the step index and the value is the step object that we need to sort
218
- // and store it as an array
219
- let unsortedStepds = getTour (
220
- accountStore .tour ?.name , context , { isSmallScreen , isMediumScreen , isLargeScreen });
221
- let steps = Object .keys (unsortedStepds )
222
- .sort ((a , b ) => (a as unknown as number ) - (b as unknown as number ))
223
- .map ((key ) => unsortedStepds [key as unknown as TourStepIndex ]);
224
-
225
215
// Initial state
216
+ const steps: Ref <ITourStep []> = ref ([]);
217
+ setTourAsArray ();
218
+
226
219
const isLoading = ref (true );
227
220
const currentStep: Ref <TourStepIndex > = ref (0 );
228
- const nSteps: Ref <number > = ref (Object . keys ( steps ) .length );
221
+ const nSteps: Ref <number > = ref (steps . value .length );
229
222
const disableNextStep = ref (true );
230
223
const showTour = ref (false );
231
224
@@ -256,7 +249,7 @@ export default defineComponent({
256
249
257
250
await context .root .$nextTick (); // to ensure DOM is ready
258
251
259
- const step = steps [currentStep .value ];
252
+ const step = steps . value [currentStep .value ];
260
253
if (! step ) return ;
261
254
262
255
// Update state
@@ -316,7 +309,7 @@ export default defineComponent({
316
309
// execute _toggleDisabledButtons but it is kind of random the amount of time
317
310
// it takes to render the button. I don't know how to fix it. Waiting 500ms works.
318
311
await sleep (500 );
319
- _toggleDisabledButtons (steps [currentStep .value ]?.ui .disabledButtons , true );
312
+ _toggleDisabledButtons (steps . value [currentStep .value ]?.ui .disabledButtons , true );
320
313
});
321
314
322
315
function goToPrevStep() {
@@ -335,8 +328,8 @@ export default defineComponent({
335
328
newStepIndex : TourStepIndex ,
336
329
goingForward : boolean ,
337
330
) {
338
- const { path : currentPath } = steps [currentStepIndex ]! ;
339
- const { path : newPath, ui : newUI, lifecycle : newLifecycle } = steps [newStepIndex ]! ;
331
+ const { path : currentPath } = steps . value [currentStepIndex ]! ;
332
+ const { path : newPath, ui : newUI, lifecycle : newLifecycle } = steps . value [newStepIndex ]! ;
340
333
341
334
tour ! .stop ();
342
335
await sleep (500 ); // ensures animation ends
@@ -353,6 +346,7 @@ export default defineComponent({
353
346
await context .root .$nextTick ();
354
347
}
355
348
349
+ _toggleDisabledButtons (steps .value [currentStepIndex ].ui .disabledButtons , false );
356
350
_updateUI (newUI , newStepIndex );
357
351
await context .root .$nextTick ();
358
352
@@ -407,7 +401,7 @@ export default defineComponent({
407
401
const tourInteractableElements = [' .tour' , ' .tour-manager' , ' .tooltip' ];
408
402
409
403
// This are the elements that are allowed to be clicked only in current step
410
- const stepInteractableElements = steps [currentStep .value ]?.ui .explicitInteractableElements || [];
404
+ const stepInteractableElements = steps . value [currentStep .value ]?.ui .explicitInteractableElements || [];
411
405
412
406
const interactableElements = tourInteractableElements .concat (stepInteractableElements )
413
407
.map ((s ) => $ (s )).filter ((e ) => !! e ) as HTMLElement [];
@@ -504,8 +498,6 @@ export default defineComponent({
504
498
$$ (` [data-explicit-interactable="${stepIndex }"] ` ).forEach ((el ) => {
505
499
el .removeAttribute (' data-explicit-interactable' );
506
500
});
507
-
508
- _toggleDisabledButtons (steps [stepIndex ].ui .disabledButtons , false );
509
501
}
510
502
511
503
// nofifyManager - if true will notify the manager that the tour has ended
@@ -582,11 +574,7 @@ export default defineComponent({
582
574
async function _screenTypeChanged() {
583
575
tour ! .stop ();
584
576
585
- unsortedStepds = getTour (
586
- accountStore .tour ?.name , context , { isSmallScreen , isMediumScreen , isLargeScreen });
587
- steps = Object .keys (unsortedStepds )
588
- .sort ((a , b ) => (a as unknown as number ) - (b as unknown as number ))
589
- .map ((key ) => unsortedStepds [key as unknown as TourStepIndex ]);
577
+ setTourAsArray ();
590
578
591
579
// end tour sofly and start it again
592
580
await endTour (false , true );
@@ -614,6 +602,10 @@ export default defineComponent({
614
602
});
615
603
}
616
604
605
+ function setTourAsArray() {
606
+ steps .value = getTour (accountStore .tour ?.name , context , { isSmallScreen , isMediumScreen , isLargeScreen });
607
+ }
608
+
617
609
return {
618
610
isSmallScreen ,
619
611
isMediumScreen ,
@@ -622,7 +614,7 @@ export default defineComponent({
622
614
623
615
// tour
624
616
tourOptions ,
625
- steps ,
617
+ vTourSteps: computed (() => steps . value . map (( s ) => s . tooltip )) ,
626
618
showTour ,
627
619
628
620
// control bar
@@ -635,6 +627,10 @@ export default defineComponent({
635
627
goToPrevStep ,
636
628
goToNextStep ,
637
629
endTour ,
630
+
631
+ // We need to expose this function so that we can call it from the steps.
632
+ // In particular /lib/tour/onboarding/06_0_BackupAlertStep.ts
633
+ setTourAsArray ,
638
634
};
639
635
},
640
636
components: {
@@ -812,10 +808,14 @@ export default defineComponent({
812
808
font-size : 14px ;
813
809
border : 1px solid transparent ;
814
810
815
- & :focus {
811
+ & .right :focus {
816
812
border : 1px solid #ffffff55 ;
817
813
}
818
814
815
+ & .left :focus {
816
+ opacity : 1 ;
817
+ }
818
+
819
819
& .left {
820
820
display : flex ;
821
821
align-items : center ;
0 commit comments