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

Feature/hints#365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 4 commits intomasterfromfeature/hints
Jun 16, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletiontypings/tutorial.d.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ export type Step = {
setup: StepActions
solution: Maybe<StepActions>
subtasks?: { [testName: string]: boolean }
hints?: string[]
}

/** A tutorial for use in VSCode CodeRoad */
Expand DownExpand Up@@ -61,7 +62,7 @@ export interface TestRunnerArgs {

export interface TestRunnerConfig {
command: string
args?: TestRunnerArgs
args: TestRunnerArgs
path?: string // deprecated
directory?: string
actions?: StepActions // deprecated
Expand Down
50 changes: 50 additions & 0 deletionsweb-app/src/containers/Tutorial/components/Hints.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
import * as React from 'react'
import Markdown from '../../../components/Markdown'
import Button from '../../../components/Button'

const styles = {
hints: {
marginTop: '1rem',
},
hintList: {
marginBottom: '0.5rem',
},
hint: {
margin: '0.5rem 0',
backgroundColor: 'rgba(255,229,100,0.3)',
borderLeft: '#ffe564',
padding: '0.5rem',
},
}

interface Props {
hints: string[]
}

const Hints = (props: Props) => {
const [hintIndex, setHintIndex] = React.useState(-1)
const isFinalHint = props.hints.length - 1 === hintIndex
const nextHint = () => {
if (!isFinalHint) {
setHintIndex((currentHintIndex) => currentHintIndex + 1)
}
}
return (
<div style={styles.hints}>
<div style={styles.hintList}>
{props.hints.map((h, i) => {
return i <= hintIndex ? (
<div key={i} style={styles.hint}>
<Markdown>{h}</Markdown>
</div>
) : null
})}
</div>
<Button onClick={nextHint} disabled={isFinalHint}>
Get A Hint
</Button>
</div>
)
}

export default Hints
1 change: 1 addition & 0 deletionsweb-app/src/containers/Tutorial/components/Level.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -173,6 +173,7 @@ const Level = ({
content={step.content}
onLoadSolution={onLoadSolution}
subtasks={subtasks}
hints={step.hints}
/>
)
})}
Expand Down
6 changes: 6 additions & 0 deletionsweb-app/src/containers/Tutorial/components/Step.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,13 +2,15 @@ import * as React from 'react'
import * as T from 'typings'
import { css, jsx } from '@emotion/core'
import TestStatusIcon from './TestStatusIcon'
import Hints from './Hints'
import Markdown from '../../../components/Markdown'

interface Props {
order: number
content: string
status: T.ProgressStatus
subtasks: { name: string; pass: boolean }[] | null
hints?: string[]
onLoadSolution(): void
}

Expand DownExpand Up@@ -54,9 +56,11 @@ const Step = (props: Props) => {
{props.status === 'COMPLETE' && <TestStatusIcon size="small" checked />}
</div>
<div>
{/* content */}
<div css={styles.content}>
<Markdown>{props.content || ''}</Markdown>
</div>
{/* subtasks */}
{props.subtasks ? (
<ul css={styles.subtasks}>
{props.subtasks.map((subtask) => (
Expand All@@ -68,6 +72,8 @@ const Step = (props: Props) => {
))}
</ul>
) : null}
{/* hints */}
{props.hints && props.hints.length ? <Hints hints={props.hints} /> : null}
</div>
</div>
</div>
Expand Down
10 changes: 10 additions & 0 deletionsweb-app/stories/Step.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -98,3 +98,13 @@ storiesOf('Step', module)
]}
/>
))
.add('Hints', () => (
<Step
order={1}
content={text('text', stepText)}
status="ACTIVE"
onLoadSolution={action('onLoadSolution')}
subtasks={null}
hints={['First hint!', 'Second hint!']}
/>
))

[8]ページ先頭

©2009-2025 Movatter.jp