Skip to content

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
create progress pie component
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
  • Loading branch information
ShMcK committed Jul 17, 2020
commit 60c171dc32c857d0784c59e18b307fac82b93502
7 changes: 4 additions & 3 deletions web-app/src/containers/Tutorial/components/Continue.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react'
import { Dialog, Message } from '@alifd/next'
import { Dialog } from '@alifd/next'
import Button from '../../../components/Button'
import ProgressPie from './ProgressPie'

interface Props {
onContinue(): void
Expand Down Expand Up @@ -31,9 +32,9 @@ const Continue = (props: Props) => {
onOk={onOk}
onCancel={onClose}
onClose={onClose}
footerActions={['ok', 'cancel']}
footerActions={['ok']}
>
<Message>Level Complete</Message>
<ProgressPie />
</Dialog>
</>
)
Expand Down
26 changes: 26 additions & 0 deletions web-app/src/containers/Tutorial/components/ProgressPie.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import * as React from 'react'
import { Progress, Icon } from '@alifd/next'

const ProgressPie = () => {
const [progress, setProgress] = React.useState(0)

React.useEffect(() => {
if (progress < 100) {
const intervals = [10, 20]
const randomInteval = intervals[Math.floor(Math.random() * intervals.length)]
setTimeout(() => {
setProgress(progress + randomInteval)
}, 200)
}
}, [progress])

return (
<Progress
percent={progress}
shape="circle"
textRender={() => (progress === 100 ? <Icon type="select" size="xl" /> : null)}
/>
)
}

export default ProgressPie