Skip to content

Instantly share code, notes, and snippets.

@shelldandy
Created October 17, 2017 19:08
Show Gist options
  • Save shelldandy/02ad1a9f8b5b86d1b2e4dd26a11967b2 to your computer and use it in GitHub Desktop.
Save shelldandy/02ad1a9f8b5b86d1b2e4dd26a11967b2 to your computer and use it in GitHub Desktop.

Revisions

  1. @Mike3run Mike3run created this gist Oct 17, 2017.
    15 changes: 15 additions & 0 deletions App.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import React from 'react'
    import { BrowserRouter as Router, Switch } from 'react-router-dom'
    import routes from './routes'
    import FancyRoute from './components/tools/FancyRoute'

    const App = props =>
    <Router>
    <Switch>
    {routes.map((route, i) =>
    <FancyRoute key={i} {...route} />
    )}
    </Switch>
    </Router>

    export default App
    23 changes: 23 additions & 0 deletions FancyRoute.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    import React from 'react'
    import { Route } from 'react-router-dom'
    import nprogress from 'nprogress'
    import 'nprogress/nprogress.css'
    import './FancyRoute.css'

    class FancyRoute extends React.Component {
    componentWillMount () {
    nprogress.start()
    }

    componentDidMount () {
    nprogress.done()
    }

    render () {
    return (
    <Route {...this.props} />
    )
    }
    }

    export default FancyRoute
    14 changes: 14 additions & 0 deletions FancyRoute.scss
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    $progress-color: #bada55;

    #nprogress .bar {
    background: $progress-color;
    }

    #nprogress .peg {
    box-shadow: 0 0 10px $progress-color, 0 0 5px $progress-color;
    }

    #nprogress .spinner-icon {
    border-top-color: $progress-color;
    border-left-color: $progress-color;
    }
    24 changes: 24 additions & 0 deletions routes.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    import Home from './views/Home'
    import About from './views/About'
    import Blog from './views/Blog'

    const routes = [
    {
    title: 'Home',
    path: '/',
    exact: true,
    component: Home
    },
    {
    title: 'Blog',
    path: '/blog',
    component: Blog
    },
    {
    title: 'About',
    path: '/about',
    component: About
    }
    ]

    export default routes