Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
### Setup
* Fork, Clone, yarn install, yarn start
<!-- * Fork, Clone, yarn install, yarn start
* Do Not use the instructions as your guide for what code to type, use the reference guide project (address book)
* Slight quirk - refreshing doesn't work from any path other than the default one so you will have to go back to the default path to refresh
* Slight quirk - refreshing doesn't work from any path other than the default one so you will have to go back to the default path to refresh -->

### App.js
* Import BrowserRouter,Switch and Route from react-router-dom
* Import components needed
<!-- * Import BrowserRouter,Switch and Route from react-router-dom -->
<!-- * Import components needed -->
* Create the appropriate routes `{/* PUT YOUR ROUTES HERE */}`
* Make sure the default route goes at the bottom
* Make sure BrowserRouter wraps everything
* Make sure you use the component prop, not render.
<!-- * Make sure the default route goes at the bottom -->
<!-- * Make sure BrowserRouter wraps everything -->
<!-- * Make sure you use the component prop, not render. -->

### Routes
* / -> Dashboard
<!-- * / -> Dashboard
* /charts -> Charts
* /tables -> Tables
* /settings -> Settings
* /wall -> Wall
* /profiles -> Profiles
* /marquee/:text -> Marquee
* /profile/:id -> Profile
* /profile/:id -> Profile -->

### Create these components. The content of the components is not important, just put anything `<div> whatever </div>`
* Charts.js
* Tables.js
* Settings.js
* Wall.js
<!-- * Charts.js -->
<!-- * Tables.js -->
<!-- * Settings.js -->
<!-- * Wall.js -->

### Existing components
* Profiles.js
* Import Link from react-router-dom
* change the `<a>` to be a Link that links to `/profile/ + user.id`
* Profile.js
* Change the hard coded 0 with the value from the parameter id
<!-- * Import Link from react-router-dom -->
<!-- * change the `<a>` to be a Link that links to `/profile/ + user.id` -->
* Profile.js
<!-- * Change the hard coded 0 with the value from the parameter id -->
* Dashboard.js
* Marquee
* replace the hard coded "hello" with the text parameter from the route
<!-- * replace the hard coded "hello" with the text parameter from the route -->

