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#21

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 4 commits intomasterfromfeature/loading
Jul 22, 2019
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
33 changes: 18 additions & 15 deletionsweb-app/src/Routes.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
import * as React from 'react'

importCond from './components/Cond'
importLoading from './components/Loading'
importRouter from './components/Router'
importLoadingPage from './containers/LoadingPage'
import ContinuePage from './containers/Continue'
import NewPage from './containers/New'
import TutorialPage from './containers/Tutorial'

const { Route } = Router

interface Props {
state: any
}
Expand DownExpand Up@@ -37,21 +39,22 @@ const Routes = ({ state }: Props) => {
}
})

// TODO: refactor cond to user <Router><Route> and accept first route as if/else if
return (
<div style={{ ...styles.page, ...dimensions }}>
<Cond state={state} path="SelectTutorial.Startup">
<Loading />
</Cond>
<Cond state={state} path="SelectTutorial.NewTutorial">
<NewPage />
</Cond>
<Cond state={state} path="SelectTutorial.ContinueTutorial">
<ContinuePage />
</Cond>
<Cond state={state} path="Tutorial">
<TutorialPage state={state} />
</Cond>
<Router state={state}>
<Route path="SelectTutorial.Startup">
<LoadingPage text="Launching..." />
</Route>
<Route path="SelectTutorial.NewTutorial">
<NewPage />
</Route>
<Route path="SelectTutorial.ContinueTutorial">
<ContinuePage />
</Route>
<Route path="Tutorial">
<TutorialPage state={state} />
</Route>
</Router>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletionweb-app/src/components/Cond/utils/state.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
exportfunctionstateMatch(state:any,statePath:string){
letcurrent=state
letpaths=statePath.split('.')
constpaths=statePath.split('.')
letcomplete=false
try{
for(constpofpaths){
Expand Down
11 changes: 8 additions & 3 deletionsweb-app/src/components/Loading/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
import * as React from 'react'
import { Loading } from '@alifd/next'

const Loading = () => {
return <div>Loading...</div>
interface Props {
text: string
}

export default Loading
const LoadingComponent = ({ text }: Props) => {
return <Loading tip={text} />
}

export default LoadingComponent
10 changes: 10 additions & 0 deletionsweb-app/src/components/Router/Route.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
import*asReactfrom'react'

interfaceProps{
children:any
path:string
}

constRoute=({ children}:Props)=>children

exportdefaultRoute
24 changes: 24 additions & 0 deletionsweb-app/src/components/Router/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
import * as React from 'react'
import Route from './Route'
import { stateMatch } from '../Cond/utils/state'

interface Props {
state: string
children: any
}

// router finds first state match of <Route path='' />
const Router = ({ state, children }: Props) => {
const childArray = React.Children.toArray(children)
for (const child of childArray) {
if (stateMatch(state, child.props.path)) {
return child.props.children
}
}
console.warn(`No Route matches for ${state}`)
return null
}

Router.Route = Route

export default Router
24 changes: 24 additions & 0 deletionsweb-app/src/containers/LoadingPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
import * as React from 'react'
import Loading from '../components/Loading'

interface Props {
text: string
}

const styles = {
page: {
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: '100%',
height: '100%',
},
}

const LoadingPage = ({ text }: Props) => (
<div style={styles.page}>
<Loading text={text} />
</div>
)

export default LoadingPage
4 changes: 3 additions & 1 deletionweb-app/src/containers/New/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
import * as React from 'react'
import { Button } from '@alifd/next'

import Cond from '../../components/Cond'
import DataContext from '../../utils/DataContext'
import { send } from '../../utils/vscode'
import LoadingPage from '../../containers/LoadingPage'

interface Props {
onNew(tutorialId: string): void
Expand All@@ -27,7 +29,7 @@ export const NewPage = (props: Props) => {
</div>
</Cond>
<Cond state={state} path="SelectTutorial.NewTutorial.InitializeTutorial">
<div>Initializing tutorial...</div>
<LoadingPage text="Launching Tutorial..." />
</Cond>
</div>
)
Expand Down
1 change: 0 additions & 1 deletionweb-app/src/containers/Tutorial/LevelPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ import Level from '../../components/Level'

interface LevelProps {
send(action: string): void
state: any
}

const LevelPage = (props: LevelProps) => {
Expand Down
1 change: 0 additions & 1 deletionweb-app/src/containers/Tutorial/StagePage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,6 @@ import DataContext from '../../utils/DataContext'
importStagefrom'../../components/Stage'

interfacePageProps{
state:any
send(action:string):void
}

Expand Down
1 change: 0 additions & 1 deletionweb-app/src/containers/Tutorial/SummaryPage.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,7 +4,6 @@ import Summary from '../../components/Summary'

interfacePageProps{
send(action:string):void
state:any
}

constSummaryPage=(props:PageProps)=>{
Expand Down
34 changes: 18 additions & 16 deletionsweb-app/src/containers/Tutorial/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
import * as React from 'react'
import { send } from '../../utils/vscode'

importCond from '../../components/Cond'
importLoading from '../../components/Loading'
importRouter from '../../components/Router'
importLoadingPage from '../LoadingPage'
import SummaryPage from './SummaryPage'
import LevelPage from './LevelPage'
import StagePage from './StagePage'

const { Route } = Router

interface Props {
state: any
}

const Tutorial = (props: Props) => {
return (
<div>
<Cond state={props.state} path="Tutorial.LoadNext">
<Loading />
</Cond>
<Cond state={props.state} path="Tutorial.Summary">
<SummaryPagestate={props.state}send={send} />
</Cond>
<Cond state={props.state} path="Tutorial.Level">
<LevelPagestate={props.state}send={send} />
</Cond>
<Cond state={props.state} path="Tutorial.Stage">
<StagePagestate={props.state}send={send} />
</Cond>
</div>
<Router state={props.state}>
<Route path="Tutorial.LoadNext">
<LoadingPage text="Loading Tutorial..." />
</Route>
<Route path="Tutorial.Summary">
<SummaryPage send={send} />
</Route>
<Route path="Tutorial.Level">
<LevelPage send={send} />
</Route>
<Route path="Tutorial.Stage">
<StagePage send={send} />
</Route>
</Router>
)
}

Expand Down
10 changes: 10 additions & 0 deletionsweb-app/stories/Loading.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
importReactfrom'react'

import{storiesOf}from'@storybook/react'
importSideBarDecoratorfrom'./utils/SideBarDecorator'

importLoadingPagefrom'../src/containers/LoadingPage'

storiesOf('Components',module)
.addDecorator(SideBarDecorator)
.add('Loading',()=><LoadingPagetext="Content"/>)
18 changes: 18 additions & 0 deletionsweb-app/stories/Router.stories.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
import React from 'react'

import { storiesOf } from '@storybook/react'
import SideBarDecorator from './utils/SideBarDecorator'

import Router from '../src/components/Router'

const { Route } = Router

storiesOf('Components', module)
.addDecorator(SideBarDecorator)
.add('Router', () => (
<Router state="Third">
<Route path="First">First</Route>
<Route path="Second">Second</Route>
<Route path="Third">Third</Route>
</Router>
))
1 change: 1 addition & 0 deletionsweb-app/stories/utils/SideBarDecorator.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import * as React from 'react'
conststyles={
width:'20rem',
borderRight:'2px solid black',
height:window.innerHeight,
}

constSideBarDecorator=storyFn=><divstyle={styles}>{storyFn()}</div>
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp