Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83a55b8

Browse files
committed
route change progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent9f5d3cb commit83a55b8

File tree

7 files changed

+40
-38
lines changed

7 files changed

+40
-38
lines changed

‎typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export interface MachineStateSchema {
7676
}
7777
Tutorial:{
7878
states:{
79-
LoadNext:{}
8079
Level:{
8180
states:{
8281
Load:{}
@@ -86,6 +85,7 @@ export interface MachineStateSchema {
8685
TestFail:{}
8786
StepNext:{}
8887
LevelComplete:{}
88+
LoadNext:{}
8989
}
9090
}
9191
Completed:{}

‎web-app/src/Routes.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const Routes = () => {
2020
)
2121
}
2222

23+
console.log('RENDER')
2324
return(
2425
<Workspace>
2526
<Router>
@@ -37,10 +38,10 @@ const Routes = () => {
3738
<LoadingPagetext="Configuring tutorial..."/>
3839
</Route>
3940
{/* Tutorial */}
40-
<Routepath={['Tutorial.LoadNext','Tutorial.Level.Load']}>
41+
<Routepath={['Tutorial.Level.Load']}>
4142
<LoadingPagetext="Loading Level..."processes={context.processes}/>
4243
</Route>
43-
<Routepath="Tutorial.Level">
44+
<Routepath={['Tutorial.LoadNext','Tutorial.Level']}>
4445
<TutorialPagesend={send}context={context}/>
4546
</Route>
4647
{/* Completed */}

‎web-app/src/components/Router/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const useRouter = (): Output => {
3030
send(action)
3131
}
3232

33-
logger(`STATE:${JSON.stringify(state.value)}`)
33+
console.log(`STATE:${JSON.stringify(state.value)}`)
3434

3535
// event bus listener
3636
React.useEffect(()=>{

‎web-app/src/containers/Tutorial/components/Hints.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ interface Props {
2626
constHints=(props:Props)=>{
2727
constisFinalHint=props.hints.length-1===props.hintIndex
2828
constnextHint=()=>{
29-
console.log('hintIndex')
30-
console.log(props.hintIndex)
3129
if(isFinalHint){
3230
return
3331
}

‎web-app/src/containers/Tutorial/components/Level.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ interface Props {
9999
onRunTest():void
100100
onLoadSolution():void
101101
onOpenLogs(channel:string):void
102-
displayHintsIndex:number[]
103-
setHintsIndex(index:number,value:number):void
104102
}
105103

106104
constLevel=({
@@ -115,14 +113,31 @@ const Level = ({
115113
onOpenLogs,
116114
processes,
117115
testStatus,
118-
displayHintsIndex,
119-
setHintsIndex,
120116
}:Props)=>{
121117
constlevel=tutorial.levels[index]
122118

123119
const[title,setTitle]=React.useState<string>(level.title)
124120
const[content,setContent]=React.useState<string>(level.content)
125121

122+
// hold state for hints for the level
123+
const[displayHintsIndex,setDisplayHintsIndex]=React.useState<number[]>([])
124+
constsetHintsIndex=(index:number,value:number)=>{
125+
returnsetDisplayHintsIndex((displayHintsIndex)=>{
126+
constnext=[...displayHintsIndex]
127+
next[index]=value
128+
returnnext
129+
})
130+
}
131+
React.useEffect(()=>{
132+
console.log(position.levelId)
133+
console.log(JSON.stringify(position))
134+
// set the hints to empty on level starts
135+
setDisplayHintsIndex(steps.map((s)=>-1))
136+
return()=>{
137+
console.log('LEVEL UNMOUNTED')
138+
}
139+
},[position.levelId])
140+
126141
constmenu=(
127142
<ContentMenu
128143
tutorial={tutorial}

‎web-app/src/containers/Tutorial/index.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@ const TutorialPage = (props: PageProps) => {
3737

3838
constlevelIndex=tutorial.levels.findIndex((l:TT.Level)=>l.id===position.levelId)
3939
constlevelStatus=progress.levels[position.levelId] ?'COMPLETE' :'ACTIVE'
40-
const{ steps}=tutorial.levels[levelIndex]
41-
const[displayHintsIndex,setDisplayHintsIndex]=React.useState<number[]>(steps.map((s)=>-1))
42-
43-
constsetHintsIndex=(index:number,value:number)=>{
44-
returnsetDisplayHintsIndex((displayHintsIndex)=>{
45-
constnext=[...displayHintsIndex]
46-
next[index]=value
47-
returnnext
48-
})
49-
}
5040

5141
return(
5242
<Level
@@ -61,8 +51,6 @@ const TutorialPage = (props: PageProps) => {
6151
onOpenLogs={onOpenLogs}
6252
processes={processes}
6353
testStatus={testStatus}
64-
displayHintsIndex={displayHintsIndex}
65-
setHintsIndex={setHintsIndex}
6654
/>
6755
)
6856
}

‎web-app/src/services/state/machine.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,6 @@ export const createMachine = (options: any) => {
142142
id:'tutorial',
143143
initial:'Level',
144144
states:{
145-
LoadNext:{
146-
id:'tutorial-load-next',
147-
onEntry:['loadNext'],
148-
on:{
149-
NEXT_STEP:{
150-
target:'Level',
151-
actions:['updatePosition'],
152-
},
153-
NEXT_LEVEL:{
154-
target:'Level',
155-
actions:['updatePosition'],
156-
},
157-
COMPLETED:'#completed-tutorial',
158-
},
159-
},
160145
Level:{
161146
initial:'Load',
162147
states:{
@@ -228,11 +213,26 @@ export const createMachine = (options: any) => {
228213
onExit:['syncLevelProgress'],
229214
on:{
230215
NEXT_LEVEL:{
231-
target:'#tutorial-load-next',
216+
target:'LoadNext',
232217
actions:['testClear','updatePosition'],
233218
},
234219
},
235220
},
221+
LoadNext:{
222+
id:'tutorial-load-next',
223+
onEntry:['loadNext'],
224+
on:{
225+
NEXT_STEP:{
226+
target:'Load',
227+
actions:['updatePosition'],
228+
},
229+
NEXT_LEVEL:{
230+
target:'Load',
231+
actions:['updatePosition'],
232+
},
233+
COMPLETED:'#completed-tutorial',
234+
},
235+
},
236236
},
237237
},
238238
Completed:{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp