-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b117215
commit 7429488
Showing
8 changed files
with
287 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from "react"; | ||
import {useAppSelector} from "../../hooks"; | ||
import {toHtml} from "../../utils/sanitize"; | ||
import {TaskHint} from "./hints_slice"; | ||
import {formatTaskInstructions} from '../utils'; | ||
import {getMessage} from '../../lang'; | ||
|
||
export interface TaskHintProps { | ||
hint?: TaskHint, | ||
askHintClassName?: string, | ||
goToHintId: (hintId: string) => void, | ||
} | ||
|
||
export function TaskHint(props: TaskHintProps) { | ||
const taskLevel = useAppSelector(state => state.task.currentLevel); | ||
const platform = useAppSelector(state => state.options.platform); | ||
const hint = props.hint; | ||
|
||
const answerYes = () => { | ||
goToHint(props.hint.yesHintId); | ||
}; | ||
|
||
const answerNo = () => { | ||
goToHint(props.hint.noHintId); | ||
}; | ||
|
||
const goToHint = (hintId: string) => { | ||
props.goToHintId(hintId); | ||
} | ||
|
||
if (hint.question) { | ||
return ( | ||
<div | ||
className="hint-carousel-item" | ||
> | ||
<div className="hint-question"> | ||
{hint.question} | ||
</div> | ||
|
||
<div className="hint-buttons"> | ||
<div className={`hint-button ${props.askHintClassName}`} onClick={answerYes}> | ||
{getMessage('YES')} | ||
</div> | ||
|
||
<div className={`hint-button ${props.askHintClassName}`} onClick={answerNo}> | ||
{getMessage('NO')} | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const instructionsJQuery = formatTaskInstructions(hint.content, platform, taskLevel); | ||
|
||
return ( | ||
<div | ||
className="hint-carousel-item" | ||
dangerouslySetInnerHTML={toHtml(instructionsJQuery.html())} | ||
> | ||
|
||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.