Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Danny Gleason #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
2,621 changes: 1,326 additions & 1,295 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-dom": "^16.12.0",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-scripts": "1.0.17"
Expand Down
26 changes: 22 additions & 4 deletions src/components/App/App.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,29 @@
import React, { Component } from 'react';
import Header from "../Header/Header"
import NewContact from "../NewContact/NewContact"
import ContactList from "../ContactList/ContactList"
import { Route } from "react-router-dom";

class App extends Component {
constructor(props) {
super(props)

this.state = {
contacts: props.contacts
}
}
render() {
return <div className="App">
<p>app</p>
</div>;
return (
<div className="App">
<Header/>
<nav>
<Route path="/" render={() => <NewContact/>}/>
<Route path="/new-contact" render={() => <ContactList contacts={this.state.contacts}/>}/>
</nav>
</div>

)
}
}

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

function Contact(props){
return(
<div className="contact">
<img src={props.image}/>
<h3>{props.name}</h3>
<h4>{props.email}</h4>
</div>


)
}

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

function ContactList(props){
return(
<div className="contact-list">
{props.contacts.map(item => <div><Contact name={item.name} email={item.email} image={item.profile_picture}/></div>)}
</div>

)
}

export default ContactList;
19 changes: 19 additions & 0 deletions src/components/Header/Header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { Link } from "react-router-dom";

function Header(){
return(
<header>
<h1>
<nav>
<Link to="/" className="link">Home</Link>
<Link to="/new-contact" className="link">Contacts</Link>
</nav>
</h1>
</header>


)
}

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

function NewContact(){
return(
<div>
<h1>New Contact</h1>
<form>
<label>Name:<input type="text" name="name" /></label>
<label>Email:<input type="text" name="email" /></label>
<label>Profile Picture:<input type="text" name="profile" /></label>
<input type="submit" value="Submit" />
</form>
</div>
)
}

export default NewContact;
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDOM from 'react-dom';
import './styles/index.css';
import App from './components/App/App';

import { BrowserRouter as Router } from "react-router-dom";
import contacts from "./contacts.json";

ReactDOM.render(<App />, document.getElementById('root'));
ReactDOM.render(<Router><App contacts={contacts}/></Router>, document.getElementById('root'));