### SideNav
* Import Link from react-router-dom
<!-- * Import Link from react-router-dom -->
* Create links to all the routes except Profile
* Hard code some links to Marquee
* /marquee/iloveroutes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"react": "^15.3.2",
"react-dom": "^15.3.2",
"react-redux": "^5.0.4",
"react-router-dom": "^4.1.1",
"react-router-dom": "^4.2.2",
"redux": "^3.6.0"
},
"scripts": {
Expand Down
24 changes: 22 additions & 2 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,41 @@
import React from "react";
import TopNav from "./components/TopNav";
import SideNav from "./components/SideNav";
import{BrowserRouter,Route,Switch} from "react-router-dom";
import Dashboard from "./components/Dashboard";
import Charts from "./components/Charts";
import Tables from "./components/Tables";
import Settings from "./components/Settings";
import Wall from "./components/Wall";
import Profiles from "./components/Profiles";
import Marquee from "./components/Marquee";
import Profile from "./components/Profile";

function App() {
return (
<div>
<BrowserRouter>
<div>
<div id="wrapper">
<nav className="navbar navbar-inverse navbar-fixed-top" role="navigation">
<TopNav />
<SideNav />
</nav>
<div style={{backgroundColor: "white"}}>
{/* PUT YOUR ROUTES HERE */}
<Switch>
<Route path="/charts" component={Charts} />
<Route path="/tables" component={Tables} />
<Route path="/settings" component={Settings} />
<Route path="/wall" component={Wall} />
<Route path="/profiles" component={Profiles} />
<Route path="/marquee/:text" component={Marquee} />
<Route path="/profile/:id" component={Profile} />
<Route path="/" component={Dashboard} />
</Switch>
</div>
</div>
</div>

</BrowserRouter>
);
}

Expand Down
11 changes: 11 additions & 0 deletions src/components/Charts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function Charts(props) {
return (
<div className="col-lg-12">
<h2>This is a Charts test</h2>
</div>
);
}

export default Charts;
4 changes: 2 additions & 2 deletions src/components/Marquee.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from "react";

function Marquee(props) {
const message = "hello";
return (
const message = props.match.params.text;
return (
<marquee>{message}</marquee>
);
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from "react";
import {connect} from "react-redux";

function Profile(props) {
const userId = 0;
const userId = props.match.params.id;
const user = props.users.find(u => u.id == userId) || {};
return (
return (
<div>
<h3>{user.firstName} {user.lastName}</h3>
<h4>{user.occupation}</h4>
Expand All @@ -18,4 +18,3 @@ function Profile(props) {
export default connect(function (state) {
return {users: state.users};
})(Profile);

7 changes: 3 additions & 4 deletions src/components/Profiles.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import React from "react";
import {connect} from "react-redux";
import {Link} from "react-router-dom";

function Profiles(props) {
const userDivs = props.users.map((user,i) => {
return (
<div key={i}>
{user.firstName} - {user.lastName}
<a href="#"> View </a>
<Link href={"/profile/ + user.id"}> View </Link>
</div>);
});
return (
return (
<div>{userDivs}</div>
);
}

export default connect(function (state) {
return {users: state.users};
})(Profiles);


11 changes: 11 additions & 0 deletions src/components/Settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function Settings(props) {
return (
<div className="col-lg-12">
<h2>This is a Settings test</h2>
</div>
);
}

export default Settings;
56 changes: 46 additions & 10 deletions src/components/SideNav.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,65 @@
import React from "react";
// import {Link} from "react-router-dom";
import {Link} from "react-router-dom";

function SideNav() {
return (
<div className="collapse navbar-collapse navbar-ex1-collapse">
<ul className="nav navbar-nav side-nav">
<li className="active">
{/*
{
/*
<Link to="/"> <i className="fa fa-fw fa-dashboard" />
Dashboard
Dashboard
</Link>
*/}
</li>
<li>
<a href="charts.html">
<i className="fa fa-fw fa-bar-chart-o" /> Charts
</a>
<Link to="/charts"> <i className="fa fa-fw fa-dashboard" />
Charts
</Link>
</li>
<li>
<Link to="/tables"> <i className="fa fa-fw fa-dashboard" />
Tables
</Link>
</li>
<li>
<Link to="/settings"> <i className="fa fa-fw fa-dashboard" />
Settings
</Link>
</li>
<li>
<Link to="/wall"> <i className="fa fa-fw fa-dashboard" />
Wall
</Link>
</li>
<li>
<a href="tables.html">
<i className="fa fa-fw fa-table" /> Tables
</a>
<Link to="/profiles"> <i className="fa fa-fw fa-dashboard" />
Profiles
</Link>
</li>
<li>
<Link to="/marquee"> <i className="fa fa-fw fa-dashboard" />
Marquee
</Link>
</li>
<li>
<Link to="/marquee/iloveroutes"> <i className="fa fa-fw fa-dashboard" />
Marquee
</Link>
</li>
<li>
<Link to="/marquee/reactrouterrules"> <i className="fa fa-fw fa-dashboard" />
Marquee
</Link>
</li>
<li>
<Link to="/marquee/sausagerulesthewaves"> <i className="fa fa-fw fa-dashboard" />
Marquee
</Link>
</li>
</ul>
</div>);
</div>);
}

export default SideNav;
11 changes: 11 additions & 0 deletions src/components/Tables.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function Tables(props) {
return (
<div className="col-lg-12">
<h2>This is a Tables test</h2>
</div>
);
}

export default Tables;
11 changes: 11 additions & 0 deletions src/components/Wall.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";

function Wall(props) {
return (
<div className="col-lg-12">
<h2>This is a Wall test</h2>
</div>
);
}

export default Wall;
Empty file added src/routes/Dashboard.js
Empty file.
Loading