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

Commitac42ad7

Browse files
committed
init/set tutorial with progress
1 parente31c39b commitac42ad7

File tree

17 files changed

+157
-62
lines changed

17 files changed

+157
-62
lines changed

‎typings/index.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ export interface Action {
114114
meta?:any
115115
}
116116

117-
exportinterfaceMachineContext{}
117+
exportinterfaceMachineContext{
118+
tutorial:G.Tutorial|null,
119+
position:CR.Position,
120+
progress:CR.Progress,
121+
}
118122

119123
exportinterfaceMachineEvent{
120124
type:string

‎web-app/package-lock.json

Lines changed: 24 additions & 4 deletions
Some generated files are not rendered by default. Learn more aboutcustomizing how changed files appear on GitHub.

‎web-app/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"markdown-it-emoji":"^1.4.0",
3636
"markdown-it-prism":"^2.0.2",
3737
"moment":"^2.24.0",
38+
"ramda":"^0.26.1",
3839
"react":"^16.9.0",
3940
"react-dom":"^16.9.0",
4041
"react-scripts":"^3.1.1",
@@ -52,6 +53,7 @@
5253
"@types/jest":"^24.0.18",
5354
"@types/markdown-it":"0.0.8",
5455
"@types/node":"^12.7.3",
56+
"@types/ramda":"^0.26.21",
5557
"@types/react":"^16.9.2",
5658
"@types/react-dom":"^16.9.0",
5759
"@types/storybook__react":"^4.0.2",

‎web-app/src/Routes.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import*asReactfrom'react'
22
// import { editorDispatch } from './services/vscode'
3-
3+
import*asCRfrom'typings'
44
importRouterfrom'./components/Router'
55
importLoadingPagefrom'./containers/LoadingPage'
66
importContinuePagefrom'./containers/Continue'
@@ -63,13 +63,13 @@ const Routes = () => {
6363
<LoadingPagetext="Loading..."/>
6464
</Route>
6565
<Routepath="Tutorial.Summary">
66-
<SummaryPagesend={tempSend}/>
66+
<SummaryPagesend={tempSend}context={{}asCR.MachineContext}/>
6767
</Route>
6868
<Routepath="Tutorial.Level">
69-
<LevelSummaryPagesend={tempSend}/>
69+
<LevelSummaryPagesend={tempSend}context={{}asCR.MachineContext}/>
7070
</Route>
7171
<Routepath="Tutorial.Stage">
72-
<StageSummaryPagesend={tempSend}/>
72+
<StageSummaryPagesend={tempSend}context={{}asCR.MachineContext}/>
7373
</Route>
7474
<Routepath="Tutorial.Completed">
7575
<CompletedPage/>

‎web-app/src/components/Debugger/debuggerWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import stateToString from './stateToString'
55
constdebuggerWrapper=(element:React.ReactElement,state:any)=>{
66
if(process.env.REACT_APP_DEBUG){
77
return(
8-
<Debuggerstate={stateToString(state.value)}>
8+
<Debuggerstate={stateToString(state.value)}{...state.context}>
99
{element}
1010
</Debugger>
1111
)

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

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
import*asReactfrom'react'
2-
// import * as CR from 'typings'
2+
import*asGfrom'typings/graphql'
3+
import*asCRfrom'typings'
34

45
interfaceProps{
56
state:string
6-
// position: CR.Position
7-
// progress: CR.Progress
7+
tutorial:G.Tutorial
8+
position:CR.Position
9+
progress:CR.Progress
810
children:React.ReactElement
911
}
1012

11-
constDebugger=({ state, children}:Props)=>(
13+
constDebugger=({ state, children, position, progress, tutorial}:Props)=>(
1214
<divstyle={{backgroundColor:'#FFFF99',color:'black',padding:'.5rem'}}>
1315
<h4>state:{state}</h4>
14-
{/* <p style={{ backgroundColor: 'khaki', padding: '.5rem' }}>position: {JSON.stringify(position)}</p>
15-
<p style={{ backgroundColor: 'moccasin', padding: '.5rem' }}>progress: {JSON.stringify(progress)}</p> */}
16+
<p>tutorial:{tutorial ?tutorial.id :'none'}</p>
17+
<pstyle={{backgroundColor:'khaki',padding:'.5rem'}}>position:{JSON.stringify(position)}</p>
18+
<pstyle={{backgroundColor:'moccasin',padding:'.5rem'}}>progress:{JSON.stringify(progress)}</p>
1619
{children}
1720
</div>
1821
)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface Props {
1313
}
1414

1515
interfaceCloneElementProps{
16+
context:CR.MachineContext
1617
send(action:CR.Action):void
1718
}
1819

@@ -22,6 +23,8 @@ const Router = ({ children }: Props): React.ReactElement<CloneElementProps>|null
2223
logger:console.log.bind('XSTATE:')
2324
})
2425

26+
console.log('state',state)
27+
2528
channel.setMachineSend(send)
2629

2730
// event bus listener
@@ -30,7 +33,7 @@ const Router = ({ children }: Props): React.ReactElement<CloneElementProps>|null
3033
constchildArray=React.Children.toArray(children)
3134
for(constchildofchildArray){
3235
if(state.matches(child.props.path)){
33-
constelement=React.cloneElement<CloneElementProps>(child.props.children,{ send})
36+
constelement=React.cloneElement<CloneElementProps>(child.props.children,{ send,context:state.context})
3437
returndebuggerWrapper(element,state)
3538
}
3639
}

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
11
import*asReactfrom'react'
22

3-
importcurrentTutorialfrom'../../../services/current'
4-
import*asCRfrom'typings'
3+
importchannelfrom'../../../services/channel'
54
import*asTfrom'typings/graphql'
65
importTutorialItemfrom'./TutorialItem'
76

87
interfaceProps{
98
tutorialList:T.Tutorial[]
10-
onNew(Action:CR.Action):void
119
}
1210

1311
constTutorialList=(props:Props)=>{
1412
constonSelect=(tutorial:T.Tutorial)=>{
15-
currentTutorial.set({
16-
tutorialId:tutorial.id,
17-
version:tutorial.version.version,
18-
})
19-
props.onNew({
13+
channel.machineSend({
2014
type:'TUTORIAL_START',
2115
payload:{
22-
id:tutorial.id,
23-
version:tutorial.version.version,
16+
tutorial,
2417
}
2518
})
2619
}

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@ import TutorialList from './TutorialList'
1010

1111
interfaceProps{
1212
tutorialList:T.Tutorial[]
13-
onNew(action:CR.Action):void
1413
}
1514

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

@@ -38,7 +37,7 @@ const NewPageContainer = (props: ContainerProps) => {
3837

3938
return(
4039
<React.Suspensefallback={Loading}>
41-
<NewPageonNew={props.send}tutorialList={data.tutorials}/>
40+
<NewPagetutorialList={data.tutorials}/>
4241
</React.Suspense>
4342
)
4443
}

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import*asReactfrom'react'
22
import{useQuery}from'@apollo/react-hooks'
3+
import*asCRfrom'typings'
34
import*asGfrom'typings/graphql'
45

56
importcurrentTutorialfrom'../../../services/current'
@@ -23,17 +24,18 @@ export const LevelSummaryPage = (props: LevelProps) => {
2324
}
2425

2526
interfaceContainerProps{
26-
send(action:string):void
27+
context:CR.MachineContext
28+
send(action:string):void
2729
}
2830

2931
constLevelSummaryPageContainer=(props:ContainerProps)=>{
30-
const{ tutorialId, version, position, progress}=currentTutorial.get()
31-
3232
console.log('load level summary')
33+
const{ tutorial, position, progress}=props.context
34+
3335
const{ loading, error, data}=useQuery(queryLevel,{
3436
variables:{
35-
tutorialId,
36-
version,
37+
tutorialId:tutorial.id,
38+
version:tutorial.version.version,
3739
levelId:position.levelId,
3840
},
3941
})

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp