diff --git a/README.md b/README.md index a6ae27c..4ad1dcb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/src/App.js b/src/App.js index 4513d4b..6add331 100644 --- a/src/App.js +++ b/src/App.js @@ -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) => ) + return (
-
+
- -
-
- -
-
-
    -
  • CURRENCY:
  • -
  • - -
  • -
-
-
+ +
+
-
-
- -
- -
-
+
- - -
+ -
- -
    -
  • -
  • -
  • -
- -
+
+ +
FEATURED PRODUCTS
-
- -

Lorem Ipsum is simply

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.

-

$512.00

- -
-
- -

Lorem Ipsum is simply

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.

-

$300.00

- -
-
- -

Lorem Ipsum is simply

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.

-

$120.00

- -
-
- -

Lorem Ipsum is simply

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.

-

$500.00

- -
-
- -

Lorem Ipsum is simply

-

Lorem ipsum dolor sit amet, consectetur adipisicing elit, in reprehenderit.

-

$120.00

- -
+ + {productCards} +
@@ -157,53 +87,13 @@ function App(props) {
-
-
-
-

INFORMATION

- -
-
-

OUR OFFERS

- -
-
-

YOUR ACCOUNT

- -
-
-

Get in touch

-
    -
  • -
  • -
  • -
  • -
-

Design by W3layouts

-
-
+ +
+
-
- -
+ + //removed
's from here... + ); } diff --git a/src/components/Footer.js b/src/components/Footer.js new file mode 100644 index 0000000..54432fb --- /dev/null +++ b/src/components/Footer.js @@ -0,0 +1,52 @@ +import React from "react"; + +function Footer() { + return( +
+
+
+

INFORMATION

+ +
+
+

OUR OFFERS

+ +
+
+

YOUR ACCOUNT

+ +
+
+

Get in touch

+
    +
  • +
  • +
  • +
  • +
+

Design by W3layouts

+
+
+
+ ); +} + +export default Footer; \ No newline at end of file diff --git a/src/components/Header.js b/src/components/Header.js index f882be0..c22b74c 100644 --- a/src/components/Header.js +++ b/src/components/Header.js @@ -1,7 +1,32 @@ import React from "react"; function Header() { - return (
); + return ( +
+
+ +
+
+
    +
  • CURRENCY:
  • +
  • + +
  • +
+
+
+
+
+ ); } export default Header; diff --git a/src/components/ImageSlider.js b/src/components/ImageSlider.js new file mode 100644 index 0000000..f099b08 --- /dev/null +++ b/src/components/ImageSlider.js @@ -0,0 +1,15 @@ +import React from "react"; + +function ImageSlider() { + return( +
+
    +
  • +
  • +
  • +
+
+ ); +} + +export default ImageSlider; \ No newline at end of file diff --git a/src/components/ProductDetails.js b/src/components/ProductDetails.js new file mode 100644 index 0000000..43c58b1 --- /dev/null +++ b/src/components/ProductDetails.js @@ -0,0 +1,22 @@ +import React from "react"; +import propTypes from "prop-types"; + +function ProductDetails(props) { + let {imgUrl, name, description, price } = props.product; + + return( +
+ +

{name}

+

{description}

+

{price}

+
Read More
+
+ ); +} + +ProductDetails.propTypes = { + product: propTypes.object.isRequired +} + +export default ProductDetails; \ No newline at end of file diff --git a/src/components/SubHeader.js b/src/components/SubHeader.js new file mode 100644 index 0000000..4fce816 --- /dev/null +++ b/src/components/SubHeader.js @@ -0,0 +1,22 @@ +import React from "react"; + +function SubHeader() { + return( +
+
+ +
+
+ + +
+
+
+ ); +} + +export default SubHeader; \ No newline at end of file diff --git a/src/components/TopNav.js b/src/components/TopNav.js new file mode 100644 index 0000000..c075adc --- /dev/null +++ b/src/components/TopNav.js @@ -0,0 +1,27 @@ +import React from "react"; +import propTypes from "prop-types"; + +function TopNav(props){ + return( +
+ +
+ ); +} + +TopNav.propTypes = { + changeCategory: propTypes.func.isRequired +} + +export default TopNav; \ No newline at end of file diff --git a/src/index.js b/src/index.js index 34d8803..15802ba 100644 --- a/src/index.js +++ b/src/index.js @@ -4,9 +4,16 @@ import App from "./App"; import "./index.css"; import state from "./state"; +let currentCategory = "tires"; + +function changeCategory(category) { + currentCategory = category; + render(); +} + function render() { ReactDOM.render( - , + , document.getElementById("root") ); } diff --git a/src/state.js b/src/state.js index 4f52c2c..b615d2f 100644 --- a/src/state.js +++ b/src/state.js @@ -1,5 +1,5 @@ export default { - products:[{ + product:[{ "id": 1, "name": "Namfix", "description": "Extraction of Nasal Turbinate, Open Approach",