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

Commit7c2bd8f

Browse files
committed
run formatting
1 parent9ba52b0 commit7c2bd8f

File tree

8 files changed

+96
-90
lines changed

8 files changed

+96
-90
lines changed

‎web-app/.prettierrc.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module.exports={
2+
printWidth:120,
3+
semi:false,
4+
singleQuote:true,
5+
tabWidth:2,
6+
trailingComma:'all',
7+
}

‎web-app/src/App.tsx

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,54 @@ import * as CR from 'typings'
33

44
importDebuggerfrom'./components/Debugger'
55
importRoutesfrom'./Routes'
6-
importDataContext,{initialState,initialData}from'./utils/DataContext'
6+
importDataContext,{initialState,initialData}from'./utils/DataContext'
77

88
interfaceReceivedEvent{
9-
data:CR.Action
9+
data:CR.Action
1010
}
1111

1212
constApp=()=>{
13-
const[state,setState]=React.useState(initialState)
14-
const[data,setData]:[CR.MachineContext,(data:CR.MachineContext)=>void]=React.useState(initialData)
15-
16-
consthandleEvent=(event:ReceivedEvent):void=>{
17-
constmessage=event.data
18-
console.log('RECEIVED')
19-
console.log(message)
20-
// messages from core
21-
if(message.type==='SET_STATE'){
22-
setState(message.payload.state)
23-
setData(message.payload.data)
24-
}elseif(message.type==='SET_DATA'){
25-
setData(message.payload.data)
26-
}
13+
const[state,setState]=React.useState(initialState)
14+
const[data,setData]:[CR.MachineContext,(data:CR.MachineContext)=>void]=React.useState(initialData)
15+
16+
consthandleEvent=(event:ReceivedEvent):void=>{
17+
constmessage=event.data
18+
console.log('RECEIVED')
19+
console.log(message)
20+
// messages from core
21+
if(message.type==='SET_STATE'){
22+
setState(message.payload.state)
23+
setData(message.payload.data)
24+
}elseif(message.type==='SET_DATA'){
25+
setData(message.payload.data)
2726
}
28-
29-
// event bus listener
30-
React.useEffect(()=>{
31-
constlistener='message'
32-
window.addEventListener(listener,handleEvent)
33-
return()=>{
34-
window.removeEventListener(listener,handleEvent)
35-
}
36-
})
37-
38-
constvalue={
39-
state,
40-
position:data.position,
41-
data:data.data,
42-
progress:data.progress,
27+
}
28+
29+
// event bus listener
30+
React.useEffect(()=>{
31+
constlistener='message'
32+
window.addEventListener(listener,handleEvent)
33+
return()=>{
34+
window.removeEventListener(listener,handleEvent)
4335
}
44-
45-
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
46-
return(
47-
<DataContext.Providervalue={value}>
48-
<div>
49-
<Debuggervalue={value}/>
50-
<Routesstate={state}/>
51-
</div>
52-
</DataContext.Provider>
53-
)
36+
})
37+
38+
constvalue={
39+
state,
40+
position:data.position,
41+
data:data.data,
42+
progress:data.progress,
43+
}
44+
45+
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
46+
return(
47+
<DataContext.Providervalue={value}>
48+
<div>
49+
<Debuggervalue={value}/>
50+
<Routesstate={state}/>
51+
</div>
52+
</DataContext.Provider>
53+
)
5454
}
5555

56-
exportdefaultApp
56+
exportdefaultApp

‎web-app/src/Routes.tsx

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

3+
importLoadingfrom'./components/Loading'
34
importCondfrom'./components/Cond'
45
importNewPagefrom'./containers/New'
56
importContinuePagefrom'./containers/Continue'
67
importTutorialPagefrom'./containers/Tutorial'
78

8-
99
interfaceProps{
1010
state:any
1111
}
1212

1313
constRoutes=({ state}:Props)=>{
14-
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
15-
return(
16-
<div>
17-
<Condstate={state}path="SelectTutorial.Startup">
18-
<div>
19-
<h3>Starting...</h3>
20-
</div>
21-
</Cond>
22-
<Condstate={state}path="SelectTutorial.NewTutorial">
23-
<NewPage/>
24-
</Cond>
25-
<Condstate={state}path="SelectTutorial.ContinueTutorial">
26-
<ContinuePage/>
27-
</Cond>
28-
<Condstate={state}path="Tutorial">
29-
<TutorialPage/>
30-
</Cond>
31-
</div>
32-
)
14+
// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
15+
return(
16+
<div>
17+
<Condstate={state}path="SelectTutorial.Startup">
18+
<Loading/>
19+
</Cond>
20+
<Condstate={state}path="SelectTutorial.NewTutorial">
21+
<NewPage/>
22+
</Cond>
23+
<Condstate={state}path="SelectTutorial.ContinueTutorial">
24+
<ContinuePage/>
25+
</Cond>
26+
<Condstate={state}path="Tutorial">
27+
<TutorialPage/>
28+
</Cond>
29+
</div>
30+
)
3331
}
3432

35-
exportdefaultRoutes
33+
exportdefaultRoutes

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import*asReactfrom'react'
2-
// import send from '../../data/send'
32

43
constLoading=()=>{
5-
React.useEffect(()=>{
6-
// load tutorial and progress on startup
7-
// send({ type: 'GET/TUTORIAL' })
8-
})
94
return<div>Loading...</div>
105
}
116

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,10 @@ export const ContinuePage = (props: Props) => {
2424
)
2525
}
2626

27-
exportdefault()=><ContinuePageonContinue={()=>{send('TUTORIAL_START')}}/>
27+
exportdefault()=>(
28+
<ContinuePage
29+
onContinue={()=>{
30+
send('TUTORIAL_START')
31+
}}
32+
/>
33+
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export const NewPage = (props: Props) => {
2626
))}
2727
</div>
2828
</Cond>
29-
<Condstate={state}path='SelectTutorial.NewTutorial.InitializeTutorial'>
30-
<div>Initializing tutorial...</div>
29+
<Condstate={state}path="SelectTutorial.NewTutorial.InitializeTutorial">
30+
<div>Initializing tutorial...</div>
3131
</Cond>
3232
</div>
3333
)

