|
1 | 1 | import React, { Component, PropTypes } from 'react'; |
2 | | -import { IndexLink, Link } from 'react-router'; |
3 | 2 | import { connect } from 'react-redux'; |
| 3 | +import { IndexLink } from 'react-router'; |
| 4 | +import { LinkContainer } from 'react-router-bootstrap'; |
| 5 | +import { Navbar, NavBrand, Nav, NavItem, CollapsibleNav } from 'react-bootstrap'; |
4 | 6 | import DocumentMeta from 'react-document-meta'; |
5 | 7 | import { isLoaded as isInfoLoaded, load as loadInfo } from 'redux/modules/info'; |
6 | 8 | import { isLoaded as isAuthLoaded, load as loadAuth, logout } from 'redux/modules/auth'; |
7 | 9 | import { InfoBar } from 'components'; |
8 | 10 | import { pushState } from 'redux-router'; |
9 | 11 | import config from '../../config'; |
10 | 12 |
|
11 | | -const NavbarLink = ({to, className, component, children}) => { |
12 | | - const Comp = component || Link; |
13 | | - |
14 | | - return ( |
15 | | - <Comp to={to} className={className} activeStyle={{ |
16 | | - color: '#33e0ff' |
17 | | - }}> |
18 | | - {children} |
19 | | - </Comp> |
20 | | - ); |
21 | | -}; |
22 | | - |
23 | 13 | @connect( |
24 | 14 | state => ({user: state.auth.user}), |
25 | 15 | {logout, pushState}) |
@@ -67,32 +57,51 @@ export default class App extends Component { |
67 | 57 | return ( |
68 | 58 | <div className={styles.app}> |
69 | 59 | <DocumentMeta {...config.app}/> |
70 | | - <nav className="navbar navbar-default navbar-fixed-top"> |
71 | | - <div className="container"> |
72 | | - <NavbarLink to="/" className="navbar-brand" component={IndexLink}> |
| 60 | + <Navbar fixedTop toggleNavKey={0}> |
| 61 | + <NavBrand> |
| 62 | + <IndexLink to="/" activeStyle={{color: '#33e0ff'}}> |
73 | 63 | <div className={styles.brand}/> |
74 | | - React Redux Example |
75 | | - </NavbarLink> |
| 64 | + <span>React Redux Example</span> |
| 65 | + </IndexLink> |
| 66 | + </NavBrand> |
76 | 67 |
|
77 | | - <ul className="nav navbar-nav"> |
78 | | - {user && <li><NavbarLink to="/chat">Chat</NavbarLink></li>} |
| 68 | + <CollapsibleNav eventKey={0}> |
| 69 | + <Nav navbar> |
| 70 | + {user && <LinkContainer to="/chat"> |
| 71 | + <NavItem eventKey={1}>Chat</NavItem> |
| 72 | + </LinkContainer>} |
79 | 73 |
|
80 | | - <li><NavbarLink to="/widgets">Widgets</NavbarLink></li> |
81 | | - <li><NavbarLink to="/survey">Survey</NavbarLink></li> |
82 | | - <li><NavbarLink to="/about">About Us</NavbarLink></li> |
83 | | - {!user && <li><NavbarLink to="/login">Login</NavbarLink></li>} |
84 | | - {user && <li className="logout-link"><a href="/logout" onClick={::this.handleLogout}>Logout</a></li>} |
85 | | - </ul> |
| 74 | + <LinkContainer to="/widgets"> |
| 75 | + <NavItem eventKey={2}>Widgets</NavItem> |
| 76 | + </LinkContainer> |
| 77 | + <LinkContainer to="/survey"> |
| 78 | + <NavItem eventKey={3}>Survey</NavItem> |
| 79 | + </LinkContainer> |
| 80 | + <LinkContainer to="/about"> |
| 81 | + <NavItem eventKey={4}>About Us</NavItem> |
| 82 | + </LinkContainer> |
| 83 | + |
| 84 | + {!user && |
| 85 | + <LinkContainer to="/login"> |
| 86 | + <NavItem eventKey={5}>Login</NavItem> |
| 87 | + </LinkContainer>} |
| 88 | + {user && |
| 89 | + <LinkContainer to="/logout"> |
| 90 | + <NavItem eventKey={6} className="logout-link" onClick={::this.handleLogout}> |
| 91 | + Logout |
| 92 | + </NavItem> |
| 93 | + </LinkContainer>} |
| 94 | + </Nav> |
86 | 95 | {user && |
87 | 96 | <p className={styles.loggedInMessage + ' navbar-text'}>Logged in as <strong>{user.name}</strong>.</p>} |
88 | | - <ul className="nav navbar-nav navbar-right"> |
89 | | - <li> |
90 | | - <a href="https://github.com/erikras/react-redux-universal-hot-example" |
91 | | - target="_blank" title="View on Github"><i className="fa fa-github"/></a> |
92 | | - </li> |
93 | | - </ul> |
94 | | - </div> |
95 | | - </nav> |
| 97 | + <Nav navbar right> |
| 98 | + <NavItem eventKey={1} target="_blank" title="View on Github" href="https://github.com/erikras/react-redux-universal-hot-example"> |
| 99 | + <i className="fa fa-github"/> |
| 100 | + </NavItem> |
| 101 | + </Nav> |
| 102 | + </CollapsibleNav> |
| 103 | + </Navbar> |
| 104 | + |
96 | 105 | <div className={styles.appContent}> |
97 | 106 | {this.props.children} |
98 | 107 | </div> |
|
0 commit comments