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*asReactfrom'react'

importCondfrom'./components/Cond'
importLoadingfrom'./components/Loading'
importRouterfrom'./components/Router'
importLoadingPagefrom'./containers/LoadingPage'
importContinuePagefrom'./containers/Continue'
importNewPagefrom'./containers/New'
importTutorialPagefrom'./containers/Tutorial'

const{ Route}=Router

interfaceProps{
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(
<divstyle={{ ...styles.page, ...dimensions}}>
<Condstate={state}path="SelectTutorial.Startup">
<Loading/>
</Cond>
<Condstate={state}path="SelectTutorial.NewTutorial">
<NewPage/>
</Cond>
<Condstate={state}path="SelectTutorial.ContinueTutorial">
<ContinuePage/>
</Cond>
<Condstate={state}path="Tutorial">
<TutorialPagestate={state}/>
</Cond>
<Routerstate={state}>
<Routepath="SelectTutorial.Startup">
<LoadingPagetext="Launching..."/>
</Route>
<Routepath="SelectTutorial.NewTutorial">
<NewPage/>
</Route>
<Routepath="SelectTutorial.ContinueTutorial">
<ContinuePage/>
</Route>
<Routepath="Tutorial">
<TutorialPagestate={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*asReactfrom'react'
import{Loading}from'@alifd/next'

constLoading=()=>{
return<div>Loading...</div>
interfaceProps{
text:string
}

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

exportdefaultLoadingComponent
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*asReactfrom'react'
importLoadingfrom'../components/Loading'

interfaceProps{
text:string
}

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

constLoadingPage=({ text}:Props)=>(
<divstyle={styles.page}>
<Loadingtext={text}/>
</div>
)

exportdefaultLoadingPage
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*asReactfrom'react'
import{Button}from'@alifd/next'

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

interfaceProps{
onNew(tutorialId:string):void
Expand All@@ -27,7 +29,7 @@ export const NewPage = (props: Props) => {
</div>
</Cond>
<Condstate={state}path="SelectTutorial.NewTutorial.InitializeTutorial">
<div>Initializing tutorial...</div>
<LoadingPagetext="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'

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

constLevelPage=(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 @@
importReactfrom'react'

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

importRouterfrom'../src/components/Router'

const{ Route}=Router

storiesOf('Components',module)
.addDecorator(SideBarDecorator)
.add('Router',()=>(
<Routerstate="Third">
<Routepath="First">First</Route>
<Routepath="Second">Second</Route>
<Routepath="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