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/loading screen processes#288

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 3 commits intomasterfromfeature/loading-screen-processes
Apr 19, 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
6 changes: 3 additions & 3 deletionsweb-app/src/Routes.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,13 +25,13 @@ const Routes = () => {
<Router>
{/* Setup */}
<Route path={['Setup.Startup', 'Setup.ValidateSetup']}>
<LoadingPage text="Launching..." />
<LoadingPage text="Launching..."processes={context.processes}/>
</Route>
<Route path="Setup.Start">
<StartPage send={send} context={context} />
</Route>
<Route path={['Setup.LoadTutorialSummary', 'Setup.LoadTutorialData', 'Setup.SetupNewTutorial']}>
<LoadingPage text="Loading Tutorial..."/>
<LoadingPage text="Loading Tutorial..."processes={context.processes} />]
</Route>
<Route path="Setup.SelectTutorial">
<SelectTutorialPage send={send} context={context} />
Expand All@@ -41,7 +41,7 @@ const Routes = () => {
</Route>
{/* Tutorial */}
<Route path={['Tutorial.LoadNext', 'Tutorial.Level.Load']}>
<LoadingPage text="Loading Level..." />
<LoadingPage text="Loading Level..."processes={context.processes}/>
</Route>
<Route path="Tutorial.Level">
<LevelSummaryPage send={send} context={context} />
Expand Down
6 changes: 3 additions & 3 deletionsweb-app/src/components/Loading/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,11 +2,11 @@ import { Loading } from '@alifd/next'
import*asReactfrom'react'

interfaceProps{
text:string
message:string
}

constLoadingComponent=({text}:Props)=>{
return<Loadingtip={text}/>
constLoadingComponent=({message}:Props)=>{
return<Loadingtip={message}/>
}

exportdefaultLoadingComponent
2 changes: 1 addition & 1 deletionweb-app/src/components/ProcessMessages/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,7 +5,7 @@ import { css, jsx } from '@emotion/core'
importTestMessagefrom'./TestMessage'

interfaceProps{
testStatus:T.TestStatus|null
testStatus?:T.TestStatus|null
processes:T.ProcessEvent[]
}

Expand Down
2 changes: 1 addition & 1 deletionweb-app/src/containers/Loading/LoadingPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,7 +22,7 @@ const styles = {
const LoadingPage = ({ text }: Props) => {
return (
<div css={styles.page}>
<Loadingtext={text} />
<Loadingmessage={text} />
</div>
)
}
Expand Down
32 changes: 22 additions & 10 deletionsweb-app/src/containers/Loading/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2,32 +2,40 @@ import * as React from 'react'
import * as T from 'typings'
import { css, jsx } from '@emotion/core'
import Loading from '../../components/Loading'
importMessage from '../../components/Message'
importProcessMessages from 'components/ProcessMessages'

interface Props {
text: string
context?: T.MachineContext
processes?: T.ProcessEvent[]
}

const styles = {
page: {
position: 'relative' as 'relative',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
display: 'flex' as 'flex',
flexDirection: 'column' as 'column',
alignItems: 'center' as 'center',
justifyContent: 'center' as 'center',
height: '100%',
width: '100%',
},
processes: {
padding: '0 1rem',
position: 'fixed' as 'fixed',
bottom: 0,
left: 0,
right: 0,
},
}

const LoadingPage = ({ text }: Props) => {
const [showLoading, setShowHiding] = React.useState(false)
const LoadingPage = ({ text, processes }: Props) => {
const [showLoading, setShowHiding] = React.useState<boolean>(!!processes?.length)

React.useEffect(() => {
// wait some time before showing loading indicator
const timeout = setTimeout(() => {
setShowHiding(true)
},600)
},500)
return () => {
clearTimeout(timeout)
}
Expand All@@ -37,10 +45,14 @@ const LoadingPage = ({ text }: Props) => {
if (!showLoading) {
return null
}

return (
<div css={styles.page}>
<Loading text={text} />
<Loading message={text} />
{processes && processes.length ? (
<div css={styles.processes}>
<ProcessMessages processes={processes} />
</div>
) : null}
</div>
)
}
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import useFetch from '../../services/hooks/useFetch'
import * as TT from 'typings/tutorial'
importLoading from '../Loading'
importLoadingPage from '../Loading'

interface Props {
url: string
Expand All@@ -11,7 +11,7 @@ interface Props {
const LoadTutorialSummary = (props: Props) => {
const { data, error, loading } = useFetch<TT.Tutorial>(props.url)
if (loading) {
return <Loading text="Loading tutorial summary..." />
return <LoadingPage text="Loading tutorial summary..." />
}
if (error) {
console.log(`Failed to load tutorial summary: ${error}`)
Expand Down
32 changes: 16 additions & 16 deletionsweb-app/src/services/state/machine.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -29,6 +29,22 @@ export const createMachine = (options: any) => {
processes: [],
testStatus: null,
},
on: {
// track commands
COMMAND_START: {
actions: ['commandStart'],
},
COMMAND_SUCCESS: {
actions: ['commandSuccess'],
},
COMMAND_FAIL: {
actions: ['commandFail'],
},
ERROR: {
// TODO: missing clearError
actions: ['setError'],
},
},
states: {
Setup: {
initial: 'Startup',
Expand DownExpand Up@@ -121,22 +137,6 @@ export const createMachine = (options: any) => {
Tutorial: {
id: 'tutorial',
initial: 'Level',
on: {
// track commands
COMMAND_START: {
actions: ['commandStart'],
},
COMMAND_SUCCESS: {
actions: ['commandSuccess'],
},
COMMAND_FAIL: {
actions: ['commandFail'],
},
ERROR: {
// TODO: missing clearError
actions: ['setError'],
},
},
states: {
LoadNext: {
id: 'tutorial-load-next',
Expand Down
13 changes: 12 additions & 1 deletionweb-app/stories/Loading.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,19 @@
import { storiesOf } from '@storybook/react'
import * as T from '../../typings'
import React from 'react'
import LoadingPage from '../src/containers/Loading'
import SideBarDecorator from './utils/SideBarDecorator'

storiesOf('Components', module)
.addDecorator(SideBarDecorator)
.add('Loading', () => <LoadingPage text="Content" context={{}} />)
.add('Loading', () => <LoadingPage text="Content" />)
.add('Loading processes', () => {
const processes: T.ProcessEvent[] = [
{
title: 'title',
description: 'description...',
status: 'RUNNING',
},
]
return <LoadingPage text="Content" processes={processes} />
})

[8]ページ先頭

©2009-2025 Movatter.jp