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

Commitf705123

Browse files
committed
test status indicator progress
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent3a79d1d commitf705123

File tree

4 files changed

+48
-22
lines changed

4 files changed

+48
-22
lines changed

‎typings/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import*asEfrom'./error'
22
import*asTTfrom'./tutorial'
33

4-
exporttypeProgressStatus='ACTIVE'|'COMPLETE'|'INCOMPLETE'
4+
exporttypeProgressStatus='ACTIVE'|'COMPLETE'|'INCOMPLETE'|'FAIL'
55

66
exportinterfaceProgress{
77
levels:{

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

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react'
22
import*asTfrom'typings'
33
import{css,jsx}from'@emotion/core'
44
importTestStatusIconfrom'./TestStatusIcon'
5+
importIconfrom'../../../components/Icon'
56
importHintsfrom'./Hints'
67
importMarkdownfrom'../../../components/Markdown'
78

@@ -54,8 +55,7 @@ const Step = (props: Props) => {
5455
<div>
5556
<divcss={styles.card}>
5657
<divcss={styles.statusContainer}>
57-
{props.status==='ACTIVE'&&<TestStatusIconsize="small"/>}
58-
{props.status==='COMPLETE'&&<TestStatusIconsize="small"checked/>}
58+
<TestStatusIconsize="small"status={props.status}/>
5959
</div>
6060
<div>
6161
{/* content */}
@@ -65,13 +65,22 @@ const Step = (props: Props) => {
6565
{/* subtasks */}
6666
{props.subtasks ?(
6767
<ulcss={styles.subtasks}>
68-
{props.subtasks.map((subtask)=>(
69-
<likey={subtask.name}css={styles.subtask}>
70-
<TestStatusIconsize="xs"checked={props.status==='COMPLETE'||subtask.pass}/>
68+
{props.subtasks.map((subtask)=>{
69+
letsubtaskStatus:'COMPLETE'|'ACTIVE'
70+
if(props.status==='COMPLETE'){
71+
subtaskStatus='COMPLETE'
72+
}else{
73+
subtaskStatus=subtask.pass ?'COMPLETE' :'ACTIVE'
74+
}
7175

72-
<spanstyle={{marginLeft:'0.5rem'}}>{subtask.name}</span>
73-
</li>
74-
))}
76+
return(
77+
<likey={subtask.name}css={styles.subtask}>
78+
<TestStatusIconsize="xs"status={subtaskStatus}/>
79+
80+
<spanstyle={{marginLeft:'0.5rem'}}>{subtask.name}</span>
81+
</li>
82+
)
83+
})}
7584
</ul>
7685
) :null}
7786
{/* hints */}

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,29 @@ import * as React from 'react'
22
importIconfrom'../../../components/Icon'
33

44
interfaceProps{
5-
size:'small'|'xs'|'xxs'
6-
checked?:boolean
5+
size:'small'|'xs'
6+
status:'COMPLETE'|'ACTIVE'|'INCOMPLETE'|'FAIL'
77
}
88

9-
constcolors={
10-
complete:'#37B809',
11-
incomplete:'lightgrey',
9+
conststyles={
10+
complete:{
11+
icon:'success-filling',
12+
color:'#37B809',
13+
},
14+
active:{
15+
icon:'success-filling',
16+
color:'lightgrey',
17+
},
18+
fail:{
19+
icon:'warning',
20+
color:'#ff9300',
21+
},
1222
}
1323

1424
constTestStatusIcon=(props:Props)=>{
15-
return(
16-
<Icon
17-
type="success-filling"
18-
size={props.size}
19-
style={{color:props.checked ?colors.complete :colors.incomplete}}
20-
/>
21-
)
25+
//@ts-ignore
26+
conststyle:{icon:string;color:string}=styles[props.status.toLowerCase()]
27+
return<Icontype="success-filling"size={props.size}style={{color:style.color}}/>
2228
}
2329

2430
exportdefaultTestStatusIcon

‎web-app/stories/Step.stories.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,17 @@ storiesOf('Step', module)
6969
setHintIndex={action('setHintIndex')}
7070
/>
7171
))
72+
.add('Fail Step',()=>(
73+
<Step
74+
index={1}
75+
content={text('text',stepText)}
76+
status="FAIL"
77+
onLoadSolution={action('onLoadSolution')}
78+
subtasks={null}
79+
hintIndex={0}
80+
setHintIndex={action('setHintIndex')}
81+
/>
82+
))
7283
.add('Step Markdown',()=>(
7384
<Step
7485
index={2}
@@ -80,7 +91,7 @@ storiesOf('Step', module)
8091
setHintIndex={action('setHintIndex')}
8192
/>
8293
))
83-
.add('Substasks',()=>(
94+
.add('Subtasks',()=>(
8495
<Step
8596
index={2}
8697
content={'A task with subtasks'}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp