2
2
<div >
3
3
<v-tour
4
4
class =" tour"
5
- name =" onboarding -tour"
5
+ name =" nimiq -tour"
6
6
:steps =" Object.values(steps).map((s) => s.tooltip)"
7
7
>
8
8
<template slot-scope="tour">
@@ -94,7 +94,7 @@ import {
94
94
} from ' @vue/composition-api' ;
95
95
import Vue from ' vue' ;
96
96
import VueTour from ' vue-tour' ;
97
- import { TourStep , TourStepIndex , useFakeTx , useOnboardingTourSteps } from ' ../composables/useTour' ;
97
+ import { TourName , TourStep , TourStepIndex , TourSteps , useFakeTx , useTour } from ' ../composables/useTour' ;
98
98
import { useWindowSize } from ' ../composables/useWindowSize' ;
99
99
import CaretRightIcon from ' ./icons/CaretRightIcon.vue' ;
100
100
@@ -104,6 +104,13 @@ require('vue-tour/dist/vue-tour.css');
104
104
105
105
export default defineComponent ({
106
106
name: ' tour' ,
107
+ props: {
108
+ tourName: {
109
+ type: String ,
110
+ required: true ,
111
+ validator : (tour : TourName ) => ([' onboarding' , ' network' ] as TourName []).indexOf (tour ) !== - 1 ,
112
+ },
113
+ },
107
114
setup(props , context ) {
108
115
// TODO Use isMobile
109
116
const { width } = useWindowSize ();
@@ -112,38 +119,47 @@ export default defineComponent({
112
119
const disconnected = computed (
113
120
() => $network .consensus !== ' established' ,
114
121
);
115
- const loading = ref (false );
116
122
117
123
let tour: VueTour .Tour | null = null ;
124
+ const steps: TourSteps <any > = useTour (props .tourName as TourName , context ) || {};
118
125
119
- // TODO This will be a prop
120
- const steps = useOnboardingTourSteps (context );
121
-
122
- const currentStep: Ref <TourStepIndex > = ref (6 );
123
- const nSteps = Object .keys (steps ).length ; // TODO Might be a ref/computed instead
124
- const disableNextStep = ref (currentStep .value >= nSteps - 1 || !! steps [currentStep .value ].ui .disabledNextStep );
126
+ // Initial state
127
+ const loading = ref (true );
128
+ const currentStep: Ref <TourStepIndex > = ref (0 );
129
+ const nSteps: Ref <number > = ref (0 );
130
+ const disableNextStep = ref (true );
125
131
126
132
onMounted (() => {
127
- tour = context .root .$tours [' onboarding-tour' ];
133
+ tourSetup ();
134
+
135
+ // REMOVE ME
136
+ const { removeTransactions } = useTransactionsStore ();
137
+ removeTransactions ([useFakeTx ()]);
138
+ });
128
139
140
+ async function tourSetup() {
141
+ // Update state
142
+ nSteps .value = Object .keys (steps ).length ;
143
+ disableNextStep .value = currentStep .value >= nSteps .value - 1
144
+ || !! steps [currentStep .value ].ui .disabledNextStep ;
129
145
_addAttributes (steps [currentStep .value ].ui , currentStep .value );
130
146
// eslint-disable-next-line no-unused-expressions
131
147
steps [currentStep .value ].lifecycle ?.onMountedStep ?.(goToNextStep );
132
148
133
- tour ! . start ( ` ${ currentStep . value } ` );
149
+ await sleep ( 500 );
134
150
135
- // REMOVE ME
136
- const { removeTransactions } = useTransactionsStore ( );
137
- removeTransactions ([ useFakeTx ()]) ;
138
- });
151
+ tour = context . root . $tours [ ' nimiq-tour ' ];
152
+ tour ! . start ( ` ${ currentStep . value } ` );
153
+ loading . value = false ;
154
+ }
139
155
140
156
function goToPrevStep() {
141
157
if (currentStep .value <= 0 ) return ;
142
158
_moveToFutureStep (currentStep .value , currentStep .value - 1 );
143
159
}
144
160
145
161
function goToNextStep() {
146
- if (currentStep .value + 1 >= nSteps ) return ;
162
+ if (currentStep .value + 1 >= nSteps . value ) return ;
147
163
_moveToFutureStep (currentStep .value , currentStep .value + 1 );
148
164
}
149
165
@@ -191,7 +207,7 @@ export default defineComponent({
191
207
192
208
// onMountedStep
193
209
loading .value = false ;
194
- disableNextStep .value = futureStepIndex >= nSteps - 1 || !! futureUI .disabledNextStep ;
210
+ disableNextStep .value = futureStepIndex >= nSteps . value - 1 || !! futureUI .disabledNextStep ;
195
211
196
212
// eslint-disable-next-line no-unused-expressions
197
213
futureLifecycle ?.onMountedStep ?.(goToNextStep );
0 commit comments