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

Commit81c3f05

Browse files
committed
progress setting up client app
1 parente71bb6f commit81c3f05

File tree

6 files changed

+44
-25
lines changed

6 files changed

+44
-25
lines changed

‎web-app/src/Routes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ const Routes = () => {
4444
<Router>
4545
<Routepath="Start.Startup">
4646
<LoadingPagetext="Launching..."/>
47+
</Route>
48+
<Routepath="Start.NewTutorial.SelectTutorial">
49+
<NewPage/>
4750
</Route>
4851
<Routepath="Start.NewTutorial.InitializeTutorial">
4952
<LoadingPagetext="Launching Tutorial..."/>
5053
</Route>
51-
<Routepath="Start.NewTutorial.SelectTutorial">
52-
<NewPage/>
53-
</Route>
5454
<Routepath="Start.ContinueTutorial">
5555
<ContinuePage/>
5656
</Route>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interfaceProps{
22
children:any
3-
path:string
3+
path:string
44
}
55

66
constRoute=({ children}:Props)=>children

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import*asReactfrom'react'
2+
import*asCRfrom'typings'
23
import{useMachine}from'@xstate/react'
34
importmachinefrom'../../services/state/machine'
45
importDebuggerfrom'../Debugger'
@@ -9,8 +10,6 @@ interface Props {
910
children:any
1011
}
1112

12-
{/* {process.env.REACT_APP_DEBUG && <Debugger {...debuggerInfo} />} */}
13-
1413
constwrapDebugger=(element:React.ReactElement,state:any)=>{
1514
if(process.env.REACT_APP_DEBUG){
1615
return(
@@ -22,19 +21,18 @@ const wrapDebugger = (element: React.ReactElement, state: any) => {
2221
returnelement
2322
}
2423

24+
interfaceCloneElementProps{
25+
send(action:CR.Action):void
26+
}
27+
2528
// router finds first state match of <Route path='' />
26-
constRouter=({ children}:Props)=>{
29+
constRouter=({ children}:Props):React.ReactElement<CloneElementProps>|null=>{
2730
const[state,send]=useMachine(machine)
2831

2932
constchildArray=React.Children.toArray(children)
3033
for(constchildofchildArray){
3134
if(state.matches(child.props.path)){
32-
letelement
33-
if(child.props.send){
34-
element=React.cloneElement(child.props.children,{ send})
35-
}else{
36-
element=child.props.children
37-
}
35+
constelement=React.cloneElement<CloneElementProps>(child.props.children,{ send})
3836
returnwrapDebugger(element,state)
3937
}
4038
}

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import * as T from 'typings/graphql'
44
import*asCRfrom'typings'
55

66
importqueryTutorialsfrom'./queryTutorials'
7-
import{editorDispatch}from'../../services/vscode'
87
importLoadingPagefrom'../LoadingPage'
98
importErrorViewfrom'../../components/Error'
109
importTutorialListfrom'./TutorialList'
@@ -16,26 +15,35 @@ interface Props {
1615

1716
exportconstNewPage=(props:Props)=>(
1817
<div>
19-
<h2>Start anew Project</h2>
18+
<h2>Start aNew Tutorial</h2>
2019
<TutorialListtutorialList={props.tutorialList}onNew={props.onNew}/>
2120
</div>
2221
)
2322

2423
constLoading=()=><LoadingPagetext="Loading tutorials"/>
2524

26-
constNewPageContainer=()=>{
25+
interfaceContainerProps{
26+
send?(action:CR.Action):void
27+
}
28+
29+
constNewPageContainer=(props:ContainerProps)=>{
30+
console.log('props',props)
2731
const{ data, loading, error}=useQuery(queryTutorials)
2832
if(loading){
2933
return<Loading/>
3034
}
3135

3236
if(error){
3337
return<ErrorViewerror={error}/>
34-
}
38+
}
39+
40+
// TODO: cleanup React.cloneElement props issue
41+
constsendFallback=(action:CR.Action)=>console.log('Cannot send')
42+
constsend=props.send||sendFallback
3543

3644
return(
3745
<React.Suspensefallback={Loading}>
38-
<NewPageonNew={editorDispatch}tutorialList={data.tutorials}/>
46+
<NewPageonNew={send}tutorialList={data.tutorials}/>
3947
</React.Suspense>
4048
)
4149
}

‎web-app/src/services/state/actions/index.ts

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import {send} from 'xstate'
88

99

1010
exportdefault{
11-
asyncnewOrContinue(){
11+
newOrContinue:send((context):'NEW'|'CONTINUE'=>{
1212
console.log('new or continue')
13-
// verify that the user has an existing tutorial to continue
1413

15-
// TODO: verifycontinue or new
14+
// TODO: verifythat the user has an existing tutorial to continue
1615
consthasExistingTutorial:boolean=false
17-
send(hasExistingTutorial ?'CONTINUE' :'NEW')
18-
},
16+
returnhasExistingTutorial ?'CONTINUE' :'NEW'
17+
}),
18+
tutorialStart(){
19+
console.log('start')
20+
}
1921
}
2022

2123
// export default {
@@ -30,9 +32,19 @@ export default {
3032
// // const codingLanguage: G.EnumCodingLanguage = result.data.codingLanguage
3133
// // editorDispatch('coderoad.test_runner_setup', codingLanguage)
3234
// },
33-
// initializeNewTutorial: () => {
34-
// console.log('initializeNewTutorial')
35+
// initializeNewTutorial: assign({
36+
// position: (context: any): CR.Position => {
37+
// const { tutorial } = context
38+
// const levelId = data.summary.levelList[0]
39+
// const stageId = data.levels[levelId].stageList[0]
40+
// const stepId = data.stages[stageId].stepList[0]
41+
// return {
42+
// levelId,
43+
// stageId,
44+
// stepId,
45+
// }
3546
// },
47+
// })
3648
// tutorialContinue() {
3749
// console.log('tutorial continue')
3850
// },

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export const machine = Machine<{}, CR.MachineStateSchema, CR.MachineEvent>(
2828
},
2929
},
3030
InitializeTutorial:{
31+
onEntry:['tutorialStart'],
3132
on:{
3233
TUTORIAL_LOADED:'#tutorial',
3334
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp