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

Commitf4f6e1c

Browse files
committed
outline hints component
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent137d07b commitf4f6e1c

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import*asReactfrom'react'
2+
importButtonfrom'../../../components/Button'
3+
4+
interfaceProps{
5+
hints:string[]
6+
}
7+
8+
constHints=(props:Props)=>{
9+
const[hintIndex,setHintIndex]=React.useState(0)
10+
constisFinalHint=props.hints.length-1===hintIndex
11+
console.log(hintIndex)
12+
constnextHint=()=>{
13+
console.log(hintIndex)
14+
if(!isFinalHint){
15+
setHintIndex((currentHintIndex)=>currentHintIndex+1)
16+
}
17+
}
18+
return(
19+
<div>
20+
{props.hints.map((h,i)=>{
21+
returni<=hintIndex ?(
22+
<divkey={i}style={{backgroundColor:'red'}}>
23+
{h}
24+
</div>
25+
) :null
26+
})}
27+
<ButtononClick={nextHint}disabled={isFinalHint}>
28+
Next Hint
29+
</Button>
30+
</div>
31+
)
32+
}
33+
34+
exportdefaultHints

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

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

78
interfaceProps{
89
order:number
910
content:string
1011
status:T.ProgressStatus
1112
subtasks:{name:string;pass:boolean}[]|null
13+
hints?:string[]
1214
onLoadSolution():void
1315
}
1416

@@ -54,9 +56,11 @@ const Step = (props: Props) => {
5456
{props.status==='COMPLETE'&&<TestStatusIconsize="small"checked/>}
5557
</div>
5658
<div>
59+
{/* content */}
5760
<divcss={styles.content}>
5861
<Markdown>{props.content||''}</Markdown>
5962
</div>
63+
{/* subtasks */}
6064
{props.subtasks ?(
6165
<ulcss={styles.subtasks}>
6266
{props.subtasks.map((subtask)=>(
@@ -68,6 +72,8 @@ const Step = (props: Props) => {
6872
))}
6973
</ul>
7074
) :null}
75+
{/* hints */}
76+
{props.hints&&props.hints.length ?<Hintshints={props.hints}/> :null}
7177
</div>
7278
</div>
7379
</div>

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,13 @@ storiesOf('Step', module)
9898
]}
9999
/>
100100
))
101+
.add('Hints',()=>(
102+
<Step
103+
order={1}
104+
content={text('text',stepText)}
105+
status="ACTIVE"
106+
onLoadSolution={action('onLoadSolution')}
107+
subtasks={null}
108+
hints={['First hint!','Second hint!']}
109+
/>
110+
))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp