3.1.30 • Published 5 years ago

the-route v3.1.30

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

the-route

Build Status npm Version JS Standard

Route of the-components

Installation

$ npm install the-route --save

Usage

'use strict'

import React from 'react'
import { TheRouter } from 'the-router'
import { TheSpinStyle } from 'the-spin'
import { TheLink } from 'the-link'
import { TheRoute, TheRouteStack, TheRouteStyle } from 'the-route'

class ExampleComponent extends React.Component {
  constructor (props) {
    super(props)
    this.state = {i: 0, vertical: false}

    setInterval(() => {
      // this.setState({i: this.state.i + 1})
    }, 1000)
  }

  render () {
    return (
      <div>
        <TheSpinStyle/>
        <TheRouteStyle/>

        <br/>
        <TheRouter.Hash>
          <TheLink exact to={'/s1'}>Show Stack</TheLink>
          <TheLink exact to={'/'}>Hide Stack</TheLink>
          <a onClick={() => this.setState({vertical: !this.state.vertical})}>
            Change direction
          </a>
          <TheRoute.Switch>
            <TheRoute path='/s1'
            >
              <TheRouteStack style={{border: '4px solid #555'}}
                             direction={this.state.vertical ? 'vertical' : 'horizontal'}
                             stack={[
                               ['/s1', class View01 extends React.Component {
                                 render () {
                                   return (
                                     <div style={{padding: '50px', background: '#EAA'}}>
                                       <h3>This is view 01</h3>

                                       <br/>
                                       <div style={{display: 'flex', justifyContent: 'space-between'}}>
                                         <span> </span>
                                         <TheLink to={'/s1/v2'}>Go to view 02 &gt;&gt; </TheLink>
                                       </div>
                                     </div>
                                   )
                                 }

                                 componentDidMount () {
                                   console.log('View01 did mount')
                                 }
                               }],
                               ['/s1/v2', class View02 extends React.Component {
                                 render () {
                                   const {pop} = this.props
                                   return (
                                     <div style={{padding: '50px', background: '#AEA', height: 920}}>
                                       <h3>This is view 02</h3>
                                       <br/>

                                       <div style={{display: 'flex', justifyContent: 'space-between'}}>
                                         <a onClick={() => pop()}> &lt;&lt; Back to view 01</a>
                                         <TheLink to={'/s1/v2/v3'}>Go to view 03 &gt;&gt; </TheLink>
                                       </div>
                                     </div>
                                   )
                                 }

                                 componentDidMount () {
                                   console.log('View02 did mount')
                                 }
                               }],
                               ['/s1/v2/v3', class View03 extends React.Component {
                                 render () {
                                   const {pop} = this.props
                                   return (
                                     <div style={{padding: '50px', background: '#AAE'}}>
                                       <h3>This is view 03</h3>
                                       <br/>
                                       <div style={{display: 'flex', justifyContent: 'space-between'}}>
                                         <a onClick={() => pop()}> &lt;&lt; Back to view 02</a>
                                         <span></span>
                                       </div>
                                     </div>
                                   )
                                 }

                                 componentDidMount () {
                                   console.log('View03 did mount')
                                   const {location, history} = this.props
                                   history.replace(location.pathname + '?a=b')
                                 }
                               }]
                             ]}>
              </TheRouteStack>
            </TheRoute>
          </TheRoute.Switch>
          <br/>
          <hr/>
          <br/>
          <h3>404</h3>
          <TheRoute.Status code="404">
            <div>Page not found!</div>
          </TheRoute.Status>
        </TheRouter.Hash>


      </div>
    )
  }
}

export default ExampleComponent

Components

TheRoute

Route of the-components

Props

NameTypeDescriptionDefault
animationDurationnumberAnimation duration400
componentanyComponent class
exactboolExact match
pathstringRouting path
scrollToTopboolRender functionfalse
strictboolStrict match

TheRouteStack

Tab for the-components

Props

NameTypeDescriptionDefault
directionenumStack direction'horizontal'
stackarrayStacks[]

TheRouteStyle

Style for TheRoute

Props

NameTypeDescriptionDefault
optionsobjectStyle options{}

License

This software is released under the MIT License.

Links

3.1.30

5 years ago

3.1.29

5 years ago

3.1.28

6 years ago

3.1.27

6 years ago

3.1.26

6 years ago

3.1.25

6 years ago

3.1.24

6 years ago

3.1.23

6 years ago

3.1.22

6 years ago

3.1.21

6 years ago

3.1.20

6 years ago

3.1.19

6 years ago

3.1.18

6 years ago

3.1.17

6 years ago

3.1.16

6 years ago

3.1.15

6 years ago

3.1.14

6 years ago

3.1.13

6 years ago

3.1.12

6 years ago

3.1.11

6 years ago

3.1.10

6 years ago

3.1.9

6 years ago

3.1.8

6 years ago

3.1.7

6 years ago

3.1.6

6 years ago

3.1.5

6 years ago

3.1.4

6 years ago

3.1.3

6 years ago

3.1.2

6 years ago

3.1.1

6 years ago

3.1.0

6 years ago

3.0.24

6 years ago

3.0.23

6 years ago

3.0.22

6 years ago

3.0.21

6 years ago

3.0.20

6 years ago

3.0.19

6 years ago

3.0.18

6 years ago

3.0.17

6 years ago

3.0.16

6 years ago

3.0.15

6 years ago

3.0.14

6 years ago

3.0.13

6 years ago

3.0.12

6 years ago

3.0.11

6 years ago

3.0.10

6 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

2.0.6

6 years ago

2.0.5

6 years ago

2.0.4

6 years ago

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago