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

Commite92a4b4

Browse files
authored
Merge pull request#391 from coderoad/feature/key-bindings
Feature/key bindings
2 parents0e806fb +10dbe7f commite92a4b4

File tree

8 files changed

+54
-13
lines changed

8 files changed

+54
-13
lines changed

‎package.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@
7878
"title":"Start",
7979
"category":"CodeRoad"
8080
}
81+
],
82+
"keybindings": [
83+
{
84+
"key":"ctrl+enter",
85+
"mac":"ctrl+enter",
86+
"command":"coderoad.enter"
87+
}
8188
]
8289
},
8390
"displayName":"CodeRoad",

‎src/editor/commands.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export const COMMANDS = {
1212
CONFIG_TEST_RUNNER:'coderoad.config_test_runner',
1313
RUN_TEST:'coderoad.run_test',
1414
SET_CURRENT_POSITION:'coderoad.set_current_position',
15+
ENTER:'coderoad.enter',
1516
}
1617

1718
interfaceCreateCommandProps{
@@ -103,5 +104,8 @@ export const createCommands = ({ extensionPath, workspaceState }: CreateCommandP
103104
logger('currentPosition',currentPosition)
104105
testRunner({position:currentPosition,onSuccess:callbacks?.onSuccess, subtasks})
105106
},
107+
[COMMANDS.ENTER]:()=>{
108+
webview.send({type:'KEY_PRESS_ENTER'})
109+
},
106110
}
107111
}

‎web-app/src/Routes.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const Routes = () => {
4040
<LoadingPagetext="Loading Level..."processes={context.processes}/>
4141
</Route>
4242
<Routepaths={{Tutorial:{Level:true}}}>
43-
<TutorialPagesend={send}context={context}/>
43+
<TutorialPagesend={send}context={context}state={route.replace('Tutorial.Level.','')}/>
4444
</Route>
4545
{/* Completed */}
4646
<Routepaths={{Tutorial:{Completed:true}}}>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import*asReactfrom'react'
2-
import{Dialog}from'@alifd/next'
2+
import{Dialog,Icon}from'@alifd/next'
33
import{css,jsx}from'@emotion/core'
44
importButtonfrom'../../../components/Button'
55
importProgressPiefrom'./ProgressPie'
@@ -14,17 +14,21 @@ const styles = {
1414
message:{
1515
textAlign:'center'as'center',
1616
},
17+
buttonSubtext:{
18+
padding:'0.5rem',
19+
},
1720
}
1821

1922
interfaceProps{
2023
title:string
2124
current:number// level index
2225
max:number// level count
26+
defaultOpen:boolean
2327
onContinue():void
2428
}
2529

2630
constContinue=(props:Props)=>{
27-
const[modalState,setModalState]=React.useState<'closed'|'open'>('closed')
31+
const[modalState,setModalState]=React.useState<'closed'|'open'>(props.defaultOpen ?'open' :'closed')
2832

2933
constonClose=()=>{
3034
setModalState('closed')
@@ -57,8 +61,10 @@ const Continue = (props: Props) => {
5761
<h3>{props.title}</h3>
5862
<br/>
5963
<Buttontype="primary"size="large"onClick={onContinue}>
60-
Continue
64+
Continue&nbsp;&nbsp;
65+
<Icontype="arrow-right"/>
6166
</Button>
67+
<divcss={styles.buttonSubtext}>(ctrl + enter)</div>
6268
</div>
6369
</div>
6470
</Dialog>

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

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import TestMessage from '../../components/TestMessage'
1111
importStepProgressfrom'./components/StepProgress'
1212
import{DISPLAY_RUN_TEST_BUTTON}from'../../environment'
1313
importformatLevelsfrom'./formatLevels'
14-
// import SettingsPage from './containers/Settings'
1514
importResetfrom'./components/Reset'
1615
importContinuefrom'./components/Continue'
1716

@@ -69,6 +68,7 @@ const styles = {
6968
interfacePageProps{
7069
context:T.MachineContext
7170
send(action:T.Action):void
71+
state:string// 'Normal' | 'TestRunning' | 'TestFail' | 'TestPass' | 'LevelComplete'
7272
}
7373

7474
/**
@@ -85,9 +85,6 @@ const TutorialPage = (props: PageProps) => {
8585
constonContinue=():void=>{
8686
props.send({
8787
type:'NEXT_LEVEL',
88-
payload:{
89-
levelId:position.levelId,
90-
},
9188
})
9289
}
9390

@@ -111,6 +108,8 @@ const TutorialPage = (props: PageProps) => {
111108
testStatus,
112109
})
113110

111+
constdisableOptions=processes.length>0||props.state==='TestRunning'
112+
114113
return(
115114
<div>
116115
<div>
@@ -141,26 +140,37 @@ const TutorialPage = (props: PageProps) => {
141140
{/* Left */}
142141
<divcss={{flex:1}}>
143142
{DISPLAY_RUN_TEST_BUTTON&&level.status!=='COMPLETE' ?(
144-
<Buttonstyle={{marginLeft:'1rem'}}type="primary"onClick={onRunTest}disabled={processes.length>0}>
143+
<Buttonstyle={{marginLeft:'1rem'}}type="primary"onClick={onRunTest}disabled={disableOptions}>
145144
Run
146145
</Button>
147146
) :null}
148147
</div>
149148

150149
{/* Center */}
151150
<divcss={{flex:1,display:'flex',justifyContent:'center'}}>
152-
<ResetonReset={onReset}disabled={processes.length>0}/>
151+
<ResetonReset={onReset}disabled={disableOptions||props.state==='LevelComplete'}/>
153152
</div>
154153

155154
{/* Right */}
156155
<divcss={{flex:1,display:'flex',justifyContent:'flex-end'}}>
157-
{level.status==='COMPLETE'||!level.steps.length ?(
156+
{!level.steps.length ?(
157+
<divcss={{marginRight:'0.5rem'}}>
158+
<Continue
159+
onContinue={onContinue}
160+
current={levelIndex+1}
161+
max={levels.length}
162+
title={tutorial.summary.title}
163+
defaultOpen={false}
164+
/>
165+
</div>
166+
) :props.state==='LevelComplete' ?(
158167
<divcss={{marginRight:'0.5rem'}}>
159168
<Continue
160169
onContinue={onContinue}
161170
current={levelIndex+1}
162171
max={levels.length}
163172
title={tutorial.summary.title}
173+
defaultOpen={true}
164174
/>
165175
</div>
166176
) :level.steps.length>1 ?(

‎web-app/src/environment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ export const TUTORIAL_LIST_URL: string = process.env.REACT_APP_TUTORIAL_LIST_URL
1414
exportconstSENTRY_DSN:string|null=process.env.REACT_APP_SENTRY_DSN||null
1515

1616
// config variables
17-
exportconstDISPLAY_RUN_TEST_BUTTON=(process.env.CODEROAD_DISPLAY_RUN_TEST_BUTTON||'').toLowerCase()==='true'
17+
exportconstDISPLAY_RUN_TEST_BUTTON=(process.env.CODEROAD_DISPLAY_RUN_TEST_BUTTON||'true').toLowerCase()==='true'

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@ const contextActions: ActionFunctionMap<T.MachineContext, T.MachineEvent> = {
118118
returnevent.payload
119119
},
120120
}),
121+
//@ts-ignore
122+
updateLevel:assign({
123+
position:(context:T.MachineContext,event:T.MachineEvent):any=>{
124+
constlevelId=context.position.levelId
125+
return{ levelId}
126+
},
127+
}),
121128
loadNext:send(
122129
(context:T.MachineContext):T.Action=>{
123130
const{ position, progress}=context

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ export const createMachine = (options: any) => {
171171
RUN_RESET:{
172172
actions:['runReset'],
173173
},
174+
KEY_PRESS_ENTER:{
175+
actions:['runTest'],
176+
},
174177
},
175178
},
176179
TestRunning:{
@@ -217,7 +220,11 @@ export const createMachine = (options: any) => {
217220
on:{
218221
NEXT_LEVEL:{
219222
target:'LoadNext',
220-
actions:['testClear','updatePosition'],
223+
actions:['testClear','updateLevel'],
224+
},
225+
KEY_PRESS_ENTER:{
226+
target:'LoadNext',
227+
actions:['testClear','updateLevel'],
221228
},
222229
},
223230
},

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp