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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ Fork, Clone, yarn install, yarn start
* Create a function in index.js called changeCategory thats takes a parameter category. It will assign category to currentCategory and call render()
* Send the changeCategory function to App and then to the TopNav component by way of props
* Send the currentCategory to App by way of props
* App should use the currentCategory value to filter the array of products by category and then map over them to create ProductDetail components
* Modify TopNav
* App should use the currentCategory value to filter the array of products by category and then map over them to create ProductDetail components REVISIT HOMEWORK
* Modify TopNav DONE
* Remove existing href and replace with "#"
* Register onClick for the links, make sure to use arrow function. Make sure to preventDefault.
* In the arrow function call props.changeCategory("tires"). Send in the category that is appropriate for the link
172 changes: 31 additions & 141 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,117 +1,47 @@
import React from "react";
import "./App.css";
import Header from "./components/Header";
import Footer from "./components/Footer";
import ImageSlider from "./components/ImageSlider";
import SubHeader from "./components/SubHeader";
import TopNav from "./components/TopNav";
import ProductDetails from "./components/ProductDetails";



function App(props) {
//REVISIT MAP AND FILTER HMWK
const productCards = props.state.product
.filter((product) => product.category === props.currentCategory? true: false)
.map((product, i) => <ProductDetails product={product} key = {i} />)

return (
<div className="App">
<div className="wrap">
<div className="wrap">

<div className="header">

<div className="top-header">
<div className="top-header-left">
<ul>
<li className="active"><a href="#">Home</a></li>
<li><a href="#">Specials</a></li>
<li><a href="#">Delivery</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div className="top-header-right">
<ul>
<li><a href="#">CURRENCY:</a></li>
<li>
<select>
<option>Dollar</option>
<option>Euro</option>
<option>Pound</option>
</select>
</li>
</ul>
</div>
<div className="clear"> </div>

<Header/>

</div>
<div className="clear"> </div>
<div className="sub-header">
<div className="logo">
<a href="index.html"><img src="images/logo.png" title="logo" /></a>
</div>
<div className="sub-header-right">
<ul>
<li><a href="#">log in</a></li>
<li><a href="#">Your account</a></li>
<li><a href="#">CART: (EMPTY) <img src="images/cart.png" title="cart" /></a></li>
</ul>
<input type="text" /><input type="submit" value="search" />
</div>
<div className="clear"> </div>
</div>
<SubHeader />
<div className="clear"> </div>
<div className="top-nav">
<ul>
<li><a href="carlights.html">car lights</a></li>
<li><a href="carwheels.html">Car wheels</a></li>
<li><a href="carbumpers.html">car bumpers</a></li>
<li><a href="caradsystem.html">car audiosystem</a></li>
<li><a href="truckbumpers.html">Truck bumpers</a></li>
<li><a href="contact.html">Feedback</a></li>
<div className="clear"> </div>
</ul>
</div>

</div>

<TopNav changeCategory = {props.changeCategory}/>

<div className="image-slider">

<ul className="rslides" id="slider1">
<li><img src="images/slider1.jpg" alt="" /></li>
<li><img src="images/slider3.jpg" alt="" /></li>
<li><img src="images/slider1.jpg" alt="" /></li>
</ul>

</div>
</div>

<ImageSlider />

<div className="content">
<div className="products-box">
<div className="products">
<h5><span>FEATURED</span> PRODUCTS</h5>
<div className="section group">
<div className="grid_1_of_5 images_1_of_5">
<img src="images/g3.png" />
<h3>Lorem Ipsum is simply </h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.</p>
<h4>$512.00</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>
<div className="grid_1_of_5 images_1_of_5">
<img src="images/g1.jpg" />
<h3>Lorem Ipsum is simply </h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.</p>
<h4>$300.00</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>
<div className="grid_1_of_5 images_1_of_5">
<img src="images/g2.jpg" />
<h3>Lorem Ipsum is simply </h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.</p>
<h4>$120.00</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>
<div className="grid_1_of_5 images_1_of_5">
<img src="images/g3.png" />
<h3>Lorem Ipsum is simply </h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.</p>
<h4>$500.00</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>
<div className="grid_1_of_5 images_1_of_5">
<img src="images/g4.jpg" />
<h3>Lorem Ipsum is simply</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.</p>
<h4>$120.00</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>

{productCards}

</div>
</div>
<div className="products products-secondbox">
Expand Down Expand Up @@ -157,53 +87,13 @@ function App(props) {
</div>
</div>
<div className="clear"> </div>
<div className="footer">
<div className="section group">
<div className="col_1_of_4 span_1_of_4">
<h3>INFORMATION</h3>
<ul>
<li><a href="#">About us</a></li>
<li><a href="#">Sitemap</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Terms and conditions</a></li>
<li><a href="#">Legal Notice</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4">
<h3>OUR OFFERS</h3>
<ul>
<li><a href="#">New products</a></li>
<li><a href="#">top sellers</a></li>
<li><a href="#">Specials</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Comments</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4">
<h3>YOUR ACCOUNT</h3>
<ul>
<li><a href="#">Your Account</a></li>
<li><a href="#">Personal info</a></li>
<li><a href="#">Prices</a></li>
<li><a href="#">Address</a></li>
<li><a href="#">Locations</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4 footer-lastgrid">
<h3>Get in touch</h3>
<ul>
<li><a href="#"><img src="images/facebook.png" title="facebook" /></a></li>
<li><a href="#"><img src="images/twitter.png" title="Twiiter" /></a></li>
<li><a href="#"><img src="images/rss.png" title="Rss" /></a></li>
<li><a href="#"><img src="images/gpluse.png" title="Google+" /></a></li>
</ul>
<p>Design by <a href="#">W3layouts</a></p>
</div>
</div>

<Footer />

</div>
</div>

</div>

//removed </div>'s from here...

);
}

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

function Footer() {
return(
<div className="footer">
<div className="section group">
<div className="col_1_of_4 span_1_of_4">
<h3>INFORMATION</h3>
<ul>
<li><a href="#">About us</a></li>
<li><a href="#">Sitemap</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Terms and conditions</a></li>
<li><a href="#">Legal Notice</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4">
<h3>OUR OFFERS</h3>
<ul>
<li><a href="#">New products</a></li>
<li><a href="#">top sellers</a></li>
<li><a href="#">Specials</a></li>
<li><a href="#">Products</a></li>
<li><a href="#">Comments</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4">
<h3>YOUR ACCOUNT</h3>
<ul>
<li><a href="#">Your Account</a></li>
<li><a href="#">Personal info</a></li>
<li><a href="#">Prices</a></li>
<li><a href="#">Address</a></li>
<li><a href="#">Locations</a></li>
</ul>
</div>
<div className="col_1_of_4 span_1_of_4 footer-lastgrid">
<h3>Get in touch</h3>
<ul>
<li><a href="#"><img src="images/facebook.png" title="facebook" /></a></li>
<li><a href="#"><img src="images/twitter.png" title="Twiiter" /></a></li>
<li><a href="#"><img src="images/rss.png" title="Rss" /></a></li>
<li><a href="#"><img src="images/gpluse.png" title="Google+" /></a></li>
</ul>
<p>Design by <a href="#">W3layouts</a></p>
</div>
</div>
</div>
);
}

export default Footer;
27 changes: 26 additions & 1 deletion src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,32 @@
import React from "react";

function Header() {
return (<div />);
return (
<div className="top-header">
<div className="top-header-left">
<ul>
<li className="active"><a href="#">Home</a></li>
<li><a href="#">Specials</a></li>
<li><a href="#">Delivery</a></li>
<li><a href="#">Contact</a></li>
</ul>
</div>
<div className="top-header-right">
<ul>
<li><a href="#">CURRENCY:</a></li>
<li>
<select>
<option>Dollar</option>
<option>Euro</option>
<option>Pound</option>
</select>
</li>
</ul>
</div>
<div className="clear">
</div>
</div>
);
}

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

function ImageSlider() {
return(
<div className="image-slider">
<ul className="rslides" id="slider1">
<li><img src="images/slider1.jpg" alt="" /></li>
<li><img src="images/slider3.jpg" alt="" /></li>
<li><img src="images/slider1.jpg" alt="" /></li>
</ul>
</div>
);
}

export default ImageSlider;
22 changes: 22 additions & 0 deletions src/components/ProductDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react";
import propTypes from "prop-types";

function ProductDetails(props) {
let {imgUrl, name, description, price } = props.product;

return(
<div className="grid_1_of_5 images_1_of_5">
<img src={imgUrl} />
<h3>{name}</h3>
<p>{description}</p>
<h4>{price}</h4>
<div className="button"><span><a href="singlepage.html">Read More</a></span></div>
</div>
);
}

ProductDetails.propTypes = {
product: propTypes.object.isRequired
}

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

function SubHeader() {
return(
<div className="sub-header">
<div className="logo">
<a href="index.html"><img src="images/logo.png" title="logo" /></a>
</div>
<div className="sub-header-right">
<ul>
<li><a href="#">log in</a></li>
<li><a href="#">Your account</a></li>
<li><a href="#">CART: (EMPTY) <img src="images/cart.png" title="cart" /></a></li>
</ul>
<input type="text" /><input type="submit" value="search" />
</div>
<div className="clear"> </div>
</div>
);
}

export default SubHeader;
27 changes: 27 additions & 0 deletions src/components/TopNav.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from "react";
import propTypes from "prop-types";

function TopNav(props){
return(
<div className="top-nav">
<ul>
<li><a href="#" onClick={(e)=>{e.preventDefault(); props.changeCategory("headlights")}}>Car Lights</a></li>

<li><a href="#" onClick={(e)=>{e.preventDefault(); props.changeCategory("tires")}}>Car Wheels</a></li>

<li><a href="#" onClick={(e)=>{e.preventDefault(); props.changeCategory("bumpers")}}>Car and Truck Bumpers</a></li>

<li><a href="#" onClick={(e)=>{e.preventDefault(); props.changeCategory("audio")}}>Car Audio System</a></li>

<li><a href="contact.html">Feedback</a></li>
<div className="clear"> </div>
</ul>
</div>
);
}

TopNav.propTypes = {
changeCategory: propTypes.func.isRequired
}

export default TopNav;
Loading