‎web-app/src/services/api/index.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,29 @@ import * as CR from 'typings'
44
importbasicTutorialfrom'tutorials/basic'
55

66
interfaceOptions{
7-
resource:string
8-
params?:any
7+
resource:string
8+
params?:any
99
}
1010

1111
consttutorialsData:{[key:string]:CR.Tutorial}={
12-
tutorialId:basicTutorial,
12+
tutorialId:basicTutorial,
1313
}
1414

1515
// TODO: replace with fetch resource
1616
exportdefaultasyncfunctionfetch(options:Options):Promise<any>{
17-
console.log('options',options)
18-
switch(options.resource){
19-
case'getTutorialsSummary':
20-
// list of ids with summaries
21-
letdata:{[id:string]:CR.TutorialSummary}={}
22-
for(consttutorialofObject.values(tutorialsData)){
23-
data[tutorial.id]=tutorial.data.summary
24-
}
25-
returndata
26-
case'getTutorial':
27-
// specific tutorial by id
28-
returntutorialsData[options.params.id]
29-
default:
30-
thrownewError('Resource not found')
31-
}
17+
console.log('options',options)
18+
switch(options.resource){
19+
case'getTutorialsSummary':
20+
// list of ids with summaries
21+
letdata:{[id:string]:CR.TutorialSummary}={}
22+
for(consttutorialofObject.values(tutorialsData)){
23+
data[tutorial.id]=tutorial.data.summary
24+
}
25+
returndata
26+
case'getTutorial':
27+
// specific tutorial by id
28+
returntutorialsData[options.params.id]
29+
default:
30+
thrownewError('Resource not found')
31+
}
3232
}

‎web-app/src/utils/DataContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ export const initialData: CR.MachineContext = {
1919

2020
constDataContext=React.createContext({state:initialState, ...initialData})
2121

22-
exportdefaultDataContext
22+
exportdefaultDataContext

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp