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

Traverse content (blocked)#296

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 5 commits intomasterfromtraverse-content
Apr 26, 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
5 changes: 5 additions & 0 deletionssrc/channel/index.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -297,6 +297,11 @@ class Channel implements Channel {
vscode.commands.executeCommand(COMMANDS.RUN_TEST)
return

case'EDITOR_SYNC_PROGRESS':
// update progress when a level is deemed complete in the client
awaitthis.context.progress.syncProgress(action.payload.progress)
return

default:
logger(`No match for action type:${actionType}`)
return
Expand Down
4 changes: 4 additions & 0 deletionssrc/channel/state/Progress.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -39,6 +39,10 @@ class Progress {
publicreset=()=>{
this.set(defaultValue)
}
publicsyncProgress=(progress:T.Progress):T.Progress=>{
constnext={ ...this.value, ...progress}
returnthis.set(next)
}
publicsetStepComplete=(tutorial:TT.Tutorial,stepId:string):T.Progress=>{
constnext=this.value
// mark step complete
Expand Down
60 changes: 47 additions & 13 deletionsweb-app/src/containers/Tutorial/components/Level.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,6 +2,8 @@ import * as React from 'react'
import*asTfrom'typings'
import*asTTfrom'typings/tutorial'
import{css,jsx}from'@emotion/core'
import{Dropdown}from'@alifd/next'
importIconfrom'../../../components/Icon'
importButtonfrom'../../../components/Button'
importMarkdownfrom'../../../components/Markdown'
importProcessMessagesfrom'../../../components/ProcessMessages'
Expand All@@ -22,12 +24,19 @@ const styles = {
paddingBottom:'5rem',
},
header:{
display:'flex'as'flex',
alignItems:'center',
justifyContent:'space-between',
height:'2rem',
backgroundColor:'#EBEBEB',
fontSize:'1rem',
lineHeight:'1rem',
padding:'10px 1rem',
},
learn:{
textDecoration:'none',
color:'inherit',
},
text:{
padding:'0rem 1rem',
paddingBottom:'1rem',
Expand DownExpand Up@@ -77,18 +86,34 @@ const styles = {
}

interfaceProps{
level:TT.Level&{status:T.ProgressStatus;index:number;steps:Array<TT.Step&{status:T.ProgressStatus}>}
menu:any
steps:Array<TT.Step&{status:T.ProgressStatus}>
title:string
index:number
content:string
status:'COMPLETE'|'ACTIVE'|'INCOMPLETE'
processes:T.ProcessEvent[]
testStatus:T.TestStatus|null
onContinue():void
onLoadSolution():void
}

constLevel=({ level, onContinue, onLoadSolution, processes, testStatus}:Props)=>{
constLevel=({
menu,
steps,
title,
content,
index,
status,
onContinue,
onLoadSolution,
processes,
testStatus,
}:Props)=>{
//@ts-ignore
letcurrentStep=level.steps.findIndex((s)=>s.status==='ACTIVE')
letcurrentStep=steps.findIndex((s)=>s.status==='ACTIVE')
if(currentStep===-1){
currentStep=level.steps.length
currentStep=steps.length
}

constpageBottomRef=React.useRef(null)
Expand All@@ -103,18 +128,27 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro
<divcss={styles.page}>
<divcss={styles.content}>
<divcss={styles.header}>
<span>Learn</span>
<Dropdown
trigger={
<acss={styles.learn}>
Learn<Icontype="arrow-down"size="xxs"/>
</a>
}
triggerType="click"
>
{menu}
</Dropdown>
</div>
<divcss={styles.text}>
<h2css={styles.title}>{level.title}</h2>
<Markdown>{level.content||''}</Markdown>
<h2css={styles.title}>{title}</h2>
<Markdown>{content||''}</Markdown>
</div>

{level.steps.length ?(
{steps.length ?(
<divcss={styles.tasks}>
<divcss={styles.header}>Tasks</div>
<divcss={styles.steps}>
{level.steps.map((step:(TT.Step&{status:T.ProgressStatus})|null,index:number)=>{
{steps.map((step:(TT.Step&{status:T.ProgressStatus})|null,index:number)=>{
if(!step){
returnnull
}
Expand DownExpand Up@@ -146,17 +180,17 @@ const Level = ({ level, onContinue, onLoadSolution, processes, testStatus }: Pro

<divcss={styles.footer}>
<span>
{typeoflevel.index==='number' ?`${level.index+1}. ` :''}
{level.title}
{typeofindex==='number' ?`${index+1}. ` :''}
{title}
</span>
<span>
{level.status==='COMPLETE'||!level.steps.length ?(
{status==='COMPLETE'||!steps.length ?(
<Buttontype="primary"onClick={onContinue}>
Continue
</Button>
) :(
<spancss={styles.taskCount}>
{currentStep} of{level.steps.length} tasks
{currentStep} of{steps.length} tasks
</span>
)}
</span>
Expand Down
77 changes: 58 additions & 19 deletionsweb-app/src/containers/Tutorial/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
import*asReactfrom'react'
import*asTfrom'typings'
import*asTTfrom'typings/tutorial'
import{Menu}from'@alifd/next'
import*asselectorsfrom'../../services/selectors'
importIconfrom'../../components/Icon'
importLevelfrom'./components/Level'
importloggerfrom'../../services/logger'

interfacePageProps{
context:T.MachineContext
Expand All@@ -15,6 +18,9 @@ const TutorialPage = (props: PageProps) => {
consttutorial=selectors.currentTutorial(props.context)
constlevelData:TT.Level=selectors.currentLevel(props.context)

const[title,setTitle]=React.useState<string>(levelData.title)
const[content,setContent]=React.useState<string>(levelData.content)

constonContinue=():void=>{
props.send({
type:'LEVEL_NEXT',
Expand All@@ -28,29 +34,62 @@ const TutorialPage = (props: PageProps) => {
props.send({type:'STEP_SOLUTION_LOAD'})
}

constlevel:TT.Level&{
status:T.ProgressStatus
index:number
steps:Array<TT.Step&{status:T.ProgressStatus}>
}={
...levelData,
index:tutorial.levels.findIndex((l:TT.Level)=>l.id===position.levelId),
status:progress.levels[position.levelId] ?'COMPLETE' :'ACTIVE',
steps:levelData.steps.map((step:TT.Step)=>{
// label step status for step component
letstatus:T.ProgressStatus='INCOMPLETE'
if(progress.steps[step.id]){
status='COMPLETE'
}elseif(step.id===position.stepId){
status='ACTIVE'
}
return{ ...step, status}
}),
conststeps=levelData.steps.map((step:TT.Step)=>{
// label step status for step component
letstatus:T.ProgressStatus='INCOMPLETE'
if(progress.steps[step.id]){
status='COMPLETE'
}elseif(step.id===position.stepId){
status='ACTIVE'
}
return{ ...step, status}
})

constsetMenuContent=(levelId:string)=>{
constselectedLevel:TT.Level|undefined=tutorial.levels.find((l:TT.Level)=>l.id===levelId)
if(selectedLevel){
setTitle(selectedLevel.title)
setContent(selectedLevel.content)
}
}

constmenu=(
<Menu>
{tutorial.levels.map((level:TT.Level)=>{
constisCurrent=level.id===position.levelId
logger('progress',progress)
constisComplete=progress.levels[level.id]
leticon
letdisabled=false

if(isComplete){
// completed icon
icon=<Icontype="minus"size="xs"/>
}elseif(isCurrent){
// current icon`
icon=<Icontype="minus"size="xs"/>
}else{
// upcoming
disabled=true
icon=<Icontype="lock"size="xs"/>
}
return(
<Menu.Itemkey={level.id}disabled={disabled}onSelect={()=>setMenuContent(level.id)}>
{icon}&nbsp;&nbsp;&nbsp;{level.title}
</Menu.Item>
)
})}
</Menu>
)

return(
<Level
level={level}
title={title}
content={content}
menu={menu}
index={tutorial.levels.findIndex((l:TT.Level)=>l.id===position.levelId)}
steps={steps}
status={progress.levels[position.levelId] ?'COMPLETE' :'ACTIVE'}
onContinue={onContinue}
onLoadSolution={onLoadSolution}
processes={processes}
Expand Down
3 changes: 1 addition & 2 deletionsweb-app/src/environment.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,6 @@ for (const required of requiredKeys) {
exportconstDEBUG:boolean=(process.env.REACT_APP_DEBUG||'').toLowerCase()==='true'
exportconstVERSION:string=process.env.VERSION||'unknown'
exportconstNODE_ENV:string=process.env.NODE_ENV||'development'
exportconstLOG:boolean=
(process.env.REACT_APP_LOG||'').toLowerCase()==='true'&&process.env.NODE_ENV!=='production'
exportconstLOG:boolean=(process.env.REACT_APP_LOG||'').toLowerCase()==='true'
exportconstTUTORIAL_LIST_URL:string=process.env.REACT_APP_TUTORIAL_LIST_URL||''
exportconstSENTRY_DSN:string|null=process.env.REACT_APP_SENTRY_DSN||null
8 changes: 8 additions & 0 deletionsweb-app/src/services/state/actions/editor.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -74,6 +74,14 @@ export default (editorSend: any) => ({
})
}
},
syncLevelProgress(context:CR.MachineContext):void{
editorSend({
type:'EDITOR_SYNC_PROGRESS',
payload:{
progress:context.progress,
},
})
},
clearStorage():void{
editorSend({type:'TUTORIAL_CLEAR'})
},
Expand Down
7 changes: 3 additions & 4 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -207,13 +207,12 @@ export const createMachine = (options: any) => {
target:'Normal',
actions:['loadStep'],
},
LEVEL_COMPLETE:{
target:'LevelComplete',
actions:['updateLevelProgress'],
},
LEVEL_COMPLETE:'LevelComplete',
},
},
LevelComplete:{
onEntry:['updateLevelProgress'],
onExit:['syncLevelProgress'],
on:{
LEVEL_NEXT:{
target:'#tutorial-load-next',
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp