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/progress#390

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 intomasterfromfeature/progress
Jul 17, 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
69 changes: 69 additions & 0 deletionsweb-app/src/containers/Tutorial/components/Continue.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
import*asReactfrom'react'
import{Dialog}from'@alifd/next'
import{css,jsx}from'@emotion/core'
importButtonfrom'../../../components/Button'
importProgressPiefrom'./ProgressPie'

conststyles={
content:{
display:'flex'as'flex',
flexDirection:'column'as'column',
justifyContent:'center'as'center',
alignItems:'center'as'center',
},
message:{
textAlign:'center'as'center',
},
}

interfaceProps{
title:string
current:number// level index
max:number// level count
onContinue():void
}

constContinue=(props:Props)=>{
const[modalState,setModalState]=React.useState<'closed'|'open'>('closed')

constonClose=()=>{
setModalState('closed')
}

constonOpen=()=>{
setModalState('open')
}

constonContinue=()=>{
props.onContinue()
onClose()
}

return(
<>
<Buttontype="primary"size="medium"onClick={onOpen}>
Continue
</Button>
<Dialog
title="Level Complete!"
visible={modalState==='open'}
onClose={onClose}
footer={false}
css={{padding:'1rem'}}
>
<divcss={styles.content}>
<ProgressPiecurrent={props.current}max={props.max}/>
<divcss={styles.message}>
<h3>{props.title}</h3>
<br/>
<Buttontype="primary"size="large"onClick={onContinue}>
Continue
</Button>
</div>
</div>
</Dialog>
</>
)
}

exportdefaultContinue
37 changes: 37 additions & 0 deletionsweb-app/src/containers/Tutorial/components/ProgressPie.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
import*asReactfrom'react'
import{Progress,Icon}from'@alifd/next'

interfaceProps{
current:number
max:number
}

constProgressPie=(props:Props)=>{
const[progress,setProgress]=React.useState(0)

React.useEffect(()=>{
lettimeout:any
if(progress<props.current){
timeout=setTimeout(()=>{
setProgress(progress+1)
},100)
}
return()=>{
if(timeout){
clearTimeout(timeout)
}
}
},[progress])

constprogressPercent=Math.floor((progress/props.max)*100)

return(
<Progress
percent={progressPercent}
shape="circle"
textRender={()=>(progressPercent===100 ?<Icontype="select"size="xl"/> :`${progressPercent}%`)}
/>
)
}

exportdefaultProgressPie
2 changes: 1 addition & 1 deletionweb-app/src/containers/Tutorial/components/Reset.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ import { Dialog, Message } from '@alifd/next'
importButtonfrom'../../../components/Button'

interfaceProps{
disabled:boolean
disabled?:boolean
onReset():void
}

Expand Down
3 changes: 2 additions & 1 deletionweb-app/src/containers/Tutorial/formatLevels.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -11,6 +11,7 @@ interface Input {
typeOutput={
level:T.LevelUI
levels:T.LevelUI[]
levelIndex:number
stepIndex:number
}

Expand DownExpand Up@@ -89,7 +90,7 @@ const formatLevels = ({ progress, position, levels, testStatus }: Input): Output
if(stepIndex===-1){
stepIndex=levels[levelIndex].steps.length
}
return{level:levelUI,levels:levelsUI, stepIndex}
return{level:levelUI,levels:levelsUI,levelIndex,stepIndex}
}

exportdefaultformatLevels
20 changes: 13 additions & 7 deletionsweb-app/src/containers/Tutorial/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,7 @@ import { DISPLAY_RUN_TEST_BUTTON } from '../../environment'
importformatLevelsfrom'./formatLevels'
// import SettingsPage from './containers/Settings'
importResetfrom'./components/Reset'
importContinuefrom'./components/Continue'

conststyles={
header:{
Expand DownExpand Up@@ -103,7 +104,7 @@ const TutorialPage = (props: PageProps) => {
const[page,setPage]=React.useState<'level'|'settings'|'review'>('level')

// format level code with status for easy rendering
const{ level, levels, stepIndex}=formatLevels({
const{ level, levels,levelIndex,stepIndex}=formatLevels({
progress,
position,
levels:tutorial.levels,
Expand DownExpand Up@@ -154,12 +155,17 @@ const TutorialPage = (props: PageProps) => {
{/* Right */}
<divcss={{flex:1,display:'flex',justifyContent:'flex-end'}}>
{level.status==='COMPLETE'||!level.steps.length ?(
<Buttonstyle={{marginRight:'1rem'}}type="primary"onClick={onContinue}>
Continue
</Button>
) :(
<StepProgresscurrent={stepIndex}max={level.steps.length}/>
)}
<divcss={{marginRight:'0.5rem'}}>
<Continue
onContinue={onContinue}
current={levelIndex+1}
max={levels.length}
title={tutorial.summary.title}
/>
</div>
) :level.steps.length>1 ?(
<StepProgresscurrent={stepIndex+1}max={level.steps.length}/>
) :null}
</div>
</div>
<SideMenuvisible={menuVisible}toggleVisible={setMenuVisible}page={page}setPage={setPage}/>
Expand Down
16 changes: 16 additions & 0 deletionsweb-app/stories/Modals.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
import{action}from'@storybook/addon-actions'
import{withKnobs}from'@storybook/addon-knobs'
import{storiesOf}from'@storybook/react'
importReactfrom'react'
importSideBarDecoratorfrom'./utils/SideBarDecorator'
importResetfrom'../src/containers/Tutorial/components/Reset'
importContinuefrom'../src/containers/Tutorial/components/Continue'

storiesOf('Modals',module)
.addDecorator(SideBarDecorator)
.addDecorator(withKnobs)
.add('Reset',()=><ResetonReset={action('onReset')}/>)
.add('Continue',()=><Continuetitle="Tutorial Title"current={9}max={11}onContinue={action('onContinue')}/>)
.add('Continue Complete',()=>(
<Continuetitle="Tutorial Title"current={11}max={11}onContinue={action('onContinue')}/>
))
37 changes: 9 additions & 28 deletionsweb-app/stories/Tutorial.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,16 +3,9 @@ import { withKnobs } from '@storybook/addon-knobs'
import{storiesOf}from'@storybook/react'
importReactfrom'react'
import*asTfrom'../../typings'
import*asTTfrom'../../typings/tutorial'
importTutorialfrom'../src/containers/Tutorial'
importSideBarDecoratorfrom'./utils/SideBarDecorator'

typeModifiedLevel=TT.Level&{
status:T.ProgressStatus
index:number
steps:Array<TT.Step&{status:T.ProgressStatus}>
}

constcontext:Partial<T.MachineContext>={
env:{machineId:'',sessionId:'',token:''},
error:null,
Expand DownExpand Up@@ -58,26 +51,6 @@ const context: Partial<T.MachineContext> = {
},
hints:['First Hint','Second Hint'],
},
{
id:'1.2',
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
setup:{
commits:['abcdefg'],
},
solution:{
commits:['hijklmn'],
},
},
{
id:'1.3',
content:'Should support markdown test\n ```js\nvar a = 1\n```\nwhew it works!',
setup:{
commits:['abcdefg'],
},
solution:{
commits:['hijklmn'],
},
},
],
},
{
Expand DownExpand Up@@ -168,4 +141,12 @@ const context: Partial<T.MachineContext> = {
storiesOf('Tutorial',module)
.addDecorator(SideBarDecorator)
.addDecorator(withKnobs)
.add('Example',()=><Tutorialcontext={context}send={action('send')}/>)
.add('1 step',()=>{
constfirstLevel={
...context,
position:{levelId:'1',stepId:'1.2'},
progress:{levels:{},steps:{},complete:false},
}
return<Tutorialcontext={firstLevel}send={action('send')}/>
})
.add('3 step',()=><Tutorialcontext={context}send={action('send')}/>)

[8]ページ先頭

©2009-2025 Movatter.jp